/* =====================================================================
   Carte Famili — bilingual family health card editor
   v4 — Visual improvements: refined typography, dotted dividers,
        gradient accent bar, softer beneficiary highlight,
        improved number band, better whitespace
   ===================================================================== */

:root {
  --bg-app: oklch(0.97 0.008 90);
  --bg-pane: oklch(0.99 0.004 90);
  --ink: oklch(0.22 0.015 240);
  --ink-soft: oklch(0.50 0.015 240);
  --ink-muted: oklch(0.62 0.012 240);
  --line: oklch(0.91 0.008 240);
  --line-strong: oklch(0.84 0.010 240);
  --brand: oklch(0.50 0.09 195);
  --accent: oklch(0.72 0.10 75);
  --paper: oklch(0.985 0.012 85);
  --shadow-card: 0 1px 2px rgba(20,30,40,.05), 0 22px 48px -18px rgba(20,40,60,.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-app);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* App layout ------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: minmax(380px, 460px) 1fr;
  height: 100vh;
  gap: 0;
}
.pane { display: flex; flex-direction: column; min-height: 0; }
.pane-form {
  background: var(--bg-pane);
  border-right: 1px solid var(--line);
}
.pane-preview {
  background:
    radial-gradient(ellipse at 50% 30%, oklch(0.98 0.010 200) 0%, oklch(0.93 0.018 215) 100%);
  position: relative;
}

/* Form pane header ------------------------------------------------- */
.pane-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-pane);
}
.brand-mini { display: flex; align-items: center; gap: 12px; }
.pane-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.pane-sub {
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}
.pane-actions { display: flex; gap: 8px; }

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.btn-primary:hover { background: oklch(0.45 0.10 195); border-color: oklch(0.45 0.10 195); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink);
}
.btn-ghost:hover { background: oklch(0.96 0.005 90); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

/* Form scroll area ------------------------------------------------- */
.pane-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 40px;
}
.form { display: flex; flex-direction: column; gap: 22px; }

.fsection {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  overflow: hidden;
}
.fsection-head {
  padding: 12px 16px;
  background: oklch(0.98 0.005 90);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.fsection-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.fsection-sub {
  font-family: "Cairo", sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.fsection-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }

.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.finput { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.finput-label {
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  font-weight: 500;
}
.finput.rtl .finput-label { font-family: "Cairo", sans-serif; font-size: 12px; text-align: right; }
.finput input, .finput select {
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.finput.rtl input { font-family: "Cairo", sans-serif; font-size: 14px; text-align: right; }
.finput input:focus, .finput select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 15%, transparent);
}

.fradio { display: flex; flex-direction: column; gap: 6px; }
.fradio-options { display: flex; gap: 8px; }
.fradio-opt {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  text-align: center;
  background: white;
  transition: all .12s;
}
.fradio-opt input { display: none; }
.fradio-opt.active {
  background: color-mix(in oklab, var(--brand) 8%, white);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 500;
}
.fradio-opt:hover:not(.active) { background: oklch(0.97 0.004 90); }

.ftoggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
}
.ftoggle input { display: none; }
.ftoggle-track {
  width: 36px;
  height: 20px;
  background: var(--line-strong);
  border-radius: 10px;
  position: relative;
  transition: background .15s;
}
.ftoggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.ftoggle input:checked ~ .ftoggle-track { background: var(--brand); }
.ftoggle input:checked ~ .ftoggle-track .ftoggle-thumb { transform: translateX(16px); }

.empty-note {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  padding: 14px;
  background: oklch(0.97 0.005 90);
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
}

/* Beneficiary form rows ------------------------------------------- */
.ben-form-list { display: flex; flex-direction: column; gap: 12px; }
.ben-form-row {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  gap: 8px;
  padding: 12px;
  background: oklch(0.98 0.005 90);
  border: 1px solid var(--line);
  border-radius: 8px;
  align-items: start;
}
.ben-form-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: grid; place-items: center;
  margin-top: 4px;
  font-family: "JetBrains Mono", monospace;
}
.ben-form-fields { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ben-rm {
  width: 24px; height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: white;
  color: var(--ink-soft);
  font-size: 16px;
  cursor: pointer;
  margin-top: 4px;
  line-height: 1;
}
.ben-rm:hover { background: oklch(0.95 0.04 25); border-color: oklch(0.65 0.15 25); color: oklch(0.45 0.15 25); }

/* =====================================================================
   PREVIEW PANE
   ===================================================================== */
.preview-bar {
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid oklch(0.88 0.012 215);
  background: oklch(0.98 0.008 215 / 0.7);
  backdrop-filter: blur(8px);
}
.preview-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.preview-meta {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: var(--ink-soft);
}
.preview-stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px;
  overflow: auto;
}

