/* Easy Pass admin panel — black & brushed gold. RTL-first, logical properties only. */
:root {
  --font: "Vazirmatn", "Vazir", Tahoma, "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --gold: #c9a84c;
  --gold-hi: #ecd48f;
  --gold-lo: #8f7530;
  --gold-grad: linear-gradient(135deg, #f0dc9c 0%, #c9a84c 48%, #9c7f33 100%);
  --ease: cubic-bezier(.22, 1, .36, 1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0e;
  --surface: #121217;
  --surface-2: #181820;
  --surface-3: #20202a;
  --border: #25252f;
  --border-strong: #35353f;
  --text: #ededf2;
  --muted: #9b9bab;
  --accent-text: #dcc074;
  --on-gold: #17130a;
  --shadow: 0 10px 40px rgb(0 0 0 / .45);
  --amber: #e6b04a; --green: #45c584; --red: #ee6b66; --gray: #9a9aa8; --info: #6fa8e6;
  --grid: rgb(255 255 255 / .06);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --surface-3: #efebe0;
  --border: #e3dece;
  --border-strong: #cfc8b3;
  --text: #1a1a1f;
  --muted: #5f5f6c;
  --accent-text: #7a5f14;
  --on-gold: #17130a;
  --shadow: 0 10px 34px rgb(60 45 10 / .14);
  --amber: #96650a; --green: #12744a; --red: #b3312c; --gray: #5f5f6c; --info: #24609e;
  --grid: rgb(0 0 0 / .07);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14.5px; line-height: 1.7;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; }
p { margin: 0; }
a { color: var(--accent-text); }
img, svg { display: block; max-inline-size: 100%; }
[hidden] { display: none !important; }
.num, .money, td.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: start; }
.ltr-inline { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; inset-block-start: 8px; inset-inline-start: 8px; z-index: 999; background: var(--gold); color: var(--on-gold); padding: 8px 14px; border-radius: 8px; transform: translateY(-200%); }
.skip-link:focus { transform: none; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--gold) 40%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-block-size: 38px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 13.5px; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .15s var(--ease), box-shadow .2s;
}
.btn:hover { border-color: var(--gold-lo); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.primary { background: var(--gold-grad); color: var(--on-gold); border-color: transparent; box-shadow: 0 4px 18px rgb(201 168 76 / .25); }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 6px 22px rgb(201 168 76 / .35); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, var(--border)); background: color-mix(in srgb, var(--red) 8%, var(--surface-2)); }
.btn.danger:hover { background: color-mix(in srgb, var(--red) 16%, var(--surface-2)); border-color: var(--red); }
.btn.success { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, var(--border)); background: color-mix(in srgb, var(--green) 8%, var(--surface-2)); }
.btn.success:hover { background: color-mix(in srgb, var(--green) 16%, var(--surface-2)); border-color: var(--green); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); border-color: var(--border); }
.btn.sm { min-block-size: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { inline-size: 38px; padding: 0; }
.btn.sm.icon { inline-size: 30px; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; inline-size: 16px; block-size: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--text) transparent var(--text) transparent; animation: spin .7s linear infinite; }
.btn.primary.busy::after { border-color: var(--on-gold) transparent var(--on-gold) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.ico { inline-size: 18px; block-size: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-inline-size: 0; }
.field > span:first-child { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field small { color: var(--muted); font-size: 12px; }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, input.input, select.input, textarea.input {
  inline-size: 100%; min-block-size: 40px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 10px; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
:root[data-theme="light"] .input, :root[data-theme="light"] .field input:not([type=checkbox]):not([type=radio]), :root[data-theme="light"] .field select, :root[data-theme="light"] .field textarea { background: #fff; }
.field textarea, textarea.input { min-block-size: 96px; resize: vertical; line-height: 1.7; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--gold-lo); }
.input:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 28%, transparent); }
.input::placeholder, .field ::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; min-block-size: 36px; }
.check input { inline-size: 18px; block-size: 18px; accent-color: var(--gold); margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
/* Bot button-style picker: select + colour swatch driven by a per-instance --dot custom property. */
.style-pick { display: flex; align-items: center; gap: 8px; }
.style-pick select { flex: 1; min-inline-size: 0; }
.style-dot { inline-size: 14px; block-size: 14px; border-radius: 50%; flex: none; background: var(--dot, var(--gray)); box-shadow: 0 0 0 1px var(--border-strong); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-block-start: 18px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px 16px; margin: 0; min-inline-size: 0; }
legend { padding-inline: 8px; color: var(--accent-text); font-weight: 700; font-size: 13px; }
.field-row { display: flex; gap: 8px; align-items: flex-end; }
.field-row > .field { flex: 1; }

/* ---------- login ---------- */
.login-screen { min-block-size: 100dvh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; isolation: isolate; }
.login-screen::before { content: ""; position: absolute; inset: 0; z-index: -2; background: var(--bg) url("../assets/darkbanner.jpg") center / cover no-repeat; opacity: .55; }
:root[data-theme="light"] .login-screen::before { opacity: .18; filter: grayscale(.4); }
.login-screen::after { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse at 50% 30%, transparent 0, var(--bg) 78%); }
.login-card { inline-size: min(100%, 420px); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); border: 1px solid var(--border-strong); border-radius: 22px; padding: 34px 30px 28px; box-shadow: var(--shadow); }
.login-card .brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-block-end: 24px; text-align: center; }
.login-card .brand img { inline-size: 76px; block-size: 76px; border-radius: 50%; box-shadow: 0 0 0 2px var(--gold), 0 0 34px rgb(201 168 76 / .35); }
.login-card h1 { font-size: 22px; }
.login-card .gold-text { background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="light"] .login-card .gold-text { background: none; color: var(--accent-text); }
.code-input { font-size: 28px !important; letter-spacing: .5em; text-align: center !important; font-family: var(--mono); padding-inline-start: .5em !important; }
.countdown { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-block: 14px; font-size: 13px; color: var(--muted); }
.countdown .ring { inline-size: 40px; block-size: 40px; flex: none; }
.countdown .ring text { font-size: 13px; fill: var(--text); font-variant-numeric: tabular-nums; }
.login-theme { position: fixed; inset-block-start: 16px; inset-inline-end: 16px; }
.form-error { color: var(--red); font-size: 13px; min-block-size: 1.5em; margin-block-start: 10px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-block-size: 100dvh; }
.sidebar {
  position: sticky; inset-block-start: 0; block-size: 100dvh; overflow-y: auto; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 70%, var(--bg)) 100%);
  border-inline-end: 1px solid var(--border); padding: 20px 14px 16px; z-index: 40;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; text-decoration: none; color: var(--text); }
