/*
 * Tranquil UI: the visual language of the Tranquil POS (Radiance.Tranquil.Pwa/src/styles.scss) for the Radiance admin web apps
 * (Masters, Developer Masters, SSO). Same tokens, same dark mode, same topbar / panels / chips / dialogs / toasts.
 * The POS is a full-window app; these are scrolling pages, so the page layout classes (.app, .page, .pagehead, .tbl, .fgrid ...) are new
 * and everything that exists in the POS (.btn, .input, .chip, .sec, .dlg, .toast, .pill, .pop ...) keeps its name and look.
 */
:root {
  --bg: #eef1f7; --panel: #ffffff; --panel-2: #f5f7fb; --ink: #141b2d; --muted: #66728a; --line: #e1e6f0;
  --brand: #4f46e5; --brand-2: #2563eb; --brand-ink: #ffffff; --brand-soft: #eceafd;
  --ok: #0f9f6e; --ok-soft: #dcf7ec; --warn: #b36b00; --warn-soft: #fff0d0; --bad: #d92d20; --bad-soft: #fde6e3; --info-soft: #e3edff;
  --focus: #4f46e5; --r: 14px; --sh1: 0 1px 2px rgba(20, 27, 45, .06), 0 6px 18px rgba(20, 27, 45, .06); --sh2: 0 12px 34px rgba(20, 27, 45, .2);
  --glow-a: #dfe8ff; --glow-b: #efe6ff; --ease: cubic-bezier(.22, 1, .36, 1);
  --topbar-h: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c111b; --panel: #151c2b; --panel-2: #1b2437; --ink: #e7ecf6; --muted: #93a0b8; --line: #263148;
    --brand: #8b86ff; --brand-2: #5b9bff; --brand-ink: #0c0f24; --brand-soft: #232049;
    --ok: #4fd1a1; --ok-soft: #10392c; --warn: #f2b556; --warn-soft: #3b2c0d; --bad: #ff8d84; --bad-soft: #43201d; --info-soft: #15294f;
    --focus: #9a96ff;
    --sh1: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3); --sh2: 0 12px 34px rgba(0, 0, 0, .6); --glow-a: #17224a; --glow-b: #261b49;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c111b; --panel: #151c2b; --panel-2: #1b2437; --ink: #e7ecf6; --muted: #93a0b8; --line: #263148;
  --brand: #8b86ff; --brand-2: #5b9bff; --brand-ink: #0c0f24; --brand-soft: #232049;
  --ok: #4fd1a1; --ok-soft: #10392c; --warn: #f2b556; --warn-soft: #3b2c0d; --bad: #ff8d84; --bad-soft: #43201d; --info-soft: #15294f;
  --focus: #9a96ff;
  --sh1: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3); --sh2: 0 12px 34px rgba(0, 0, 0, .6); --glow-a: #17224a; --glow-b: #261b49;
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; }
body {
  margin: 0; color: var(--ink); font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(1100px 520px at 8% -12%, var(--glow-a), transparent 62%), radial-gradient(900px 480px at 100% -8%, var(--glow-b), transparent 58%), var(--bg);
  background-attachment: fixed;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 800; letter-spacing: .1px; } h2 { font-size: 17px; font-weight: 750; } h3 { font-size: 15px; font-weight: 750; } h4 { font-size: 13.5px; font-weight: 700; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent); outline-offset: 1px; }
::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.strong { font-weight: 700; }
.ok-t { color: var(--ok); } .warn-t { color: var(--warn); } .bad-t { color: var(--bad); }
kbd { font: 700 11.5px/1 ui-monospace, Consolas, monospace; padding: 2px 6px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; }
code { font: 12.5px ui-monospace, Consolas, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; }