/* New: side-by-side card preview (Recto + Verso) */
.preview-stage-cards {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  justify-content: center;
  padding: 32px;
  flex-wrap: wrap;
}
.preview-card-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.preview-card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-family: "Cairo", "Inter", sans-serif;
}
.preview-card-frame {
  /* Scale the 600×950 cards down to fit nicely on screen */
  transform: scale(0.62);
  transform-origin: top center;
  /* Reserve the scaled space (otherwise other elements would think the card is full size) */
  width: 600px;
  height: 950px;
  margin-bottom: -361px; /* 950 × (1 - 0.62) = 361 collapsed */
  margin-right: -228px;  /* 600 × (1 - 0.62) = 228 collapsed */
  filter: drop-shadow(0 12px 32px rgba(20, 40, 60, 0.16));
  border-radius: 14px;
  overflow: hidden;
}
.preview-card-frame .card-compact,
.preview-card-frame .card-back {
  border-radius: 14px;
}

/* When the screen is narrow, scale a bit smaller */
@media (max-width: 1700px) {
  .preview-card-frame {
    transform: scale(0.50);
    margin-bottom: -475px;
    margin-right: -300px;
  }
}
@media (max-width: 1400px) {
  .preview-card-frame {
    transform: scale(0.42);
    margin-bottom: -551px;
    margin-right: -348px;
  }
}

/* =====================================================================
   THE CARD — refined v4
   ===================================================================== */
.card-wrap { filter: drop-shadow(0 30px 50px rgba(20,40,60,.10)); }

.card {
  width: 920px;
  background: var(--paper);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
  box-shadow: var(--shadow-card);
  color: var(--ink);
  border: 1px solid oklch(0.88 0.014 200);
}

/* NEW: top accent bar — gradient signature */
.card::before {
  content: "";
  display: block;
  height: 5px;
  background: linear-gradient(
    90deg,
    var(--brand) 0%,
    color-mix(in oklab, var(--brand) 70%, var(--accent)) 50%,
    var(--accent) 100%
  );
  flex-shrink: 0;
}

/* Inner content padding */
.card-head,
.number-band,
.card-body,
.ben-section,
.card-foot {
  padding-left: 36px;
  padding-right: 36px;
}

.card-bg { position: absolute; inset: 0; pointer-events: none; }
.pattern-svg { width: 100%; height: 100%; display: block; }

/* Decorative ribbons — softer */
.ribbon {
  position: absolute;
  width: 220px;
  height: 220px;
  pointer-events: none;
}
.ribbon-tl {
  top: -110px; left: -110px;
  background: var(--brand);
  opacity: 0.05;
  transform: rotate(45deg);
}
.ribbon-br {
  bottom: -110px; right: -110px;
  background: var(--accent);
  opacity: 0.08;
  transform: rotate(45deg);
}

/* Header ----------------------------------------------------------- */
.card-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  position: relative;
  z-index: 1;
  padding-top: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid color-mix(in oklab, var(--brand) 22%, transparent);
}
.head-left { display: flex; align-items: center; gap: 14px; }
.brand-block { display: flex; flex-direction: column; }
.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--brand);
  line-height: 1;
}
.brand-sub {
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-top: 5px;
  text-transform: uppercase;
  font-weight: 500;
}
.head-center { text-align: center; padding: 0 8px; }
.head-title-fr {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.35;
}
.head-sub-fr {
  font-size: 10px;
  color: var(--ink-soft);
  margin-top: 4px;
  letter-spacing: 0.02em;
  line-height: 1.35;
}
.head-right { text-align: right; font-family: "Cairo", sans-serif; }
.head-title-ar {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.head-sub-ar {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 4px;
  font-weight: 500;
  line-height: 1.35;
}
.head-sub-ar-2 {
  font-family: "Cairo", sans-serif;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 2px;
  font-weight: 400;
  line-height: 1.35;
  opacity: 0.85;
}

/* CNSS logo — official logo image */
.cnss-logo-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.cnss-logo {
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.05));
}
.cnss-mark {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #1F3A8A;
  font-family: "Inter", sans-serif;
}

