/* ===== Tokens ===== */
:root {
  --orange: #FF5A1F;
  --orange-text: #C2410C;
  --on-orange: #141B34;
  --orange-dark: #C2410C;
  --orange-light: #FFF4EF;
  --orange-border: #FFD3C2;
  --navy: #141B34;
  --logo-tile: #141B34;
  --ink: #141B34;
  --ink-muted: #5B6272;
  --surface: #FFFFFF;
  --surface-2: #F4F5F8;
  --border: #E3E6EE;
  --status-paid: #15803D;
  --status-soon: #B45309;
  --status-late: #B91C1C;
  --surface-raised: #FFFFFF;
  --sand-deep: var(--surface-2);
  --line: var(--border);
  --atlas: var(--navy);
  --on-atlas: #FFFFFF;
  --mint: var(--orange);
  --ink-on-mint: var(--on-orange);
  --saffron: var(--status-soon);
  --brand: var(--orange);
  --on-brand: var(--on-orange);
  --paid: var(--status-paid);
  --paid-soft: #DDF4E7;
  --due: var(--status-soon);
  --due-soft: #FBEACB;
  --overdue: var(--status-late);
  --overdue-soft: #F8DED6;
  --focus-ring: var(--orange);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-full: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --shadow-card: 0 1px 2px rgba(20,27,52,.06), 0 4px 16px rgba(20,27,52,.06);

  --bg: var(--surface);
  --surface-panel: var(--surface-raised);
  --ink-2: var(--ink-muted);
  --iron: var(--atlas);
  --iron-2: var(--atlas);
  --iron-ink: var(--on-atlas);
  --action: var(--brand);
  --action-dark: var(--orange-dark);
  --action-ink: var(--on-brand);
  --mint-2: var(--orange-light);
  --accent: var(--mint);
  --ring: color-mix(in srgb, var(--orange) 12%, transparent);
  --ok: var(--paid);
  --ok-bg: var(--paid-soft);
  --warn: var(--due);
  --warn-bg: var(--due-soft);
  --bad: var(--overdue);
  --bad-bg: var(--overdue-soft);
  --none: var(--ink-muted);
  --none-bg: var(--sand-deep);

  --r-s: var(--radius-sm);
  --r-m: var(--radius-md);
  --r-l: var(--radius-lg);
  --r-xl: var(--radius-lg);
  --shadow: var(--shadow-card);
  --track: -.02em;

  --font: "Plus Jakarta Sans", "IBM Plex Sans Arabic", "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
html[dir="rtl"] {
  --font: "IBM Plex Sans Arabic", Tahoma, "Segoe UI", sans-serif;
  --track: 0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --logo-tile: #1C2547;
    --orange-text: #FF7A47;
    --status-paid: #4ADE80;
    --status-soon: #FBBF24;
    --status-late: #F87171;
    --surface: #0E1326;
    --surface-raised: #1C2547;
    --surface-2: #26305A;   /* hover/raised rows in dark mode */
    --border: #2E3A66;
    --orange-light: #3A2420;
    --orange-border: #6B3420;
    --sand-deep: #1C2547;
    --line: #2E3A66;
    --ink: #FFFFFF;
    --ink-muted: #A5ADC0;
    --atlas: #141B34;
    --on-atlas: #FFFFFF;
    --brand: var(--orange);
    --on-brand: var(--on-orange);
    --paid: var(--status-paid);
    --paid-soft: #10301F;
    --due: var(--status-soon);
    --due-soft: #36290C;
    --overdue: var(--status-late);
    --overdue-soft: #3E1C18;
    --focus-ring: var(--orange);
    --bg: var(--surface);
    --surface-panel: var(--surface-raised);
    --ink-2: var(--ink-muted);
    --iron: var(--atlas);
    --iron-2: var(--atlas);
    --iron-ink: var(--on-atlas);
    --action: var(--brand);
    --action-dark: var(--orange-dark);
    --action-ink: var(--on-brand);
    --mint-2: #1C2547;
    --accent: var(--mint);
    --ring: color-mix(in srgb, var(--orange) 18%, transparent);
    --ok: var(--paid);
    --ok-bg: var(--paid-soft);
    --warn: var(--due);
    --warn-bg: var(--due-soft);
    --bad: var(--overdue);
    --bad-bg: var(--overdue-soft);
    --none: #A5ADC0;
    --none-bg: #25323C;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --logo-tile: #1C2547;
  --orange-text: #FF7A47;
  --status-paid: #4ADE80;
  --status-soon: #FBBF24;
  --status-late: #F87171;
  --surface: #0E1326;
  --surface-raised: #1C2547;
  --surface-2: #26305A;   /* hover/raised rows in dark mode */
  --border: #2E3A66;
  --orange-light: #3A2420;
  --orange-border: #6B3420;
  --sand-deep: #1C2547;
  --line: #2E3A66;
  --ink: #FFFFFF;
  --ink-muted: #A5ADC0;
  --atlas: #141B34;
  --on-atlas: #FFFFFF;
  --brand: var(--orange);
  --on-brand: var(--on-orange);
  --paid: var(--status-paid);
  --paid-soft: #10301F;
  --due: var(--status-soon);
  --due-soft: #36290C;
  --overdue: var(--status-late);
  --overdue-soft: #3E1C18;
  --focus-ring: var(--orange);
  --bg: var(--surface);
  --surface-panel: var(--surface-raised);
  --ink-2: var(--ink-muted);
  --iron: var(--atlas);
  --iron-2: var(--atlas);
  --iron-ink: var(--on-atlas);
  --action: var(--brand);
  --action-dark: var(--orange-dark);
  --action-ink: var(--on-brand);
  --mint-2: #1C2547;
  --accent: var(--mint);
  --ring: color-mix(in srgb, var(--orange) 18%, transparent);
  --ok: var(--paid);
  --ok-bg: var(--paid-soft);
  --warn: var(--due);
  --warn-bg: var(--due-soft);
  --bad: var(--overdue);
  --bad-bg: var(--overdue-soft);
  --none: #A5ADC0;
  --none-bg: #25323C;
  color-scheme: dark;
}

/* ===== Theme toggle ===== */
body, .sidenav, .mobile-top, .tabbar, .panel, .cell, input, select, textarea, .btn, .icon-btn, .toast {
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
@media (prefers-reduced-motion: reduce) {
  body, .sidenav, .mobile-top, .tabbar, .panel, .cell, input, select, textarea, .btn, .icon-btn, .toast { transition: none !important; }
}
.theme-ico [data-icon="sun"] { display: none; }
:root[data-theme="dark"] .theme-ico [data-icon="sun"] { display: inline-flex; }
:root[data-theme="dark"] .theme-ico [data-icon="moon"] { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-ico [data-icon="sun"] { display: inline-flex; }
  :root:not([data-theme="light"]) .theme-ico [data-icon="moon"] { display: none; }
}
.icon-btn.theme-btn { width: 40px; padding: 0; }

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--orange-text); }
h1, h2 { line-height: 1.25; letter-spacing: var(--track); }
.cell .num, .tag b, .amount, .nav-badge { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }
svg { display: block; }
[data-icon] { display: inline-grid; place-items: center; }
[data-icon] svg { width: 20px; height: 20px; }

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  padding: 24px;
  text-align: center;
}
.boot code { direction: ltr; unicode-bidi: embed; background: var(--surface); padding: 2px 6px; border-radius: var(--r-s); }

