:root {
  --bg: #f6f7f9; --card: #fff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --good: #16a34a; --ok: #0284c7; --warn: #d97706; --bad: #dc2626; --info: #6b7280;
  --good-bg: #dcfce7; --ok-bg: #e0f2fe; --warn-bg: #fef3c7; --bad-bg: #fee2e2; --info-bg: #f3f4f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #111827; --ink: #e5e7eb; --muted: #9ca3af; --line: #1f2937;
    --good-bg: #052e16; --ok-bg: #082f49; --warn-bg: #451a03; --bad-bg: #450a0a; --info-bg: #1f2937;
    --good: #4ade80; --ok: #38bdf8; --warn: #fbbf24; --bad: #f87171; --info: #9ca3af;
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px 80px; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 8px 0 12px; }
h2 { font-size: 1.05rem; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.top .brand { color: var(--ink); font-weight: 700; }
.top nav { display: flex; gap: 4px; margin-left: auto; }
.top nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.top nav a.active { background: var(--info-bg); color: var(--ink); }
.who { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: .85rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 120px; min-width: 0; }
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 3px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { min-height: 60px; }
button.primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 600; width: 100%; }
button.primary:disabled { opacity: .5; }
button.ghost { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--muted); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
.error { color: var(--bad); font-weight: 600; margin: 8px 0; }

/* login */
.login { max-width: 360px; margin: 60px auto; text-align: center; }
.login input { text-align: center; font-size: 1.3rem; margin: 12px 0; }
.login .names { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }

/* slot rows on the batch form */
.slot { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 10px; }
.slot:first-of-type { border-top: 0; margin-top: 0; }
.slot .head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.slot .head strong { font-size: .9rem; }
.slot .nums { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.cellpick { display: flex; gap: 8px; align-items: center; }
.cellpick select { flex: 1; }
.rating { white-space: nowrap; font-size: .8rem; color: var(--muted); }

/* feedback notes */
.notes { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 5px; }
.notes li { padding: 6px 9px; border-radius: 8px; font-size: .88rem; border-left: 4px solid var(--info); background: var(--info-bg); }
.notes li.good { border-color: var(--good); background: var(--good-bg); }
.notes li.ok   { border-color: var(--ok);   background: var(--ok-bg); }
.notes li.warn { border-color: var(--warn); background: var(--warn-bg); }
.notes li.bad  { border-color: var(--bad);  background: var(--bad-bg); }
.notes li.info { border-color: var(--info); background: var(--info-bg); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.ok   { background: var(--ok-bg);   color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad  { background: var(--bad-bg);  color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }

/* cells list */
.cells { list-style: none; padding: 0; margin: 0; }
.cells li.swipe { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.cells li:last-child { border-bottom: 0; }
.cells .swipe-content { position: relative; z-index: 1; display: grid; grid-template-columns: 4.6rem minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 10px 12px; color: inherit; background: var(--card); touch-action: pan-y; user-select: none; -webkit-user-select: none; will-change: transform; }
.cells .swipe-actions { position: absolute; inset: 0 0 0 auto; width: 96px; display: flex; visibility: hidden; }
.cells .swipe.open .swipe-actions, .cells .swipe.dragging .swipe-actions { visibility: visible; }
.cells .id { overflow-wrap: anywhere; }
.cells .del { flex: 1; border: 0; background: var(--bad); color: #fff; font-weight: 700; font-size: .9rem; }
.cells .swipe-confirm { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--bad-bg); color: var(--ink); font-size: .92rem; visibility: visible; }
.cells .swipe-confirm .btns { display: flex; gap: 6px; flex-shrink: 0; }
.cells .swipe-confirm .del2 { border: 0; background: var(--bad); color: #fff; font-weight: 700; border-radius: 8px; padding: 6px 12px; }
.cells .id { font-weight: 700; font-size: .95rem; }
.cells .mid { font-size: .92rem; line-height: 1.3; }
.cells .meta { color: var(--muted); font-size: .8rem; }
.cells .pct { font-weight: 700; text-align: right; }
.cells .badge { font-size: .68rem; padding: 2px 6px; }

/* add form: serial choice */
.serial-choice { margin-bottom: 10px; }
.serial-choice .radio { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; color: var(--ink); font-size: .95rem; }
.serial-choice .radio input { width: auto; margin: 0; }
.serial-choice input[name=serial] { margin-top: 6px; text-transform: uppercase; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.filters button { border-radius: 999px; padding: 5px 11px; font-size: .85rem; }
.filters button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* detail */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.chart { width: 100%; height: auto; display: block; margin: 6px 0; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .dot { fill: var(--accent); }
.chart .retire { stroke: var(--bad); stroke-dasharray: 4 4; }
.reading { border-top: 1px solid var(--line); padding: 10px 0; }
.reading:first-child { border-top: 0; }
.reading .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.reading .head .when { font-weight: 600; }
.reading .vals { color: var(--muted); font-size: .9rem; }
details summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { display: grid; grid-template-columns: 5.5rem 1fr auto; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.recent li:last-child { border-bottom: 0; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 9; }
.serial-choice input[name=serial]::placeholder { text-transform: none; }