/* Number band — refined with subtle background tint and frame */
.number-band {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding-top: 14px;
  padding-bottom: 14px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    color-mix(in oklab, var(--brand) 4%, transparent) 100%
  );
}
.num-label-fr {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}
.num-label-ar {
  font-family: "Cairo", sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  color: var(--ink-soft);
}
.num-value {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 28px;
  font-weight: 600;
  color: var(--brand);
  letter-spacing: 0.06em;
  white-space: nowrap;
  padding: 6px 22px;
  border-top: 1px solid color-mix(in oklab, var(--brand) 35%, transparent);
  border-bottom: 1px solid color-mix(in oklab, var(--brand) 35%, transparent);
  background: linear-gradient(
    180deg,
    transparent 0%,
    color-mix(in oklab, var(--accent) 8%, transparent) 100%
  );
}

/* Identity body — refined with dotted dividers */
.card-body {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 28px;
  position: relative;
  z-index: 1;
  align-items: start;
  padding-top: 16px;
  padding-bottom: 8px;
}
.col { display: flex; flex-direction: column; gap: 2px; }
.col-divider {
  background: linear-gradient(180deg, transparent, var(--line-strong) 20%, var(--line-strong) 80%, transparent);
  width: 1px;
  height: 100%;
  min-height: 140px;
}

/* Field — French (label NOW on RIGHT, value on LEFT — mirroring Arabic style) */
.field-fr {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 12px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dotted color-mix(in oklab, var(--ink) 12%, transparent);
}
.field-fr:last-child { border-bottom: none; }
.field-fr .field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  text-align: right;
}
.field-fr .field-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
}

/* Field — Arabic (RIGHT, value first then label on right) */
.field-ar {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 12px;
  align-items: baseline;
  padding: 6px 0;
  direction: rtl;
  border-bottom: 1px dotted color-mix(in oklab, var(--ink) 12%, transparent);
}
.field-ar:last-child { border-bottom: none; }
.field-ar .field-value {
  font-family: "Cairo", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
}
.field-ar .field-label {
  font-family: "Cairo", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  text-align: right;
}

/* Beneficiaries ---------------------------------------------------- */
.ben-section {
  position: relative;
  z-index: 1;
  padding-top: 8px;
  padding-bottom: 22px;
}
.ben-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.ben-fr {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
}
.ben-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--brand), transparent 50%, var(--brand));
  opacity: 0.30;
}
.ben-ar {
  font-family: "Cairo", sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
}

/* Table-style beneficiary list */
.ben-table {
  border: 1px solid color-mix(in oklab, var(--brand) 20%, transparent);
  border-radius: 8px;
  overflow: hidden;
  background: oklch(0.99 0.005 90 / 0.6);
}
.ben-row {
  display: grid;
  grid-template-columns: 36px 130px 1fr 130px 140px;
  align-items: center;
  padding: 8px 14px;
  gap: 10px;
  border-bottom: 1px solid color-mix(in oklab, var(--brand) 10%, transparent);
  font-family: "Cairo", sans-serif;
  position: relative;
}
.ben-row:last-child { border-bottom: none; }
.ben-row-head {
  background: color-mix(in oklab, var(--brand) 9%, transparent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand);
  padding: 7px 14px;
}
/* NEW: titulaire highlighted with accent side bar instead of full background tint */
.ben-row-titulaire {
  background: color-mix(in oklab, var(--accent) 5%, transparent);
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
}
.ben-row-titulaire::before {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}
.bc { font-size: 13px; }
.bc-num {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  font-weight: 600;
}
.bc-rel { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.bc-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.bc-birth {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
}
.bc-id {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--brand);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.ben-row-titulaire .bc-rel { color: var(--brand); font-weight: 700; }

/* Footer ----------------------------------------------------------- */
.card-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding-top: 14px;
  padding-bottom: 18px;
  margin-top: 6px;
  border-top: 1px solid color-mix(in oklab, var(--brand) 18%, transparent);
  position: relative;
  z-index: 1;
}
.foot-label, .foot-label-ar {
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
}
.foot-label-ar { font-family: "Cairo", sans-serif; font-size: 11px; letter-spacing: 0; text-transform: none; }
.foot-value { font-size: 11px; color: var(--ink); margin-top: 2px; }
.foot-value-ar {
  font-family: "Cairo", sans-serif;
  font-size: 12px;
  color: var(--ink);
  margin-top: 2px;
  text-align: right;
}
.foot-right { text-align: right; }