/* ---------- layout helpers (same names as the POS) ---------- */
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; } .row.top { align-items: flex-start; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; } .sp { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; } .stack.lg { gap: 14px; }
.right { text-align: right; } .center { text-align: center; }
.gap-s { gap: 4px; } .gap-l { gap: 14px; }
.mt { margin-top: 10px; } .mb { margin-bottom: 10px; }
.nowrap { white-space: nowrap; }
.contents { display: contents; }
.ms { margin-left: 6px; } .me { margin-right: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 10px; padding: 7px 14px; font-weight: 650; line-height: 1.3; white-space: nowrap; transition: transform .12s, background .15s, box-shadow .15s, filter .15s; text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--panel-2); text-decoration: none; } .btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-ink); border-color: transparent; box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--brand), var(--brand-2)); filter: brightness(1.1); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 45%, transparent); }
.btn.ok { background: var(--ok); color: #fff; border-color: transparent; } .btn.ok:hover:not(:disabled) { background: var(--ok); filter: brightness(1.1); }
.btn.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.btn.bad:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 22%, var(--bad-soft)); }
.btn.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; } .btn.ghost:hover:not(:disabled) { background: var(--panel-2); }
.btn.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 6px 9px; } .btn.icon.sm { padding: 3px 7px; }
.btn.block { width: 100%; }
.btn kbd { margin-left: 8px; opacity: .85; color: var(--ink); }

