/* ---------- Design tokens (light, then dark) ---------- */
:root {
    color-scheme: light;
    --bg: #f2f4f8; --surface: #ffffff; --surface-2: #f7f8fb; --line: #e3e7ee; --line-strong: #cbd2dd;
    --ink: #0f172a; --ink-2: #475569; --muted: #64748b;
    --primary: #0f766e; --primary-ink: #ffffff; --primary-soft: #e0f2ef;
    --green: #15803d; --green-soft: #dcfce7; --amber: #b45309; --amber-soft: #fef3c7; --red: #c2262b; --red-soft: #fee2e2;
    --series-1: #1a9e8f; --grid: #e6e9ef;
    --nav-bg: #0f172a; --nav-ink: #cbd5e1;
    --radius: 14px; --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
    --tabbar-h: 62px;
}
@media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) {
        color-scheme: dark;
        --bg: #0b1220; --surface: #141c2b; --surface-2: #1a2333; --line: #263043; --line-strong: #37425a;
        --ink: #e8edf5; --ink-2: #b4bfcf; --muted: #8b97aa;
        --primary: #2bb3a3; --primary-ink: #04201d; --primary-soft: #0f2e2b;
        --green: #4ade80; --green-soft: #12301f; --amber: #fbbf24; --amber-soft: #3a2a0a; --red: #f87171; --red-soft: #3b1418;
        --series-1: #2bb3a3; --grid: #222c3d;
        --nav-bg: #0a101c; --nav-ink: #a7b2c4;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1220; --surface: #141c2b; --surface-2: #1a2333; --line: #263043; --line-strong: #37425a;
    --ink: #e8edf5; --ink-2: #b4bfcf; --muted: #8b97aa;
    --primary: #2bb3a3; --primary-ink: #04201d; --primary-soft: #0f2e2b;
    --green: #4ade80; --green-soft: #12301f; --amber: #fbbf24; --amber-soft: #3a2a0a; --red: #f87171; --red-soft: #3b1418;
    --series-1: #2bb3a3; --grid: #222c3d;
    --nav-bg: #0a101c; --nav-ink: #a7b2c4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Ethiopic", Arial, sans-serif; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; letter-spacing: -.01em; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 0 0 12px; }
small, .muted { color: var(--muted); }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
b, strong { font-weight: 650; }

/* ---------- Desktop sidebar ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 236px; background: var(--nav-bg); color: var(--nav-ink); display: flex; flex-direction: column; padding: 18px 12px; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 4px 8px 18px; line-height: 1.2; }
.brand:hover { text-decoration: none; }
.logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: #fff; flex-shrink: 0; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--nav-ink); font-weight: 500; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav a .count { margin-left: auto; }
.me { display: flex; align-items: center; gap: 4px; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 12px; }
.me form { margin: 0; }
.who { display: flex; align-items: center; gap: 10px; color: #fff; flex: 1; min-width: 0; font-size: 14px; line-height: 1.2; }
.who:hover { text-decoration: none; }
.who small { display: block; color: var(--nav-ink); font-size: 12px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; flex-shrink: 0; }
.sidebar .avatar { background: rgba(255, 255, 255, .12); color: #fff; }
.iconbtn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--nav-ink); cursor: pointer; }
.iconbtn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.count { display: inline-block; min-width: 20px; text-align: center; background: #ef4444; color: #fff; border-radius: 10px; padding: 0 6px; font-size: 12px; font-weight: 700; line-height: 20px; }

.appbar, .tabbar, .sheet, .sheet-backdrop { display: none; }

.page { max-width: 1240px; margin: 0 auto; padding: 28px 28px 48px; }
body.has-nav .page { margin-left: 236px; }
@media (min-width: 1500px) { body.has-nav .page { margin-left: calc(236px + (100vw - 236px - 1240px) / 2); } }

/* ---------- Panels and layout helpers ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid > .card, .grid > form.card, .grid > div > .card:last-child { margin-bottom: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card .grid { margin-bottom: 0; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 750; margin-top: 2px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.right { text-align: right; }
.mt { margin-top: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--ink-2); }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; background: var(--surface); color: var(--ink); min-height: 42px; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; vertical-align: middle; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.field { margin-bottom: 14px; }
.inline input, .inline select { width: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; min-height: 42px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.btn.big { padding: 14px 20px; font-size: 17px; width: 100%; min-height: 52px; }
.btn.small { padding: 5px 11px; min-height: 32px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.low td { background: var(--amber-soft); }
tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); }
table.kv th { background: none; width: 38%; text-transform: none; letter-spacing: 0; font-size: 14px; }

/* ---------- Messages and badges ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid; }
.alert.ok { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, transparent); color: var(--green); }
.alert.error { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 30%, transparent); color: var(--red); }
.alert.warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 30%, transparent); color: var(--amber); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 650; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 2px; scrollbar-width: none; }
.tabs a { padding: 8px 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; font-weight: 500; }
.tabs a:hover { text-decoration: none; }
.tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Dashboard ---------- */
.hello { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.hello h1 { margin: 0; }
.hello p { margin: 0; color: var(--muted); }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.quick a { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); min-width: 0; }
.quick a:hover { text-decoration: none; border-color: var(--primary); }
.quick a .ic { width: 38px; height: 38px; padding: 9px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.quick a.main { background: var(--primary); color: #fff; border-color: var(--primary); }
.quick a.main .ic { background: rgba(255, 255, 255, .18); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; color: var(--ink); }
a.kpi:hover { text-decoration: none; border-color: var(--primary); }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 750; margin-top: 4px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value small { font-size: 13px; font-weight: 600; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.delta { font-weight: 650; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.kpi.warn .value { color: var(--amber); }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--line-strong); stroke-width: 1; }
.chart .bar { fill: var(--series-1); transition: opacity .12s; }
.chart.hovering .bar { opacity: .35; }
.chart.hovering .bar.on { opacity: 1; }
.chart .hit { fill: transparent; cursor: pointer; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); border-radius: 8px; padding: 7px 10px; font-size: 12px; line-height: 1.45; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); box-shadow: 0 4px 14px rgba(0, 0, 0, .2); z-index: 5; }
.tip b { font-size: 13px; }
.hbars { display: flex; flex-direction: column; gap: 13px; }
.hbar .top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 5px; }
.hbar .top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .top span:last-child { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 3px; }
details.as-table { margin-top: 12px; font-size: 13px; }
details.as-table summary { cursor: pointer; color: var(--muted); }
details.as-table table { margin-top: 8px; }
.list { display: flex; flex-direction: column; }
.list > a, .list > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.list > :last-child { border-bottom: 0; }
.list > a:hover { text-decoration: none; }
.list .t { min-width: 0; }
.list .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .t small { display: block; }
.list .v { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty-note { color: var(--muted); padding: 6px 0; margin: 0; }

/* ---------- Pharmacy ---------- */
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.seg label { margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; height: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.seg span b { display: block; color: var(--ink); }
.seg span small { font-weight: 400; }
.seg input:checked + span { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.seg input:focus-visible + span { outline: 3px solid var(--primary-soft); }
.kpi.danger .value { color: var(--red); }
.kpi.danger { border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.cart td:first-child { min-width: 210px; }
.cart td.num input { min-width: 0; width: 72px; }
.cart th, .cart td { padding-left: 6px; padding-right: 6px; }
.cart input.dosage { display: block; width: 100%; margin-top: 6px; font-size: 13px; min-height: 34px; padding: 5px 8px; }
.cart select { min-height: 38px; padding: 6px 8px; width: auto; }
.rx-card { border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.rx-card h2 { display: flex; align-items: center; gap: 8px; }
.stockin-line { box-shadow: none; background: var(--surface-2); margin: 10px 0 0; }
.ctl-req { color: var(--red); }

/* ---------- Vehicles on the part form ---------- */
.fit-make { border-bottom: 1px solid var(--line); padding: 8px 0; }
.fit-make summary { cursor: pointer; padding: 4px 0; }
.fit-models { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; padding: 8px 0 4px 4px; }
.fit-models label { font-weight: 400; color: var(--ink); margin: 0; display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.fit-models label.all { grid-column: 1 / -1; font-weight: 600; }

/* ---------- Sell screen ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.searchbox { position: relative; }
.searchbox > .ic { position: absolute; left: 13px; top: 24px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.searchbox input { padding-left: 42px; min-height: 48px; font-size: 16px; }
.results { max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 8px; background: var(--surface); }
.result { display: flex; justify-content: space-between; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.result:last-child { border-bottom: 0; }
.result:hover, .result.active { background: var(--primary-soft); }
.result .meta { color: var(--muted); font-size: 13px; }
.result.out { opacity: .55; }
.cart input { padding: 7px 9px; min-width: 70px; min-height: 38px; }
.totals div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 24px; font-weight: 800; border-top: 2px solid var(--ink); margin-top: 8px; padding-top: 10px; }
.limit-note { font-size: 13px; padding: 9px 12px; border-radius: var(--radius-sm); margin-top: 10px; background: var(--surface-2); color: var(--ink-2); }
.limit-note.over { background: var(--amber-soft); color: var(--amber); }
.pay-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr 36px; gap: 6px; margin-bottom: 8px; }
.pay-row input[data-f=amount]:has(+ input[hidden]) { grid-column: span 2; }
.mobile-total { display: none; }

/* ---------- Sign in ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 400px; }
.login .logo { width: 52px; height: 52px; border-radius: 14px; margin-bottom: 14px; }
.login .logo .ic { width: 28px; height: 28px; }

.mobile-only { display: none !important; }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
    .kpis, .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Phone and Telegram: app bar on top, tabs at the bottom ---------- */
@media (max-width: 900px) {
    .sidebar { display: none; }
    body.has-nav .page { margin-left: 0; padding: 14px 14px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
    body.has-nav .page-title { display: none; }
    .page { padding: 16px; }
    .appbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); padding: calc(8px + env(safe-area-inset-top)) 14px 8px; min-height: 56px; }
    .appbar-title { min-width: 0; line-height: 1.2; }
    .appbar-title small { display: block; font-size: 12px; }
    .appbar-title b { display: block; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .appbar .avatar:hover { text-decoration: none; }

    .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
    .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabbar-h); color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; background: none; border: 0; cursor: pointer; position: relative; }
    .tabbar a:hover { text-decoration: none; }
    .tabbar .ic { width: 24px; height: 24px; }
    .tabbar .active { color: var(--primary); }
    .tabbar .dot { position: absolute; top: 10px; right: calc(50% - 16px); width: 9px; height: 9px; border-radius: 50%; background: #ef4444; border: 2px solid var(--surface); }

    .sheet-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .45); z-index: 40; }
    .sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 14px calc(18px + env(safe-area-inset-bottom)); transform: translateY(105%); visibility: hidden; transition: transform .22s ease, visibility .22s; display: block; }
    body.sheet-open .sheet { transform: none; visibility: visible; }
    body.sheet-open .sheet-backdrop { display: block; }
    .sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 14px; }
    .sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
    .sheet-grid a, .sheet-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: 14px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; border: 0; width: 100%; height: 100%; cursor: pointer; position: relative; text-align: center; }
    .sheet-grid a:hover { text-decoration: none; }
    .sheet-grid a.active { color: var(--primary); background: var(--primary-soft); }
    .sheet-grid .ic { width: 26px; height: 26px; }
    .sheet-grid .count { position: absolute; top: 8px; right: 10px; }
    .sheet-grid form { margin: 0; }

    .card { padding: 14px; border-radius: 16px; }
    .g2, .g3, .g4, .pos { grid-template-columns: minmax(0, 1fr) !important; }
    .grid { gap: 12px; margin-bottom: 12px; }
    .kpis { gap: 10px; margin-bottom: 12px; }
    .kpi { padding: 13px; }
    .kpi .value { font-size: 20px; }
    .quick { gap: 10px; margin-bottom: 12px; }
    .quick a { padding: 11px; font-size: 14px; gap: 10px; }
    .quick a .ic { width: 34px; height: 34px; padding: 8px; }
    .hello { margin-bottom: 12px; }
    .hello h1 { font-size: 20px; }
    .row > div { flex: 1 1 140px; }
    .pay-row { grid-template-columns: 1fr 1fr 36px; }
    .seg { grid-template-columns: 1fr; }
    .cart td:first-child { min-width: 0; }
    .cart td.num input { width: auto; flex: 0 1 62%; }
    .pay-row [data-f=reference] { grid-column: 1 / 3; }
    .pay-row input[data-f=amount]:has(+ input[hidden]) { grid-column: auto; }

    .mobile-only { display: flex !important; }
    .desktop-only { display: none !important; }
    .card.list { padding: 2px 14px; }
    .list > a { padding: 12px 0; }
    form.card.row { gap: 8px; }
    form.card.row > div { flex: 1 1 45%; }

    /* Table rows become cards */
    .card.table-wrap:has(table.rt) { background: transparent; border: 0; box-shadow: none; padding: 0; overflow: visible; }
    .table-wrap:has(table.rt) { overflow: visible; }
    table.rt, table.rt > tbody, table.rt > tfoot, table.rt > thead, table.rt tr, table.rt td { display: block; width: 100%; }
    table.rt tr.head, table.rt thead tr { display: none; }
    table.rt tr { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
    table.rt tr.low { border-left: 4px solid var(--amber); }
    table.rt tr.low td { background: none; }
    table.rt td { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 0; padding: 6px 0; text-align: right; }
    table.rt td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; text-align: left; flex-shrink: 0; }
    table.rt td[data-label=""]::before { display: none; }
    table.rt td:first-child { display: block; text-align: left; font-size: 15px; padding: 9px 0 7px; border-bottom: 1px solid var(--line); }
    table.rt td:first-child::before { display: none; }
    table.rt td:only-child { border-bottom: 0; }
    table.rt td.empty { display: none; }
    table.rt td input, table.rt td select { max-width: 62%; }
    table.rt td:first-child input { max-width: none; }
    table.rt td form { margin: 0; }
    table.rt tfoot tr { background: var(--primary-soft); border-color: transparent; box-shadow: none; }
    table.rt tfoot td { border: 0; }
    .card > h2 + .table-wrap table.rt tr, .card table.rt tr { box-shadow: none; }

    .mobile-total { display: flex; position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 25; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(0, 0, 0, .06); }
    .mobile-total b { font-size: 20px; display: block; line-height: 1.1; font-variant-numeric: tabular-nums; }
    .mobile-total small { display: block; }
    .mobile-total .btn { min-width: 140px; }
    body.selling .page { padding-bottom: calc(var(--tabbar-h) + 100px + env(safe-area-inset-bottom)); }
}

