/* =========================================================
   GCA — Admin design system
   Deep navy + gold, pulled from the school-of-* marketing
   sheets and the pencil-with-graduation-cap logo. Refined,
   trustworthy, still warm — never sterile.
   ========================================================= */

:root {
  /* ── GCA brand ─────────────────────────────
     Navy for structure and voice, gold for accents,
     Romanian-flag red reserved for celebratory moments.    */

  /* Navy — headers, CTAs, wordmark, key actions. */
  --primary:              #0F2A5E;
  --primary-container:    #DDE5F4;
  --primary-fixed:        #0F2A5E;
  --primary-dim:          #0A1F45;
  --on-primary:           #FFFFFF;
  --on-primary-container: #0A1F45;

  /* Gold — badges, highlights, focal points. */
  --secondary:              #F5C518;
  --secondary-container:    #FFF3C4;
  --secondary-dim:          #C99B00;
  --on-secondary:           #4A3800;
  --on-secondary-container: #4A3800;

  /* ── Tertiary (Romanian red — celebratory only) ── */
  --tertiary:            #CE1126;
  --tertiary-container:  #FFD9DE;
  --tertiary-dim:        #A00E1F;
  --on-tertiary:         #FFFFFF;
  --on-tertiary-container: #5C000A;

  /* ── Surfaces (cool navy-tinted neutrals) ──
     Kept off-white so the app still feels warm at hand, but pulled the yellow
     out so navy reads as the voice and gold as a real accent — not a wash. */
  --background:                 #F5F7FB;
  --surface:                    #F5F7FB;
  --surface-container-lowest:   #FFFFFF;
  --surface-container-low:      #EEF2F8;
  --surface-container:          #E5EBF3;
  --surface-container-high:     #DDE4EE;
  --surface-container-highest:  #D5DEE9;
  --surface-variant:            #D5DEE9;

  /* ── Ink (navy-tinted, never pure black) ── */
  --on-surface:          #14213D;
  --on-surface-variant:  #4E5566;
  --outline:             #7A7F8C;
  --outline-variant:     #B2B6BF;

  /* ── Semantic ── */
  --error:            #B02500;
  --error-container:  #F95630;
  --on-error:         #FFEFEC;
  --success:          #16A34A;
  --success-container:#E9F7EE;

  /* ── Radii (bubbly) ── */
  --radius-input:  12px;   /* input fields */
  --radius-btn:    16px;   /* buttons */
  --radius-card:   24px;   /* cards */
  --radius-lg:     32px;   /* large containers */
  --radius-full:  9999px;

  /* ── Ambient shadow tinted with primary navy at 6% ── */
  --shadow-ambient: 0 12px 32px rgba(15, 42, 94, .06);
  --shadow-soft:    0 4px 12px rgba(15, 42, 94, .05);
  --shadow-brand:   0 10px 24px -6px rgba(15, 42, 94, .30);

  --sidebar-w: 252px;
  --topbar-h:  68px;
  --ease: cubic-bezier(.2,.8,.2,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Be Vietnam Pro', 'Cairo', system-ui, -apple-system, sans-serif;
  color: var(--on-surface);
  background: var(--background);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
html[lang="ar"] body { font-family: 'Cairo', 'Be Vietnam Pro', sans-serif; }

a { color: var(--primary); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary-dim); }

h1, h2, h3, h4 {
  font-family: 'Plus Jakarta Sans', 'Cairo', sans-serif;
  color: var(--on-surface); font-weight: 800; margin: 0; line-height: 1.2;
  letter-spacing: -.01em;
}
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] h4 {
  font-family: 'Cairo', 'Plus Jakarta Sans', sans-serif; font-weight: 800;
}
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p  { margin: 0; }
.fredoka { font-family: 'Fredoka One', 'Cairo', cursive; }
.muted { color: var(--on-surface-variant); }
.mono  { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }

/* Material Symbols setup */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  font-size: 22px;
}