/* ===== Shell ===== */
.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}
.sidenav {
  background: var(--iron);
  color: var(--iron-ink);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 24px 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: var(--track);
  padding: 4px 8px 20px;
}
.brand svg, .brand img { width: auto; height: 36px; border-radius: 0; object-fit: contain; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  position: relative;
  padding: 11px 16px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
  opacity: .75;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); opacity: 1; }
.nav-link.active { background: rgba(255, 255, 255, .08); opacity: 1; font-weight: 600; }
.nav-link.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 6px;
  top: 50%;
  width: 4px;
  height: 18px;
  margin-top: -9px;
  border-radius: 4px;
  background: var(--accent);
}
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.who { margin: 8px 12px; font-size: 13px; opacity: .6; overflow-wrap: anywhere; }

.content { min-width: 0; }
#view {
  padding: 32px clamp(16px, 4vw, 40px) 56px;
  max-width: 1180px;
}
.mobile-top {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface-raised) 86%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.mobile-top .brand { padding: 0; font-size: 17px; }
.mobile-top .icon-btn { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.tabbar { display: none; }
.offline {
  margin: 14px clamp(16px, 4vw, 44px) 0;
  max-width: 1180px;
  border-radius: var(--r-m);
  padding: 10px 16px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 14px;
  text-align: center;
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidenav { display: none; }
  .mobile-top { display: flex; }
  #view { padding: 18px 14px 100px; }
  .tabbar {
    display: grid;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    z-index: 10;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px 9px;
    font-size: 12px;
    color: var(--ink-2);
    text-decoration: none;
  }
  .tabbar a.active { color: var(--action); font-weight: 700; }
  .tabbar a [data-icon] { padding: 3px 16px; border-radius: 999px; }
  .tabbar a.active [data-icon] { background: var(--mint); }
  .sub-banner, .offline { margin-top: 12px; }
}

/* ===== Page header ===== */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: clamp(26px, 3.6vw, 38px); font-weight: 800; }
.sub { margin: 4px 0 0; color: var(--ink-2); }
.back {
  display: inline-block;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--ink-2);
  text-decoration: none;
}
.back::before { content: "‹ "; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--action); color: var(--action-ink); }
.btn.primary:hover:not(:disabled) { background: var(--action-dark); color: #FFFFFF; }
.btn.ghost:hover:not(:disabled), .btn.danger:hover:not(:disabled) { background: var(--surface-2); }
[dir="rtl"] .btn .chev { transform: scaleX(-1); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--line); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn.wa { color: var(--ok); }
.icon-btn svg { width: 20px; height: 20px; }

/* ===== Summary strip ===== */
.strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.cell {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}
.cell:hover { background: var(--surface-2); }
.cell .num {
  display: block;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: var(--track);
  font-variant-numeric: tabular-nums;
}
.cell .lbl { color: var(--ink-2); font-size: 14px; }
.cell.ok .num { color: var(--ok); }
.cell.warn .num { color: var(--warn); }
.cell.bad .num { color: var(--bad); }
.cell.money { cursor: default; }
.cell.money:hover { background: var(--surface); }
.cell.money .num { font-size: 26px; padding-top: 5px; }
@media (max-width: 900px) { .strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .strip { grid-template-columns: 1fr 1fr; gap: 10px; }
  .strip .cell:nth-child(5) { grid-column: 1 / -1; }
  .cell { padding: 14px 16px; }
  .cell .num { font-size: 28px; }
}

/* ===== Panels ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 24px;
  margin-bottom: 18px;
}
.panel h2 { font-size: 20px; font-weight: 700; margin: 0 0 10px; }
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.panel-head h2 { margin: 0; }
.cols {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.cols > .panel { margin-bottom: 0; }
@media (max-width: 920px) { .cols { grid-template-columns: 1fr; } }
.empty { color: var(--ink-2); padding: 14px 0; margin: 0; list-style: none; }
.muted { color: var(--ink-2); font-size: 14px; }

/* ===== Client rows & the locker tag ===== */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row-main {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: var(--r-m);
}
.row-main:hover strong { text-decoration: underline; }
.row:hover { background: var(--surface-2); border-radius: var(--r-m); box-shadow: 0 0 0 8px var(--surface-2); }
.row-text { display: flex; flex-direction: column; min-width: 0; }
.row-text strong, .row-text .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: flex; gap: 6px; }