/* ---------- Camera scanning ---------- */
.scan-wrap { display: flex; gap: 6px; align-items: stretch; width: 100%; }
.scan-wrap > input { flex: 1; min-width: 0; }
.scan-btn { flex: 0 0 auto; width: 48px; border: 0; border-radius: var(--radius-sm); background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; cursor: pointer; }
.scan-btn .ic { width: 22px; height: 22px; }
.scan-btn:hover { filter: brightness(1.08); }
.scanner { position: fixed; inset: 0; z-index: 100; background: rgba(2, 6, 23, .88); display: grid; place-items: center; padding: 16px; }
.scanner-box { position: relative; width: min(100%, 520px); text-align: center; }
.scanner video { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 16px; background: #000; }
.scanner-frame { position: absolute; left: 12%; right: 12%; top: 0; height: 0; padding-top: calc((100% * 3 / 4) * .42); margin-top: calc(100% * 3 / 4 * .29); border: 3px solid rgba(255, 255, 255, .9); border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .25); pointer-events: none; }
.scanner-status { color: #fff; margin: 14px 0; font-weight: 600; }
.scanner-status.error { color: #fecaca; }

@media print {
    .sidebar, .appbar, .tabbar, .sheet, .btn, form { display: none !important; }
    body.has-nav .page { margin: 0; }
}
