/* UniTrade web — design tokens */
:root {
  --bg: #F2F4F7;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --ink: #17202C;
  --ink-2: #4B5768;
  --ink-3: #7A8596;
  --line: #E0E5EC;
  --line-2: #CDD4DE;
  --primary: #2B4C7E;
  --primary-hover: #223E68;
  --primary-soft: #E7EDF6;
  --accent: #E3A12F;
  --accent-soft: #FCF1DC;
  --side: #15263E;
  --side-ink: #C3CEDD;
  --side-active: #23395A;
  --ok: #1D7A4C; --ok-soft: #E3F3EA;
  --warn: #A15F00; --warn-soft: #FDF0D8;
  --bad: #B42318; --bad-soft: #FCE8E6;
  --info: #2B5FA8; --info-soft: #E5EEFA;
  --violet: #6741C2; --violet-soft: #EFE9FB;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(20, 34, 54, .06), 0 1px 1px rgba(20, 34, 54, .04);
  --shadow-lg: 0 18px 48px rgba(16, 28, 46, .22);
  --font: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1722; --surface: #172231; --surface-2: #1B2838; --ink: #E6ECF3; --ink-2: #AEB9C8; --ink-3: #7F8B9C;
    --line: #26354A; --line-2: #33465F; --primary: #6F9BDB; --primary-hover: #86ABE2; --primary-soft: #1E3049;
    --accent: #F0B44C; --accent-soft: #3A2E18; --side: #0B121C; --side-ink: #A9B6C7; --side-active: #1B2A40;
    --ok: #57C08A; --ok-soft: #173326; --warn: #E8A94A; --warn-soft: #3A2C14; --bad: #F2867B; --bad-soft: #3D1D1A;
    --info: #7FA8E6; --info-soft: #1A2B44; --violet: #A98BF0; --violet-soft: #2A2142;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); font-feature-settings: 'tnum' 1; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 8px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--ink-3); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 600; font-size: 16px; }
.brand:hover { text-decoration: none; }
.mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--primary); color: var(--accent); font-weight: 700; }
.side nav { flex: 1; padding: 4px 10px 12px; }
.nav-group { margin-bottom: 10px; }
.nav-title { font-size: 11.5px; color: #7D8DA4; padding: 10px 10px 4px; font-weight: 500; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--side-ink); font-size: 13.5px; }
.side nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; color: #fff; }
.side nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { border-top: 1px solid rgba(255,255,255,.07); padding: 10px; }
.me { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 6px; color: var(--side-ink); }
.me:hover { background: rgba(255,255,255,.05); text-decoration: none; }
.me b { display: block; color: #fff; font-weight: 500; font-size: 13px; }
.me small { display: block; font-size: 11.5px; color: #8797AD; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #2A1C00; display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 0 24px; height: 52px; background: var(--surface); border-bottom: 1px solid var(--line); }
.crumbs { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: center; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs span:last-child { color: var(--ink); font-weight: 500; }
.crumbs .sep { color: var(--line-2); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; }
#inbox-btn { position: relative; }
.dot { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #2A1C00; font-size: 10px; font-weight: 700; line-height: 16px; }
#view { outline: none; }
.page { padding: 22px 24px 48px; max-width: 1440px; }

/* ---------------------------------------------------------- page header */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.ph .sub { color: var(--ink-3); margin-top: 4px; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------- buttons */
.btn { appearance: none; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; padding: 7px 14px; border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--accent); border-color: var(--accent); color: #2A1C00; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; }
.icon-btn { appearance: none; border: 0; background: transparent; color: var(--ink-2); width: 34px; height: 34px; border-radius: 6px; cursor: pointer; display: inline-grid; place-items: center; font-size: 15px; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.small { width: 24px; height: 24px; font-size: 12px; }

/* ---------------------------------------------------------- cards / panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel .body { padding: 14px 16px; }
.panel .body .body { padding: 0; }
.panel + .panel { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }

/* KPI strip: one row of figures, not a card grid */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.kpi { padding: 14px 16px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi .label { color: var(--ink-3); font-size: 12.5px; }
.kpi .value { font-size: 21px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 12px; color: var(--ink-3); }
.kpi .note.up { color: var(--ok); } .kpi .note.down { color: var(--bad); }

/* ---------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12.5px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.link { cursor: pointer; }
.t tbody tr.link:hover td { background: var(--primary-soft); }
.t .num, .t th.num { text-align: right; }
.t td.empty { text-align: center; color: var(--ink-3); padding: 36px; }
.t tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line-2); }
.t .sub { display: block; color: var(--ink-3); font-size: 12px; }
.t input, .t select { width: 100%; min-width: 64px; }
.t.compact td, .t.compact th { padding: 6px 10px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); gap: 8px; flex-wrap: wrap; }
.pager span:last-child { display: flex; gap: 6px; }

/* ---------------------------------------------------------- filters / forms */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.filters .grow { flex: 1; min-width: 200px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; accent-color: var(--primary); flex: none; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.field small { color: var(--ink-3); font-size: 12px; }
.field input, .field select, .field textarea { width: 100%; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font: inherit; color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary); color: #fff; }

/* typeahead */
.ta-menu { position: absolute; left: 0; right: 0; top: 100%; z-index: 40; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; display: none; margin-top: 2px; }
.ta-menu.open { display: block; }
.ta-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 12px; font: inherit; color: var(--ink); cursor: pointer; border-bottom: 1px solid var(--line); }
.ta-item small { display: block; color: var(--ink-3); font-size: 12px; }
.ta-item.active, .ta-item:hover { background: var(--primary-soft); }

/* ---------------------------------------------------------- badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.badge.muted { color: var(--ink-3); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--ink-2); margin: 0 4px 4px 0; }

/* ---------------------------------------------------------- definition lists */
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------- workflow timeline (the signature element) */
.flow { list-style: none; margin: 0; padding: 4px 0 0; position: relative; }
.flow li { position: relative; padding: 0 0 16px 30px; }
.flow li::before { content: ''; position: absolute; left: 9px; top: 20px; bottom: -2px; width: 2px; background: var(--line); }
.flow li:last-child::before { display: none; }
.flow .node { position: absolute; left: 0; top: 1px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--surface); display: grid; place-items: center; font-size: 11px; color: transparent; }
.flow li.done .node { background: var(--primary); border-color: var(--primary); color: #fff; }
.flow li.done::before { background: var(--primary); }
.flow li.now .node { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); }
.flow li.stop .node { background: var(--bad); border-color: var(--bad); color: #fff; }
.flow b { display: block; font-weight: 500; }
.flow li:not(.done):not(.now):not(.stop) b { color: var(--ink-3); font-weight: 400; }
.flow small { color: var(--ink-3); display: block; }

.actions-box { display: flex; flex-direction: column; gap: 8px; }
.actions-box .btn { justify-content: center; }
.callout { border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--line); background: var(--surface-2); }
.callout.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.callout p { margin: 4px 0 0; color: inherit; }

.totals { margin-left: auto; width: min(320px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals div.grand { border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 8px; font-weight: 600; font-size: 15px; }

ul.files { list-style: none; margin: 0; padding: 0; }
ul.files li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
ul.files li:last-child { border-bottom: 0; }
ul.files li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload { display: flex; gap: 6px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.upload select { padding: 4px 8px; font-size: 12.5px; }

.msgs { list-style: none; padding: 0; margin: 0 0 10px; }
.msgs li { padding: 8px 10px; background: var(--surface-2); border-radius: 6px; margin-bottom: 6px; white-space: pre-wrap; }
.msgs small { display: block; color: var(--ink-3); margin-top: 2px; }

/* inbox */
.inbox { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0; }
.inbox a { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); color: var(--ink); }
.inbox a:hover { background: var(--primary-soft); text-decoration: none; }
.inbox a b { font-size: 18px; font-variant-numeric: tabular-nums; }
.inbox a.zero b { color: var(--ink-3); font-weight: 400; }
.inbox a:not(.zero) b { color: var(--warn); }

/* bar chart */
.bars { display: flex; align-items: flex-end; gap: 0; padding-top: 8px; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; padding: 0 3px; }
.bar { width: 100%; max-width: 38px; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 1px; }
.bar-col:last-child .bar { background: var(--accent); }
.bar-label { font-size: 11px; color: var(--ink-3); margin-top: 4px; white-space: nowrap; }
.hbar { height: 6px; background: var(--primary-soft); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.hbar i { display: block; height: 100%; background: var(--primary); }

/* stock cells */
.stock { font-variant-numeric: tabular-nums; }
.stock.zero { color: var(--ink-3); }
.stock.low { color: var(--bad); font-weight: 600; }

/* gallery */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.thumb { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--surface-2); }
.thumb div { padding: 6px 8px; font-size: 12px; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.pimg { width: 40px; height: 40px; border-radius: 5px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); display: block; }
.pimg.big { width: 100%; height: auto; aspect-ratio: 4/3; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 12px; font: inherit; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--primary); font-weight: 500; }

/* ---------------------------------------------------------- modal / toast */
.modal-wrap { position: fixed; inset: 0; background: rgba(12, 20, 33, .5); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 10px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(900px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-body > * + * { margin-top: 12px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 6px; box-shadow: var(--shadow-lg); max-width: 380px; transition: opacity .4s, transform .4s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
.loading-bar { height: 3px; width: 160px; background: linear-gradient(90deg, var(--primary) 40%, var(--primary-soft) 40%); background-size: 200% 100%; animation: lb 1s linear infinite; border-radius: 2px; }
@keyframes lb { to { background-position: -200% 0; } }

/* ---------------------------------------------------------- login (Unitrade logo colours) */
.login { --u-red: #EE3425; --u-red-d: #C42A1E; --u-dark: #472A29; --u-tan: #F4C785; --u-tan-d: #AE8C5E; --u-cream: #FDF6EC;
  display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; min-height: 100dvh; background: #fff; color: #2A1C1B; color-scheme: light; }
.login-art { position: relative; overflow: hidden; background: var(--u-cream); padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 22px; border-right: 1px solid #F1E3CF; }
.login-art::before { content: ''; position: absolute; right: -90px; bottom: -90px; width: 300px; height: 300px; border: 46px solid var(--u-tan); border-left-color: transparent; border-top-color: transparent; opacity: .45; }
.login-art::after { content: ''; position: absolute; left: 0; top: 0; width: 100%; height: 6px; background: linear-gradient(90deg, var(--u-dark) 0 12%, var(--u-red) 12% 62%, var(--u-tan) 62%); }
.login-logo { width: min(340px, 80%); height: auto; }
.login-brand { display: inline-flex; align-self: flex-start; padding: 4px 12px; border-radius: 6px; background: var(--u-red); color: #fff; font-size: 15px; font-weight: 700; letter-spacing: .12em; }
.login-tag { font-size: 20px; line-height: 1.45; color: var(--u-dark); max-width: 30ch; }
.login-flow { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px 0; }
.login-flow li { display: flex; align-items: center; color: var(--u-dark); font-size: 13px; }
.login-flow li span { padding: 6px 12px; border: 1px solid var(--u-tan); background: #fff; border-radius: 999px; }
.login-flow li:not(:last-child)::after { content: ''; width: 16px; height: 2px; background: var(--u-tan); }
.login-flow li:last-child span { border-color: var(--u-red); background: var(--u-red); color: #fff; }
.login-form { align-self: center; justify-self: center; width: min(380px, 100% - 40px); display: flex; flex-direction: column; gap: 14px; padding: 32px 0; }
.login-form h1 { font-size: 26px; color: var(--u-dark); }
.login-form .muted { color: #7A6A66; }
.login-form .field span { color: var(--u-dark); }
.login-form input { background: #fff; color: #2A1C1B; border-color: #E6D6C2; padding: 11px 12px; font-size: 16px; }
.login-form input:focus { outline: 3px solid #FDE2DF; border-color: var(--u-red); }
.login-form .btn.primary { background: var(--u-red); border-color: var(--u-red); color: #fff; padding: 12px; font-size: 16px; font-weight: 600; }
.login-form .btn.primary:hover { background: var(--u-red-d); border-color: var(--u-red-d); }
.login-logo-sm { display: none; }
.mark-img { width: 28px; height: 28px; border-radius: 7px; background: #fff; padding: 3px; object-fit: contain; }

/* ---------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr) !important; }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-grid; }
  .top { padding: 0 12px; }
  .page { padding: 16px 16px 40px; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-art { display: none; }
  .login-form { align-self: start; width: min(420px, 100% - 40px); padding: max(36px, env(safe-area-inset-top)) 0 32px; }
  .login-logo-sm { display: block; width: 220px; max-width: 70%; height: auto; margin: 8px auto 18px; }
  .login-form h1 { font-size: 22px; text-align: center; }
  .login-form > p.muted:first-of-type { text-align: center; }
  /* 16px inputs stop phones from zooming in when a field is tapped */
  input, select, textarea { font-size: 16px; }
  .btn { min-height: 40px; }
  .kpi { border-right: 0; border-bottom: 1px solid var(--line); }
  dl.kv { grid-template-columns: 110px 1fr; }
}
/* Phone: list tables become one card per record */
@media (max-width: 640px) {
  .t.cards-m thead { display: none; }
  .t.cards-m, .t.cards-m tbody, .t.cards-m tr, .t.cards-m td { display: block; width: 100%; }
  .t.cards-m tbody tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .t.cards-m tbody tr:last-child { border-bottom: 0; }
  .t.cards-m td { border: 0; padding: 3px 0; min-width: 0 !important; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; text-align: left !important; }
  .t.cards-m td::before { content: attr(data-label); color: var(--ink-3); font-size: 12px; padding-top: 2px; }
  .t.cards-m td:first-child { grid-template-columns: 1fr; font-size: 15px; padding-bottom: 6px; }
  .t.cards-m td:first-child::before { display: none; }
  .t.cards-m td[data-label=""]::before { content: none; }
  .t.cards-m td.empty { display: block; text-align: center !important; }
  .t.cards-m td.empty::before { display: none; }
  .t.cards-m td .badge { justify-self: start; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters > * { width: 100%; min-width: 0 !important; }
  .filters .grow, .filters > label { grid-column: 1 / -1; }
  .filters > label { display: flex; align-items: center; gap: 8px; }
  .filters > label input { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------------------------------------------------------- print documents */
.doc { background: #fff; color: #111; max-width: 820px; margin: 24px auto; padding: 36px 40px; box-shadow: var(--shadow-lg); font-size: 12.5px; }
.doc-bar { max-width: 820px; margin: 16px auto 0; display: flex; gap: 8px; justify-content: flex-end; }
.doc .head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #2B4C7E; padding-bottom: 12px; margin-bottom: 16px; }
.doc .head h1 { font-size: 20px; color: #2B4C7E; }
.doc .addr { white-space: pre-line; font-size: 11px; color: #444; text-align: right; }
.doc table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.doc th, .doc td { border: 1px solid #ccd; padding: 6px 8px; text-align: left; }
.doc th { background: #EEF2F8; font-weight: 600; }
.doc .num { text-align: right; }
.doc .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; }
.doc .sig { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-top: 48px; }
.doc .sig div { border-top: 1px solid #888; padding-top: 6px; text-align: center; color: #555; }
@media print {
  body { background: #fff; }
  .doc-bar { display: none; }
  .doc { box-shadow: none; margin: 0; max-width: none; padding: 0; }
  @page { margin: 14mm; }
}
.grid > .panel + .panel, .split > .panel + .panel { margin-top: 0; }

.split > *, .stack > *, .grid > * { min-width: 0; }
.t td b { white-space: normal; }
.t td:first-child { min-width: 160px; }