.side-brand img { inline-size: 44px; block-size: 44px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--gold), 0 0 20px rgb(201 168 76 / .25); }
.side-brand b { display: block; font-size: 17px; letter-spacing: .01em; }
.side-brand small { color: var(--muted); font-size: 11.5px; }
.nav-group { margin-block-end: 14px; }
.nav-group h2 { font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 12px; letter-spacing: .04em; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13.5px; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link[aria-current="page"] { background: linear-gradient(270deg, color-mix(in srgb, var(--gold) 20%, transparent), color-mix(in srgb, var(--gold) 4%, transparent)); color: var(--accent-text); }
.nav-link[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -14px; inset-block: 8px; inline-size: 3px; border-radius: 0 3px 3px 0; background: var(--gold-grad); }
[dir="rtl"] .nav-link[aria-current="page"]::before { border-radius: 3px 0 0 3px; }
.nav-badge { margin-inline-start: auto; background: var(--gold); color: var(--on-gold); font-size: 11px; font-weight: 800; border-radius: 99px; padding: 0 7px; min-inline-size: 20px; text-align: center; line-height: 20px; }
.side-foot { margin-block-start: auto; padding: 12px 8px 0; color: var(--muted); font-size: 11.5px; }
.scrim { display: none; }

.workspace { min-inline-size: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; inset-block-start: 0; z-index: 30; block-size: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding-inline: 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); border-block-end: 1px solid var(--border);
}
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-inline-size: 420px; }
.search input { padding-inline-start: 40px; border-radius: 99px; background: var(--surface); }
.search .ico { position: absolute; inset-inline-start: 13px; inset-block-start: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.top-spacer { flex: 1; }
.admin-chip { display: flex; align-items: center; gap: 8px; padding: 4px 14px 4px 6px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); font-size: 13px; }
.admin-chip .av { inline-size: 28px; block-size: 28px; border-radius: 50%; background: var(--gold-grad); color: var(--on-gold); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.main { padding: 26px 24px 60px; max-inline-size: 1500px; inline-size: 100%; margin-inline: auto; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-block-end: 22px; }
.page-head h1 { font-size: 24px; }
.page-head p { color: var(--muted); margin-block-start: 2px; font-size: 13.5px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-inline-size: 0; }
.card > header, .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-block-end: 16px; }
.card h2 { font-size: 15.5px; }
.card h3 { font-size: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > header { padding: 18px 20px 0; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-block-end: 16px; }
.grid.two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.even { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.kpi { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; }
.kpi::after { content: ""; position: absolute; inset-inline-end: -40px; inset-block-start: -40px; inline-size: 120px; block-size: 120px; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--gold) 18%, transparent), transparent); pointer-events: none; }
a.kpi { transition: border-color .2s, transform .2s var(--ease); }
a.kpi:hover { border-color: var(--gold-lo); transform: translateY(-2px); }
.kpi .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kpi .label .ico { color: var(--accent-text); }
.kpi .value { font-size: 27px; font-weight: 800; letter-spacing: -.01em; }
.kpi .value small { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-inline-start: 4px; }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.kpi.hero { background: linear-gradient(140deg, color-mix(in srgb, var(--gold) 16%, var(--surface)), var(--surface) 60%); border-color: color-mix(in srgb, var(--gold) 35%, var(--border)); }
.kpi.hero .value { background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="light"] .kpi.hero .value { background: none; color: var(--accent-text); }
.kpi.attn .value { color: var(--amber); }