.tag {
  position: relative;
  flex: none;
  width: 56px;
  height: 60px;
  padding-top: 10px;
  border-radius: 12px 12px 16px 16px;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tag::before {
  content: "";
  position: absolute;
  top: 6px;
  right: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface);
  transform: translateX(50%);
}
.tag b { font-size: 21px; font-weight: 700; }
.tag small { display: block; margin-top: 4px; font-size: 11px; }
.tag.big { width: 84px; height: 90px; padding-top: 14px; }
.tag.big::before { top: 9px; width: 10px; height: 10px; }
.tag.big b { font-size: 34px; }
.tag.big small { font-size: 13px; }
.tag.ok   { background: var(--ok-bg);   color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad  { background: var(--bad-bg);  color: var(--bad); }
.tag.none { background: var(--none-bg); color: var(--none); }

.pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.active   { background: var(--ok-bg);   color: var(--ok); }
.pill.expiring { background: var(--warn-bg); color: var(--warn); }
.pill.expired  { background: var(--bad-bg);  color: var(--bad); }
.pill.none     { background: var(--none-bg); color: var(--none); }

/* ===== Client detail ===== */
.client-head { align-items: center; }
.client-id { display: flex; align-items: center; gap: 16px; min-width: 0; }
.client-id h1 { overflow-wrap: anywhere; }
.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 18px;
  margin: 0;
}
.facts dt { color: var(--ink-2); font-size: 14px; padding-top: 2px; }
.facts dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.ltr { direction: ltr; unicode-bidi: embed; }