/* ========== Layout ========== */
.layout { display: flex; min-height: 100vh; background: var(--background); }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface-container-lowest);
  padding: 24px 12px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  flex-shrink: 0;
  /* Nav grew past a single viewport once we added HR/Sessions/Chat/etc.
     Without this, items past the fold silently clip. Scroll the sidebar
     itself instead so every nav row is reachable. */
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--outline); border-radius: 3px;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 12px 28px;
}
.sidebar__brand .logo {
  width: 44px; height: 44px; border-radius: var(--radius-btn);
  background: #fff;
  display: grid; place-items: center;
  padding: 2px;
}
.sidebar__brand img.logo { object-fit: contain; }
.sidebar__brand span {
  font-family: 'Fredoka One', 'Cairo', cursive;
  font-size: 22px; color: var(--primary); letter-spacing: -.01em;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.sidebar__label {
  padding: 16px 14px 8px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--outline); font-weight: 700;
}
.sidebar a.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-btn);
  color: var(--on-surface-variant); font-weight: 600; font-size: 14px;
  transition: all .15s var(--ease);
}
.sidebar a.nav-link:hover { background: var(--surface-container-low); color: var(--on-surface); }
.sidebar a.nav-link.active {
  background: var(--primary); color: var(--on-primary);
}
.sidebar a.nav-link.active .icon { color: var(--on-primary); }
.sidebar a.nav-link .icon { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar__footer { margin-top: auto; padding-top: 12px; }
.sidebar__user {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-radius: var(--radius-btn);
}
.sidebar__user:hover { background: var(--surface-container-low); }

.avatar {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: var(--primary-container); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  flex-shrink: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(252,245,239,.85);
  backdrop-filter: saturate(180%) blur(14px);
  height: var(--topbar-h);
  display: flex; align-items: center;
  padding: 0 32px;
  gap: 16px;
}
.topbar__title {
  font-family: 'Plus Jakarta Sans', 'Cairo', sans-serif;
  font-weight: 700; color: var(--on-surface); font-size: 15px;
}
.topbar__spacer { flex: 1; }
.topbar__right { display: flex; align-items: center; gap: 10px; }

.content { padding: 32px 32px 80px; max-width: 1400px; width: 100%; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 28px;
}
.page-header__meta { display: flex; flex-direction: column; gap: 6px; }
.page-header__title {
  font-family: 'Plus Jakarta Sans', 'Cairo', sans-serif;
  font-size: 28px; font-weight: 800; color: var(--on-surface); letter-spacing: -.015em;
}
.page-header__desc  { color: var(--on-surface-variant); font-size: 14px; }
.page-header__actions { display: flex; align-items: center; gap: 8px; }

/* ========== Buttons — bubbly, scale on hover (no color change) ========== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; height: 42px;
  background: var(--surface-container-low); color: var(--on-surface);
  border: 0; border-radius: var(--radius-btn);
  font: inherit; font-weight: 700; font-size: 14px;
  cursor: pointer;
  transition: transform .15s var(--ease);
  white-space: nowrap; user-select: none;
}
.btn:hover { transform: scale(1.03); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 3px solid var(--primary-container); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--primary); color: var(--on-primary);
}
.btn--secondary {
  background: var(--secondary-container); color: var(--on-secondary-container);
}
.btn--tertiary {
  background: var(--tertiary-container); color: var(--on-tertiary-container);
}
.btn--danger {
  background: var(--error); color: var(--on-error);
}
.btn--ghost { background: transparent; color: var(--on-surface-variant); }
.btn--ghost:hover { background: var(--surface-container-low); }
.btn--sm { height: 34px; padding: 6px 14px; font-size: 13px; }
.btn--icon { width: 42px; height: 42px; padding: 0; justify-content: center; border-radius: var(--radius-full); }
.btn--sm.btn--icon { width: 34px; height: 34px; }
.btn .icon { width: 18px; height: 18px; }
.btn--full { width: 100%; justify-content: center; }
.btn--lg { height: 54px; font-size: 15.5px; padding: 14px 28px; }

/* Icon-only colored round buttons */
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--radius-full);
  display: grid; place-items: center; color: #fff; border: 0; cursor: pointer;
  transition: transform .15s var(--ease);
}
.icon-btn:hover { transform: scale(1.05); }
.icon-btn--primary   { background: var(--primary); }
.icon-btn--secondary { background: var(--secondary); }
.icon-btn--tertiary  { background: var(--tertiary-container); color: var(--on-tertiary-container); }

/* ========== Cards — no borders, tonal depth ========== */
.card {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.card__header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 24px 12px;
}
.card__title {
  font-family: 'Plus Jakarta Sans', 'Cairo', sans-serif;
  font-weight: 800; font-size: 16px; color: var(--on-surface);
}
.card__body { padding: 20px 24px 24px; }
.card__body--flush { padding: 0; }

