/* ============================================================================
   Wesha Marble System — design system
   RTL-first, light theme only. LOGICAL properties only (inline-start = right
   in RTL). Brand tokens from weshamarble.com. Font: Alexandria.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Alexandria:wght@300..700&display=swap');

:root {
  --teal: #0D4B57; --teal-2: #083640; --gold: #D8B472; --gold-ink: #86651A;
  --cream: #FBF8F1; --cream-2: #F4EEE1; --paper: #fff;
  --ink: #141414; --ink-2: #4A4F57; --line: #ECE5D5;
  --ok: #1F8A5B; --warn: #B8860B; --bad: #B3261E; --wa: #1FA855;
  --r: 12px; --r-lg: 16px;
  /* derived */
  --teal-bg: #E4EEF0; --gold-bg: #F7EFDD; --ok-bg: #E6F4EC; --warn-bg: #FBF3DC; --bad-bg: #F9E5E3;
  --font: 'Alexandria', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 6px 20px rgba(13, 75, 87, .06);
  --shadow-lg: 0 16px 48px rgba(13, 75, 87, .22);
  --sidebar-w: 248px; --bottom-nav-h: 64px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--cream); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.6; text-align: start;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 600; color: var(--teal-2); }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; } h4 { font-size: 14px; }
p { margin: 0 0 .75em; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--ink-2); font-size: 13px; }
hr { border: 0; border-block-start: 1px solid var(--line); margin: 16px 0; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--cream-2); padding: 1px 6px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; }
img { max-width: 100%; }
svg.i { width: 20px; height: 20px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* numbers always Latin digits, left-to-right, tabular */
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num, th.num { text-align: end; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- app layout: sidebar (inline-start) + main ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100dvh; }
.main { padding: 14px 16px; padding-block-end: calc(var(--bottom-nav-h) + var(--sab) + 24px); min-width: 0; }
.main > * + * { margin-block-start: 16px; }
.container { max-width: 1100px; margin-inline: auto; }
@media (min-width: 768px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .main { padding: 24px 32px 48px; }
}

/* ---------- sidebar (desktop only) ---------- */
.sidebar { display: none; }
@media (min-width: 768px) {
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    background: var(--teal-2); color: #E6EEF0; padding: 18px 14px calc(16px + var(--sab));
    border-inline-end: 1px solid rgba(255, 255, 255, .06);
  }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; }
  .sidebar .brand img { width: 38px; height: 38px; border-radius: 10px; }
  .sidebar .brand b { font-size: 18px; font-weight: 600; display: block; line-height: 1.2; }
  .sidebar .brand small { color: var(--gold); font-size: 11px; }
  .sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
  .sidebar .group { margin-block-start: 12px; padding: 0 10px 4px; font-size: 11px; letter-spacing: .02em; color: var(--gold); opacity: .9; }
  .sidebar nav a {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
    color: #D2DEE1; font-size: 14px; text-decoration: none; transition: background .15s;
  }
  .sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
  .sidebar nav a.active { background: var(--teal); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
  [dir="rtl"] .sidebar nav a.active { box-shadow: inset -3px 0 0 var(--gold); }
  .sidebar .user { margin-block-start: 14px; padding: 12px 10px 0; border-block-start: 1px solid rgba(255, 255, 255, .1); display: flex; align-items: center; gap: 10px; font-size: 13px; color: #B8C9CD; }
  .sidebar .user .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar .user button { background: none; border: 0; color: #B8C9CD; cursor: pointer; padding: 6px; border-radius: 8px; }
  .sidebar .user button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  margin: -14px -16px 16px; padding: calc(10px + var(--sat)) 14px 10px;
  background: var(--teal); color: #fff; min-height: 56px;
}
.topbar h1 { flex: 1; min-width: 0; font-size: 18px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { display: block; font-size: 12px; font-weight: 400; color: var(--gold); line-height: 1.2; }
.topbar .back { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; color: #fff; background: rgba(255, 255, 255, .1); }
.topbar .back:hover { text-decoration: none; background: rgba(255, 255, 255, .18); }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
.topbar .actions .btn { padding: 8px 12px; font-size: 14px; }
.topbar .actions .btn.primary { background: var(--gold); color: var(--teal-2); }
@media (min-width: 768px) {
  .topbar { margin: -24px -32px 24px; padding: 14px 32px; background: var(--paper); color: var(--teal-2); border-block-end: 1px solid var(--line); min-height: 64px; }
  .topbar h1 { font-size: 22px; color: var(--teal-2); }
  .topbar .sub { color: var(--ink-2); }
  .topbar .back { color: var(--teal); background: var(--teal-bg); }
  .topbar .actions .btn.primary { background: var(--teal); color: #fff; }
}

/* ---------- cards & KPIs ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card > h2, .card > h3 { margin-block-end: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-block-end: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); margin: 20px 0 8px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 768px) { .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; } }
.kpi { container-type: inline-size; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; min-width: 0; position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; inset-block-start: 0; inset-inline-start: 0; width: 4px; height: 100%; background: var(--teal); }
.kpi.gold::before { background: var(--gold); } .kpi.ok::before { background: var(--ok); } .kpi.warn::before { background: var(--warn); } .kpi.bad::before { background: var(--bad); }
.kpi .label { font-size: 12.5px; color: var(--ink-2); }
.kpi .value { font-size: 19px; font-weight: 600; color: var(--teal-2); direction: ltr; unicode-bidi: isolate; text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value.ok { color: var(--ok); } .kpi .value.bad { color: var(--bad); } .kpi .value.warn { color: var(--warn); }
.kpi .hint { font-size: 12px; color: var(--ink-2); }
@media (min-width: 768px) { .kpi .value { font-size: 24px; } }
/* scale the number to the card width where container units exist (falls back to the sizes above) */
.kpi .value { font-size: clamp(15px, 12.5cqi, 26px); }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1.7; background: var(--teal-bg); color: var(--teal); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--gold-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.muted { background: var(--cream-2); color: var(--ink-2); }
.pill.gold { background: var(--gold-bg); color: var(--gold-ink); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--paper); color: var(--teal-2); font: inherit; font-size: 15px; font-weight: 500;
  cursor: pointer; text-decoration: none; line-height: 1.3; min-height: 42px; transition: filter .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; background: var(--cream-2); }
.btn:active { filter: brightness(.95); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; }
.btn.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn.primary:hover { background: var(--teal-2); }
.btn.gold { background: var(--gold); color: var(--teal-2); border-color: var(--gold); }
.btn.gold:hover { filter: brightness(1.05); background: var(--gold); }
.btn.wa { background: var(--wa); color: #fff; border-color: var(--wa); }
.btn.wa:hover { background: #18944A; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--teal); }
.btn.ghost:hover { background: var(--teal-bg); }
.btn.danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.btn.danger:hover { background: #F2D2CF; }
.btn.sm { padding: 6px 12px; font-size: 13px; min-height: 34px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.icon { padding: 8px; width: 42px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 768px) { .quick-actions { display: flex; flex-wrap: wrap; } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-block-end: 12px; min-width: 0; }
.field > label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field .help { font-size: 12px; color: var(--ink-2); }
.field .err { font-size: 12px; color: var(--bad); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zoom */
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); color: var(--ink);
  min-height: 44px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13, 75, 87, .12); }
input[type="number"], input[inputmode="decimal"], input[inputmode="numeric"], input[type="date"], input[type="tel"], input[type="email"], input[inputmode="email"] { direction: ltr; text-align: start; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--teal); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
select { appearance: none; -webkit-appearance: none; padding-inline-end: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234A4F57' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; }
[dir="ltr"] select { background-position: right 12px center; }
.input-group { display: flex; align-items: stretch; }
.input-group input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; background: var(--cream-2); border: 1px solid var(--line); border-inline-start: 0; border-start-end-radius: var(--r); border-end-end-radius: var(--r); font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.search { position: relative; }
.search input { padding-inline-start: 38px; }
.search svg { position: absolute; inset-inline-start: 12px; inset-block-start: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--ink-2); fill: none; stroke-width: 2; }

/* filters row: horizontally scrollable chips/selects on phones */
.filters { display: flex; gap: 8px; align-items: center; overflow-x: auto; padding-block-end: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.filters::-webkit-scrollbar { display: none; }
.filters > * { flex: 0 0 auto; }
.filters select, .filters input { width: auto; min-height: 38px; padding: 6px 10px; font-size: 14px; border-radius: 10px; }
.filters .search { flex: 1 1 180px; min-width: 160px; }
.filters .search input { width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: 13px; color: var(--ink-2); cursor: pointer; font-family: inherit; white-space: nowrap; }
.chip.active { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: start; border-block-end: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-size: 12.5px; font-weight: 500; color: var(--ink-2); background: var(--cream-2); position: sticky; top: 0; }
tbody tr:last-child td { border-block-end: 0; }
tbody tr:hover td { background: #FCFAF5; }
tr.clickable { cursor: pointer; }
td.wrap { white-space: normal; }
td.actions { text-align: end; }
td.actions .btn + .btn { margin-inline-start: 4px; }
tfoot td { font-weight: 600; background: var(--cream-2); }
table.compact th, table.compact td { padding: 7px 10px; font-size: 13px; }
/* .cards variant: under 720px each row becomes a stacked card; td needs data-label */
@media (max-width: 719px) {
  .table-wrap.cards { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table-wrap.cards table, .table-wrap.cards tbody, .table-wrap.cards tr, .table-wrap.cards td { display: block; width: 100%; }
  .table-wrap.cards thead, .table-wrap.cards tfoot { display: none; }
  .table-wrap.cards tr { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 14px; margin-block-end: 10px; box-shadow: var(--shadow); }
  .table-wrap.cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border: 0; white-space: normal; border-block-end: 1px dashed var(--line); }
  .table-wrap.cards td:last-child { border-block-end: 0; }
  .table-wrap.cards td::before { content: attr(data-label); color: var(--ink-2); font-size: 12.5px; flex: 0 0 auto; }
  .table-wrap.cards td:not([data-label])::before { content: none; }
  .table-wrap.cards td.num { direction: rtl; }
  .table-wrap.cards td.num > * , .table-wrap.cards td.num { font-variant-numeric: tabular-nums; }
  .table-wrap.cards td.actions { justify-content: flex-start; padding-block-start: 10px; }
  .table-wrap.cards td.actions::before { content: none; }
  .table-wrap.cards td.title { font-weight: 600; color: var(--teal-2); font-size: 15px; }
  .table-wrap.cards td.title::before { content: none; }
}

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list .row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-block-end: 1px solid var(--line); }
.list .row:last-child { border-block-end: 0; }
.list .row .grow { flex: 1; min-width: 0; }
.list .row .t { font-weight: 500; color: var(--teal-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .row .s { font-size: 12.5px; color: var(--ink-2); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--teal-bg); color: var(--teal); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex: 0 0 auto; }

/* ---------- empty / loading ---------- */
.empty { text-align: center; color: var(--ink-2); padding: 36px 16px; font-size: 14px; }
.empty svg { width: 40px; height: 40px; stroke: var(--gold); fill: none; stroke-width: 1.5; margin-block-end: 8px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-block-start-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
.loading { display: flex; justify-content: center; padding: 32px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--cream-2) 25%, #FAF6EC 50%, var(--cream-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; color: transparent; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- modal (bottom sheet on phones, dialog on desktop) ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(8, 54, 64, .45); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal-backdrop.show { opacity: 1; }
.modal { background: var(--paper); width: 100%; max-height: calc(100dvh - 40px - var(--sat)); overflow-y: auto; border-start-start-radius: 20px; border-start-end-radius: 20px; padding: 10px 18px calc(18px + var(--sab)); box-shadow: var(--shadow-lg); transform: translateY(16px); transition: transform .2s; }
.modal-backdrop.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 6px 0 12px; position: sticky; top: 0; background: var(--paper); z-index: 1; }
.modal-head h2 { flex: 1; font-size: 17px; }
.modal-head .modal-x { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--cream-2); color: var(--ink-2); font-size: 20px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-block-start: 8px; padding-block-start: 12px; border-block-start: 1px solid var(--line); }
.modal .actions .btn { flex: 1; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { max-width: 520px; border-radius: var(--r-lg); padding: 12px 22px 22px; max-height: calc(100dvh - 40px); }
  .modal.wide { max-width: 820px; }
  .modal .actions .btn { flex: 0 0 auto; min-width: 110px; }
}

/* ---------- toasts ---------- */
.toasts { position: fixed; inset-inline: 0; inset-block-start: calc(12px + var(--sat)); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; background: var(--teal-2); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow-lg); max-width: 100%; animation: toast-in .2s ease-out; display: flex; align-items: center; gap: 8px; }
.toast.error { background: var(--bad); }
.toast.warn { background: var(--gold-ink); }
.toast.success { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@media (min-width: 768px) { .toasts { inset-block-start: auto; inset-block-end: 24px; align-items: flex-end; padding: 0 32px; } }

/* ---------- bottom tab bar (phones only) ---------- */
.bottom-nav {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 40;
  height: calc(var(--bottom-nav-h) + var(--sab)); padding-block-end: var(--sab);
  background: var(--paper); border-block-start: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
}
.bottom-nav a, .bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-2); font: inherit; font-size: 11px; text-decoration: none; background: none; border: 0; cursor: pointer; padding: 6px 2px; position: relative;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav .active { color: var(--teal); font-weight: 600; }
.bottom-nav .active::after { content: ''; position: absolute; inset-block-start: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold); }
.bottom-nav .scan { color: var(--teal-2); }
.bottom-nav .scan .orb { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; background: var(--gold); color: var(--teal-2); margin-block-start: -24px; box-shadow: 0 6px 18px rgba(216, 180, 114, .55), 0 0 0 5px var(--paper); }
.bottom-nav .scan .orb svg { stroke-width: 2; }
.bottom-nav .scan.active::after { content: none; }
@media (min-width: 768px) { .bottom-nav { display: none; } }

/* "more" sheet (phones) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(8, 54, 64, .45); display: flex; align-items: flex-end; opacity: 0; transition: opacity .18s; }
.sheet-backdrop.show { opacity: 1; }
.sheet { width: 100%; background: var(--paper); border-start-start-radius: 20px; border-start-end-radius: 20px; padding: 8px 12px calc(var(--bottom-nav-h) + var(--sab) + 8px); max-height: 80dvh; overflow-y: auto; transform: translateY(20px); transition: transform .2s; }
.sheet-backdrop.show .sheet { transform: none; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 10px; }
.sheet .group { font-size: 11px; color: var(--gold-ink); padding: 10px 10px 2px; }
.sheet a, .sheet button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 10px; border-radius: 10px; color: var(--teal-2); font: inherit; font-size: 15px; background: none; border: 0; text-align: start; cursor: pointer; text-decoration: none; }
.sheet a:hover, .sheet button:hover { background: var(--cream-2); }
.sheet a.active { background: var(--teal-bg); color: var(--teal); font-weight: 600; }
.sheet svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sheet .logout { color: var(--bad); }

/* ---------- auth pages ---------- */
.auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(circle at 20% 10%, #E9F0F1 0, var(--cream) 55%); }
.auth .card { width: 100%; max-width: 400px; padding: 28px 24px 24px; }
.auth .logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-block-end: 20px; text-align: center; }
.auth .logo img { width: 72px; height: 72px; border-radius: 18px; box-shadow: var(--shadow); }
.auth .logo h1 { font-size: 20px; }
.auth .logo small { color: var(--ink-2); }
.auth .links { display: flex; justify-content: space-between; margin-block-start: 12px; font-size: 13px; }

/* ---------- misc utilities ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mt { margin-block-start: 16px; } .mb { margin-block-end: 16px; }
.ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); } .gold-ink { color: var(--gold-ink); }
.hide { display: none !important; }
.phone-only { display: initial; } .desktop-only { display: none !important; }
@media (min-width: 768px) { .phone-only { display: none !important; } .desktop-only { display: initial !important; } }
.fab { position: fixed; inset-inline-end: 16px; inset-block-end: calc(var(--bottom-nav-h) + var(--sab) + 16px); z-index: 35; width: 54px; height: 54px; border-radius: 50%; background: var(--teal); color: #fff; border: 0; box-shadow: var(--shadow-lg); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.fab svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }
@media (min-width: 768px) { .fab { display: none; } }
.scan-frame { aspect-ratio: 1; max-width: 360px; margin-inline: auto; border-radius: var(--r-lg); overflow: hidden; background: #000; position: relative; }
.scan-frame video { width: 100%; height: 100%; object-fit: cover; }

/* ---------- print ---------- */
@media print {
  .sidebar, .bottom-nav, .topbar .actions, .fab, .toasts, .no-print { display: none !important; }
  .app { display: block; } .main { padding: 0; } body { background: #fff; }
  .card, .table-wrap { box-shadow: none; }
}
