/* =====================================================================================
   مطبعة الابتدائي والمتوسط الرئيسية — universal stylesheet (the ONLY css file)
   Theme: "The Press Room" — warm paper, ink typography, section-coloured accents.
   Every colour is a token on :root; dark variant under [data-theme="dark"].
   ===================================================================================== */

/* ---- Self-hosted font: IBM Plex Sans Arabic (arabic + latin subsets) ----------------- */
@font-face{font-family:'IBM Plex Sans Arabic';font-style:normal;font-weight:400;font-display:swap;src:url('../fonts/IBMPlexSansArabic-400-arabic.woff2') format('woff2');unicode-range:U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;}
@font-face{font-family:'IBM Plex Sans Arabic';font-style:normal;font-weight:400;font-display:swap;src:url('../fonts/IBMPlexSansArabic-400-latin.woff2') format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
@font-face{font-family:'IBM Plex Sans Arabic';font-style:normal;font-weight:500;font-display:swap;src:url('../fonts/IBMPlexSansArabic-500-arabic.woff2') format('woff2');unicode-range:U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;}
@font-face{font-family:'IBM Plex Sans Arabic';font-style:normal;font-weight:500;font-display:swap;src:url('../fonts/IBMPlexSansArabic-500-latin.woff2') format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
@font-face{font-family:'IBM Plex Sans Arabic';font-style:normal;font-weight:600;font-display:swap;src:url('../fonts/IBMPlexSansArabic-600-arabic.woff2') format('woff2');unicode-range:U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;}
@font-face{font-family:'IBM Plex Sans Arabic';font-style:normal;font-weight:600;font-display:swap;src:url('../fonts/IBMPlexSansArabic-600-latin.woff2') format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
@font-face{font-family:'IBM Plex Sans Arabic';font-style:normal;font-weight:700;font-display:swap;src:url('../fonts/IBMPlexSansArabic-700-arabic.woff2') format('woff2');unicode-range:U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;}
@font-face{font-family:'IBM Plex Sans Arabic';font-style:normal;font-weight:700;font-display:swap;src:url('../fonts/IBMPlexSansArabic-700-latin.woff2') format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}

/* ---- Tokens --------------------------------------------------------------------------- */
:root {
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;

  --paper:        #f4f1ea;      /* page background */
  --paper-2:      #fcfbf8;      /* cards, sheets */
  --paper-3:      #ece8df;      /* sunk areas, table header */
  --ink:          #1c1917;      /* headings, primary text, sidebar */
  --ink-2:        #44403c;      /* body text */
  --ink-3:        #78716c;      /* muted */
  --ink-4:        #a8a29e;      /* placeholders, dividers text */
  --line:         rgba(28,25,23,.12);
  --line-strong:  rgba(28,25,23,.28);
  --on-ink:       #f4f1ea;      /* text on ink backgrounds */

  --accent:       #1e40af;      /* links / focus */
  --accent-soft:  rgba(30,64,175,.10);
  --sec:          #1e40af;      /* section colour — overridden per section */
  --sec-soft:     rgba(30,64,175,.10);
  --sec-on:       #ffffff;

  --success:      #15803d;  --success-soft: rgba(21,128,61,.12);
  --warning:      #b45309;  --warning-soft: rgba(180,83,9,.14);
  --danger:       #b91c1c;  --danger-soft:  rgba(185,28,28,.12);
  --info:         #0e7490;  --info-soft:    rgba(14,116,144,.12);

  --shadow-1: 0 1px 2px rgba(28,25,23,.06), 0 1px 1px rgba(28,25,23,.04);
  --shadow-2: 0 6px 20px -8px rgba(28,25,23,.25), 0 2px 6px rgba(28,25,23,.06);
  --shadow-3: 0 30px 60px -20px rgba(28,25,23,.45), 0 10px 24px -10px rgba(28,25,23,.2);

  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --sidebar-w: 264px; --rail-w: 76px; --topbar-h: 68px;
  --ease: cubic-bezier(.2,.7,.2,1);

  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
:root[data-theme="dark"] {
  --paper:        #141311;
  --paper-2:      #1d1b18;
  --paper-3:      #26231f;
  --ink:          #f3efe7;
  --ink-2:        #d6d0c4;
  --ink-3:        #9c958a;
  --ink-4:        #6f695f;
  --line:         rgba(243,239,231,.10);
  --line-strong:  rgba(243,239,231,.26);
  --on-ink:       #141311;

  --accent:       #8fb0ff;  --accent-soft: rgba(143,176,255,.14);
  --success:      #4ade80;  --success-soft: rgba(74,222,128,.14);
  --warning:      #fbbf24;  --warning-soft: rgba(251,191,36,.16);
  --danger:       #f87171;  --danger-soft:  rgba(248,113,113,.16);
  --info:         #67e8f9;  --info-soft:    rgba(103,232,249,.14);

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 8px 24px -10px rgba(0,0,0,.7);
  --shadow-3: 0 30px 70px -20px rgba(0,0,0,.85);
}
/* Section accents (body[data-section]) */
body[data-section="home"]       { --sec:#1e40af; --sec-soft:rgba(30,64,175,.10); }
body[data-section="schools"]    { --sec:#0f766e; --sec-soft:rgba(15,118,110,.11); }
body[data-section="elementary"] { --sec:#c2410c; --sec-soft:rgba(194,65,12,.11); }
body[data-section="middle"]     { --sec:#0e7490; --sec-soft:rgba(14,116,144,.11); }
body[data-section="admin"]      { --sec:#5b21b6; --sec-soft:rgba(91,33,182,.11); }
:root[data-theme="dark"] body[data-section="home"]       { --sec:#93b4ff; --sec-on:#0b1536; --sec-soft:rgba(147,180,255,.14); }
:root[data-theme="dark"] body[data-section="schools"]    { --sec:#5eead4; --sec-on:#042f2e; --sec-soft:rgba(94,234,212,.14); }
:root[data-theme="dark"] body[data-section="elementary"] { --sec:#fb923c; --sec-on:#431407; --sec-soft:rgba(251,146,60,.14); }
:root[data-theme="dark"] body[data-section="middle"]     { --sec:#67e8f9; --sec-on:#083344; --sec-soft:rgba(103,232,249,.14); }
:root[data-theme="dark"] body[data-section="admin"]      { --sec:#c4b5fd; --sec-on:#2e1065; --sec-soft:rgba(196,181,253,.14); }

/* ---- Reset / base --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  color: var(--ink-2); background: var(--paper);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 1; font-variant-numeric: tabular-nums;
}
body::before { /* paper grain */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: var(--grain); opacity: .55; mix-blend-mode: multiply;
}
:root[data-theme="dark"] body::before { opacity: .35; mix-blend-mode: screen; }
h1, h2, h3, h4 { color: var(--ink); margin: 0 0 .5rem; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.65rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
small, .small { font-size: .82rem; }
.muted { color: var(--ink-3); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
td.ltr, th.ltr { display: table-cell; }   /* never turn a table cell into an inline-block */
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
::selection { background: var(--sec); color: var(--sec-on); }
*:focus-visible { outline: 2px solid var(--sec); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- App shell ----------------------------------------------------------------------- */
.app { position: relative; z-index: 1; min-height: 100vh; display: flex; }
.sidebar {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; color: var(--on-ink);
  background: var(--ink); transition: width .25s var(--ease), transform .3s var(--ease);
}
:root[data-theme="dark"] .sidebar { background: #0c0b0a; border-left: 1px solid var(--line); }
.sidebar::after { /* decorative registration mark */
  content: ''; position: absolute; left: -1px; top: 50%; width: 2px; height: 46px; transform: translateY(-50%);
  background: var(--sec); border-radius: 2px; opacity: .9;
}
.brand { display: flex; align-items: center; gap: .8rem; padding: 1.1rem 1.15rem .9rem; border-bottom: 1px solid rgba(255,255,255,.08); min-height: var(--topbar-h); }
.brand img { width: 40px; height: 40px; object-fit: contain; flex: none; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.brand-text { line-height: 1.2; overflow: hidden; }
.brand-text b { display: block; font-size: .92rem; font-weight: 700; color: #fff; white-space: nowrap; }
.brand-text span { display: block; font-size: .72rem; color: rgba(255,255,255,.55); white-space: nowrap; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .8rem .75rem 1rem; scrollbar-width: thin; }
.nav-group { margin-bottom: .9rem; }
.nav-group-title { font-size: .68rem; font-weight: 600; letter-spacing: .12em; color: rgba(255,255,255,.4); padding: .4rem .75rem .35rem; text-transform: uppercase; white-space: nowrap; display: flex; align-items: center; gap: .5rem; }
.nav-group-title::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.08); }
.nav-group-title .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--g, #fff); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--g, #fff) 25%, transparent); }
.nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .58rem .75rem; margin: 2px 0;
  border-radius: var(--r-md); color: rgba(255,255,255,.78); font-size: .92rem; font-weight: 500;
  transition: background .15s, color .15s, transform .15s var(--ease); white-space: nowrap; position: relative;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; transform: translateX(-2px); }
.nav-link.active { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1); }
.nav-link.active::before { content: ''; position: absolute; right: -0.75rem; top: 20%; bottom: 20%; width: 3px; border-radius: 3px; background: var(--g, var(--sec)); }
.nav-link svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-link .nav-badge { margin-inline-start: auto; font-size: .7rem; background: rgba(255,255,255,.14); padding: .05rem .45rem; border-radius: 999px; }
.nav-link.active .nav-badge { background: var(--sec-soft); color: var(--sec); }
.sidebar-foot { padding: .75rem; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: .6rem; }
.user-chip { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; padding: .4rem .5rem; border-radius: var(--r-md); color: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: .9rem; color: var(--sec-on); background: var(--sec); }
.user-chip .u-name { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .u-role { font-size: .7rem; color: rgba(255,255,255,.55); }
.icon-btn { background: transparent; border: 1px solid transparent; color: inherit; width: 36px; height: 36px; border-radius: var(--r-md); display: inline-grid; place-items: center; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.icon-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn svg { width: 18px; height: 18px; }
.main { flex: 1; min-width: 0; margin-right: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; transition: margin .25s var(--ease); }

/* Collapsed rail */
.app.rail .sidebar { width: var(--rail-w); }
.app.rail .main { margin-right: var(--rail-w); }
.app.rail .brand { justify-content: center; padding-inline: 0; }
.app.rail .brand-text, .app.rail .nav-link span, .app.rail .nav-group-title, .app.rail .user-chip, .app.rail .nav-badge { display: none; }
.app.rail .nav-link { justify-content: center; padding: .65rem 0; }
.app.rail .nav-link.active::before { display: none; }
.app.rail .nav-group { margin-bottom: .35rem; padding-top: .35rem; border-top: 1px solid rgba(255,255,255,.08); }
.app.rail .sidebar-foot { flex-direction: column; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 1rem;
  padding: 0 1.75rem; background: color-mix(in srgb, var(--paper) 82%, transparent); backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title h1 { font-size: 1.2rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs { display: flex; gap: .4rem; font-size: .76rem; color: var(--ink-3); }
.crumbs a { color: var(--ink-3); } .crumbs a:hover { color: var(--sec); text-decoration: none; }
.crumbs .sep { opacity: .5; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .55rem; }
.year-stamp {
  display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .7rem; border-radius: var(--r-sm);
  border: 1.5px dashed var(--sec); color: var(--sec); font-weight: 600; font-size: .82rem; background: var(--sec-soft);
}
.year-stamp svg { width: 15px; height: 15px; }
.topbar .icon-btn { color: var(--ink-2); border-color: var(--line); background: var(--paper-2); }
.topbar .icon-btn:hover { border-color: var(--line-strong); background: var(--paper-3); }

/* Page body */
.page { padding: 1.5rem 1.75rem 3rem; flex: 1; animation: fade .35s var(--ease) both; } /* no transform here: it would become the containing block of fixed modals */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h2 { font-size: 1.45rem; margin: 0; }
.page-head .lead { color: var(--ink-3); margin: .2rem 0 0; font-size: .92rem; }
.page-actions { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
.section-eyebrow { display: inline-flex; align-items: center; gap: .45rem; font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--sec); margin-bottom: .35rem; }
.section-eyebrow::before { content: ''; width: 18px; height: 2px; background: var(--sec); border-radius: 2px; }

/* ---- Buttons --------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--paper-2); --btn-fg: var(--ink); --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .55rem 1.05rem; border-radius: var(--r-md); border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg); font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: transform .15s var(--ease), box-shadow .15s, background .15s, border-color .15s, opacity .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-2); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { --btn-bg: var(--ink); --btn-fg: var(--on-ink); --btn-bd: var(--ink); }
.btn-accent  { --btn-bg: var(--sec); --btn-fg: var(--sec-on); --btn-bd: var(--sec); }
.btn-danger  { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn-success { --btn-bg: var(--success); --btn-fg: #fff; --btn-bd: var(--success); }
.btn-outline-danger { --btn-bg: transparent; --btn-fg: var(--danger); --btn-bd: var(--danger); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--ink-2); }
.btn-ghost:hover { --btn-bg: var(--paper-3); box-shadow: none; transform: none; }
.btn-sm { padding: .38rem .75rem; font-size: .82rem; border-radius: var(--r-sm); }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { padding: .75rem 1.4rem; font-size: 1rem; border-radius: var(--r-lg); }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--r-sm); --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--ink-3); }
.btn-icon:hover { --btn-bg: var(--sec-soft); --btn-fg: var(--sec); box-shadow: none; transform: none; }
.btn-icon.danger:hover { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); }
.btn-icon svg { width: 17px; height: 17px; }
.btn .spin { display: none; } .btn.loading .spin { display: inline-block; } .btn.loading > :not(.spin) { opacity: .4; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-group { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; background: var(--paper-2); }
.btn-group .btn { border: 0; border-radius: 0; box-shadow: none; transform: none; }
.btn-group .btn + .btn { border-inline-start: 1px solid var(--line); }
.btn-group .btn.active { background: var(--ink); color: var(--on-ink); }

/* ---- Cards ----------------------------------------------------------------------------- */
.card {
  position: relative; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); padding: 1.25rem 1.35rem;
}
.page > .card + .card, .card-stack > * + * { margin-top: 1.25rem; } /* not inside grids: grid cards must stay equal */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h3 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.card-head h3 svg { width: 18px; height: 18px; color: var(--sec); }
.card-head .sub { color: var(--ink-3); font-size: .82rem; margin-top: .15rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 1rem 1.25rem 0; }
/* Crop-mark corners (print registration motif) */
.crop { --cm: 10px; }
.crop::before, .crop::after { content: ''; position: absolute; width: var(--cm); height: var(--cm); border: 1.5px solid var(--line-strong); pointer-events: none; }
.crop::before { top: -6px; right: -6px; border-left: 0; border-bottom: 0; border-radius: 0 3px 0 0; }
.crop::after  { bottom: -6px; left: -6px; border-right: 0; border-top: 0; border-radius: 0 0 0 3px; }
/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.kpi { position: relative; overflow: hidden; padding: 1.1rem 1.25rem; border-radius: var(--r-lg); background: var(--paper-2); border: 1px solid var(--line); box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: .25rem; min-height: 118px; transition: transform .2s var(--ease), box-shadow .2s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.kpi::after { content: ''; position: absolute; inset: auto -20px -20px auto; width: 90px; height: 90px; border-radius: 50%; background: var(--k, var(--sec)); opacity: .08; }
.kpi .k-label { font-size: .8rem; color: var(--ink-3); font-weight: 600; display: flex; align-items: center; gap: .45rem; }
.kpi .k-label svg { width: 16px; height: 16px; color: var(--k, var(--sec)); }
.kpi .k-value { font-size: 2.1rem; font-weight: 700; color: var(--ink); line-height: 1.1; letter-spacing: -.02em; }
.kpi .k-sub { font-size: .78rem; color: var(--ink-3); margin-top: auto; }
.kpi .k-sub b { color: var(--k, var(--sec)); }

/* Hub cards (module launchers) */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.hub-card { position: relative; display: flex; flex-direction: column; gap: .6rem; padding: 1.25rem; border-radius: var(--r-lg); background: var(--paper-2); border: 1px solid var(--line); box-shadow: var(--shadow-1); color: inherit; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; overflow: hidden; }
.hub-card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--h, var(--sec)) 45%, var(--line)); }
.hub-card .h-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--h, var(--sec)) 12%, transparent); color: var(--h, var(--sec)); }
.hub-card .h-icon svg { width: 22px; height: 22px; }
.hub-card .h-title { font-weight: 700; color: var(--ink); font-size: 1rem; }
.hub-card .h-desc { font-size: .82rem; color: var(--ink-3); }
.hub-card .h-count { position: absolute; top: 1rem; left: 1rem; font-size: .78rem; font-weight: 700; color: var(--h, var(--sec)); background: color-mix(in srgb, var(--h, var(--sec)) 12%, transparent); padding: .1rem .55rem; border-radius: 999px; }
.hub-card.soon { opacity: .6; } .hub-card.soon:hover { transform: none; box-shadow: var(--shadow-1); }

/* ---- Forms ----------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
[hidden] { display: none !important; }   /* the HTML hidden attribute must beat component display rules */
.field-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.label { font-size: .82rem; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: .35rem; }
.label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; font: inherit; font-size: .93rem; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); padding: .55rem .8rem; transition: border-color .15s, box-shadow .15s, background .15s; min-height: 42px;
}
:root[data-theme="dark"] .input, :root[data-theme="dark"] .select, :root[data-theme="dark"] .textarea { background: var(--paper-3); }
.input::placeholder { color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--sec); box-shadow: 0 0 0 3px var(--sec-soft); background: var(--paper-2); }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.input.num, input[type="number"].input { direction: ltr; text-align: center; font-variant-numeric: tabular-nums; }
.input[readonly] { background: var(--paper-3); color: var(--ink-3); }
.select { appearance: none; -webkit-appearance: none; padding-inline-end: 2.2rem; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: left .7rem center; }
.textarea { min-height: 96px; resize: vertical; }
.help { font-size: .76rem; color: var(--ink-3); }
.err { font-size: .78rem; color: var(--danger); display: none; }
.field.has-error .err { display: block; }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--ink-4); pointer-events: none; }
.input-wrap > .input { padding-inline-start: 2.4rem; }
.input-wrap.ltr-icon > svg { right: auto; left: .8rem; }
input[type="color"].color { width: 46px; height: 42px; padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--paper); cursor: pointer; }
.color-field { display: flex; gap: .5rem; align-items: center; }
.color-field .input { flex: 1; direction: ltr; text-align: center; font-family: ui-monospace, Menlo, monospace; }
/* checkbox / radio */
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .9rem; user-select: none; }
.check input { appearance: none; width: 18px; height: 18px; border: 1.5px solid var(--line-strong); border-radius: 5px; background: var(--paper); display: grid; place-items: center; transition: background .15s, border-color .15s; flex: none; margin: 0; cursor: pointer; }
.check input:checked { background: var(--sec); border-color: var(--sec); }
.check input:checked::after { content: ''; width: 5px; height: 10px; border: 2px solid var(--sec-on); border-top: 0; border-left: 0; transform: translateY(-1px) rotate(45deg); }
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]:checked::after { width: 7px; height: 7px; border: 0; border-radius: 50%; background: var(--sec-on); transform: none; }
/* switch */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .2s; }
.switch .track::after { content: ''; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(-18px); }
.switch input:disabled + .track { opacity: .5; cursor: not-allowed; }
.open-switch .track { width: 38px; height: 22px; } .open-switch .track::after { width: 16px; height: 16px; } .open-switch input:checked + .track::after { transform: translateX(-16px); }
.table tbody tr.row-closed td { color: var(--ink-4); } .table tbody tr.row-closed td.strong { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--danger); text-decoration-thickness: 1px; }
.table tbody tr.row-closed .badge, .table tbody tr.row-closed .swatch { opacity: .55; }
/* segmented */
.segmented { display: inline-flex; padding: 3px; border-radius: var(--r-md); background: var(--paper-3); border: 1px solid var(--line); gap: 2px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .85rem; border-radius: 7px; font-size: .85rem; font-weight: 600; color: var(--ink-3); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.segmented input:checked + span { background: var(--paper-2); color: var(--ink); box-shadow: var(--shadow-1); }
.segmented input:focus-visible + span { outline: 2px solid var(--sec); }
.form-foot { display: flex; gap: .6rem; justify-content: flex-start; align-items: center; padding-top: 1rem; margin-top: .5rem; border-top: 1px solid var(--line); }
.form-foot .spacer { flex: 1; }

/* ---- Tables ---------------------------------------------------------------------------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--paper-2); box-shadow: var(--shadow-1); position: relative; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th { position: sticky; top: 0; z-index: 2; background: var(--paper-3); color: var(--ink-3); font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-align: start; padding: .7rem .9rem; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table th.num, .table td.num, .table th.center, .table td.center { text-align: center; }
.table td { padding: .62rem .9rem; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: var(--sec-soft); }
.table tbody tr.row-even td { background: color-mix(in srgb, var(--paper-3) 45%, transparent); }
.table tbody tr.row-even:hover td { background: var(--sec-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .fit { width: 1%; white-space: nowrap; }
.table td.strong, .table .strong { color: var(--ink); font-weight: 600; }
.table .actions { display: inline-flex; gap: .15rem; }
.table tfoot td { background: var(--paper-3); font-weight: 700; color: var(--ink); border-top: 3px double var(--line-strong); border-bottom: 0; }
.table .group-row td { background: var(--ink); color: var(--on-ink); font-weight: 700; font-size: .82rem; letter-spacing: .04em; padding: .45rem .9rem; }
.table td.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-3); }
.table td.empty svg { width: 34px; height: 34px; opacity: .4; display: block; margin: 0 auto .5rem; }
.table .count-cell { min-width: 84px; }
.table.counts td.school-name { min-width: 240px; white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.table .count-cell .cv { display: inline-flex; min-width: 56px; justify-content: center; padding: .22rem .5rem; border-radius: var(--r-sm); font-weight: 700; color: var(--ink); background: var(--paper-3); font-variant-numeric: tabular-nums; }
.table .count-cell .cv.zero { color: var(--ink-4); background: transparent; font-weight: 500; }
.table .count-cell .cv.full { color: var(--danger); }
.table .count-cell input { width: 74px; text-align: center; padding: .3rem .4rem; min-height: 34px; font-weight: 700; }
.table .count-cell input.saved { animation: flash-ok .9s var(--ease); }
.table .count-cell input.error { border-color: var(--danger); }
.table .sub { font-size: .72rem; color: var(--ink-3); display: block; font-weight: 500; }
.table-note { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 1rem; font-size: .8rem; color: var(--ink-3); border-top: 1px solid var(--line); background: var(--paper-3); }
.table.compact td { padding: .4rem .7rem; } .table.compact th { padding: .5rem .7rem; }
.sticky-first th:first-child, .sticky-first td:first-child { position: sticky; right: 0; z-index: 1; background: var(--paper-2); }
.sticky-first th:first-child { z-index: 3; background: var(--paper-3); }

/* ---- Badges / chips -------------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.4; white-space: nowrap; background: var(--paper-3); color: var(--ink-2); border: 1px solid transparent; }
.badge svg { width: 12px; height: 12px; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger  { background: var(--danger-soft);  color: var(--danger); }
.badge.info    { background: var(--info-soft);    color: var(--info); }
.badge.muted   { background: var(--paper-3); color: var(--ink-3); }
.badge.sec     { background: var(--sec-soft); color: var(--sec); }
.badge.ink     { background: var(--ink); color: var(--on-ink); }
.badge.outline { background: transparent; border-color: var(--line-strong); }
.badge.boys  { background: rgba(30,64,175,.12); color: #1e40af; }
.badge.girls { background: rgba(190,24,93,.12); color: #be185d; }
.badge.mixed { background: rgba(109,40,217,.12); color: #6d28d9; }
:root[data-theme="dark"] .badge.boys  { color: #93b4ff; } :root[data-theme="dark"] .badge.girls { color: #f9a8d4; } :root[data-theme="dark"] .badge.mixed { color: #c4b5fd; }
.badge.elementary { background: rgba(194,65,12,.12); color: #c2410c; }
.badge.middle     { background: rgba(14,116,144,.12); color: #0e7490; }
:root[data-theme="dark"] .badge.elementary { color: #fb923c; } :root[data-theme="dark"] .badge.middle { color: #67e8f9; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--paper-2); box-shadow: 0 0 0 1px var(--line-strong); vertical-align: middle; }
.swatch-pair { display: inline-flex; } .swatch-pair .swatch + .swatch { margin-inline-start: -6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Filter chips */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .32rem .8rem; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper-2); color: var(--ink-2); font-size: .82rem; font-weight: 600; cursor: pointer; user-select: none; transition: all .15s; }
.chip:hover { border-color: var(--sec); color: var(--sec); }
.chip.on { background: var(--sec); border-color: var(--sec); color: var(--sec-on); }
.chip .cnt { font-size: .7rem; opacity: .75; }
.chip-group { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.chip-group .lbl { font-size: .78rem; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.chip-group .all { font-size: .74rem; color: var(--sec); cursor: pointer; background: none; border: 0; padding: 0; font-family: inherit; font-weight: 600; }
.chip-group .all:hover { text-decoration: underline; }

/* ---- Tabs ------------------------------------------------------------------------------ */
.tabs { display: inline-flex; gap: .25rem; padding: 4px; border-radius: var(--r-lg); background: var(--paper-3); border: 1px solid var(--line); }
.tabs .tab { padding: .5rem 1.1rem; border-radius: 10px; color: var(--ink-3); font-weight: 600; font-size: .9rem; text-decoration: none; display: inline-flex; align-items: center; gap: .45rem; transition: all .15s; border: 0; background: transparent; font-family: inherit; cursor: pointer; }
.tabs .tab:hover { color: var(--ink); }
.tabs .tab.active { background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-1); }
.tabs .tab svg { width: 16px; height: 16px; }
.tabs .tab .tcount { font-size: .72rem; opacity: .7; }
.tabs.accent .tab.active { background: var(--sec); color: var(--sec-on); }

/* ---- Toolbar ---------------------------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar .input-wrap { min-width: 240px; }
.filters-card { padding: .9rem 1.1rem; display: flex; flex-direction: column; gap: .7rem; margin-bottom: 1rem; }
.filters-row { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; align-items: center; }
.result-count { font-size: .82rem; color: var(--ink-3); } .result-count b { color: var(--ink); }

/* ---- Modal ------------------------------------------------------------------------------ */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 1.25rem; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(28,25,23,.55); backdrop-filter: blur(6px); animation: fade .2s both; }
:root[data-theme="dark"] .modal-backdrop { background: rgba(0,0,0,.7); }
.modal-sheet { position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 2.5rem); display: flex; flex-direction: column; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-3); animation: pop .28s var(--ease) both; }
.modal-sheet.sm { max-width: 440px; } .modal-sheet.lg { max-width: 760px; } .modal-sheet.xl { max-width: 980px; }
.modal-sheet::before { content: ''; position: absolute; top: 0; left: 1.5rem; right: 1.5rem; height: 3px; background: var(--sec); border-radius: 0 0 4px 4px; }
.modal-head { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.5rem .75rem; }
.modal-head h3 { margin: 0; font-size: 1.1rem; display: flex; align-items: center; gap: .55rem; }
.modal-head h3 svg { width: 20px; height: 20px; color: var(--sec); }
.modal-head .icon-btn { margin-inline-start: auto; color: var(--ink-3); }
.modal-head .icon-btn:hover { background: var(--paper-3); color: var(--ink); }
.modal-body { padding: .25rem 1.5rem 1rem; overflow: auto; }
.modal-foot { display: flex; gap: .6rem; align-items: center; padding: .9rem 1.5rem 1.25rem; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }
.alert.modal-form-error { display: none; }
.alert.modal-form-error.show { display: flex; }
body.modal-open { overflow: hidden; }
/* Confirm dialog */
.confirm-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: .25rem auto .9rem; background: var(--sec-soft); color: var(--sec); }
.confirm-icon.danger { background: var(--danger-soft); color: var(--danger); }
.confirm-icon.warning { background: var(--warning-soft); color: var(--warning); }
.confirm-icon svg { width: 26px; height: 26px; }
.confirm-title { text-align: center; font-size: 1.1rem; margin-bottom: .35rem; }
.confirm-text { text-align: center; color: var(--ink-3); font-size: .92rem; margin: 0 0 .5rem; white-space: pre-line; }
.confirm-text b { color: var(--ink); }