/* Stat cards */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-card);
  padding: 22px 24px;
  transition: transform .18s var(--ease);
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.stat-card:hover { transform: translateY(-2px) scale(1.01); box-shadow: var(--shadow-ambient); }
.stat-card__label {
  color: var(--on-surface-variant); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
}
.stat-card__value {
  font-family: 'Plus Jakarta Sans', 'Cairo', sans-serif;
  font-size: 38px; font-weight: 800; color: var(--on-surface);
  margin-top: 8px; letter-spacing: -.02em;
}
.stat-card__delta { margin-top: 4px; font-size: 12.5px; color: var(--on-surface-variant); }
.stat-card__icon {
  position: absolute; inset-inline-end: 20px; top: 20px;
  width: 44px; height: 44px; border-radius: var(--radius-btn);
  background: var(--primary-container); color: #fff;
  display: grid; place-items: center;
}
.stat-card__icon .icon { width: 22px; height: 22px; }

/* Color-cycle for the stat icons — soft container hues */
.stat-card:nth-child(4n+2) .stat-card__icon { background: var(--secondary-container); color: var(--on-secondary-container); }
.stat-card:nth-child(4n+3) .stat-card__icon { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.stat-card:nth-child(4n+4) .stat-card__icon { background: #F0EAFB; color: #6B46C1; }

/* ========== Tables ========== */
.table-wrap { overflow-x: auto; }
table.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 14px;
}
.table th, .table td {
  text-align: start;
  padding: 16px 22px;
  vertical-align: middle;
}
.table th {
  background: var(--surface-container-low);
  font-weight: 700; color: var(--on-surface-variant);
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
}
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr + tr td { border-top: 1px solid var(--surface-container-low); }
.table tbody tr:hover { background: var(--surface-container-low); }
.table td.actions { text-align: end; white-space: nowrap; }
.table .row-title { font-weight: 700; color: var(--on-surface); }
.table .row-sub { color: var(--on-surface-variant); font-size: 12.5px; margin-top: 2px; }

/* ========== Forms — ghost-border pill inputs ========== */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field > label {
  font-weight: 700; font-size: 11.5px; color: var(--on-surface-variant);
  text-transform: uppercase; letter-spacing: .08em;
}
.field > .hint  { font-size: 12.5px; color: var(--on-surface-variant); }
.field > .error { font-size: 12.5px; color: var(--error); }

.input, .select, textarea.input {
  width: 100%; height: 50px; padding: 14px 18px;
  background: var(--surface-container-highest);
  border: 2px solid transparent;
  border-radius: var(--radius-input);
  font: inherit; font-size: 14.5px; color: var(--on-surface);
  transition: all .15s var(--ease);
}
textarea.input {
  height: auto; min-height: 100px; resize: vertical;
  padding: 16px 18px;
}
.input::placeholder { color: var(--outline); }
.input:hover, .select:hover { background: var(--surface-container-high); }
.input:focus, .select:focus {
  outline: none;
  background: var(--surface-container-lowest);
  border-color: var(--primary);
}

/* ── Native <select> — strip the browser chevron, draw our own, and
   explicitly style the popup <option> list so options don't inherit
   the pale field background (which was making them read as light-on-
   light on Chrome + Firefox). */
.select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  padding-right: 44px;
  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='%230F2A5E' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px 16px;
}
html[dir="rtl"] .select {
  padding-right: 18px;
  padding-left: 44px;
  background-position: left 16px center;
}
.select::-ms-expand { display: none; }

