[hidden] { display: none !important; }
:root {
  --bg: #f6f1ea; --card: #ffffff; --ink: #2a1a12; --muted: #7a6a5f; --line: #e6dccf;
  --brand: #3b2418; --accent: #a8652f; --accent-ink: #fff;
  --ok: #2f7d4f; --warn: #b7791f; --bad: #b3362b; --info: #2c5d8a;
  --ok-bg: #e5f2ea; --warn-bg: #fbf0dc; --bad-bg: #f8e3e0; --info-bg: #e3edf6;
  --radius: 14px; --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17110d; --card: #221a15; --ink: #f2e9e1; --muted: #a8988c; --line: #3a2e26;
    --brand: #0f0a07; --accent: #d08a4f; --accent-ink: #1a110b;
    --ok-bg: #18301f; --warn-bg: #3a2c12; --bad-bg: #3c1a16; --info-bg: #15283a;
    --ok: #6cc28f; --warn: #e6b05a; --bad: #ec7b6f; --info: #7fb2e0;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: #f6e7d6;
}
.brand { font-weight: 700; letter-spacing: .3px; }
.brand small { font-weight: 500; opacity: .6; margin-left: 4px; }
.logo { color: var(--accent); }
.badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.12); }
main { padding: 14px 16px 24px; max-width: 760px; margin: 0 auto; }
h2 { font-size: 20px; margin: 6px 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs button {
  border: 0; background: none; color: var(--muted); font-size: 11px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.tabs button span { font-size: 20px; line-height: 1; }
.tabs button.on { color: var(--accent); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

button.btn, a.btn, label.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .45; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 9px 4px; border-radius: 9px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.seg button.on { background: var(--card); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.12); }

input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
label.f { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label.f > input, label.f > select { margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.camera { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; }
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera .frame {
  position: absolute; left: 6%; right: 6%; top: 22%; bottom: 22%; border: 2px solid rgba(255,255,255,.85);
  border-radius: 10px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); pointer-events: none;
}
.camera .frame.hit { border-color: #5bd38a; }
.camera .hint { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; color: #fff; font-size: 13px; text-shadow: 0 1px 2px #000; }
.camera.off { display: grid; place-items: center; color: #cbb; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 11px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.tap { cursor: pointer; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.neutral { background: var(--line); color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi b { display: block; font-size: 24px; }
.kpi span { font-size: 13px; color: var(--muted); }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto;
}
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom)); z-index: 30;
  background: #2a1a12; color: #fff; padding: 12px 14px; border-radius: 12px; display: flex; gap: 10px; align-items: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 728px; margin: 0 auto;
}
.toast button { background: none; border: 0; color: #f0b27a; font: inherit; font-weight: 700; cursor: pointer; margin-left: auto; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.note { font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--info-bg); color: var(--info); }