/* ---- Toasts ----------------------------------------------------------------------------- */
.toasts { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; width: min(92vw, 480px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: .65rem; width: 100%; padding: .75rem 1rem; border-radius: var(--r-lg); background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-3); font-size: .9rem; font-weight: 500; animation: drop .35s var(--ease) both; border-inline-start: 4px solid var(--t, var(--sec)); }
.toast.leaving { animation: lift .25s var(--ease) forwards; }
.toast svg { width: 19px; height: 19px; flex: none; color: var(--t, var(--sec)); }
.toast.success { --t: #4ade80; } .toast.danger { --t: #f87171; } .toast.warning { --t: #fbbf24; } .toast.info { --t: #67e8f9; }
:root[data-theme="dark"] .toast { background: var(--paper-3); color: var(--ink); border: 1px solid var(--line); }
.toast .close { margin-inline-start: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: .2rem; display: grid; place-items: center; }
.toast .close:hover { opacity: 1; } .toast .close svg { width: 15px; height: 15px; color: inherit; }

/* ---- Alerts / empty ----------------------------------------------------------------------- */
.alert { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--r-md); font-size: .9rem; border: 1px solid transparent; margin-bottom: 1rem; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: .1rem; }
.alert.danger  { background: var(--danger-soft);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert.success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert.warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert.info    { background: var(--info-soft);    color: var(--info);    border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert ul { margin: 0; padding-inline-start: 1.1rem; }
.empty-state { text-align: center; padding: 3.5rem 1.5rem; color: var(--ink-3); }
.empty-state svg { width: 48px; height: 48px; opacity: .35; margin: 0 auto 1rem; display: block; }
.empty-state h2 { font-size: 1.15rem; color: var(--ink); }
.empty-state p { max-width: 420px; margin: 0 auto 1.25rem; }

/* ---- Pagination -------------------------------------------------------------------------- */
.pager { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.pager a, .pager span { min-width: 34px; height: 34px; padding: 0 .6rem; display: inline-grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--line); color: var(--ink-2); font-size: .85rem; font-weight: 600; background: var(--paper-2); }
.pager a:hover { border-color: var(--sec); color: var(--sec); text-decoration: none; }
.pager .cur { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.pager .dots { border: 0; background: transparent; }

/* ---- Login page -------------------------------------------------------------------------- */
.login { position: relative; z-index: 1; min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; overflow: hidden; background: var(--ink); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-art .marks { position: absolute; inset: 0; opacity: .14; background-image: radial-gradient(circle at center, #fff 1.5px, transparent 1.6px); background-size: 28px 28px; mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 70%); }
.login-art .ring { position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.login-art .ring.r1 { width: 520px; height: 520px; right: -160px; bottom: -200px; }
.login-art .ring.r2 { width: 760px; height: 760px; right: -280px; bottom: -320px; }
.login-art .ring.r3 { width: 300px; height: 300px; right: -50px; bottom: -90px; border-color: var(--sec); opacity: .7; }
.login-art .art-top { position: relative; display: flex; align-items: center; gap: .9rem; }
.login-art .art-top img { width: 58px; height: 58px; object-fit: contain; }
.login-art .art-top span { font-size: .8rem; color: rgba(255,255,255,.6); letter-spacing: .1em; }
.login-art .art-title { position: relative; }
.login-art .art-title .eyebrow { color: #fb923c; font-weight: 700; letter-spacing: .18em; font-size: .78rem; margin-bottom: 1rem; display: flex; gap: .6rem; align-items: center; }
.login-art .art-title .eyebrow::before { content: ''; width: 28px; height: 2px; background: currentColor; }
.login-art .art-title h1 { color: #fff; font-size: clamp(2rem, 3.6vw, 3.1rem); line-height: 1.2; margin: 0 0 1rem; letter-spacing: -.01em; }
.login-art .art-title p { color: rgba(255,255,255,.65); font-size: 1rem; max-width: 420px; }
.login-art .art-foot { position: relative; display: flex; gap: 1.2rem; flex-wrap: wrap; color: rgba(255,255,255,.55); font-size: .78rem; }
.login-art .art-foot span { display: inline-flex; align-items: center; gap: .4rem; } .login-art .art-foot svg { width: 14px; height: 14px; }
.login-pane { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.login-card { width: 100%; max-width: 420px; padding: 2.25rem 2rem; }
.login-card h2 { font-size: 1.45rem; margin-bottom: .25rem; }
.login-card .sub { color: var(--ink-3); margin-bottom: 1.5rem; font-size: .9rem; }
.login-card .btn-lg { width: 100%; margin-top: .5rem; }
.login-foot { text-align: center; font-size: .78rem; color: var(--ink-4); margin-top: 1.5rem; }

/* ---- Utilities ----------------------------------------------------------------------------- */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.gap-1 { gap: .35rem; } .gap-2 { gap: .6rem; } .gap-3 { gap: 1rem; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; } .text-start { text-align: start; } .hidden { display: none !important; } .w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.divider-label { display: flex; align-items: center; gap: .75rem; font-size: .75rem; font-weight: 700; letter-spacing: .1em; color: var(--ink-3); margin: 1.25rem 0 .75rem; }
.divider-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: .75rem; background: var(--paper-3); border: 1px solid var(--line-strong); border-bottom-width: 2px; padding: 0 .35rem; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stat-inline { display: inline-flex; align-items: baseline; gap: .3rem; } .stat-inline b { font-size: 1.1rem; color: var(--ink); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .78rem; color: var(--ink-3); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.timeline-time { font-size: .78rem; color: var(--ink-3); white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.ua { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; color: var(--ink-4); direction: ltr; unicode-bidi: isolate; }
.ip { font-family: ui-monospace, Menlo, monospace; font-size: .78rem; direction: ltr; unicode-bidi: isolate; }
.tiers-table td { padding: .35rem .5rem; } .tiers-table .input { min-height: 36px; padding: .3rem .5rem; }

/* ---- Animations --------------------------------------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
@keyframes lift { to { opacity: 0; transform: translateY(-10px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flash-ok { 0% { box-shadow: 0 0 0 0 var(--success-soft); border-color: var(--success); } 100% { box-shadow: 0 0 0 10px transparent; } }
.stagger > * { animation: rise .4s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: .05s; } .stagger > *:nth-child(3) { animation-delay: .1s; } .stagger > *:nth-child(4) { animation-delay: .15s; }
.stagger > *:nth-child(5) { animation-delay: .2s; } .stagger > *:nth-child(6) { animation-delay: .25s; } .stagger > *:nth-child(n+7) { animation-delay: .3s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---- Responsive ---------------------------------------------------------------------------- */
.menu-btn { display: none; }
.sidebar-scrim { display: none; position: fixed; inset: 0; background: rgba(28,25,23,.5); z-index: 39; }
@media (max-width: 1024px) {
  .sidebar { transform: translateX(100%); }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .sidebar-scrim { display: block; }
  .main, .app.rail .main { margin-right: 0; }
  .app.rail .sidebar { width: var(--sidebar-w); }
  .app.rail .brand-text, .app.rail .nav-link span, .app.rail .nav-group-title, .app.rail .user-chip { display: initial; }
  .app.rail .nav-link { justify-content: flex-start; padding: .58rem .75rem; }
  .menu-btn { display: inline-grid; }
  .rail-btn { display: none; }
  .topbar { padding: 0 1rem; } .page { padding: 1rem 1rem 2.5rem; }
  .login { grid-template-columns: 1fr; } .login-art { min-height: 260px; padding: 2rem; } .login-art .ring { display: none; }
}
@media (max-width: 640px) {
  .topbar-title h1 { font-size: 1rem; } .year-stamp span { display: none; }
  .kpi .k-value { font-size: 1.7rem; }
  .modal { padding: 0; align-items: flex-end; } .modal-sheet { border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92vh; }
}
@media print {
  .sidebar, .topbar, .toasts, .page-actions, .toolbar, .filters-card { display: none !important; }
  .main { margin: 0 !important; } body::before { display: none; } .card, .table-wrap { box-shadow: none; }
}

/* ---- الكشوف: two-row header tables ---- */
.table.sheet { font-size: .84rem; }
.table.sheet th { white-space: nowrap; text-align: center; padding: .5rem .55rem; }
.table.sheet td { padding: .45rem .55rem; }
.table-wrap.scroll-x { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--ink-4) var(--paper-3); }
.table-wrap.scroll-x::-webkit-scrollbar { height: 11px; }
.table-wrap.scroll-x::-webkit-scrollbar-track { background: var(--paper-3); border-radius: 999px; }
.table-wrap.scroll-x::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 999px; border: 2px solid var(--paper-3); }
.table-wrap.scroll-x::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }
.toolbar form, form.toolbar { margin: 0; } form.is-loading { opacity: .6; pointer-events: none; }
.table.sheet thead tr:nth-child(2) th { top: 2.35rem; font-size: .7rem; letter-spacing: 0; color: var(--ink-2); background: color-mix(in srgb, var(--paper-3) 70%, var(--paper-2)); }
.table.sheet th.grp { border-bottom: 1px solid var(--line-strong); color: var(--ink); background: var(--sec-soft); }
.table.sheet td.v, .table.sheet th.v { text-align: center; font-variant-numeric: tabular-nums; }
.table.sheet td.v.r { color: var(--ink); font-weight: 600; }
.table.sheet td.v.env { color: var(--sec); font-weight: 700; }
.table.sheet td.sep, .table.sheet th.sep { border-inline-start: 1px solid var(--line-strong); }
.table.sheet td.name { white-space: nowrap; }
.pdf-orient span { font-size: .8rem; padding: .35rem .7rem; }
.pdf-orient span svg { width: 14px; height: 14px; }
.check-row { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; min-height: 2.5rem; }
.check-row .check { margin: 0; }
.sheet-meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; color: var(--ink-3); font-size: .85rem; align-items: center; }
.sheet-meta b { color: var(--ink); }

/* ---- ملصقات الأظرف: live preview (mirrors includes/env_stickers.php, black & white) ---- */
.env-grid { grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.1fr); align-items: start; }
@media (max-width: 900px) { .env-grid { grid-template-columns: 1fr; } }
.env-per span { min-width: 2.6rem; justify-content: center; font-variant-numeric: tabular-nums; }
.env-stage { display: grid; place-items: center; padding: 1rem; background: var(--paper-3); border-radius: var(--r-md); border: 1px dashed var(--line); }
.env-sheet { width: min(100%, 340px); aspect-ratio: 210 / 297; background: #fff; color: #000; box-shadow: 0 6px 24px rgba(0,0,0,.18); display: grid; direction: rtl; }
.env-sheet[data-per="2"] { grid-template: repeat(2, 1fr) / 1fr; }
.env-sheet[data-per="3"] { grid-template: repeat(3, 1fr) / 1fr; }
.env-sheet[data-per="4"] { grid-template: repeat(2, 1fr) / repeat(2, 1fr); }
.env-sheet[data-per="6"] { grid-template: repeat(3, 1fr) / repeat(2, 1fr); }
.env-sheet[data-orient="landscape"] { aspect-ratio: 297 / 210; width: min(100%, 420px); }
.env-sheet[data-orient="landscape"] .env-logo { width: 34%; }
.env-sheet[data-orient="landscape"] .env-meta { font-size: clamp(5px, 3.4cqw, 10px); }
.env-sheet[data-orient="landscape"] .env-body { font-size: clamp(7px, 7.5cqw, 20px); }
.segmented input:disabled + span { opacity: .4; cursor: not-allowed; }
.segmented span svg { width: 14px; height: 14px; }
.env-cell { display: none; padding: 4%; min-width: 0; }
.env-sheet[data-per="2"] .env-cell:nth-child(-n+2), .env-sheet[data-per="3"] .env-cell:nth-child(-n+3),
.env-sheet[data-per="4"] .env-cell:nth-child(-n+4), .env-sheet[data-per="6"] .env-cell { display: block; }
.env-sheet[data-per="2"] .env-cell, .env-sheet[data-per="3"] .env-cell { padding: 2.5% 4%; }
.env-sticker { height: 100%; border: 1px solid #000; border-radius: 4px; display: flex; flex-direction: column; padding: 4%; gap: 2%; font-family: inherit; container-type: inline-size; }
.env-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 4%; border-bottom: 1px solid #000; padding-bottom: 3%; }
.env-logo { height: auto; width: 42%; max-height: 28%; object-fit: contain; filter: grayscale(1); }
.env-meta { display: flex; flex-direction: column; text-align: left; direction: rtl; font-size: clamp(5px, 4cqw, 11px); line-height: 1.5; color: #000; }
.env-sheet[data-per="4"] .env-logo, .env-sheet[data-per="6"] .env-logo { width: 40%; }
.env-sheet[data-per="4"] .env-meta, .env-sheet[data-per="6"] .env-meta { font-size: clamp(4px, 3.8cqw, 9px); }
.env-body { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; text-align: center; font-size: clamp(7px, 9cqw, 22px); line-height: 1.2; }
.env-box { display: flex; border: 1.5px solid #000; border-radius: 4px; margin: 0 2%; overflow: hidden; }
.env-box .env-lab { width: 30%; display: grid; place-items: center; border-left: 1px solid #000; font-size: clamp(5px, 5cqw, 12px); padding: 3% 0; }
.env-box .env-num { flex: 1; display: grid; place-items: center; font-size: clamp(9px, 14cqw, 34px); line-height: 1; padding: 3% 0; direction: ltr; font-variant-numeric: tabular-nums; }
:root[data-theme="dark"] .env-sheet { box-shadow: 0 6px 24px rgba(0,0,0,.5); }
@media print { .env-stage { display: none; } }