.select option {
  background-color: var(--surface-container-lowest);
  color: var(--on-surface);
  font-weight: 500;
  padding: 10px 14px;
}
.select option:checked,
.select option:hover {
  background-color: var(--primary-container);
  color: var(--on-primary-container);
  font-weight: 700;
}
.select option:disabled {
  color: var(--outline);
  background-color: var(--surface-container);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.checkbox { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.checkbox input {
  width: 18px; height: 18px; accent-color: var(--primary);
}

/* ========== Badges (pill) ========== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; height: 26px;
  border-radius: var(--radius-full);
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
}
.badge--brand   { background: var(--primary);           color: var(--on-primary); }
.badge--soft    { background: var(--primary-container); color: var(--on-primary-container); }
.badge--gray    { background: var(--surface-container); color: var(--on-surface-variant); }
.badge--success { background: var(--success-container); color: var(--success); }
.badge--warning { background: var(--tertiary-container);color: var(--on-tertiary-container); }
.badge--danger  { background: #FFDACC;                  color: var(--error); }
.badge--info    { background: var(--secondary-container); color: var(--on-secondary-container); }

/* Role tag */
.role-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
}
.role-tag[data-role="super_admin"] { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.role-tag[data-role="admin"]       { background: var(--primary-container);  color: #fff; }
.role-tag[data-role="teacher"]     { background: var(--secondary-container); color: var(--on-secondary-container); }
.role-tag[data-role="parent"]      { background: var(--success-container); color: var(--success); }
.role-tag[data-role="staff"]       { background: var(--surface-container-high); color: var(--on-surface-variant); }

/* ========== Toolbar (search + filters) ========== */
.toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 20px 24px 14px;
  background: transparent;
}
.search {
  position: relative; flex: 1; min-width: 240px; max-width: 460px;
}
.search .icon {
  position: absolute; inset-inline-start: 18px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--outline); pointer-events: none;
}
.search input {
  width: 100%; height: 46px;
  padding-inline-start: 46px; padding-inline-end: 18px;
  border: 2px solid transparent; border-radius: var(--radius-full);
  background: var(--surface-container-highest);
  font: inherit; font-size: 14px;
  transition: all .15s var(--ease);
}
.search input::placeholder { color: var(--outline); }
.search input:focus {
  outline: none; background: var(--surface-container-lowest);
  border-color: var(--primary);
}

/* Branch selector in topbar */
.branch-picker {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: var(--surface-container-low);
  border-radius: var(--radius-full);
  font-size: 14px; font-weight: 700; color: var(--on-surface);
  cursor: pointer; transition: transform .15s var(--ease);
}
.branch-picker:hover { transform: scale(1.02); }
.branch-picker .icon { width: 16px; height: 16px; color: var(--primary); }
.branch-picker .caret { width: 13px; height: 13px; color: var(--outline); }

.lang-toggle {
  display: inline-flex; background: var(--surface-container-low); border-radius: var(--radius-full); padding: 3px;
}
.lang-toggle a {
  padding: 7px 16px; font-size: 12.5px; font-weight: 800;
  color: var(--on-surface-variant); border-radius: var(--radius-full);
  transition: all .15s var(--ease);
}
.lang-toggle a.active { background: var(--primary); color: var(--on-primary); }

/* ========== Empty state ========== */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 80px 28px; text-align: center;
}
.empty__icon {
  width: 84px; height: 84px; border-radius: var(--radius-card);
  background: var(--tertiary-container); color: var(--on-tertiary-container);
  display: grid; place-items: center;
}
.empty__icon .icon { width: 38px; height: 38px; }
.empty__title {
  font-family: 'Plus Jakarta Sans', 'Cairo', sans-serif;
  font-weight: 800; color: var(--on-surface); font-size: 17px;
}
.empty__desc { color: var(--on-surface-variant); font-size: 14px; max-width: 400px; }

/* ========== Toasts / flashes ========== */
.flashes {
  position: fixed; z-index: 100;
  top: 24px; inset-inline-end: 24px;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 400px;
}
.flash {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius-btn);
  background: var(--surface-container-lowest);
  box-shadow: var(--shadow-ambient);
  font-size: 14px; color: var(--on-surface);
  animation: slideIn .3s var(--ease);
}
.flash .icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.flash--success { border-inline-start: 4px solid var(--success); }
.flash--success .icon { color: var(--success); }
.flash--error   { border-inline-start: 4px solid var(--error); }
.flash--error .icon { color: var(--error); }
.flash--info    { border-inline-start: 4px solid var(--primary); }
.flash--info .icon { color: var(--primary); }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ========== Auth pages ========== */
.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1200px 600px at 100% 0%, rgba(156,63,0,.14), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(254,178,70,.28), transparent 60%),
    linear-gradient(180deg, #FFF3E4 0%, var(--background) 100%);
}
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--surface-container-lowest);
  border-radius: 32px;
  box-shadow: var(--shadow-ambient);
  padding: 40px 36px;
}
.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 4px;
}
.auth-brand .logo {
  width: 56px; height: 56px; border-radius: var(--radius-btn);
  background: #fff;
  display: grid; place-items: center;
  padding: 4px;
}
.auth-brand img.logo { object-fit: contain; }
.auth-brand h1 {
  font-family: 'Fredoka One', 'Cairo', cursive;
  font-size: 28px; color: var(--primary); letter-spacing: -.01em; font-weight: 400;
}
html[lang="ar"] .auth-brand h1 { font-family: 'Cairo', sans-serif; font-weight: 800; }
.auth-sub {
  text-align: center; color: var(--on-surface-variant); font-size: 14px; margin: 6px 0 28px;
}
.auth-footer { text-align: center; margin-top: 20px; color: var(--on-surface-variant); font-size: 13px; }