.input, select.input, textarea.input { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 7px 10px; min-width: 0; width: 100%; line-height: 1.3; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.input:disabled, .input[readonly] { background: var(--panel-2); color: var(--muted); }
.input.sm { padding: 4px 8px; font-size: 13px; border-radius: 8px; }
.input.num { text-align: right; }
.input.invalid, .ng-touched.ng-invalid.input { border-color: var(--bad); background: color-mix(in srgb, var(--bad-soft) 55%, var(--panel)); }
select.input { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
select.input[multiple] { padding-right: 10px; background-image: none; }
textarea.input { resize: vertical; min-height: 72px; }
.input-wrap { position: relative; display: flex; align-items: center; } .input-wrap > i { position: absolute; left: 10px; color: var(--muted); pointer-events: none; } .input-wrap > .input { padding-left: 32px; }
input[type=range] { accent-color: var(--brand); }
input[type=color] { border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--panel); height: 32px; width: 48px; }

.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > label, .lbl { font-size: 12px; font-weight: 650; color: var(--muted); letter-spacing: .01em; }
.fld .hint, .hint { font-size: 12px; color: var(--muted); }
.fld .err, .err { font-size: 12.5px; color: var(--bad); font-weight: 600; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.fgrid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .fgrid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .fgrid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fgrid .span2 { grid-column: span 2; } .fgrid .full { grid-column: 1 / -1; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.toolbar .fld { min-width: 150px; } .toolbar .grow { flex: 1 1 200px; }

/* switch + check */
input.sw[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 38px; height: 22px; margin: 0; border-radius: 999px; background: color-mix(in srgb, var(--muted) 35%, var(--panel)); border: 1px solid var(--line); cursor: pointer; transition: background .2s, border-color .2s; vertical-align: middle; }
input.sw[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); transition: transform .2s var(--ease); }
input.sw[type=checkbox]:checked { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; }
input.sw[type=checkbox]:checked::after { transform: translateX(16px); }
input.sw[type=checkbox]:disabled { opacity: .5; cursor: not-allowed; }
input.sw.dim[type=checkbox] { opacity: .5; }
input.cb[type=checkbox], input.rd[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; vertical-align: middle; cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; } .check.block { display: flex; padding: 3px 0; }

/* chips, tabs, segmented */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.info { background: var(--info-soft); color: var(--brand-2); }
.chip.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
button.chip { cursor: pointer; } button.chip:hover { border-color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chipx { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 11px; opacity: .7; } .chipx:hover { opacity: 1; }
.tabbar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabbar::-webkit-scrollbar { display: none; }
.tabbar .tab { flex: none; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 10px; padding: 6px 14px; font-weight: 700; font-size: 13px; transition: background .15s, color .15s; }
.tabbar .tab:hover { color: var(--ink); } .tabbar .tab.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.tg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.tg button { border: 0; background: var(--panel-2); padding: 4px 11px; font-size: 12.5px; font-weight: 650; color: inherit; }
.tg button + button { border-left: 1px solid var(--line); } .tg button.on { background: var(--brand-soft); color: var(--brand); }

/* ---------- app shell ---------- */
.app { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.app > main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 80; display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: var(--topbar-h); color: #eaf0ff; background: linear-gradient(100deg, #0e1b38 0%, #1b2a6b 55%, #3a2f94 100%); box-shadow: 0 2px 14px rgba(14, 27, 56, .35); }
.topbar a { color: inherit; } .topbar a:hover { text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 14.5px; letter-spacing: .2px; white-space: nowrap; color: #eaf0ff; }
.logo { width: 28px; height: 28px; flex: none; border-radius: 9px; display: grid; place-items: center; font-weight: 800; background: linear-gradient(135deg, #7c7bff, #38bdf8); color: #fff; }
.clientname { font-weight: 700; font-size: 13.5px; letter-spacing: .2px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #eaf0ff; }
.nav { display: flex; align-items: center; gap: 2px; padding: 3px; margin-left: 6px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .12); border-radius: 12px; min-width: 0; }
.nl { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 0; border-radius: 9px; background: transparent; font-weight: 650; font-size: 13.5px; color: rgba(255, 255, 255, .72); white-space: nowrap; cursor: pointer; transition: background .2s, color .2s; }
.nl:hover { color: #fff; } .nl.on, .nl.active { color: #fff; background: linear-gradient(135deg, #6f6dff, #3aa6ff); box-shadow: 0 4px 14px rgba(80, 120, 255, .45); }
.nl .caret { font-size: 9px; opacity: .8; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .1); color: inherit; white-space: nowrap; }
button.pill { cursor: pointer; } button.pill:hover { background: rgba(255, 255, 255, .22); }
.pill .dot, .dot { width: 8px; height: 8px; border-radius: 50%; background: #48d597; display: inline-block; } .pill.offline .dot, .dot.offline { background: #ff8a80; }
.pill.offline { background: rgba(255, 138, 128, .3); } .pill.alert { background: rgba(255, 138, 128, .28); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px; background: rgba(255, 255, 255, .18); flex: none; }
.burger { display: none; border: 0; background: rgba(255, 255, 255, .12); color: #fff; border-radius: 9px; padding: 5px 10px; font-size: 17px; line-height: 1; }
.menuwrap { position: relative; display: inline-flex; }
.pop { position: absolute; z-index: 90; top: calc(100% + 8px); left: 0; min-width: 230px; max-height: 70vh; overflow: auto; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh2); padding: 6px; animation: popin .14s var(--ease); }
.pop.right { left: auto; right: 0; }
.pop a, .pop .mi { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 9px; background: none; color: var(--ink); font-weight: 600; font-size: 13.5px; text-align: left; text-decoration: none; cursor: pointer; }
.pop a:hover, .pop .mi:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.pop a.active, .pop .mi.active { color: var(--brand); background: var(--brand-soft); }
.pop .mhead { padding: 8px 10px 3px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pop hr { margin: 5px 4px; }
.pop .mrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px; font-weight: 600; }
@keyframes popin { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.banner { padding: 8px 14px; font-weight: 600; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--warn); } .banner.bad { background: var(--bad-soft); color: var(--bad); } .banner.info { background: var(--info-soft); color: var(--brand-2); }
.footer { padding: 14px; text-align: center; color: var(--muted); font-size: 12px; }

/* ---------- pages ---------- */
.page { width: 100%; max-width: 1480px; margin: 0 auto; padding: 16px 18px 40px; display: flex; flex-direction: column; gap: 14px; }
.page.narrow { max-width: 920px; } .page.wide { max-width: none; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 14px; }
.pagehead .titles { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pagehead .sub { color: var(--muted); font-weight: 600; font-size: 13px; }
.pagehead .acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.back { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; font-weight: 650; font-size: 13px; color: var(--muted); padding: 3px 4px; border-radius: 8px; }
.back:hover { color: var(--brand); text-decoration: none; background: var(--brand-soft); }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 11px; font-size: 13px; background: var(--info-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--brand-2) 25%, transparent); }
.note > i:first-child { color: var(--brand-2); margin-top: 1px; } .note.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); } .note.warn > i:first-child { color: var(--warn); }
.note.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); } .note.bad > i:first-child { color: var(--bad); }
.note.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); } .note.ok > i:first-child { color: var(--ok); }

.sec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh1); min-width: 0; }
.sec > header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--line); font-weight: 700; background: var(--panel-2); border-radius: var(--r) var(--r) 0 0; }
.sec > header h2, .sec > header h3 { font-size: 14.5px; }
.sec > header.clickable { cursor: pointer; user-select: none; } .sec > header.clickable:hover { background: color-mix(in srgb, var(--brand-soft) 60%, var(--panel-2)); }
.sec > .body { padding: 14px; min-width: 0; }
.sec > .body.flush { padding: 0; }
.sec.pad { padding: 14px; }
.sec.tint { background: var(--panel-2); box-shadow: none; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.cols.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 14px; align-items: start; }