.line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.line:first-child { border-top: 0; }
.line-main { display: flex; flex-direction: column; min-width: 0; }
.line-main a { color: inherit; font-weight: 600; text-decoration: none; }
.line-main a:hover { text-decoration: underline; }
.line-end { display: flex; align-items: center; gap: 10px; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.total {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 2px solid var(--ink);
  font-weight: 700;
}
.dues-total { color: var(--bad); border-color: var(--bad); }
.dues-clear { margin: 8px 0; color: var(--ok); font-weight: 600; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn.wa-send { background: var(--ok); color: var(--on-brand); border-color: var(--ok); }
.receipt-panel { background: var(--mint); border-color: var(--mint-2); }
.nav-badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-inline-start: 6px;
  border-radius: 9px;   background: var(--bad); color: var(--on-brand);
  font-size: 11px; line-height: 18px; text-align: center; font-weight: 700;
}
.nav-badge[hidden] { display: none; }
.preview {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r-m);
  background: var(--surface-2);
  color: var(--ink);
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.toolbar input[type="search"] { flex: 1 1 240px; width: auto; }
.toolbar input[type="month"] { width: auto; }
.seg {
  display: flex;
  max-width: 100%;
  overflow-x: auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.seg button {
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
.seg button.on { background: var(--iron); color: var(--on-atlas); font-weight: 600; }

/* ===== Forms ===== */
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--action);
  outline: none;
  box-shadow: 0 0 0 4px var(--ring);
}
.form { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-2); }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea { font-size: 16px; }
fieldset.sub-panel {
  margin: 4px 0 0;
  padding: 16px 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface-2);
}
fieldset.sub-panel input, fieldset.sub-panel select, fieldset.sub-panel textarea { background: var(--surface); }
legend { padding: 0 6px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 16px; }
.check input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--action); }
.form-error { min-height: 1.4em; margin: 0; color: var(--bad); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hint { margin: 0; color: var(--ink-2); font-size: 14px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }

/* ===== Login / onboarding ===== */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  background: radial-gradient(60% 50% at 50% 30%, rgba(99, 211, 159, .22), transparent 70%), var(--bg);
}
.auth-card {
  width: min(440px, 100%);
  padding: 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
}
.auth-logo { border-radius: 0; }
.auth-card h1 { margin: 14px 0 4px; font-size: 28px; font-weight: 800; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.auth-card .btn.primary { width: 100%; }
.auth-card > .btn.ghost { width: 100%; margin-top: 10px; }
.uid {
  padding: 10px;
  border-radius: var(--r-m);
  background: var(--surface-2);
  font-family: Consolas, monospace;
  font-size: 14px;
  overflow-wrap: anywhere;
  user-select: all;
}
@media (max-width: 480px) { .auth-card { padding: 26px 20px; } }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  inset-inline: 0;
  z-index: 50;
  width: max-content;
  max-width: calc(100% - 32px);
  margin-inline: auto;
  padding: 12px 20px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  background: var(--iron);
  color: var(--iron-ink);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--bad); color: var(--on-brand); }