/* Compact layout --------------------------------------------------- */
.card.layout-compact .card-head { padding-top: 18px; padding-bottom: 12px; }
.card.layout-compact .number-band { padding-top: 10px; padding-bottom: 10px; }
.card.layout-compact .card-body { padding-top: 12px; padding-bottom: 6px; }
.card.layout-compact .ben-section { padding-top: 6px; }
.card.layout-compact .card-foot { padding-top: 10px; padding-bottom: 14px; }
.card.layout-compact .field-fr,
.card.layout-compact .field-ar { padding: 4px 0; }
.card.layout-compact .ben-row { padding: 6px 12px; }
.card.layout-compact .num-value { font-size: 24px; padding: 4px 18px; }

/* =====================================================================
   COMPACT CARD — Business card vertical (54×85.6mm = 600×950px)
   Hidden off-screen, used only for PNG download
   ===================================================================== */
.card-compact-host {
  position: absolute;
  left: -10000px;
  top: 0;
  pointer-events: none;
}

.card-compact {
  width: 600px;
  height: 950px;
  min-height: 950px;
  max-height: 950px;
  background: #ffffff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: "Inter", -apple-system, sans-serif;
  color: var(--ink, #1a2535);
  border: 1px solid #c8cdd4;
  box-sizing: border-box;
  /* White safe margin for printing */
  padding: 18px;
  transform: none;
}

/* Inner surface — now pure white instead of paper */
.card-compact::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 6px;
  pointer-events: none;
  background: #ffffff;
  z-index: 0;
}
.card-compact > * {
  position: relative;
  z-index: 1;
}