.dl { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: 7px 14px; margin: 0; align-items: baseline; }
.dl dt { color: var(--muted); font-weight: 600; font-size: 12.5px; } .dl dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- data ---------- */
.tblwrap { width: 100%; overflow-x: auto; border-radius: 0 0 var(--r) var(--r); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
table.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 650; padding: 8px 10px; background: var(--panel-2); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
table.tbl td { padding: 7px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:first-child td { border-top: 0; }
table.tbl tbody tr:hover td { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
table.tbl th.num, table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl th.act, table.tbl td.act { text-align: right; white-space: nowrap; width: 1%; }
table.tbl tr.inactive td { opacity: .55; } table.tbl tr.dirty td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
table.tbl tr.sel td { background: var(--brand-soft); }
table.tbl tr.group td { background: var(--panel-2); font-weight: 700; color: var(--muted); }
table.tbl.fixed { table-layout: fixed; }
table.tbl.compact td { padding: 4px 8px; } table.tbl.compact th { padding: 6px 8px; }
.sticky-col { position: sticky; left: 0; z-index: 2; background: var(--panel); box-shadow: 1px 0 0 var(--line); }
table.tbl th.sticky-col { background: var(--panel-2); z-index: 3; }
table.tbl tbody tr:hover td.sticky-col { background: color-mix(in srgb, var(--brand-soft) 45%, var(--panel)); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; align-content: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh1); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card.click { cursor: pointer; transition: transform .12s, box-shadow .15s, border-color .15s; } .card.click:hover { transform: translateY(-1px); border-color: var(--brand); }
.card.accent-ok { border-left: 4px solid var(--ok); } .card.accent-warn { border-left: 4px solid var(--warn); } .card.accent-bad { border-left: 4px solid var(--bad); } .card.accent-brand { border-left: 4px solid var(--brand); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tile { text-align: left; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); display: flex; flex-direction: column; gap: 2px; min-height: 66px; text-decoration: none; transition: transform .12s, box-shadow .15s, border-color .15s; }
.tile:hover { transform: translateY(-1px); box-shadow: var(--sh1); border-color: var(--brand); text-decoration: none; }
.tile b { font-size: 14px; } .tile small { color: var(--muted); }
.stat { display: flex; flex-direction: column; gap: 1px; } .stat b { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; } .stat span { color: var(--muted); font-size: 12px; font-weight: 600; }
.list { display: flex; flex-direction: column; } .list > * { padding: 8px 4px; border-top: 1px solid var(--line); } .list > *:first-child { border-top: 0; }
.pager { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; flex-wrap: wrap; }

.scrollbox { max-height: 320px; overflow: auto; }
.empty { display: grid; place-items: center; padding: 28px 16px; color: var(--muted); text-align: center; gap: 4px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 34px 16px; color: var(--muted); font-weight: 600; }
.spin { display: inline-block; width: 1.05em; height: 1.05em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: tqspin .7s linear infinite; vertical-align: -.15em; flex: none; }
.spin.lg { width: 26px; height: 26px; border-width: 3px; color: var(--brand); }
@keyframes tqspin { to { transform: rotate(360deg); } }
.matrix-scroll { max-height: calc(100vh - 230px); overflow: auto; }
.progress { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--brand) 16%, transparent); overflow: hidden; } .progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 999px; transition: width .3s var(--ease); }