.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.todo-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 11px; text-decoration: none; color: var(--text); background: var(--surface-2); transition: border-color .15s; }
.todo-list a:hover { border-color: var(--gold-lo); }
.todo-list .n { font-weight: 800; font-size: 18px; color: var(--accent-text); }
.todo-list .n.zero { color: var(--muted); font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: inherit; }
table { inline-size: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: start; color: var(--muted); font-weight: 700; font-size: 12px; padding: 12px 14px; white-space: nowrap; border-block-end: 1px solid var(--border); background: var(--surface); position: sticky; inset-block-start: 0; }
td { padding: 12px 14px; border-block-end: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--gold) 5%, transparent); }
tbody tr:last-child td { border-block-end: 0; }
td.actions, th.actions { text-align: end; white-space: nowrap; }
td .cell-sub { display: block; color: var(--muted); font-size: 12px; }
.trunc { max-inline-size: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty svg { margin: 0 auto 10px; inline-size: 40px; block-size: 40px; color: var(--gold-lo); stroke: currentColor; fill: none; stroke-width: 1.4; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-block-start: 1px solid var(--border); flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 16px 20px; border-block-end: 1px solid var(--border); }
.toolbar .field { min-inline-size: 150px; }
.toolbar .grow { flex: 1; min-inline-size: 200px; }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 11px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; --c: var(--gray); color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); }
.pill::before { content: ""; inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; }
.pill.pending, .pill.waiting { --c: var(--amber); }
.pill.active, .pill.approved, .pill.ok, .pill.announced { --c: var(--green); }
.pill.failed, .pill.rejected, .pill.bad { --c: var(--red); }
.pill.cancelled, .pill.closed, .pill.gray, .pill.awaiting_receipt { --c: var(--gray); }
.pill.gold, .pill.open, .pill.drawn, .pill.scheduled { --c: var(--accent-text); }
.pill.info, .pill.sending { --c: var(--info); }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; inline-size: fit-content; max-inline-size: 100%; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 7px 16px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 700; font-size: 13px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"], .tab[aria-pressed="true"] { background: var(--gold-grad); color: var(--on-gold); }

