:root {
  --bg: #f6f5f2; --surface: #ffffff; --surface-2: #f0eee9; --ink: #1d1c1a; --muted: #6b6760; --line: #e1ddd5;
  --accent: #2f5d50; --accent-ink: #ffffff; --warn-bg: #fff4d6; --warn-line: #e0b100; --warn-ink: #5c4600;
  --bad: #a3322a; --bad-bg: #fbe9e7; --good: #2f6b3a; --good-bg: #e6f2e7; --info-bg: #e8eef7; --info-ink: #24426b;
  --radius: 12px; --tap: 44px; --gutter: 16px;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151514; --surface: #1f1e1c; --surface-2: #2a2926; --ink: #ecebe7; --muted: #a29e96; --line: #36342f;
    --accent: #7fb8a5; --accent-ink: #0d1b16; --warn-bg: #3a3112; --warn-line: #8a6d00; --warn-ink: #f3dc8a;
    --bad: #f0958c; --bad-bg: #3b1d1a; --good: #8fd19a; --good-bg: #1b3020; --info-bg: #1d2a3b; --info-ink: #b9cdea;
  }
}
:root[data-theme="dark"] {
  --bg: #151514; --surface: #1f1e1c; --surface-2: #2a2926; --ink: #ecebe7; --muted: #a29e96; --line: #36342f;
  --accent: #7fb8a5; --accent-ink: #0d1b16; --warn-bg: #3a3112; --warn-line: #8a6d00; --warn-ink: #f3dc8a;
  --bad: #f0958c; --bad-bg: #3b1d1a; --good: #8fd19a; --good-bg: #1b3020; --info-bg: #1d2a3b; --info-ink: #b9cdea;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); overflow-x: hidden; overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 4px 0 12px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
h3 { font-size: .95rem; margin: 12px 0 6px; }
.synthetic { background: var(--warn-bg); color: var(--warn-ink); border-bottom: 1px solid var(--warn-line); padding: 6px var(--gutter); font-size: .8rem; text-align: center; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: calc(8px + env(safe-area-inset-top)) calc(var(--gutter) + env(safe-area-inset-right)) 8px calc(var(--gutter) + env(safe-area-inset-left)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); flex: 0 0 auto; min-height: var(--tap); display: inline-flex; align-items: center; }
.who { font-size: .8rem; color: var(--muted); text-align: right; min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.who > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who > a { flex: 0 0 auto; min-height: var(--tap); display: inline-flex; align-items: center; white-space: nowrap; }
.view { max-width: 980px; margin: 0 auto; padding: 12px calc(var(--gutter) + env(safe-area-inset-right)) 24px calc(var(--gutter) + env(safe-area-inset-left)); min-width: 0; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.nav::-webkit-scrollbar { display: none; }
.nav a { flex: 1 0 72px; min-width: 72px; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .64rem; color: var(--muted); text-decoration: none; padding: 4px 1px; }
.nav .lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .7rem; }
.nav a.on { color: var(--accent); font-weight: 600; }
.nav .ico { font-size: 1.15rem; line-height: 1; }
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 200px; }
  .nav { top: 0; bottom: 0; right: auto; width: 200px; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 60px 0 env(safe-area-inset-bottom) env(safe-area-inset-left); overflow-x: hidden; overflow-y: auto; }
  .nav .lbl { font-size: inherit; }
  .nav a { flex: 0 0 auto; min-width: 0; flex-direction: row; justify-content: flex-start; gap: 10px; font-size: .9rem; padding: 0 18px; min-height: 46px; }
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.card.link { display: block; text-decoration: none; color: inherit; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); font-size: .85rem; }
.small { font-size: .8rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; word-break: break-all; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-decoration: none; color: inherit; min-height: 84px; display: flex; flex-direction: column; justify-content: space-between; }
.tile .n { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .l { font-size: .8rem; color: var(--muted); }
.tile.off .n { color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.info { background: var(--info-bg); color: var(--info-ink); }
.notice { border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; font-size: .9rem; background: var(--info-bg); color: var(--info-ink); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
button, .btn { min-height: var(--tap); padding: 8px 16px; line-height: 1.25; text-align: center; touch-action: manipulation; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
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:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions > * { flex: 1 1 140px; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; max-width: 100%; min-height: var(--tap); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: max(16px, 1rem); }
textarea { min-height: 80px; }
input[type="checkbox"] { width: 28px; min-height: 28px; height: 28px; flex: 0 0 auto; margin: 8px; accent-color: var(--accent); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 8px 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chips button { min-height: var(--tap); padding: 0 12px; border-radius: 999px; font-weight: 500; white-space: nowrap; flex: 0 0 auto; }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.line { border-top: 1px solid var(--line); padding: 10px 0; }
.line:first-child { border-top: 0; }
.kv { display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 60%); gap: 4px 10px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.qty { max-width: 140px; }
.hist { font-size: .82rem; border-left: 2px solid var(--line); padding-left: 10px; margin: 6px 0; }
.sheet { border: 0; border-radius: 16px; padding: 16px; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; background: var(--surface); color: var(--ink); }
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 10; max-width: calc(100vw - 32px); font-size: .9rem; }
.toast.bad { background: var(--bad); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.pin { letter-spacing: .4em; font-size: 1.4rem; text-align: center; }
table.lines { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table.lines th, table.lines td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
@media (max-width: 599px) { .wide-only { display: none; } }
.pick { width: 100%; text-align: left; justify-content: flex-start; font-weight: 500; }

.card.late{border-left:4px solid var(--warn, #b7791f)}
/* users screen */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; min-width: 0; }

/* ---- responsive / touch ---- */
summary { min-height: var(--tap); display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "\25B8"; color: var(--muted); }
details[open] > summary::before { content: "\25BE"; }
.card, .tile, .grow, .kv > * { min-width: 0; }
.row > * { min-width: 0; }
h1 { overflow-wrap: anywhere; }
img, video, canvas, svg { max-width: 100%; height: auto; }
/* Save / submit bar stays reachable above the bottom nav on long forms */
.actions.sticky-bottom { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 4; margin: 12px calc(-1 * var(--gutter)) 0; padding: 10px var(--gutter); background: var(--bg); border-top: 1px solid var(--line); box-shadow: 0 -6px 12px rgba(0, 0, 0, .12); }
@media (min-width: 900px) { .actions.sticky-bottom { bottom: 0; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; } }
@media (max-width: 380px) { :root { --gutter: 12px; } .tile .n { font-size: 1.5rem; } .card { padding: 12px; } }
@media (max-width: 599px) { .grid2 { grid-template-columns: minmax(0, 1fr); } .kv { grid-template-columns: minmax(0, 38%) minmax(0, 62%); } }