@media (max-width: 820px) { .toast { bottom: 86px; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Language switch / LTR */
.auth-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.lang-switch { width: auto; }
.icon-btn.lang-btn { width: auto; padding: 0 10px; font-size: 13px; }

/* Excel import */
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; text-align: center; border: 2px dashed var(--line); border-radius: var(--r-m); background: var(--surface-2); color: var(--ink-2); cursor: pointer; }
.dropzone.over, .dropzone:focus-within { border-color: var(--action); background: var(--mint); color: var(--ink); }
.dropzone strong { color: var(--ink); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.imp-progress { height: 10px; border-radius: 99px; background: var(--none-bg); overflow: hidden; }
.imp-progress > div { height: 100%; background: var(--action); transition: width .2s; }
.imp-err { color: var(--bad); font-size: 14px; }
.imp-opts { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.imp-opts label { display: inline-flex; gap: 6px; align-items: center; }
.imp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }


.auth-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.auth-links.stack { flex-direction: column; align-items: stretch; }
#onboard form[hidden], #onboard #onb-choice[hidden] { display: none; }
#onb-found { margin: 0; font-weight: 600; }

.set-sep { margin-top: 22px; }
.logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-prev { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; background: var(--none-bg); }
.invite-code { font-size: 24px; letter-spacing: .12em; }

.sub-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 14px clamp(16px, 4vw, 44px) 0; max-width: 1180px; padding: 12px 18px; border-radius: var(--r-m); background: var(--mint); color: var(--action); font-weight: 600; }
.sub-banner.warn { background: var(--warn-bg); color: var(--warn); }
.sub-banner.bad { background: var(--bad-bg); color: var(--bad); }
.is-ro { opacity: .45; cursor: not-allowed; }
.adm-list { display: flex; flex-direction: column; gap: 10px; padding: 0; list-style: none; }
.adm-row { margin-bottom: 0; }

/* ===== Search field with icon ===== */
input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
  padding-inline-start: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%239AABA3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px 50%;
}
[dir="rtl"] input[type="search"] { background-position: calc(100% - 14px) 50%; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ===== Tables (import preview, admin, settings) ===== */
.table, .panel table { width: 100%; border-collapse: collapse; }
.table th, .panel table th { padding: 10px 12px; color: var(--ink-2); font-size: 13px; font-weight: 600; text-align: start; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; }
.table td, .panel table td { padding: 12px; border-bottom: 1px solid var(--line); text-align: start; }
.table tbody tr:hover, .panel table tbody tr:hover { background: var(--surface-2); }
.table-wrap { max-width: 100%; overflow: auto; border-radius: var(--r-l); }

/* ===== Mobile safety ===== */
@media (max-width: 820px) {
  .page-head h1 { font-size: 26px; }
  .panel { padding: 18px; }
  .head-actions .btn { padding: 0 16px; }
}
.panel, .row-text, .line-main { min-width: 0; }
.panel { overflow-wrap: anywhere; }

/* ===== Direction details ===== */
[dir="rtl"] .back::before { content: "\203A "; }
[dir="ltr"] .back::before { content: "\2039 "; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input[type="search"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%239AABA3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E"); }
}
:root[data-theme="dark"] input[type="search"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%239AABA3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E"); }

.toolbar input[type="search"] { min-width: 0; }
@media (max-width: 820px) { .tabbar a { min-width: 0; font-size: 11px; } .tabbar a [data-icon] { padding: 3px 10px; } }

.cell { display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; }

/* ===== QR check-in ===== */
.ci-today { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 24px; }
.ci-today .num { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ci-today .lbl { color: var(--ink-2); }
.qr-reader { width: 100%; max-width: 420px; min-height: 240px; margin: 0 auto 12px; border-radius: var(--r-l); overflow: hidden; background: var(--navy); }
.manual-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; max-width: 420px; margin: 0 auto; }
.manual-form .field { flex: 1 1 180px; }
#ci-code { text-align: center; text-transform: uppercase; font-weight: 700; letter-spacing: .25em; }
.ci-result {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center; cursor: pointer;
}
.ci-result.ok { background: var(--mint); color: var(--ink-on-mint); }
.ci-result.soon { background: var(--saffron); color: var(--ink-on-mint); }
.ci-result.late, .ci-result.unknown { background: var(--overdue-soft); color: var(--overdue); }
.ci-mark { font-size: clamp(90px, 22vw, 160px); line-height: 1; font-weight: 800; }
.ci-name { font-size: clamp(30px, 7vw, 56px); font-weight: 800; }
.ci-line { font-size: clamp(18px, 4vw, 28px); font-weight: 600; }
.ci-photo { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; }

/* ===== Member card ===== */
.card-overlay {
  position: fixed; inset: 0; z-index: 90; overflow: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 20px; background: rgba(20, 27, 52, .92);
}
.member-card {
  width: min(380px, 100%); padding: 32px 28px; border-radius: 28px;
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  background: #FFFFFF; color: #141B34;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.mc-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.mc-brand img { width: 56px; height: 56px; border-radius: 14px; object-fit: contain; }
.mc-name { font-size: 26px; font-weight: 800; overflow-wrap: anywhere; }
.mc-qr { padding: 12px; border-radius: 16px; background: #fff; line-height: 0; }
.mc-qr svg { display: block; width: 240px; height: 240px; }
.mc-code { font-family: ui-monospace, Consolas, monospace; font-size: 34px; font-weight: 800; letter-spacing: .18em; }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
@media print {
  /* only hide the rest of the page when a member card is being printed */
  body:has(#card-overlay) > *:not(#card-overlay) { display: none !important; }
  .card-overlay { position: static; padding: 0; background: none; overflow: visible; }
  .no-print { display: none !important; }
  .member-card { margin: 0 auto; border: 1px solid #999; }
}

/* ===== Presence (calendar + daily list) ===== */
.lkp-nav, .pres-day-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.lkp-month { min-width: 150px; text-align: center; text-transform: capitalize; }
.lkp-arrow { font-size: 22px; line-height: 1; }
.lkp-arrow:disabled { opacity: .35; cursor: default; }
html[dir="rtl"] .lkp-arrow { transform: scaleX(-1); }
.lkp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 420px; }
.lkp-wd { font-size: 11px; color: var(--ink-2); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lkp-day {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1;
  border-radius: var(--r-s); font-size: 13px; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--ink);
}
.lkp-day.pad { background: transparent; }
.lkp-day.future { opacity: .4; }
.lkp-day.on { background: var(--orange); color: var(--on-orange); font-weight: 700; }
.lkp-day.today { box-shadow: inset 0 0 0 2px var(--orange); }
.lkp-day.on.today { box-shadow: inset 0 0 0 2px var(--navy); }
.lkp-stats { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 16px; }
.lkp-stats > div { display: flex; flex-direction: column; }
.lkp-stats .num, .pres-count .num { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.lkp-stats .lbl, .pres-count .lbl { font-size: 12px; color: var(--ink-2); }
.lkp-away { margin: 12px 0 0; padding: 8px 12px; border-radius: var(--r-s); background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.pres-q { width: 100%; margin: 8px 0 4px; }
.pres-day-nav input[type="date"] { width: auto; }
.pres-count { margin-inline-start: auto; }
.pres-long { margin: 0 0 8px; text-transform: capitalize; }
.pres-time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 48px; }