.progress { block-size: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex; min-inline-size: 90px; }
.progress > i { display: block; block-size: 100%; background: var(--gold-grad); }
.progress > i.bad { background: var(--red); }
.progress > i.good { background: var(--green); }

/* ---------- charts ---------- */
.chart { position: relative; inline-size: 100%; direction: ltr; }
.chart svg { inline-size: 100%; block-size: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--surface); stroke: var(--gold-hi); stroke-width: 2; opacity: 0; transition: opacity .12s; }
.chart .bar { transition: opacity .15s; }
.chart .cursor { stroke: var(--gold-lo); stroke-dasharray: 3 4; opacity: 0; }
.chart .show { opacity: 1; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 10px; padding: 7px 12px; font-size: 12.5px; box-shadow: var(--shadow); direction: rtl; translate: -50% -110%; white-space: nowrap; opacity: 0; transition: opacity .1s; }
.chart-tip.show { opacity: 1; }
.chart-tip b { display: block; font-size: 14px; color: var(--accent-text); }

.rank { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.rank li { display: grid; gap: 6px; }
.rank .top { display: flex; justify-content: space-between; gap: 10px; }

/* ---------- toasts / modals ---------- */
#toasts { position: fixed; inset: auto; inset-block-end: 20px; inset-inline-start: 20px; margin: 0; padding: 0; border: 0; background: none; overflow: visible; display: flex; flex-direction: column; gap: 10px; inline-size: min(380px, calc(100vw - 40px)); color: var(--text); }
#toasts:not(:popover-open) { display: none; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow); border-inline-start: 4px solid var(--gold); animation: toast-in .3s var(--ease); font-size: 13.5px; }
.toast.error { border-inline-start-color: var(--red); }
.toast.success { border-inline-start-color: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

dialog { padding: 0; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); inline-size: min(94vw, 640px); max-block-size: 90dvh; overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; animation: dlg-in .25s var(--ease); }
dialog.wide { inline-size: min(94vw, 860px); }
dialog.narrow { inline-size: min(94vw, 440px); }
dialog::backdrop { background: rgb(0 0 0 / .62); backdrop-filter: blur(3px); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.dlg-form { display: flex; flex-direction: column; flex: 1; min-block-size: 0; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-block-end: 1px solid var(--border); }
.dlg-head h2 { font-size: 17px; }
.dlg-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.dlg-foot { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 22px; border-block-start: 1px solid var(--border); background: var(--surface-2); }
dialog.drawer { margin: 0; inset-block: 0; inset-inline: 0 auto; block-size: 100dvh; max-block-size: 100dvh; inline-size: min(100vw, 560px); border-radius: 0; border-block: 0; border-inline-start: 0; border-inline-end: 1px solid var(--border-strong); }
[dir="rtl"] dialog.drawer { inset-inline-start: 0; inset-inline-end: auto; }
dialog.drawer[open] { animation: drawer-in .3s var(--ease); }
@keyframes drawer-in { from { transform: translateX(-30px); opacity: 0; } }
.confirm-msg { line-height: 1.9; }
.confirm-msg .warn { color: var(--red); }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-inline-size: 0; overflow-wrap: anywhere; }
pre.block { margin: 0; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; direction: ltr; text-align: start; max-block-size: 260px; overflow: auto; }
.section-title { font-size: 13px; color: var(--accent-text); font-weight: 800; margin-block: 20px 10px; }
.chip { display: inline-block; padding: 1px 9px; border-radius: 99px; background: var(--surface-3); font-size: 12px; margin: 2px; }
.thumb { inline-size: 44px; block-size: 44px; border-radius: 10px; object-fit: cover; background: var(--surface-3); }
.receipt-img { inline-size: 100%; max-block-size: 60dvh; object-fit: contain; border-radius: 10px; background: #000; }
.loader { display: grid; place-items: center; padding: 70px; }
.loader i { inline-size: 30px; block-size: 30px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--gold); animation: spin .8s linear infinite; }
.err-box { text-align: center; padding: 50px 20px; }
.err-box p { color: var(--red); margin-block-end: 14px; }
.low { color: var(--red); font-weight: 700; }
.warn-text { color: var(--amber); }
.bubbles { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-inline-size: 88%; padding: 10px 14px; border-radius: 14px; background: var(--surface-3); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; align-self: flex-start; }
.bubble.admin { align-self: flex-end; background: color-mix(in srgb, var(--gold) 14%, var(--surface)); border-color: color-mix(in srgb, var(--gold) 35%, var(--border)); }
.bubble.internal { background: repeating-linear-gradient(-45deg, transparent 0 8px, color-mix(in srgb, var(--amber) 8%, transparent) 8px 16px); border-style: dashed; border-color: var(--amber); }
.bubble .meta { display: block; font-size: 11.5px; color: var(--muted); margin-block-end: 3px; }
.btn-list { display: flex; gap: 6px; flex-wrap: wrap; }
.repeat-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-block-end: 8px; align-items: center; }
.theme-ico-light { display: none; }
[data-theme="light"] .theme-ico-light { display: block; }
[data-theme="light"] .theme-ico-dark { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* Off-canvas rail. `translate` is a PHYSICAL axis so it cannot be expressed with logical
     properties: the rail is pinned to the inline-start (right in RTL — the same side as the desktop
     rail and the hamburger) and parked off that edge per direction. Pinning it to inline-end while
     translating +100% left 90px of the drawer on screen and buried the menu button underneath it. */
  .sidebar {
    position: fixed; inset-block: 0;
    inset-inline-start: 0; inset-inline-end: auto;
    inline-size: min(300px, 86vw);
    translate: -100% 0;
    transition: translate .3s var(--ease);
    box-shadow: var(--shadow);
    padding-block-end: max(16px, env(safe-area-inset-bottom));
  }
  [dir="rtl"] .sidebar { translate: 100% 0; }
  .shell.nav-open .sidebar { translate: 0 0; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(0 0 0 / .6); }
  /* stop the page behind the drawer from scrolling */
  body:has(.shell.nav-open) { overflow: hidden; }
  .menu-btn { display: inline-flex; }
  /* comfortable touch targets */
  .btn { min-block-size: 42px; }
  .btn.sm { min-block-size: 36px; }
  .btn.icon { inline-size: 42px; }
  .btn.sm.icon { inline-size: 36px; }
  .topbar { padding-inline: 14px; gap: 8px; }
  .main { padding: 18px 14px max(60px, env(safe-area-inset-bottom)); }
  .admin-chip .id-label { display: none; }
  .page-head h1 { font-size: 21px; }
}
@media (max-width: 560px) {
  .search { display: none; }
  .top-spacer { display: block; }
  .kpi .value { font-size: 23px; }
  .grid.even { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; }
  .toolbar { padding: 14px; }
  .toolbar .field { flex: 1 1 100%; }
  /* 16px controls stop iOS Safari zooming the whole page when a field is focused */
  input, select, textarea { font-size: 16px; }
  .trunc { max-inline-size: 190px; }
  /* stacked label/value pairs read better than two squeezed columns */
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dt { margin-block-start: 8px; }
  .form-actions .btn { flex: 1; }
  dialog { inline-size: 100vw; max-inline-size: 100vw; }
  dialog:not(.drawer) { max-block-size: 94dvh; border-radius: 18px 18px 0 0; margin-block: auto 0; }
  .repeat-row { grid-template-columns: 1fr auto; }
  .repeat-row .url { grid-column: 1 / -1; grid-row: 2; }
  #toasts { inset-inline: 10px; inset-block-end: max(10px, env(safe-area-inset-bottom)); inline-size: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
