:root {
  --bg: #f2f3ef; --card: #ffffff; --ink: #0B2027; --muted: #6b7280; --line: #e3e6ea;
  --accent: #0B2027; --accent-ink: #ffffff; --ok: #2f7d6d; --warn: #c2410c; --bad: #c81e1e; --soft: #e6f0ee; --teal: #70A9A1;
  --tabbar: 64px; --radius: 14px; --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --card: #171b21; --ink: #eceff3; --muted: #9aa3b2; --line: #2a3039; --accent: #70A9A1; --accent-ink: #0B2027; --soft: #1a2a30; --ok: #35c073; --warn: #f59e5b; --bad: #ff6b6b; }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 8px; }
code { font-family: var(--mono); font-size: 13px; background: var(--soft); padding: 1px 5px; border-radius: 5px; }
.hidden { display: none !important; }

header.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); padding: calc(10px + env(safe-area-inset-top)) 14px 10px; display: flex; align-items: center; gap: 10px; }
header.top h1 { flex: 1; font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .back { font-size: 15px; padding: 6px 8px; margin-left: -8px; }
header.top .who { font-size: 12px; color: var(--muted); }
#view { padding: 12px 12px 24px; max-width: 760px; margin: 0 auto; }
.offline { background: var(--warn); color: #fff; text-align: center; font-size: 13px; padding: 6px; }

nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: flex; z-index: 5; }
nav.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; }
nav.tabs a .ic { font-size: 22px; line-height: 1; }
nav.tabs a.on { color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card.error { border-color: var(--bad); }
.card.soft { background: var(--soft); border-color: transparent; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; } .mono { font-family: var(--mono); }
.right { text-align: right; } .center { text-align: center; } .bold { font-weight: 700; } .nowrap { white-space: nowrap; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat .v { font-size: 22px; font-weight: 700; } .stat .l { font-size: 12px; color: var(--muted); }

button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 12px 16px; min-height: 46px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.ok { color: var(--ok); border-color: var(--ok); }
button.small, .btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
button.wide { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.actions > * { flex: 1; }

label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 10px 0 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 11px 12px; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { min-height: 70px; }
input[type=number] { font-variant-numeric: tabular-nums; }
.inline { display: flex; gap: 8px; align-items: end; } .inline > * { flex: 1; } .inline label { margin-top: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-height: 42px; padding: 8px 12px; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ink); font-weight: 500; margin: 8px 0; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 0; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: inherit; min-height: 56px; }
.item:last-child { border-bottom: 0; }
.item .t { font-weight: 600; } .item .s { font-size: 13px; color: var(--muted); }
.item .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item.link { cursor: pointer; } .item.link:active { background: var(--soft); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: #2f6b64; text-transform: uppercase; letter-spacing: .03em; }
.pill.ok { background: #e3f5ea; color: var(--ok); } .pill.warn { background: #fdecdf; color: var(--warn); } .pill.bad { background: #fde3e3; color: var(--bad); } .pill.muted { background: var(--line); color: var(--muted); }
@media (prefers-color-scheme: dark) { .pill.ok { background: #16321f; } .pill.warn { background: #3b2412; } .pill.bad { background: #3a1818; } }

.lines .line { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.lines .line:last-child { border-bottom: 0; }
.lines .line .fields { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 8px; margin-top: 6px; }
.lines .line input { min-height: 40px; padding: 8px 10px; }
.qtybtns { display: flex; gap: 4px; }
.qtybtns button { min-height: 40px; padding: 0 10px; }
.qtybtns input { flex: 1; min-width: 44px; text-align: center; padding: 8px 4px; }
.total { font-size: 20px; font-weight: 800; }

.picker { position: fixed; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; }
.picker .head { padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.picker .body { overflow: auto; flex: 1; padding: 10px 12px calc(20px + env(safe-area-inset-bottom)); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 30; font-weight: 600; max-width: 90%; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll { overflow: auto; -webkit-overflow-scrolling: touch; }

.login { max-width: 360px; margin: 10vh auto; }
.login .logo { font-size: 40px; text-align: center; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 10px; }
.brand .wordmark { font-size: 20px; font-weight: 600; letter-spacing: .3em; margin-right: -.3em; color: var(--ink); }
@media (prefers-color-scheme: dark) { .brand svg path[fill="#0B2027"], .brand svg path[stroke="#0B2027"] { fill: #eceff3; } .brand svg path[stroke="#0B2027"] { fill: none; stroke: #eceff3; } }
.spin { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp 1s linear infinite; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.vd { text-decoration: line-through; opacity: .6; }