/* ========== Small utilities ========== */
.table-empty td { padding: 56px 20px; text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
.text-end { text-align: end; }
.grow { flex: 1; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* Scrollbar (subtle) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-container-high); border-radius: 8px; border: 2px solid var(--background); }
::-webkit-scrollbar-thumb:hover { background: var(--outline-variant); }

/* ========== Mobile hamburger + backdrop ========== */
/* Hidden on desktop; shown at ≤900px */
.hamburger {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-btn);
  background: transparent; color: var(--on-surface);
  border: 1px solid var(--outline-variant);
  cursor: pointer; padding: 0;
}
.hamburger svg { width: 22px; height: 22px; }
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  /* Nearly opaque navy so page content behind the drawer disappears
     entirely — earlier .55 let cards / branch chips bleed through. */
  background: rgba(15, 42, 94, .82);
  z-index: 40; opacity: 0; transition: opacity .18s var(--ease);
}

/* Close (×) button: floats fixed at the top-corner of the drawer so
   it's always reachable even when the nav has been scrolled. Invisible
   on desktop; the responsive block below reveals it in drawer mode. */
.sidebar__close {
  display: none;
  position: fixed; top: 12px;
  inset-inline-end: 12px;   /* right in LTR, left in RTL */
  z-index: 52;              /* above the sidebar (50) + backdrop (40) */
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  background: var(--surface); color: var(--on-surface);
  border: 1px solid var(--outline-variant); border-radius: var(--radius-full);
  cursor: pointer; padding: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,.14);
}
.sidebar__close:hover { background: var(--surface-container-low); }

/* ========== Responsive layout (≤900px) ========== */
@media (max-width: 900px) {
  .hamburger { display: inline-flex; }
  .sidebar__close { display: inline-flex; }

  /* Sidebar becomes a fixed drawer. Uses logical property so it slides
     off-screen on the correct edge for LTR and RTL. */
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; height: 100vh;
    height: 100dvh;                /* proper mobile viewport height */
    width: min(85vw, 300px);
    inset-inline-start: 0;
    transform: translateX(-100%);
    transition: transform .22s var(--ease);
    z-index: 50;
    box-shadow: 0 12px 40px rgba(0,0,0,.18);
    overflow-y: auto; /* nav scrolls independently of body */
    -webkit-overflow-scrolling: touch;
  }
  /* Phone-sized viewports: fill the whole screen so nothing peeks in
     the strip beside the drawer. Threshold bumped to 600px so common
     phones (390-430px width) get the clean full-screen drawer. */
  @media (max-width: 600px) {
    .sidebar { width: 100vw; box-shadow: none; }
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }

  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; opacity: 1; }
  /* Prevent the page behind from scrolling while the drawer is open —
     otherwise touch/wheel events bleed through and the drawer feels
     "leaky". */
  body.sidebar-open { overflow: hidden; }

  /* Main content fills the width */
  .layout { display: block; }
  .main   { width: 100%; }

  .topbar { padding: 0 14px; gap: 10px; }
  .topbar__title { font-size: 14px; }
  .content { padding: 16px !important; }

  /* Rein in oversized page headers on narrow screens */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-header__title { font-size: 18px; }
  .page-header__actions { width: 100%; }

  /* Convert dense 2-column card grids to single column */
  .grid.grid--2 { grid-template-columns: 1fr !important; }

  /* Tables scroll horizontally instead of overflowing the viewport */
  .card table, .table-wrap table { display: block; overflow-x: auto; white-space: nowrap; }
}

