/* ============================================================
   Outdoor Ads Dashboard — styles
   Design tokens follow the validated reference dataviz palette.
   RTL-first with logical properties; EN mode flips automatically.
   ============================================================ */

/* ---------------- Fonts (self-hosted, no third-party requests) ------------ */
@font-face {
  font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

/* ------------------------------ Tokens ------------------------------------ */
/* Remat identity: primary green #00785C, gold #B6833A, theme accents.
   Series hues validated (dataviz six-checks) in both modes:
   منتقلة #007EA6 · جديدة #B6833A · إحلال #00A58E  (dark: #2E9FC9/#BF8534/#0EA98F) */
:root {
  color-scheme: light;
  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --ink:         #1f2523;
  --ink-2:       #4d5551;
  --muted:       #86908b;
  --grid:        #e2e1da;
  --baseline:    #c2c6c0;
  --border:      rgba(20, 40, 33, 0.10);
  --brand:       #00785C;  /* Remat green */
  --gold:        #B6833A;  /* Remat gold  */
  --series-1:    #007EA6;  /* منتقلة  relocated */
  --series-2:    #B6833A;  /* جديدة   new       */
  --series-3:    #00A58E;  /* إحلال   redesign  */
  --seq-track:   #d5e8e2;  /* light step of the green ramp (meter track) */
  --good:        #0ca30c;
  --warning:     #fab219;
  --serious:     #ec835a;
  --critical:    #A6192E;  /* Remat crimson */
  --delta-good:  #005c46;
  --accent:      var(--brand);
  --accent-ink:  #ffffff;
  --tint-lic:    rgba(0, 120, 92, 0.06);
  --tint-act:    rgba(0, 126, 166, 0.06);
  --tint-plan:   rgba(182, 131, 58, 0.08);
  --tint-rem:    rgba(163, 151, 192, 0.12);
  --tint-pct:    rgba(0, 120, 92, 0.10);
  --shadow:      0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.05);
  --radius:      14px;
  --radius-s:    9px;
  --font:        'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:        #0d0d0d;
  --surface:     #1a1a19;
  --ink:         #ffffff;
  --ink-2:       #c3c2b7;
  --muted:       #898781;
  --grid:        #2c2c2a;
  --baseline:    #383835;
  --border:      rgba(255, 255, 255, 0.10);
  --brand:       #12A186;
  --gold:        #BF8534;
  --series-1:    #2E9FC9;
  --series-2:    #BF8534;
  --series-3:    #0EA98F;
  --seq-track:   #0e4a3d;
  --critical:    #d24a5d;
  --delta-good:  #12A186;
  --tint-lic:    rgba(18, 161, 134, 0.10);
  --tint-act:    rgba(46, 159, 201, 0.10);
  --tint-plan:   rgba(191, 133, 52, 0.12);
  --tint-rem:    rgba(163, 151, 192, 0.13);
  --tint-pct:    rgba(18, 161, 134, 0.14);
  --shadow:      0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.30);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page:        #0d0d0d;
    --surface:     #1a1a19;
    --ink:         #ffffff;
    --ink-2:       #c3c2b7;
    --muted:       #898781;
    --grid:        #2c2c2a;
    --baseline:    #383835;
    --border:      rgba(255, 255, 255, 0.10);
    --brand:       #12A186;
    --gold:        #BF8534;
    --series-1:    #2E9FC9;
    --series-2:    #BF8534;
    --series-3:    #0EA98F;
    --seq-track:   #0e4a3d;
    --critical:    #d24a5d;
    --delta-good:  #12A186;
    --tint-lic:    rgba(18, 161, 134, 0.10);
    --tint-act:    rgba(46, 159, 201, 0.10);
    --tint-plan:   rgba(191, 133, 52, 0.12);
    --tint-rem:    rgba(163, 151, 192, 0.13);
    --tint-pct:    rgba(18, 161, 134, 0.14);
    --shadow:      0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.30);
  }
}