.cc-accent {
  height: 10px;
  flex-shrink: 0;
  background: linear-gradient(
    90deg,
    var(--brand, #0F6E56) 0%,
    color-mix(in oklab, var(--brand, #0F6E56) 70%, var(--accent, #BA7517)) 50%,
    var(--accent, #BA7517) 100%
  );
}

/* Header — three columns: CNSS | AMO TADAMON center | Morocco */
.cc-head {
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  align-items: center;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 2px solid color-mix(in oklab, var(--brand, #0F6E56) 28%, transparent);
}
.cc-logo-side {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
}
.cc-brand-center {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.cc-brand-name {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--brand, #0F6E56);
  line-height: 1;
  white-space: nowrap;
}
.cc-brand-sub-fr {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5F5E5A;
  line-height: 1.2;
}

.cc-num-band {
  padding: 18px 24px;
  text-align: center;
  background: transparent;
  border-bottom: 1px solid color-mix(in oklab, var(--brand, #0F6E56) 18%, transparent);
  flex-shrink: 0;
  white-space: nowrap;
}
.cc-num-label {
  font-size: 13px;
  color: #5F5E5A;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 8px;
  font-family: "Cairo", "Inter", sans-serif;
  white-space: nowrap;
}
.cc-num-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 32px;
  font-weight: 700;
  color: var(--brand, #0F6E56);
  letter-spacing: 0.10em;
  display: inline-block;
  padding: 6px 18px;
  border-top: 1.5px solid color-mix(in oklab, var(--brand, #0F6E56) 40%, transparent);
  border-bottom: 1.5px solid color-mix(in oklab, var(--brand, #0F6E56) 40%, transparent);
  white-space: nowrap;
}

/* Identity block — bigger fonts */
.cc-identity {
  padding: 18px 24px 16px;
  border-bottom: 1px solid #d8d8d8;
  flex-shrink: 0;
}
.cc-identity-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #d0d0d0;
}
.cc-identity-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink, #1a2535);
  letter-spacing: 0.02em;
  line-height: 1.15;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cc-identity-value-ar {
  font-family: "Cairo", sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink, #1a2535);
  text-align: right;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cc-identity-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  font-size: 15px;
  color: #2C2C2A;
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
}
.cc-identity-meta b {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  color: #5F5E5A;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 6px;
}

/* Beneficiaries — bigger */
.cc-ben {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 24px;
  min-height: 0;
}
.cc-ben-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--brand, #0F6E56);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 2px solid color-mix(in oklab, var(--brand, #0F6E56) 32%, transparent);
  white-space: nowrap;
  flex-shrink: 0;
}
.cc-ben-title span:last-child {
  font-family: "Cairo", sans-serif;
  font-size: 17px;
  letter-spacing: 0;
}
.cc-ben-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.cc-ben-row {
  display: grid;
  grid-template-columns: 32px 1fr 130px 120px;
  gap: 14px;
  align-items: center;
  padding: 9px 6px;
  font-family: "Cairo", sans-serif;
  border-bottom: 0.5px dotted #b8b8b8;
  font-size: 19px;
  position: relative;
  flex: 1;
  min-height: 46px;
}
.cc-ben-row:last-child { border-bottom: none; }
.cc-ben-num {
  font-family: "JetBrains Mono", monospace;
  font-size: 16px;
  color: #5F5E5A;
  text-align: center;
  font-weight: 700;
  background: color-mix(in oklab, var(--brand, #0F6E56) 10%, transparent);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  margin: 0 auto;
}
.cc-ben-name {
  font-weight: 700;
  font-size: 21px;
  color: var(--ink, #1a2535);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.cc-ben-id {
  font-family: "JetBrains Mono", monospace;
  font-size: 18px;
  color: var(--brand, #0F6E56);
  font-weight: 700;
  text-align: left;
  direction: ltr;
  letter-spacing: 0.02em;
}
.cc-ben-birth {
  font-family: "JetBrains Mono", monospace;
  font-size: 17px;
  color: #2C2C2A;
  font-weight: 600;
  text-align: left;
  direction: ltr;
}

/* Footer — designer signature */
.cc-foot {
  padding: 12px 24px;
  font-family: "Cairo", sans-serif;
  font-size: 11px;
  color: #5F5E5A;
  text-align: center;
  border-top: 1px solid #d0d0d0;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.cc-foot-fr {
  font-family: "Inter", sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand, #0F6E56);
  letter-spacing: 0.04em;
}
.cc-foot-ar {
  font-family: "Cairo", sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand, #0F6E56);
}

/* =====================================================================
   CARD BACK — Verso of the business card (54×85.6mm vertical)
   Decorative side with logos and brand name only
   ===================================================================== */
.card-back-host {
  position: absolute;
  left: -10000px;
  top: 0;
  pointer-events: none;
}

.card-back {
  width: 600px;
  height: 950px;
  min-height: 950px;
  max-height: 950px;
  background: #ffffff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: "Inter", -apple-system, sans-serif;
  color: var(--ink, #1a2535);
  border: 1px solid #c8cdd4;
  box-sizing: border-box;
  padding: 18px;
  transform: none;
}

/* Inner surface — pure white */
.card-back::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 6px;
  pointer-events: none;
  background: #ffffff;
  z-index: 0;
}
.card-back > * {
  position: relative;
  z-index: 1;
}

.cb-accent {
  height: 10px;
  flex-shrink: 0;
  background: linear-gradient(
    90deg,
    var(--brand, #0F6E56) 0%,
    color-mix(in oklab, var(--brand, #0F6E56) 70%, var(--accent, #BA7517)) 50%,
    var(--accent, #BA7517) 100%
  );
}
.cb-accent-bottom {
  background: linear-gradient(
    90deg,
    var(--accent, #BA7517) 0%,
    color-mix(in oklab, var(--brand, #0F6E56) 70%, var(--accent, #BA7517)) 50%,
    var(--brand, #0F6E56) 100%
  );
}

/* Background pattern — hidden for white background */
.cb-pattern {
  display: none;
}

/* Corner ornaments */
.cb-corner {
  position: absolute;
  width: 60px;
  height: 60px;
  pointer-events: none;
}
.cb-corner-tl { top: 22px; left: 22px; }
.cb-corner-tr { top: 22px; right: 22px; }
.cb-corner-bl { bottom: 22px; left: 22px; }
.cb-corner-br { bottom: 22px; right: 22px; }

/* Content */
.cb-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  padding: 50px 50px;
  position: relative;
  z-index: 2;
}

/* Morocco coat of arms section */
.cb-morocco {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.cb-morocco-img {
  width: 130px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.10));
}
.cb-morocco-label {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cb-morocco-ar {
  font-family: "Cairo", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink, #1a2535);
  letter-spacing: 0.04em;
}
.cb-morocco-fr {
  font-size: 11px;
  font-weight: 600;
  color: #5F5E5A;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

/* Decorative divider */
.cb-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 380px;
}
.cb-divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in oklab, var(--brand, #0F6E56) 50%, transparent),
    transparent
  );
}
.cb-divider-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* Central brand block */
.cb-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  width: 100%;
}

/* Holder info block (when totalCount >= 6) */
.cb-content-with-holder {
  padding: 32px 36px !important;
  justify-content: space-between !important;
  gap: 6px;
}
.cb-content-with-holder .cb-morocco-img { width: 95px; }
.cb-content-with-holder .cb-cnss-img { width: 85px; }

.cb-holder-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0;
}
.cb-person {
  background: #ffffff;
  border: 1.5px solid color-mix(in oklab, var(--brand, #0F6E56) 28%, transparent);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.cb-person-holder {
  border-color: color-mix(in oklab, var(--accent, #BA7517) 50%, transparent);
}
.cb-person-holder::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 5px;
  background: var(--accent, #BA7517);
}
.cb-person-spouse::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 5px;
  background: var(--brand, #0F6E56);
}
.cb-person-rel {
  font-family: "Cairo", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--brand, #0F6E56);
  letter-spacing: 0.02em;
  padding: 3px 12px;
  background: color-mix(in oklab, var(--brand, #0F6E56) 7%, transparent);
  border-radius: 12px;
}
.cb-person-holder .cb-person-rel {
  color: var(--accent, #BA7517);
  background: color-mix(in oklab, var(--accent, #BA7517) 8%, transparent);
}
.cb-person-name {
  font-family: "Cairo", sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink, #1a2535);
  line-height: 1.2;
  margin-top: 2px;
}
.cb-person-name-lat {
  font-size: 13px;
  font-weight: 600;
  color: #5F5E5A;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: -4px;
}
.cb-person-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
.cb-person-meta-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.cb-person-meta-label {
  font-size: 10px;
  font-weight: 600;
  color: #5F5E5A;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}
.cb-person-meta-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand, #0F6E56);
  letter-spacing: 0.02em;
}
.cb-person-meta-sep {
  width: 1px;
  height: 26px;
  background: color-mix(in oklab, var(--brand, #0F6E56) 25%, transparent);
}
.cb-brand-name {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--brand, #0F6E56);
  line-height: 1;
  text-shadow: 0 1px 2px color-mix(in oklab, var(--brand, #0F6E56) 18%, transparent);
  white-space: nowrap;
}
.cb-brand-ar {
  font-family: "Cairo", sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--accent, #BA7517);
  letter-spacing: 0.06em;
  margin-top: 4px;
  line-height: 1;
}
.cb-brand-tagline {
  font-size: 11px;
  font-weight: 600;
  color: #5F5E5A;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 10px;
  line-height: 1.4;
  white-space: nowrap;
}
.cb-brand-tagline-ar {
  font-family: "Cairo", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #5F5E5A;
  letter-spacing: 0.02em;
  line-height: 1.4;
  white-space: nowrap;
}

/* CNSS section */
.cb-cnss {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.cb-cnss-img {
  width: 120px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}
.cb-cnss-label {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cb-cnss-ar {
  font-family: "Cairo", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink, #1a2535);
  letter-spacing: 0.02em;
}
.cb-cnss-fr {
  font-size: 10.5px;
  font-weight: 600;
  color: #5F5E5A;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* === BENEFICIARY LAYOUT VARIANTS === */

/* Single beneficiary — hero card layout */
.cc-ben-single {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 30px 20px;
  text-align: center;
  background: #ffffff;
  border-radius: 12px;
  border: 1.5px solid color-mix(in oklab, var(--brand, #0F6E56) 22%, transparent);
  position: relative;
  overflow: hidden;
}
.cc-ben-single::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 5px;
  background: var(--accent, #BA7517);
}
.cc-ben-single-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.cc-ben-single-rel {
  font-family: "Cairo", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand, #0F6E56);
  letter-spacing: 0.04em;
  padding: 5px 18px;
  background: color-mix(in oklab, var(--brand, #0F6E56) 8%, transparent);
  border-radius: 20px;
  border: 1px solid color-mix(in oklab, var(--brand, #0F6E56) 25%, transparent);
}
.cc-ben-single-name {
  font-family: "Cairo", sans-serif;
  font-size: 30px;
  font-weight: 800;
  color: var(--ink, #1a2535);
  line-height: 1.2;
  text-align: center;
  padding: 0 10px;
}
.cc-ben-single-meta {
  display: flex;
  align-items: center;
  gap: 24px;
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}
.cc-ben-single-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.cc-ben-single-label {
  font-size: 10px;
  font-weight: 600;
  color: #5F5E5A;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}
.cc-ben-single-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 17px;
  font-weight: 700;
  color: var(--brand, #0F6E56);
  letter-spacing: 0.04em;
}
.cc-ben-single-divider {
  width: 1px;
  height: 38px;
  background: color-mix(in oklab, var(--brand, #0F6E56) 25%, transparent);
}

/* Two beneficiaries — paired card layout */
.cc-ben-pair {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 12px 0;
  align-items: stretch;
}
.cc-ben-pair-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  gap: 14px;
  padding: 28px 14px;
  background: #ffffff;
  border: 1px solid color-mix(in oklab, var(--brand, #0F6E56) 22%, transparent);
  border-radius: 10px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.cc-ben-pair-titulaire {
  background: #ffffff;
  border-color: color-mix(in oklab, var(--accent, #BA7517) 40%, transparent);
}
.cc-ben-pair-titulaire::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent, #BA7517);
}
.cc-ben-pair-rel {
  font-family: "Cairo", sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--brand, #0F6E56);
  letter-spacing: 0.02em;
  padding: 5px 14px;
  background: white;
  border-radius: 18px;
  border: 1px solid color-mix(in oklab, var(--brand, #0F6E56) 18%, transparent);
}
.cc-ben-pair-titulaire .cc-ben-pair-rel {
  color: var(--accent, #BA7517);
  border-color: color-mix(in oklab, var(--accent, #BA7517) 35%, transparent);
}
.cc-ben-pair-name {
  font-family: "Cairo", sans-serif;
  font-size: 25px;
  font-weight: 800;
  color: var(--ink, #1a2535);
  line-height: 1.25;
  margin: 8px 0;
}
.cc-ben-pair-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.cc-ben-pair-label {
  font-size: 12px;
  font-weight: 600;
  color: #5F5E5A;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}
.cc-ben-pair-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 17px;
  font-weight: 700;
  color: var(--brand, #0F6E56);
  letter-spacing: 0.02em;
}

/* PRINT ------------------------------------------------------------ */
@media print {
  @page { size: landscape; margin: 12mm; }
  html, body { background: white; }
  .pane-form, .preview-bar, .pane-actions { display: none !important; }
  .app { display: block; height: auto; }
  .pane-preview { background: white !important; }
  .preview-stage { padding: 0; }
  .card-wrap { filter: none; }
  .card { box-shadow: none; border: 1px solid oklch(0.85 0.010 200); page-break-inside: avoid; }
}

/* Responsive ------------------------------------------------------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  .pane-form { max-height: 50vh; }
  .preview-stage { padding: 20px; }
  .card { transform: scale(0.7); transform-origin: top center; }
}