/* ---------- dialogs, toasts ---------- */
.dlg-back { position: fixed; inset: 0; background: rgba(8, 12, 24, .5); display: grid; place-items: center; z-index: 200; padding: 14px; animation: fadein .15s ease-out; }
.dlg { background: var(--panel); color: var(--ink); border-radius: 16px; box-shadow: var(--sh2); width: min(520px, 100%); max-height: min(88vh, 100%); display: flex; flex-direction: column; overflow: hidden; animation: dlgin .22s var(--ease); }
.dlg.sm { width: min(400px, 100%); } .dlg.lg { width: min(820px, 100%); } .dlg.xl { width: min(1100px, 100%); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h3, .dlg-head .dlg-title { flex: 1; margin: 0; font-size: 16px; font-weight: 750; }
.dlg-body { padding: 16px 18px; overflow: auto; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.dlg-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel-2); }
.dlg-x { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); border-radius: 8px; padding: 0 8px; } .dlg-x:hover { background: var(--panel-2); color: var(--ink); }
@keyframes fadein { from { opacity: 0; } }
@keyframes dlgin { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: 380px; width: calc(100vw - 28px); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); border-left-width: 4px; box-shadow: var(--sh2); font-weight: 600; pointer-events: auto; animation: toastin .25s var(--ease); word-break: break-word; }
.toast .tmsg { flex: 1; min-width: 0; } .toast .ttitle { display: block; font-weight: 800; }
.toast .tx { border: 0; background: none; color: var(--muted); padding: 0 2px; font-size: 16px; line-height: 1; }
.toast.ok { border-left-color: var(--ok); } .toast.warn { border-left-color: var(--warn); } .toast.bad { border-left-color: var(--bad); background: var(--bad-soft); } .toast.info { border-left-color: var(--brand-2); }
@keyframes toastin { from { opacity: 0; transform: translateX(24px); } }

/* ---------- gate: sign-in / redirect / error pages ---------- */
.gate { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 18px; }
.gate .card { background: var(--panel); padding: 28px 34px; border-radius: 18px; box-shadow: var(--sh2); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 420px; width: 100%; border: 1px solid var(--line); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 6px 12px; row-gap: 6px; }
  .burger { display: inline-block; margin-left: auto; order: 2; }
  .topbar .tb-end { order: 3; }
  .nav { order: 5; flex-basis: 100%; margin: 0; flex-direction: column; align-items: stretch; border-radius: 12px; display: none; }
  .topbar.open .nav { display: flex; }
  .nav .menuwrap { display: block; } .nav .nl { width: 100%; justify-content: space-between; }
  .nav .pop { position: static; margin: 3px 0 6px; box-shadow: none; max-height: none; animation: none; }
  .clientname, .uname { display: none; }
  .page { padding: 12px 12px 32px; }
  .fgrid.c2, .fgrid.c3, .fgrid.c4 { grid-template-columns: 1fr; } .fgrid .span2 { grid-column: auto; }
  .cols, .cols.c2 { grid-template-columns: 1fr; } .split { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 0; } .dl dt { margin-top: 8px; }
  .btn { min-height: 38px; } .btn.sm { min-height: 32px; } .input { min-height: 38px; }
  .toasts { left: 10px; right: 10px; max-width: none; width: auto; }
  .dlg-back { align-items: end; padding: 0; } .dlg, .dlg.sm, .dlg.lg, .dlg.xl { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .matrix-scroll { max-height: calc(100vh - 190px); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .topbar, .footer, .toasts, .banner { display: none !important; } body { background: #fff; } }
