/* MotoWave BD — Graphite look (dark by default, light one tap away). Version 2.0.0 */
:root {
  --page: #f6f7f9; --surface: #ffffff; --surface-2: #f1f3f5; --rail: #ffffff; --rail-2: #f1f3f5;
  --line: #dde1e6; --line-soft: #e9ecef;
  --ink: #12161b; --ink-2: #4a5360; --ink-3: #6b7480;
  --amber: #f5b301; --amber-strong: #ffc21a; --amber-ink: #8a5a00; --amber-soft: #fff4d1; --amber-line: #f3d27a;
  --link: #9a6700; --seg-on: #12161b; --seg-on-ink: #fff;
  --go: #15803d; --go-soft: #dcfce7; --warn: #a16207; --warn-soft: #fef3c7; --stop: #dc2626; --stop-soft: #fee2e2;
  --bar: #c9ced6; --bar-best: #e0a100; --bar-neg: #dc2626; --line-2: #2563eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --display: 'Space Grotesk', 'Inter', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --page: #0b0d10; --surface: #13161b; --surface-2: #181c22; --rail: #0e1014; --rail-2: #1a1f26;
  --line: #262d36; --line-soft: #1f252d;
  --ink: #eef1f4; --ink-2: #b4bcc5; --ink-3: #8b95a0;
  --amber-ink: #ffd166; --amber-soft: #1a1607; --amber-line: #3d3110;
  --link: #f5b301; --seg-on: #262c35; --seg-on-ink: #fff;
  --go: #4ade80; --go-soft: #10261a; --warn: #fbbf24; --warn-soft: #2a210a; --stop: #f87171; --stop-soft: #2a1414;
  --bar: #4a5562; --bar-best: #f5b301; --bar-neg: #f87171; --line-2: #60a5fa;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.logo-onlight { display: none; }
:root[data-theme="light"] .logo-ondark { display: none; }
:root[data-theme="light"] .logo-onlight { display: block; }

/* boot */
.boot { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--ink-3); background: var(--page); z-index: 100; }
.boot img { border-radius: 16px; }

/* ---------- Sign in ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; display: flex; flex-direction: column; gap: 20px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand img, .brand img { width: 48px; height: auto; }
.auth-brand strong, .brand strong { display: block; font: 700 18px var(--display); }
.auth-brand span, .brand span { display: block; font-size: 12px; color: var(--ink-3); }
.auth h2 { font: 600 22px var(--display); }
.auth-sub { margin: 4px 0 0; color: var(--ink-3); font-size: 14px; }
.auth-foot { color: var(--ink-3); font-size: 12.5px; text-align: center; max-width: 360px; margin: 0; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font-weight: 600; font-size: 14px; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--rail); border-right: 1px solid var(--line-soft); padding: 22px 14px 16px; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); padding: 14px 12px 6px; }
.nav-group:first-child { padding-top: 0; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; font-size: 14px; color: var(--ink-2); text-decoration: none; }
.nav a:hover { background: var(--rail-2); color: var(--ink); }
.nav a.on { background: var(--rail-2); color: var(--ink); font-weight: 600; }
.nav a.on svg { color: var(--amber); }
.nav a.on::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.rail-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-soft); font-size: 13px; }
.rail-user b { display: block; font-size: 13.5px; }
.rail-user span { color: var(--ink-3); font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 26px 36px 14px; position: relative; }
.topbar-left { display: flex; flex-direction: column-reverse; gap: 4px; min-width: 0; }
.topbar h1 { font: 600 32px/1.15 var(--display); letter-spacing: -.5px; }
.topbar p { margin: 0; color: var(--ink-3); font-size: 13.5px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--amber); color: #1a1300; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex: none; }
.menu { position: absolute; right: 36px; top: 84px; z-index: 40; min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px; box-shadow: 0 20px 50px -20px rgba(0,0,0,.5); }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.menu .who b { display: block; }
.menu .who span { color: var(--ink-3); font-size: 12.5px; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; color: var(--ink); text-decoration: none; font-size: 14px; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.view { padding: 6px 36px 56px; max-width: 1320px; width: 100%; display: flex; flex-direction: column; gap: 20px; outline: none; }

/* ---------- Building blocks ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #1a1300; }
.btn-amber:hover:not(:disabled) { background: var(--amber-strong); border-color: var(--amber-strong); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); border-color: transparent; color: var(--ink); }
.btn-danger { color: var(--stop); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-wide { width: 100%; height: 48px; font-size: 15px; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--ink-3) transparent var(--ink-3) transparent; animation: spin .8s linear infinite; }
.btn-amber.busy::after { border-color: #1a1300 transparent #1a1300 transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; font-weight: 600; }
.card-head p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.section-title h2 { font: 600 21px var(--display); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 14px; align-items: start; }

.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile .lbl { font-size: 13.5px; color: var(--ink-2); }
.tile .val { font: 600 28px/1.15 var(--display); letter-spacing: -.5px; overflow-wrap: anywhere; }
.tile .foot { font-size: 12.5px; color: var(--ink-3); }
.tile.hero { background: var(--amber-soft); border-color: var(--amber-line); }
.tile.hero .lbl, .tile.hero .val { color: var(--amber-ink); }
.good { color: var(--go); } .bad { color: var(--stop); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.seg button { height: 34px; padding: 0 13px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font-size: 13.5px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--seg-on-ink); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.ok { background: var(--go-soft); color: var(--go); }
.chip.due { background: var(--warn-soft); color: var(--warn); }
.chip.void { background: var(--stop-soft); color: var(--stop); }
.chip.amber { background: var(--amber-soft); color: var(--amber-ink); }

/* bars */
.hbar { display: flex; flex-direction: column; gap: 6px; }
.hbar + .hbar { margin-top: 12px; }
.grid > .hbar + .hbar { margin-top: 0; }
.hbar .row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.hbar .row span:first-child { color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; background: var(--amber); }
.hbar .fill.grey { background: var(--bar); }
.chart { width: 100%; height: 240px; display: block; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* lists */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .grow { flex: 1 1 220px; }
.search { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-3); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; color: var(--ink); }
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 12px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--surface-2); }
table.list .r { text-align: right; white-space: nowrap; }
table.list .sub { display: block; color: var(--ink-3); font-size: 12.5px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.list tr.voided td { opacity: .55; }
table.list tfoot td { font-weight: 700; border-bottom: 0; }
.cards-list { display: none; }
.empty { text-align: center; padding: 28px 12px; color: var(--ink-3); border: 1px dashed var(--line); border-radius: 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--ink-3); }

/* forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field > span em { font-style: normal; font-weight: 400; color: var(--ink-3); }
.field input, .field select, .field textarea, .cell-input {
  height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); width: 100%; min-width: 0; font-size: 15px;
}
.field textarea { height: 76px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .cell-input:focus, .combo input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(245, 179, 1, .22); }
.field.err input, .field.err select { border-color: var(--stop); }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.form-error { padding: 12px 14px; border-radius: 12px; background: var(--stop-soft); color: var(--stop); font-weight: 600; font-size: 14px; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--amber-soft); color: var(--amber-ink); border: 1px solid var(--amber-line); font-size: 14px; }
.notice.good { background: var(--go-soft); color: var(--go); border-color: transparent; }
.radio-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); height: 44px; }
.radio-seg button { border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 14px; }
.radio-seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--seg-on-ink); font-weight: 600; }
.with-btn { display: flex; gap: 8px; }
.with-btn > :first-child { flex: 1; min-width: 0; }
.with-btn .icon-btn { height: 44px; width: 44px; border-radius: 10px; }

/* item lines in sale / purchase forms */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 84px 120px 100px 110px 40px; gap: 10px; align-items: end; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-soft); }
.line.item-line { grid-template-columns: minmax(70px, .7fr) minmax(0, 1fr) minmax(0, 1fr) minmax(90px, auto) 40px; }
.line.item-line > .field:first-child { grid-column: 1 / -1; }
.line .field > span { font-size: 12px; }
.line .field input { background: var(--surface); }
.line .total { font: 600 16px var(--display); text-align: right; padding-bottom: 10px; }
.line .rm { width: 40px; height: 44px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.line .rm:hover { color: var(--stop); background: var(--stop-soft); }
.line .stockhint { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-3); margin-top: -4px; }
.add-line { align-self: flex-start; border: 1.5px dashed var(--line); background: transparent; border-radius: 999px; height: 40px; padding: 0 16px; color: var(--ink); font-weight: 600; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.add-line:hover { border-color: var(--amber); }

/* combobox (search a list) */
.combo { position: relative; }
.combo input { height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 100%; font-size: 15px; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 24px 50px -20px rgba(0,0,0,.55); }
.combo-list button { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 10px; border: 0; border-radius: 9px; background: none; cursor: pointer; color: var(--ink); font-size: 14px; }
.combo-list button small { color: var(--ink-3); white-space: nowrap; }
.combo-list button:hover, .combo-list button.active { background: var(--surface-2); }
.combo-list .none { padding: 10px; color: var(--ink-3); font-size: 13.5px; }

/* bill summary */
.bill { background: #111418; color: #f3f3ef; border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 16px; }
:root[data-theme="dark"] .bill { background: #0e1014; border: 1px solid var(--line); }
.bill h3 { font: 600 18px var(--display); }
.bill .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14.5px; }
.bill .row span:first-child { color: #b5b5ba; }
.bill input { width: 110px; height: 38px; text-align: right; border-radius: 9px; border: 1px solid #2f2f33; background: #1c1c1f; color: #f3f3ef; padding: 0 10px; font-size: 15px; }
.bill .big { font: 700 38px/1.1 var(--display); color: #ffd166; letter-spacing: -1px; }
.bill .rule { height: 1px; background: #2f2f33; }
.bill .profit { padding: 10px 12px; border-radius: 12px; background: #1c1c1f; display: flex; justify-content: space-between; font-size: 13.5px; }
.bill .profit b { color: #6ee79a; }
.bill .btn { border-color: #3a3a3d; background: transparent; color: #f3f3ef; }
.bill .btn-amber { background: var(--amber); color: #1a1300; border-color: var(--amber); }

/* dialogs */
.dlg-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(5, 7, 10, .6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dlg { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; display: flex; flex-direction: column; }
.dlg.wide { max-width: 860px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px 10px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-head h2 { font: 600 20px var(--display); }
.dlg-body { padding: 6px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; flex-wrap: wrap; border-top: 1px solid var(--line-soft); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }

/* toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--go); border-radius: 12px; padding: 12px 14px; box-shadow: 0 20px 50px -20px rgba(0,0,0,.5); font-size: 14px; }
.toast.bad { border-left-color: var(--stop); }
.toast strong { display: block; }
.toast span { color: var(--ink-2); }

/* phone parts */
.tabbar, .sheet, .scrim { display: none; }
.skeleton { height: 120px; border-radius: 16px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border: 1px solid var(--line-soft); }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(300px, 86vw); height: 100%; transform: translateX(-105%); visibility: hidden; transition: transform .22s ease, visibility .22s; border-right: 1px solid var(--line); padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .app.nav-open .rail { transform: none; visibility: visible; box-shadow: 20px 0 50px -20px rgba(0,0,0,.6); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(5,7,10,.55); }
  .scrim[hidden] { display: none; }
  .topbar { padding: 16px 16px 8px; padding-top: calc(16px + env(safe-area-inset-top)); }
  .topbar h1 { font-size: 24px; }
  .topbar-new { display: none; }
  .menu { right: 16px; top: 70px; }
  .view { padding: 4px 16px calc(110px + env(safe-area-inset-bottom)); gap: 16px; }
  .split { grid-template-columns: 1fr; }
  .bill { position: static; }
  .toasts { left: 16px; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); max-width: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; position: fixed; left: 0; right: 0; bottom: 0; z-index: 57; height: calc(70px + env(safe-area-inset-bottom)); padding: 6px 8px env(safe-area-inset-bottom); background: var(--rail); border-top: 1px solid var(--line); }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; border: 0; background: transparent; color: var(--ink-3); font-size: 11px; font-weight: 500; text-decoration: none; cursor: pointer; }
  .tab svg { width: 22px; height: 22px; }
  .tab.on { color: var(--amber); font-weight: 600; }
  .tab-add { justify-self: center; width: 56px; height: 56px; min-height: 0; border-radius: 18px; background: var(--amber); color: #1a1300; margin-top: -22px; box-shadow: 0 10px 24px rgba(245,179,1,.28); }
  .tab-add svg { width: 24px; height: 24px; transition: transform .15s; }
  .tab-add[aria-expanded="true"] svg { transform: rotate(45deg); }
  .sheet { display: flex; flex-direction: column; gap: 2px; position: fixed; left: 12px; right: 12px; z-index: 58; bottom: calc(84px + env(safe-area-inset-bottom)); padding: 10px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 24px 60px -20px rgba(0,0,0,.6); }
  .sheet[hidden] { display: none; }
  .sheet-title { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); padding: 6px 12px 4px; }
  .sheet a { display: flex; align-items: center; gap: 14px; min-height: 50px; padding: 0 12px; border-radius: 12px; color: var(--ink); text-decoration: none; font-size: 15.5px; font-weight: 600; }
  .sheet a:hover { background: var(--surface-2); }
  .sheet svg { width: 20px; height: 20px; color: var(--amber); }
  .line:not(.item-line) { grid-template-columns: 1fr 1fr; }
  .line:not(.item-line) > .field:first-child { grid-column: 1 / -1; }
  .line.item-line { grid-template-columns: repeat(3, minmax(0, 1fr)) 40px; }
  .line.item-line .total { grid-column: 1 / 4; grid-row: 3; text-align: left; padding: 0; }
  .line.item-line .rm { grid-row: 3; grid-column: 4; }
}
@media (max-width: 640px) {
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .tile { padding: 14px 16px; }
  .tile .val { font-size: 22px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seg { display: flex; flex-wrap: nowrap; overflow-x: auto; width: 100%; }
  .seg button { flex: none; }
  table.list.mobile-cards thead { display: none; }
  table.list.mobile-cards tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
  table.list.mobile-cards td { padding: 0; border: 0; }
  table.list.mobile-cards td.hide-sm { display: none; }
  table.list.mobile-cards td.r { grid-column: 2; grid-row: 1; }
  table.list.mobile-cards tfoot tr { border: 0; }
  .dlg-scrim { align-items: flex-end; padding: 0; }
  .dlg { max-height: 92vh; border-radius: 20px 20px 0 0; }
  .dlg-foot { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .dlg-foot .btn { flex: 1; }
}

@media print {
  body { background: #fff; color: #000; }
  .rail, .topbar, .tabbar, .toasts, .sheet, .scrim { display: none !important; }
}