/* ------------------------------ Base --------------------------------------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
}
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; color: inherit; }
svg { display: block; }

/* ------------------------------ Topbar ------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap;
  padding: 14px clamp(14px, 3vw, 28px);
  border-block-end: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-text h1 { font-size: 16.5px; font-weight: 700; line-height: 1.25; }
.subtitle { color: var(--ink-2); font-size: 12px; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.updated-pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; color: var(--ink-2);
  background: var(--page);
}
.updated-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.updated-pill.checking .dot { background: var(--warning); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  padding: 7px 13px; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--page); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.primary:disabled { opacity: 0.6; cursor: progress; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface); border-color: var(--baseline); }
.btn.icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }
.btn.icon.lang { font-weight: 700; font-size: 12px; width: auto; min-width: 34px; padding-inline: 9px; }
.btn.small { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ------------------------------ Banners / toast ----------------------------- */
#banners { display: grid; gap: 8px; padding: 0 clamp(14px, 3vw, 28px); }
#banners:not(:empty) { padding-top: 10px; }
.banner {
  border: 1px solid var(--border); border-radius: var(--radius-s);
  padding: 9px 14px; font-size: 12.5px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline;
  background: var(--surface);
}
.banner strong { font-weight: 700; }
.banner.info { border-inline-start: 3px solid var(--series-1); }
.banner.warn { border-inline-start: 3px solid var(--warning); }
.banner[hidden] { display: none; }

.toast {
  position: fixed; inset-block-end: 22px; inset-inline-start: 50%;
  transform: translateX(-50%);
  background: var(--ink); color: var(--page);
  padding: 9px 18px; border-radius: 999px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow); z-index: 100;
  animation: toast-in 0.25s ease;
}
[dir="rtl"] .toast { transform: translateX(50%); }
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } }

/* ------------------------------ Layout ------------------------------------- */
#main { padding: 16px clamp(14px, 3vw, 28px) 40px; max-width: 1460px; margin-inline: auto; }
.loading { display: grid; place-items: center; gap: 14px; padding: 90px 0; color: var(--ink-2); }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--grid); border-top-color: var(--series-1);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px;
}
.card-head { margin-block-end: 10px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-head h2 { font-size: 14px; font-weight: 700; }
.card-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.chart-total {
  flex: none; text-align: center;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--page); padding: 5px 13px; min-width: 74px;
}
.chart-total .ct-label { display: block; font-size: 10px; color: var(--muted); font-weight: 600; }
.chart-total .ct-value { display: block; font-size: 17px; font-weight: 700; color: var(--ink); line-height: 1.2; }
/* numeric values always read left-to-right (digits then %), even in RTL UI */
.ct-value, .hero-value, .tile .t-value,
.pdf-kpi .k-value, .pdf-cc-head .cc-total b,
.pdf-media-pct .mp-value, .pdf-panel .pp-row b { direction: ltr; unicode-bidi: isolate; }
.chart-total.brand { border-color: color-mix(in srgb, var(--brand) 35%, transparent); background: var(--tint-pct); }
.chart-total.brand .ct-value { color: var(--brand); }
.footnote { color: var(--muted); font-size: 11px; margin-top: 8px; }

#dash.stale { opacity: 0.55; transition: opacity 0.2s ease; pointer-events: none; }
#dash { transition: opacity 0.2s ease; }

/* ------------------------------ Error view ---------------------------------- */
.error-view { display: grid; place-items: center; padding: 60px 0; }
.error-card { max-width: 560px; text-align: center; display: grid; gap: 10px; padding: 28px; }
.error-card h2 { font-size: 17px; }
.error-message { color: var(--ink-2); font-size: 13.5px; word-break: break-word; }
.error-hint { color: var(--muted); font-size: 12.5px; }
.error-actions { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }

/* ------------------------------ Filters ------------------------------------- */
.filters {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-block-end: 14px;
}
.combo { position: relative; }
.combo-btn .combo-count {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; font-size: 11px; font-weight: 700;
  padding: 0 7px; line-height: 18px; min-width: 18px; text-align: center;
}
.combo-pop {
  position: absolute; inset-block-start: calc(100% + 6px); inset-inline-start: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s);
  box-shadow: var(--shadow); padding: 6px; z-index: 60;
  max-height: 320px; overflow: auto; min-width: 230px;
}
.combo-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; border-radius: 7px; cursor: pointer; font-size: 13px;
  user-select: none;
}
.combo-item:hover { background: var(--page); }
.combo-item input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.combo-sep { border-block-start: 1px solid var(--grid); margin: 5px 2px; }
.combo-item.combo-all { font-weight: 600; }

