:root {
  /* Bar W Bahr — Land & Sea palette */
  --sea-900: #0d2433; --sea-800: #123247; --sea-700: #1b465f; --sea-600: #27566f;
  --sand-50: #fbf7f0; --sand-100: #f3ece1; --sand-200: #e7dccb; --sand-300: #d8c9b2;
  --terra: #c8663b; --terra-600: #b2552f;
  --info: #2b6c8f; --info-bg: #e1eef4;
  --warn: #a9742a; --warn-bg: #f6edda;

  /* Semantic tokens (names kept; values remapped to the new palette) */
  --navy: var(--sea-900);
  --navy-700: var(--sea-700);
  --navy-50: var(--sand-100);
  --accent: var(--terra);
  --bg: var(--sand-50);
  --card: #ffffff;
  --border: var(--line);
  --line: #e4dccd;
  --field-border: #d8c9b2;
  --text: #1b2a32;
  --muted: #6f7f89;
  --ok-bg: #e6f3ec;
  --ok-fg: #2f8f5b;
  --off-bg: #f6e3df;
  --off-fg: #b8463a;
  --err: #b8463a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(13, 36, 51, .06), 0 1px 3px rgba(13, 36, 51, .05);
}

* { box-sizing: border-box; }

html { overflow-x: clip; }
body {
  margin: 0;
  /* clip, not hidden — hidden would force overflow-y to a computed "auto"
     (per spec, when only one axis is set to non-visible, the browser
     computes the other as auto too), which silently turns body into its own
     scroll container and breaks .sidebar's position: sticky (confirmed live:
     the sidebar scrolled away with the page instead of staying pinned).
     clip prevents horizontal overflow without that side effect. */
  overflow-x: clip; /* safety net — a single missed fixed-width element
    anywhere on the page must never cause page-level horizontal scroll on a
    narrow screen; per-component overflow (e.g. .table-card) still scrolls
    internally where intended. */
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Top bar ─────────────────────────────────── */
.topbar {
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-700) 60%, var(--accent) 160%);
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-inner { max-width: 1240px; }
.topbar-left { display: flex; align-items: center; gap: 12px; flex: 0 0 216px; justify-content: space-between; }
body.sidebar-collapsed .topbar-left { flex-basis: 76px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.sidebar-toggle {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; padding: 0; border: none; cursor: pointer;
  border-radius: 8px; background: transparent; color: rgba(255, 255, 255, .75);
  transition: background .15s ease, color .15s ease;
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.sidebar-toggle svg { width: 18px; height: 18px; transition: transform .2s ease; }
.sidebar-toggle[aria-expanded="false"] svg { transform: rotate(180deg); }

/* ── Collapsed icon-only rail ─────────────────── */
.shell.sidebar-collapsed .sidebar { width: 76px; flex: 0 0 76px; }
.shell.sidebar-collapsed .sidenav { padding: 16px 12px; }
.shell.sidebar-collapsed .sidenav a { justify-content: center; gap: 0; padding: 12px 0; }
.shell.sidebar-collapsed .sidenav a > span { display: none; }
.shell.sidebar-collapsed .sidenav-section { display: none; }
.shell.sidebar-collapsed .side-footer { padding: 12px 10px; align-items: center; }
.shell.sidebar-collapsed .side-user { justify-content: center; padding: 6px; }
.shell.sidebar-collapsed .side-user-meta { display: none; }
.shell.sidebar-collapsed .side-lang { justify-content: center; padding: 11px 0; }
.shell.sidebar-collapsed .side-lang-main { gap: 0; }
.shell.sidebar-collapsed .side-lang-main span,
.shell.sidebar-collapsed .side-lang-code { display: none; }
.shell.sidebar-collapsed .lang-menu { left: 0; right: auto; min-width: 170px; }
.shell.sidebar-collapsed .side-logout { padding: 11px 0; }
.shell.sidebar-collapsed .side-logout span { display: none; }
.shell.sidebar-collapsed .side-logout-ic { display: inline-block; }
.shell.sidebar-collapsed .side-brand { justify-content: center; padding: 16px 8px 12px; }
.shell.sidebar-collapsed .side-brand .brand { display: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.brand-name { font-weight: 600; letter-spacing: .2px; }
.topnav { display: flex; align-items: center; gap: 18px; }
.topnav a { color: #cbd7e6; text-decoration: none; font-size: 14px; }
.topnav a:hover { color: #fff; }
.lang-toggle { display: inline-flex; gap: 6px; }
.lang-toggle a {
  padding: 2px 8px; border-radius: 6px; border: 1px solid transparent;
}
.lang-toggle a.active { background: rgba(255,255,255,.14); color: #fff; }
.logout { border-inline-start: 1px solid rgba(255,255,255,.2); padding-inline-start: 18px; }

/* ── Shell + sidebar ─────────────────────────── */
.shell { display: flex; align-items: stretch; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px;
  background: var(--sea-900); color: #cdd9df;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.side-brand {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 16px 16px 12px;
}
.side-brand .brand { color: #fff; }
.side-brand .brand-name { color: #fff; }
.sidenav {
  display: flex; flex-direction: column; gap: 3px; padding: 16px 14px;
  overflow-y: auto; overflow-x: hidden; flex: 1 1 auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent;
}
.sidenav::-webkit-scrollbar { width: 7px; }
.sidenav::-webkit-scrollbar-track { background: transparent; }
.sidenav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 8px; }
.sidenav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .28); }
.sidenav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 9px;
  color: #b6c5cd; text-decoration: none; font-size: 14px; font-weight: 500;
  white-space: nowrap; border-inline-start: 3px solid transparent;
}
.sidenav a .ic { color: #8ea3ad; }
.sidenav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidenav a:hover .ic { color: #fff; }
.sidenav a.active {
  background: rgba(200, 102, 59, .16);
  color: #fff; font-weight: 600; border-inline-start-color: var(--terra);
}
.ic { width: 20px; height: 20px; flex: none; }
.sidenav-section {
  font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: #7c8f99; font-weight: 700; padding: 18px 15px 6px;
}
.container-shell { flex: 1 1 auto; min-width: 0; max-width: none; margin: 0; }

/* ── Sidebar footer (user / language / logout) ─ */
.side-footer {
  margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .08);
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.side-user { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; text-decoration: none; color: #cdd9df; }
.side-user:hover { background: rgba(255, 255, 255, .06); }
.side-user .avatar { width: 38px; height: 38px; border-color: rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .12); }
.side-user-meta { display: flex; flex-direction: column; min-width: 0; }
.side-user-name { font-weight: 600; font-size: 13px; line-height: 1.25; color: #fff; }
.side-user-email { font-size: 12px; color: #8ea3ad; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.side-lang-wrap { position: relative; }
.side-lang {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 10px 13px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 9px;
  text-decoration: none; color: #dbe6eb; font-size: 13.5px;
  background: rgba(255, 255, 255, .06); font-family: inherit; cursor: pointer; text-align: start;
}
.side-lang:hover { border-color: rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .12); }
.side-lang-main { display: inline-flex; align-items: center; gap: 10px; }
.side-lang-main .ic { color: #8ea3ad; }
.side-lang-code { font-size: 12px; font-weight: 700; color: #8ea3ad; letter-spacing: .04em; }
.lang-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px);
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .16); padding: 6px; z-index: 30;
}
.lang-menu[hidden] { display: none; }
.lang-menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 8px; text-decoration: none;
  color: var(--text); font-size: 14.5px;
}
.lang-menu-item:hover { background: #f1f3fb; }
.lang-menu-item.is-active { background: #f1f5f9; font-weight: 700; }
.lang-menu-item .check { width: 18px; height: 18px; color: var(--accent); flex: none; }
.side-logout {
  display: block; text-align: center; padding: 10px; border-radius: 9px;
  background: rgba(255, 255, 255, .06); color: #dbe6eb; font-weight: 600; font-size: 13.5px;
  border: 1px solid rgba(255, 255, 255, .1); text-decoration: none;
}
.side-logout:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.side-logout-ic { display: none; width: 18px; height: 18px; vertical-align: middle; }

/* ── Responsive: mobile top bar + off-canvas drawer ── */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  /* Mobile top bar with a hamburger (shown only on small screens) */
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 40;
    background: var(--sea-900); color: #fff; padding: 10px 14px;
  }
  .mobile-topbar .brand, .mobile-topbar .brand-name { color: #fff; }
  .drawer-btn {
    display: grid; place-items: center; width: 40px; height: 40px; flex: none;
    border: none; cursor: pointer; border-radius: 9px;
    background: rgba(255, 255, 255, .12); color: #fff;
  }
  .drawer-btn svg { width: 22px; height: 22px; }

  /* Sidebar becomes an off-canvas drawer */
  .shell { display: block; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 60;
    width: 264px; max-width: 84vw; flex: none; height: 100vh;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .35);
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .shell.sidebar-open .sidebar { transform: none; }
  .shell.sidebar-collapsed .sidebar { width: 264px; flex: none; }  /* ignore desktop collapse */
  .side-brand .sidebar-toggle { display: none; }                    /* drawer uses hamburger/backdrop */

  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(13, 36, 51, .5);
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
  }
  .shell.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  body.drawer-lock { overflow: hidden; }

  /* Content spacing + controls */
  .container-shell { padding: 16px 14px 40px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head > .btn, .page-head > .btn-primary { width: 100%; justify-content: center; }
  .search-box { max-width: none; }
  .seg { width: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .toolbar { flex-wrap: wrap; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

  /* Tables scroll inside their card instead of breaking the page */
  .table-card, .recent { overflow-x: auto; }
  .table { min-width: 560px; }
}

/* ── Responsive: stacked-card tables on the smallest phones ──
   Below this width even the horizontal-scroll table from the 900px block
   above is awkward to read one-handed, so each <tr> becomes a card and each
   <td> a labeled row inside it — no JS, driven by a data-label attribute
   the row-rendering templates emit per cell. Overrides the 900px block's
   min-width/overflow-x since this rule comes after it in source order. */
@media (max-width: 480px) {
  .table-card, .recent { overflow-x: visible; }
  .table { min-width: 0; display: block; border-collapse: collapse; }
  .table thead { display: none; }
  .table tbody { display: block; }
  .table tr {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 10px;
  }
  .table tbody tr:hover { background: var(--card); }
  .table tbody tr:last-child { margin-bottom: 0; }
  .table td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 10px 14px; text-align: end; border-bottom: 1px solid var(--sand-100);
  }
  .table td:last-child { border-bottom: none; }
  .table td::before {
    content: attr(data-label);
    flex: none; text-align: start; margin-inline-end: auto;
    font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
    color: var(--muted);
  }
  .table td.col-actions { justify-content: flex-end; }
  .table td.col-actions::before { content: none; } /* row-actions links are already self-labeled */
  .row-actions { flex-wrap: wrap; justify-content: flex-end; }
  /* A colspan "no records" row is a single centered message, not a labeled
     field — opt it out of the per-cell card/label treatment above. */
  .table td.empty { display: block; text-align: center; }
  .table td.empty::before { content: none; }

  /* The donut chart is a fixed 150px SVG (see stats.py's donut()) that
     doesn't shrink — below this width there isn't room beside it for the
     legend too, so drop the legend underneath instead of cramping it. */
  .donut-wrap { flex-wrap: wrap; justify-content: center; }
  .legend { flex: 1 1 100%; }
}

/* ── Layout ──────────────────────────────────── */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }
.container-shell { padding: 22px 26px 48px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.container-shell .page-head::after {
  content: ""; position: absolute; left: 0; bottom: -1px; width: 84px; height: 3px;
  border-radius: 3px; background: linear-gradient(90deg, var(--terra), var(--sea-700));
}
[dir="rtl"] .container-shell .page-head::after { left: auto; right: 0; }
.page-title { font-size: 21px; margin: 0; letter-spacing: -.2px; }
.muted { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ── Toolbar / search ────────────────────────── */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.search {
  flex: 1; padding: 10px 12px; border: 1.5px solid var(--field-border);
  border-radius: 10px; font-size: 14px; background: #fff;
}
.search:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(200,102,59,.16); }

/* ── Table ───────────────────────────────────── */
/* overflow-x: auto so a table with more columns than fit the card scrolls
   instead of silently clipping (confirmed: the Actions column can sit
   partially or fully outside the card at ordinary desktop widths once a
   resource has enough columns, e.g. Jobs) — overflow-y stays hidden to
   preserve the card's rounded corners against the table's flat edges. */
.table-card { overflow-x: auto; overflow-y: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 12px 16px; text-align: start;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.table thead th {
  background: var(--navy-50); color: var(--navy-700);
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fbfaf6; }
.table th, .table td { border-bottom: 1px solid var(--sand-100); }
.th-sort {
  display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none;
  font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer;
}
.th-sort:hover { color: var(--terra); }
.th-sort.active { color: var(--terra-600); }
/* CSS-drawn triangle, not a unicode glyph — renders identically everywhere
   regardless of the system/browser's font fallback for symbol characters. */
.sort-arrow {
  display: inline-block; width: 0; height: 0; opacity: .85; flex: none;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
}
.sort-arrow.up { border-bottom: 5px solid currentColor; }
.sort-arrow.down { border-top: 5px solid currentColor; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.col-actions { text-align: end; }
.empty { text-align: center; color: var(--muted); padding: 32px; }
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--navy-50); color: var(--navy-700); font-size: 12px;
}

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-off { background: var(--off-bg); color: var(--off-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }

.row-thumb { width: 44px; height: 62px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.form-preview { width: 100%; max-width: 220px; height: auto; border-radius: 6px; border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ── Segmented status tabs + search box ──────── */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 2px; margin-bottom: 14px;
  background: var(--sand-100); border: 1px solid var(--line); border-radius: 10px; padding: 3px;
}
.seg-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.seg-stack .seg { margin-bottom: 0; }
.seg a {
  padding: 7px 16px; border-radius: 8px; font-weight: 600; font-size: 13px;
  color: var(--muted); text-decoration: none;
}
.seg a:hover { color: var(--text); }
.seg a.active { background: var(--terra); color: #fff; }
.seg label { padding: 7px 16px; border-radius: 8px; font-weight: 600; font-size: 13px;
  color: var(--muted); cursor: pointer; }
.seg label:hover { color: var(--text); }
.seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input[type="radio"]:checked) { background: var(--terra); color: #fff; }
.seg button {
  padding: 7px 16px; border-radius: 8px; font-weight: 600; font-size: 13px;
  color: var(--muted); background: none; border: none; cursor: pointer; font-family: inherit;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--terra); color: #fff; }
.cms-crumb { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.cms-crumb strong { color: var(--text); }

/* ── CMS minimal list (FAQ / Contact Methods) — a plain card per row
   instead of the generic table, no tiles/tabs/search chrome. ─────────── */
.cms-list { display: flex; flex-direction: column; gap: 12px; }
.cms-item {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.cms-item-icon {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy-50); color: var(--accent);
}
.cms-item-icon svg { width: 18px; height: 18px; }
.cms-item-body { flex: 1; min-width: 0; }
.cms-item-title { font-weight: 700; font-size: 14px; color: var(--text); }
.cms-item-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.search-box { margin-bottom: 16px; max-width: 420px; }
/* Owns the positioning context for the icon + dropdown, scoped to just the
   input's own height — kept separate from .search-box itself so the icon
   stays centered on the input even once the scope chip (a normal-flow
   sibling below the input) makes the outer form taller. */
.search-box-field { position: relative; }
.search-box input {
  width: 100%; padding: 11px 14px 11px 40px; border: 1px solid var(--field-border);
  border-radius: 11px; background: #fff; outline: none; font-size: 14px; font-family: inherit;
}
.search-box input:focus { border-color: var(--terra); box-shadow: 0 0 0 3px rgba(200, 102, 59, .16); }
.search-box .s-ico { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.search-box .s-ico svg { width: 17px; height: 17px; }
[dir="rtl"] .search-box input { padding: 11px 40px 11px 14px; }

/* ── Per-field search dropdown ("search by this header") ──────── */
.search-scope-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 11px;
  box-shadow: var(--shadow); padding: 4px; max-height: 260px; overflow-y: auto;
}
.search-scope-option {
  display: block; width: 100%; text-align: left; padding: 8px 12px; border: none;
  background: none; border-radius: 8px; font-size: 13px; font-family: inherit;
  color: var(--text); cursor: pointer;
}
[dir="rtl"] .search-scope-option { text-align: right; }
.search-scope-option:hover { background: var(--sand-100); }
.search-scope-option.active { background: var(--sand-100); color: var(--terra-600); font-weight: 700; }
/* Several fields can be selected at once — each gets its own removable chip. */
.search-scope-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.search-scope-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px;
  border-radius: 999px; background: var(--navy-50); color: var(--navy-700); font-size: 12px; font-weight: 600;
}
.search-scope-clear {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border: none; border-radius: 50%; background: rgba(0, 0, 0, .08); color: inherit; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0;
}
.search-scope-clear:hover { background: rgba(0, 0, 0, .16); }

/* ── Pagination ──────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px;
}
.pager { display: inline-flex; gap: 8px; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 14px; font-weight: 500;
  text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--sand-100); }
.btn-primary { background: var(--terra); border-color: var(--terra); color: #fff; }
.btn-primary:hover { background: var(--terra-600); border-color: var(--terra-600); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #9c3a2f; border-color: #9c3a2f; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn.disabled { opacity: .5; pointer-events: none; }
.link { color: var(--accent); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ── Row actions (edit / delete) ─────────────── */
.row-actions { display: inline-flex; align-items: center; gap: 14px; justify-content: flex-end; }
.inline-form { display: inline; margin: 0; }
.link-danger {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--err); font-size: 14px; font-weight: 500; font-family: inherit;
}
.link-danger:hover { text-decoration: underline; }
.row-reorder-btn {
  background: none; border: none; padding: 0 2px; cursor: pointer;
  color: var(--muted); font-size: 12px; line-height: 1; font-family: inherit;
}
.row-reorder-btn:hover:not(:disabled) { color: var(--text); }
.row-reorder-btn:disabled { opacity: 0.3; cursor: default; }

/* ── Forms ───────────────────────────────────── */
.form-card { padding: 24px; max-width: 640px; }
.form-card-wide { max-width: 900px; }
.mono-textarea { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12.5px; line-height: 1.5; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
/* .field's own `display: flex` otherwise wins the specificity tie against the
   browser's built-in `[hidden] { display: none }` UA rule, since both are
   (0,1,0) and this stylesheet loads after the UA one — silently keeping a
   hidden EN/AR language panel visible. */
.field[hidden] { display: none; }
.field > span { font-size: 13px; font-weight: 600; color: #334155; }
.req { color: var(--err); font-weight: 700; }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1.5px solid var(--field-border); border-radius: 10px;
  font-size: 14px; background: #fff; color: var(--text); width: 100%;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(200,102,59,.16);
}
.field input:disabled { background: #f1f5f9; color: var(--muted); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-inline-end: 44px; }
.pw-toggle {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: none; background: transparent; color: var(--muted); cursor: pointer; border-radius: 8px;
}
.pw-toggle:hover { color: var(--navy-700); background: var(--navy-50); }
.pw-toggle svg { width: 19px; height: 19px; }
.pw-toggle .pw-eye-off { display: none; }
.pw-toggle.pw-visible .pw-eye { display: none; }
.pw-toggle.pw-visible .pw-eye-off { display: block; }
.field input[type="file"] { padding: 8px 10px; background: #f8fafc; cursor: pointer; }
.field input[type="checkbox"] {
  width: 18px; height: 18px; padding: 0; border-radius: 4px;
  accent-color: var(--navy); cursor: pointer;
}
.check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--navy); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.checks { display: flex; gap: 24px; margin: 6px 0 20px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); }
.err { font-size: 12px; color: var(--err); }
.field.has-error input, .field.has-error select, .field.has-error textarea {
  border-color: var(--err); box-shadow: 0 0 0 3px rgba(184,70,58,.12);
}
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }

.list-editor { display: flex; flex-direction: column; gap: 6px; }
.list-editor-row { display: flex; gap: 6px; align-items: center; }
.list-editor-row input {
  flex: 1; padding: 10px 12px; border: 1.5px solid var(--field-border); border-radius: 10px;
  font-size: 14px; background: #fff; color: var(--text); font-family: inherit;
}
.list-editor-row input:focus {
  border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(200,102,59,.16);
}
.list-editor-remove {
  flex: none; width: 32px; height: 32px; border: 1.5px solid var(--field-border); border-radius: 8px;
  background: #fff; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer;
}
.list-editor-remove:hover { color: var(--err); border-color: var(--err); }
.list-editor-add {
  align-self: flex-start; padding: 7px 12px; border: 1.5px dashed var(--field-border); border-radius: 8px;
  background: transparent; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer;
}
.list-editor-add:hover { background: var(--navy-50); }

/* ── Plans form: section headers + quota cards ──────────── */
.form-section-title {
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); margin: 26px 0 14px; padding-top: 18px; border-top: 1px solid var(--line);
}
/* :first-child never matches — the form's actual first child is the hidden
   #lang input, not this div. :first-of-type matches correctly since that
   hidden input isn't a <div>, making this the first <div> sibling. */
.form-section-title:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.form-section-sub { font-size: 12.5px; color: var(--muted); margin: -10px 0 14px; }

.quota-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 4px; }
.quota-grid[hidden] { display: none; }
.quota-card {
  border: 1.5px solid var(--field-border); border-radius: 14px; padding: 14px;
  display: flex; flex-direction: column; gap: 12px; background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.quota-card:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,102,59,.12); }
.quota-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.quota-card-title { display: flex; align-items: center; gap: 9px; }
.quota-card-ico {
  width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; flex: none;
}
.quota-card-ico svg { width: 15px; height: 15px; }
.quota-card-label { font-size: 13px; font-weight: 700; color: var(--text); }
.quota-card-row input[type="number"] {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--field-border); border-radius: 9px;
  font-size: 14px; background: #fff; color: var(--text); font-family: inherit;
}
.quota-card-row input[type="number"]:disabled { background: #f1f5f9; color: var(--muted); }
.quota-card-row input[type="number"]:focus {
  border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(200,102,59,.16);
}

.quota-switch { position: relative; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; flex: none; }
.quota-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.quota-switch-track {
  width: 32px; height: 19px; border-radius: 999px; background: var(--field-border);
  position: relative; transition: background .15s ease; flex: none;
}
.quota-switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; transition: transform .15s ease; box-shadow: 0 1px 2px rgba(13,36,51,.3);
}
.quota-switch input:checked + .quota-switch-track { background: var(--accent); }
.quota-switch input:checked + .quota-switch-track::after { transform: translateX(13px); }
.quota-switch-label { font-size: 11px; font-weight: 700; letter-spacing: .2px; color: var(--muted); white-space: nowrap; }

@media (max-width: 640px) {
  .quota-grid { grid-template-columns: 1fr; }
}

/* ── Auth ────────────────────────────────────── */
.auth-wrap {
  display: grid; place-items: center; min-height: calc(100vh - 148px);
  padding: 20px;
  background:
    radial-gradient(1100px 500px at 12% -10%, rgba(43,122,155,.18), transparent 60%),
    radial-gradient(900px 500px at 105% 110%, rgba(30,58,95,.20), transparent 55%);
}
.auth-card {
  width: 100%; max-width: 880px;
  display: grid; grid-template-columns: 1fr 1.05fr;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(16, 24, 40, .16);
}
.auth-form-panel { order: 1; }
.auth-hero { order: 2; }

/* Left brand hero */
.auth-hero {
  position: relative; overflow: hidden; color: #fff;
  padding: 40px 36px;
  display: flex; flex-direction: column; gap: 26px;
  background: linear-gradient(155deg, var(--navy) 0%, var(--navy-700) 45%, var(--accent) 130%);
}
.auth-hero-top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.auth-logo {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
  background: rgba(255, 255, 255, .16); backdrop-filter: blur(2px);
  border: 1px solid rgba(255, 255, 255, .25);
}
.auth-brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.auth-hero-copy { position: relative; z-index: 1; }
.auth-hero-copy h2 { margin: 0 0 10px; font-size: 26px; line-height: 1.2; }
.auth-hero-copy p { margin: 0; font-size: 14.5px; line-height: 1.6; color: rgba(255, 255, 255, .82); }
.auth-points { list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.auth-points li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: rgba(255, 255, 255, .92); }
.auth-points svg {
  width: 18px; height: 18px; flex: none; padding: 8px; border-radius: 9px;
  background: rgba(255, 255, 255, .14); box-sizing: content-box;
}
.auth-glow { position: absolute; border-radius: 50%; filter: blur(6px); pointer-events: none; }
.auth-glow-a { width: 220px; height: 220px; top: -70px; right: -60px; background: rgba(255, 255, 255, .10); }
.auth-glow-b { width: 160px; height: 160px; bottom: -50px; left: -40px; background: rgba(43, 122, 155, .35); }

/* Right form panel */
.auth-form-panel { padding: 44px 40px; display: flex; flex-direction: column; justify-content: center; }
.auth-form-head { margin-bottom: 22px; }
.auth-title { margin: 0 0 6px; font-size: 24px; font-weight: 700; }
.auth-sub { margin: 0; font-size: 14px; color: var(--muted); }
.auth-submit { margin-top: 6px; padding: 13px; font-size: 15px; }

/* Inputs with a leading icon */
.input-icon { position: relative; display: block; }
.input-icon .in-ic {
  position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
.input-icon input { padding-inline-start: 42px; }

.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 18px;
}
.alert svg { width: 18px; height: 18px; flex: none; }
.alert-error { background: var(--off-bg); color: var(--off-fg); }

@media (max-width: 720px) {
  .auth-card { grid-template-columns: 1fr; max-width: 420px; }
  .auth-hero { display: none; }
  .auth-form-panel { padding: 32px 26px; }
}

/* ── Avatar / account ────────────────────────── */
.account { display: inline-flex; align-items: center; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,255,255,.5); display: grid; place-items: center;
}
.avatar-fallback { background: var(--accent); color: #fff; font-weight: 700; }
.avatar-lg { width: 112px; height: 112px; font-size: 40px; border-color: var(--border); }
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.account-grid .form-card { max-width: none; }
.avatar-row { display: flex; gap: 20px; align-items: center; }
.avatar-actions { display: flex; flex-direction: column; gap: 10px; }
.section-title { font-size: 16px; margin: 0 0 16px; color: var(--navy-700); }

/* ── Toast (create / edit / delete feedback) ─── */
.toast {
  position: fixed; top: 74px; inset-inline-end: 24px; z-index: 50;
  background: var(--ok-fg); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(16,24,40,.18);
  animation: toast-in .25s ease, toast-out .4s ease 3.2s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); visibility: hidden; } }

/* ── Modal (create / edit popup) ─────────────── */
.modal {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(13, 36, 51, .5);
  align-items: center; justify-content: center; padding: 24px 16px;
}
.modal.open { display: flex; }
.modal-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 20px 55px rgba(16, 24, 40, .32);
  width: 100%; max-width: 640px; max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modal-in .2s ease;
}
.modal-card-sm { max-width: 420px; }
.confirm-message { font-size: 14.5px; color: var(--text); margin: 0 0 20px; line-height: 1.5; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
.modal-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.modal-title { margin: 0; font-size: 18px; }
.modal-close { background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; }
.modal-body .form-card { border: none; box-shadow: none; padding: 0; max-width: none; }
.modal-body .page-head { display: none; }
/* Freeze the page behind the modal (JS sets `top` to the current scroll offset). */
body.modal-open { position: fixed; inset-inline: 0; width: 100%; overflow: hidden; }

/* ── Overview dashboard ──────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 15px 16px; text-decoration: none; color: var(--text); display: block; }
.tile.link { transition: box-shadow .15s ease; }
.tile.link:hover { box-shadow: 0 8px 20px rgba(13, 36, 51, .09); }
.tile-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.tile-k { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .2px; }
.tile-ico { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex: none; }
.tile-ico svg { width: 18px; height: 18px; }
.tile-v { font-size: 25px; font-weight: 700; margin-top: 12px; letter-spacing: -.5px; }
.tile-v small { font-size: 13px; color: var(--muted); font-weight: 600; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.dist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; margin-bottom: 16px; }
.recent-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; color: var(--text); }
.chart-card .ct-title { font-size: 13px; font-weight: 700; }
.chart-card .ct-sub { font-size: 20px; font-weight: 700; margin: 2px 0 12px; letter-spacing: -.4px; }
.chart-card .ct-sub small { font-size: 13px; color: var(--muted); font-weight: 600; }
.donut-wrap { display: flex; align-items: center; gap: 18px; margin-top: 10px; }
.legend { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.lg-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.lg-dot { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.lg-lb { color: var(--muted); }
.lg-v { margin-inline-start: auto; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.recent { overflow: hidden; }
.recent .rhead { display: flex; justify-content: space-between; align-items: center; padding: 13px 15px; border-bottom: 1px solid var(--sand-100); }
.recent .rhead b { font-size: 13.5px; }
.badge-mut { background: var(--sand-100); color: var(--muted); }
@media (max-width: 900px) { .chart-grid, .recent-grid { grid-template-columns: 1fr; } }

/* ── Focus / motion ──────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media (max-width: 860px) {
  .account-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; }
  .avatar-row { flex-direction: column; align-items: flex-start; }
}