.switch { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 34px; height: 20px; border-radius: 999px; background: var(--baseline);
  position: relative; transition: background 0.15s ease; flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 14px; height: 14px; border-radius: 50%; background: var(--surface);
  transition: translate 0.15s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { translate: 14px 0; }
[dir="rtl"] .switch input:checked + .track::after { translate: -14px 0; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-note { color: var(--muted); font-size: 12px; }

/* ------------------------------ KPIs ---------------------------------------- */
.kpis {
  display: grid; gap: 12px;
  grid-template-columns: minmax(250px, 1.15fr) 2.6fr;
  margin-block-end: 14px;
  align-items: stretch;
}
.hero { display: grid; align-content: center; gap: 10px; }
.hero .hero-label { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.hero .hero-value { font-size: 52px; font-weight: 700; line-height: 1; letter-spacing: -0.01em; }
.hero .hero-sub { color: var(--muted); font-size: 12px; }
.meter { height: 8px; border-radius: 999px; background: var(--seq-track); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.5s ease; }
.hero .chip { justify-self: start; }

.tiles {
  display: grid; gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.tile { display: grid; align-content: start; gap: 4px; padding: 14px 16px; }
.tile .t-label { color: var(--ink-2); font-size: 12px; font-weight: 500; }
.tile .t-value { font-size: 26px; font-weight: 600; line-height: 1.15; }
.tile .t-sub { color: var(--muted); font-size: 11px; }
.tile .t-sub .warn { color: var(--serious); font-weight: 600; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
  background: var(--page);
}

/* ------------------------------ Charts grid --------------------------------- */
.charts-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-block-end: 14px;
}
.chart-card { display: flex; flex-direction: column; }
.chart-box { position: relative; width: 100%; }
.trend-card { margin-block-end: 14px; }
.trend-box { height: 260px; }
.empty-state { padding: 34px 10px; text-align: center; color: var(--muted); font-size: 12.5px; display: grid; gap: 5px; }

/* ------------------------------ Tables -------------------------------------- */
.tables-card { padding: 0; overflow: hidden; margin-block-end: 14px; }
.tables-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-block-end: 1px solid var(--border);
}
.tabs { display: flex; gap: 4px; background: var(--page); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.tab {
  border: 0; background: transparent; border-radius: 8px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(11,11,11,0.08); }
.table-search {
  border: 1px solid var(--border); border-radius: 9px; background: var(--page);
  color: var(--ink); font-family: inherit; font-size: 13px; padding: 7px 12px; min-width: 200px;
}
.table-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* No inner vertical scroll: the full table is always visible (horizontal
   scroll only, for narrow screens). */
.table-wrap { overflow-x: auto; }
table.data {
  border-collapse: separate; border-spacing: 0; width: 100%;
  font-size: 12.5px; white-space: nowrap;
}
table.data th, table.data td {
  padding: 7px 12px; border-block-end: 1px solid var(--grid);
  text-align: center; font-variant-numeric: tabular-nums;
}
table.data thead th {
  background: var(--surface); z-index: 3;
  font-size: 11.5px; color: var(--ink-2); font-weight: 600;
  border-block-end: 1px solid var(--baseline);
}
table.data thead tr.group-row th { border-block-end: 0; padding-block: 7px 4px; }
table.data thead th.group {
  font-weight: 700; color: var(--ink);
  border-block-end: 2px solid var(--grid);
}
/* sticky header/footer cells need OPAQUE backgrounds: tint layered on surface */
table.data thead th.g-lic  { background: linear-gradient(var(--tint-lic), var(--tint-lic)) var(--surface);  border-block-end-color: var(--brand); }
table.data thead th.g-act  { background: linear-gradient(var(--tint-act), var(--tint-act)) var(--surface);  border-block-end-color: var(--series-1); }
table.data thead th.g-plan { background: linear-gradient(var(--tint-plan), var(--tint-plan)) var(--surface); border-block-end-color: var(--gold); }
table.data thead th.g-rem  { background: linear-gradient(var(--tint-rem), var(--tint-rem)) var(--surface);  border-block-end-color: #A397C0; }
table.data thead th.g-pct  { background: linear-gradient(var(--tint-pct), var(--tint-pct)) var(--surface);  border-block-end-color: var(--brand); }
table.data thead tr.head-row th.c-lic  { background: linear-gradient(var(--tint-lic), var(--tint-lic)) var(--surface); }
table.data thead tr.head-row th.c-act  { background: linear-gradient(var(--tint-act), var(--tint-act)) var(--surface); }
table.data thead tr.head-row th.c-plan { background: linear-gradient(var(--tint-plan), var(--tint-plan)) var(--surface); }
table.data thead tr.head-row th.c-rem  { background: linear-gradient(var(--tint-rem), var(--tint-rem)) var(--surface); }
table.data thead tr.head-row th.c-pct  { background: linear-gradient(var(--tint-pct), var(--tint-pct)) var(--surface); }
/* body cells: light transparent wash */
table.data tbody td.c-lic  { background: var(--tint-lic); }
table.data tbody td.c-act  { background: var(--tint-act); }
table.data tbody td.c-plan { background: var(--tint-plan); }
table.data tbody td.c-rem  { background: var(--tint-rem); }
table.data tbody td.c-pct  { background: var(--tint-pct); }
table.data tfoot td.c-lic  { background: linear-gradient(var(--tint-lic), var(--tint-lic)) var(--page); }
table.data tfoot td.c-act  { background: linear-gradient(var(--tint-act), var(--tint-act)) var(--page); }
table.data tfoot td.c-plan { background: linear-gradient(var(--tint-plan), var(--tint-plan)) var(--page); }
table.data tfoot td.c-rem  { background: linear-gradient(var(--tint-rem), var(--tint-rem)) var(--page); }
table.data tfoot td.c-pct  { background: linear-gradient(var(--tint-pct), var(--tint-pct)) var(--page); }
/* identity dots tying columns to the chart series */
.hdot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-inline-end: 5px; vertical-align: middle; translate: 0 -1px;
}
.hdot.d-rel { background: var(--series-1); }
.hdot.d-new { background: var(--series-2); }
.hdot.d-red { background: var(--series-3); }
.hdot.d-rmv { background: var(--critical); }
.hdot.d-ins { background: #7C878E; }
.legend-strip {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  padding: 8px 16px 0; font-size: 11px; color: var(--ink-2);
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--ink); }
table.data th .arrow { font-size: 9px; margin-inline-start: 3px; }
table.data td.name, table.data th.name {
  position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 2;
  text-align: start; font-weight: 600; white-space: normal; min-width: 130px;
  border-inline-end: 1px solid var(--grid);
}
table.data thead th.name { z-index: 4; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
table.data td.zero { color: var(--muted); }
table.data tfoot td {
  background: var(--page); font-weight: 700;
  border-block-start: 2px solid var(--baseline); z-index: 2;
}
table.data tfoot td.name { z-index: 3; }
table.data td.pct { font-weight: 600; }
.mini-meter {
  display: inline-block; width: 52px; height: 5px; border-radius: 999px;
  background: var(--seq-track); overflow: hidden; vertical-align: middle; margin-inline-start: 7px;
}
.mini-meter i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.foot { color: var(--muted); font-size: 11.5px; display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------------------- PDF stage — Remat identity ------------------------- */
#pdfStage {
  position: absolute; inset-inline-start: -20000px; top: 0;
  width: 1123px; pointer-events: none;
}
.pdf-slide {
  --r-green: #00785C; --r-gold: #B6833A; --r-ink: #3A3838; --r-ink2: #666461;
  --r-muted: #8f8d8a; --r-line: #e4e3de;
  --r-blue: #007EA6; --r-teal: #00A58E; --r-red: #A6192E; --r-lav: #A397C0;
  width: 1123px; height: 794px; overflow: hidden; position: relative;
  background: #ffffff; color: var(--r-ink);
  font-family: var(--font);
  display: flex; flex-direction: column;
  padding: 40px 52px 46px;
}
.pdf-slide, .pdf-slide * { box-shadow: none !important; }
.pdf-pattern {
  position: absolute; inset-inline: 0; bottom: 0; height: 92px;
  background-image: url('../assets/remat-pattern.png');
  background-repeat: repeat-x; background-size: auto 92px; background-position: bottom center;
  opacity: 0.16; pointer-events: none;
}
.pdf-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.pdf-head .p-title { font-size: 21px; font-weight: 700; color: var(--r-green); }
.pdf-head .p-sub { font-size: 12px; color: var(--r-ink2); margin-top: 3px; }
.pdf-head .p-logo { height: 44px; width: auto; }
.pdf-foot {
  position: absolute; inset-inline: 52px; bottom: 14px;
  display: flex; justify-content: space-between; align-items: center;
  color: var(--r-muted); font-size: 10.5px;
}
.pdf-foot .f-logo { height: 22px; width: auto; opacity: 0.9; }
.pdf-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

/* Cover */
.pdf-cover { justify-content: center; align-items: center; text-align: center; gap: 12px; display: flex; flex-direction: column; }
.pdf-slide .c-logo { height: 118px; width: auto; margin-bottom: 14px; }
.pdf-cover .c-title { font-size: 33px; font-weight: 700; max-width: 840px; color: var(--r-green); }
.pdf-cover .c-sub { font-size: 16px; color: var(--r-ink2); }
.pdf-cover .c-meta { font-size: 12.5px; color: var(--r-muted); margin-top: 14px; display: grid; gap: 4px; }

/* Section divider (الملحقات) */
.pdf-divider { justify-content: center; align-items: center; display: flex; flex-direction: column; gap: 12px; }
.pdf-divider .d-title { font-size: 44px; font-weight: 700; color: var(--r-green); }
.pdf-divider .d-sub { font-size: 15px; color: var(--r-ink2); }

/* KPI slide */
.pdf-kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; align-content: center; flex: 1; }
.pdf-kpi {
  border: 1px solid var(--r-line); border-radius: 12px; padding: 18px 22px;
  display: grid; gap: 5px; align-content: center; background: #ffffff;
}
.pdf-kpi .k-label { font-size: 13px; color: var(--r-ink2); font-weight: 600; }
.pdf-kpi .k-value { font-size: 33px; font-weight: 700; line-height: 1.1; color: var(--r-ink); }
.pdf-kpi .k-sub { font-size: 11px; color: var(--r-muted); }
.pdf-kpi.k-hero { grid-row: span 2; background: var(--r-green); border-color: var(--r-green); gap: 10px; }
.pdf-kpi.k-hero .k-label, .pdf-kpi.k-hero .k-sub { color: rgba(255, 255, 255, 0.85); }
.pdf-kpi.k-hero .k-value { font-size: 58px; color: #ffffff; }
.pdf-kpi.k-hero .k-meter { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.28); overflow: hidden; }
.pdf-kpi.k-hero .k-meter i { display: block; height: 100%; background: #ffffff; border-radius: 999px; }

/* Combined charts slide */
.pdf-charts-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.pdf-charts-grid.rows-3 { grid-template-rows: 1fr 1fr 1fr; }
.pdf-chart-cell {
  border: 1px solid var(--r-line); border-radius: 12px; padding: 12px 15px 10px;
  display: flex; flex-direction: column; min-height: 0; background: #ffffff;
}
.pdf-chart-cell.span-2 { grid-column: span 2; }
.pdf-cc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.pdf-cc-head .cc-title { font-size: 12.5px; font-weight: 700; color: var(--r-green); }
.pdf-cc-head .cc-total { font-size: 11px; color: var(--r-ink2); font-weight: 600; }
.pdf-cc-head .cc-total b { font-size: 14px; color: var(--r-ink); margin-inline-start: 4px; }
.pdf-chart-cell img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }

/* Tables — Remat style: green header band, tinted groups */
.pdf-table { font-size: 10px; position: relative; z-index: 1; }
.pdf-table table { border-collapse: collapse; width: 100%; }
.pdf-table th, .pdf-table td {
  padding: 4.5px 6px; text-align: center; font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--r-line);
}
.pdf-table thead th { background: var(--r-green); color: #ffffff; font-weight: 600; font-size: 9.5px; border-bottom: 0; }
.pdf-table thead tr.pg-groups th { font-size: 10.5px; font-weight: 700; }
.pdf-table thead tr.pg-groups th.pg-lic { background: #00785C; }
.pdf-table thead tr.pg-groups th.pg-act { background: #007EA6; }
.pdf-table thead tr.pg-groups th.pg-plan { background: #B6833A; }
.pdf-table thead tr.pg-groups th.pg-rem { background: #8b7fa8; }
.pdf-table thead tr.pg-groups th.pg-pct { background: #005c46; }
.pdf-table thead tr.pg-cols th.pg-lic { background: #1d8a71; }
.pdf-table thead tr.pg-cols th.pg-act { background: #2691b3; }
.pdf-table thead tr.pg-cols th.pg-plan { background: #c29552; }
.pdf-table thead tr.pg-cols th.pg-rem { background: #9c92b5; }
.pdf-table thead tr.pg-cols th.pg-pct { background: #1d7a63; }
.pdf-table tbody td.pg-lic { background: rgba(0, 120, 92, 0.055); }
.pdf-table tbody td.pg-act { background: rgba(0, 126, 166, 0.055); }
.pdf-table tbody td.pg-plan { background: rgba(182, 131, 58, 0.075); }
.pdf-table tbody td.pg-rem { background: rgba(163, 151, 192, 0.12); }
.pdf-table tbody td.pg-pct { background: rgba(0, 120, 92, 0.10); font-weight: 700; }
.pdf-table td.pname, .pdf-table th.pname { text-align: start; font-weight: 700; white-space: nowrap; }
.pdf-table tfoot td { background: rgba(0, 120, 92, 0.12); font-weight: 700; border-top: 2px solid var(--r-green); }
.pdf-table .zero { color: #b0aeaa; font-weight: 400; }

/* Appendix media cards */
.pdf-media-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.pdf-media-head .m-name { font-size: 26px; font-weight: 700; color: var(--r-ink); }
.pdf-media-head .m-tag { font-size: 12px; color: var(--r-ink2); margin-top: 2px; }
.pdf-media-pct { text-align: center; background: var(--r-green); color: #fff; border-radius: 12px; padding: 10px 22px; display: grid; gap: 4px; min-width: 150px; }
.pdf-media-pct .mp-value { font-size: 30px; font-weight: 700; line-height: 1; }
.pdf-media-pct .mp-label { font-size: 10.5px; color: rgba(255,255,255,0.85); }
.pdf-media-pct .mp-meter { height: 6px; border-radius: 999px; background: rgba(255,255,255,0.28); overflow: hidden; }
.pdf-media-pct .mp-meter i { display: block; height: 100%; background: #fff; }
.pdf-media-pct.neutral { background: #f1f0ec; color: var(--r-ink2); }
.pdf-media-pct.neutral .mp-label { color: var(--r-muted); }
.pdf-media-grid { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; align-content: start; grid-auto-rows: min-content; min-height: 0; }
.pdf-panel { border: 1px solid var(--r-line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; background: #fff; }
.pdf-panel .pp-head { padding: 8px 14px; font-size: 12.5px; font-weight: 700; color: #ffffff; }
.pdf-panel.p-lic .pp-head { background: var(--r-green); }
.pdf-panel.p-act .pp-head { background: var(--r-blue); }
.pdf-panel.p-plan .pp-head { background: var(--r-gold); }
.pdf-panel.p-rem .pp-head { background: #8b7fa8; }
.pdf-panel .pp-body { padding: 8px 14px 10px; display: grid; gap: 0; align-content: start; flex: 1; }
.pdf-panel .pp-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 5.5px 0; border-bottom: 1px solid #f0efeb; font-size: 12px; color: var(--r-ink2); }
.pdf-panel .pp-row:last-child { border-bottom: 0; }
.pdf-panel .pp-row b { font-size: 14.5px; color: var(--r-ink); font-variant-numeric: tabular-nums; }
.pdf-panel .pp-row.em { background: none; }
.pdf-panel .pp-row.em b { color: var(--r-green); font-size: 16px; }
.pdf-panel .pp-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-inline-end: 6px; translate: 0 -1px; }

/* ------------------------------ Responsive ----------------------------------- */
@media (max-width: 1060px) {
  .kpis { grid-template-columns: 1fr; }
  .hero .hero-value { font-size: 44px; }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar { padding-block: 10px; }
  .brand-text h1 { font-size: 14.5px; }
  .subtitle { display: none; }
  .btn span[data-i18n="refresh"] { display: none; }
  .updated-pill { order: 10; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile .t-value { font-size: 22px; }
  .tables-head { padding: 10px 12px; }
  .table-search { min-width: 0; flex: 1; }
  .trend-box { height: 220px; }
}
