:root {
  color-scheme: light;
  --bg: #eff4f2; --surface: #ffffff; --soft: #e6efeb; --ink: #122c29; --muted: #415d56;
  --line: #c8d8d0; --accent: #00614e; --accent-hover: #004c3d; --on-accent: #ffffff;
  --amber: #61400a; --amber-bg: #f8ebc9; --green: #185841; --green-bg: #dcefe3;
  --red: #811c33; --red-bg: #fae4e9; --ring: #00614e;
  --shadow: 0 12px 35px #17383112;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101e1d; --surface: #192b29; --soft: #223a35; --ink: #edf8f3; --muted: #b2cac1;
  --line: #405d54; --accent: #9ce8cc; --accent-hover: #bbf1dd; --on-accent: #10372c;
  --amber: #ffe0a0; --amber-bg: #503612; --green: #b3ebcb; --green-bg: #254c3c;
  --red: #ffc0ca; --red-bg: #502632; --ring: #9ce8cc;
  --shadow: 0 12px 35px #0004;
}
* { box-sizing: border-box; }
html { min-width: 280px; min-height: 100%; background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); background: var(--bg); font-size: 15px; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; color: var(--ink); -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .63; }
button:focus-visible, input:focus-visible, summary:focus-visible, .scroll:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.boot { margin: 2rem auto; width: min(90%, 480px); color: var(--muted); }
.shell {
  width: min(100%, 580px); height: 100vh; height: 100dvh; margin-inline: auto;
  display: flex; flex-direction: column; overflow: hidden;
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
  border-inline: 1px solid var(--line); background: var(--bg);
}
.top { padding: calc(8px + var(--safe-top)) 15px 8px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { min-width: 0; flex: 1; }
.brand strong { display: block; font-size: 17px; line-height: 1.1; font-weight: 800; letter-spacing: -.04em; }
.brand small { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; color: var(--muted); font-size: 11px; margin-top: 4px; font-weight: 650; }
.network-label { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 100%; background: var(--accent); flex: none; }
.dot.offline { background: var(--amber); }
.icon-button, .btn, .search, .chip, .nav-button, .square, .key, .action, .record, .check-row, .archive-option {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; min-height: 44px;
}
.icon-button, .square { display: inline-grid; place-items: center; flex: none; width: 44px; padding: 0; font-size: 20px; font-weight: 650; }
.top .icon-button { background: var(--soft); }
.back { font-size: 23px; }
.scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 9px 15px 15px; }
.shell.no-dock .scroll { padding-bottom: calc(16px + var(--safe-bottom)); }
.page-title { font-size: clamp(26px, 7vw, 32px); line-height: 1.13; margin: 4px 0 12px; letter-spacing: -.052em; overflow-wrap: anywhere; }
.page-title.number { font-variant-numeric: tabular-nums; }
.view-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 8px; }
.view-heading h2, .panel h2 { font-size: 16px; margin: 0; letter-spacing: -.025em; }
.heading-actions { display: flex; align-items: center; gap: 6px; }
.home-operation { font-size: 13px; }
.count { font-size: 12px; font-weight: 730; text-align: center; }
.pill { display: inline-block; padding: 4px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.searchbar { display: grid; grid-template-columns: minmax(0, 1fr) 56px; gap: 7px; }
.search, .searchbar .square { min-height: 56px; width: 100%; }
.search { text-align: left; padding: 0 11px; font-size: 22px; font-weight: 780; letter-spacing: .04em; min-width: 0; font-variant-numeric: tabular-nums; }
.search.placeholder { color: var(--muted); font-size: 16px; font-weight: 650; letter-spacing: 0; }
.search.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.muted { color: var(--muted); }
p { line-height: 1.45; margin: 0 0 12px; }
.empty { border: 1px dashed var(--line); border-radius: 13px; padding: 19px 15px; color: var(--muted); line-height: 1.45; }
.empty strong { display: block; color: var(--ink); margin-bottom: 3px; font-size: 15px; }
.rows, .actions, .events { display: grid; gap: 7px; }
.record, .check-row, .archive-option { width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 10px; text-align: left; }
.record-body { flex: 1; min-width: 0; }
.record-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; margin-bottom: 4px; }
.record-title strong { font-size: 18px; font-weight: 800; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.record-title .location-inline { color: var(--accent); font-size: 13px; font-weight: 800; overflow-wrap: anywhere; min-width: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { border-radius: 5px; padding: 2px 5px; font-size: 11px; font-weight: 720; line-height: 1.45; color: var(--muted); background: var(--soft); }
.tag.pending { color: var(--amber); background: var(--amber-bg); }
.tag.loaded { color: var(--green); background: var(--green-bg); }
.chevron { color: var(--muted); font-size: 23px; line-height: 1; }
.dock { flex: none; border-top: 1px solid var(--line); padding: 8px 15px calc(8px + var(--safe-bottom)); background: var(--bg); }
.home-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.nav-button { min-height: 50px; font-size: 14px; font-weight: 770; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 4px 7px; }
.nav-button.primary, .btn.primary, .action.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.nav-button .badge { border-radius: 999px; background: var(--on-accent); color: var(--accent); padding: 2px 7px; min-width: 23px; font-size: 12px; line-height: 1.4; font-variant-numeric: tabular-nums; }
.keypad { background: var(--soft); }
.keypad-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin: -3px 0 3px; }
.keypad-top span { font-size: 12px; font-weight: 750; color: var(--muted); }
.keypad-top button { border: 0; background: transparent; min-height: 44px; padding: 0 7px; font-weight: 760; font-size: 13px; }
.keypad.permanent { padding-top: 7px; }
.keypad.permanent .keypad-top { display: none; }
.keygrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.key { min-height: 44px; padding: 2px; background: var(--surface); color: var(--ink); font-size: 20px; font-weight: 780; font-variant-numeric: tabular-nums; }
.key.utility { background: var(--bg); color: var(--ink); }
.key.submit { grid-column: 1 / -1; background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-size: 15px; }
.detail-strip, .panel, .event { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 12px; margin-bottom: 10px; }
.detail-strip > strong { display: block; font-size: 20px; overflow-wrap: anywhere; margin-bottom: 8px; }
.action { font-weight: 740; text-align: left; padding: 9px 12px; min-height: 49px; }
.actions .action:disabled { opacity: .52; }
.row-help { margin: 4px 0 0; font-size: 13px; }
.btn { font-weight: 740; padding: 7px 12px; }
.btn.full { width: 100%; min-height: 48px; }
.btn.link { border-color: transparent; background: transparent; color: var(--accent); }
.btn.danger { background: var(--red-bg); color: var(--red); border-color: var(--line); }
.button-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.button-row > .btn { flex: 1 1 auto; }
.locations { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.chip { padding: 4px; overflow-wrap: anywhere; font-weight: 780; }
.chip[aria-pressed="true"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.location-legend { font-size: 12px; line-height: 1.4; margin: 6px 0 8px; overflow-wrap: anywhere; }
.fields { display: grid; gap: 9px; }
.fields label { display: grid; gap: 4px; font-weight: 700; }
.fields input { width: 100%; min-height: 46px; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 16px; }
.archive-option { min-height: 57px; font-weight: 770; gap: 10px; justify-content: space-between; }
.archive-option small { display: block; font-weight: 550; color: var(--muted); margin-top: 3px; }
.shelf-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.shelf-card {
  display: grid; justify-items: center; align-content: center; gap: 4px;
  min-height: 64px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.shelf-card strong { font-size: 16px; overflow-wrap: anywhere; max-width: 100%; }
.shelf-heading { margin-top: 0; }
.shelf-heading .page-title { margin-bottom: 4px; }
.checkbox { display: grid; place-items: center; font-size: 23px; line-height: 1; font-weight: 800; border: 2px solid var(--muted); border-radius: 9px; width: 44px; height: 44px; flex: none; }
.check-row[aria-pressed="true"] .checkbox { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.check-row { min-height: 63px; }
.event { margin: 0; }
.event header { display: flex; justify-content: space-between; gap: 5px 9px; align-items: baseline; flex-wrap: wrap; }
.event time { font-size: 12px; color: var(--muted); }
.event p { font-size: 13px; margin: 5px 0 0; }
.inventory-header { display: flex; justify-content: space-between; gap: 7px; align-items: center; }
.inventory-header h1 { margin-bottom: 8px; }
.inventory-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.observation { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 3px 6px 3px 10px; gap: 5px; }
.observation strong { flex: 1; font-variant-numeric: tabular-nums; }
.observation .icon-button { min-width: 44px; }
.compare-grid { display: grid; gap: 7px; }
.compare { border: 1px solid var(--line); border-radius: 10px; padding: 9px; background: var(--surface); }
.compare strong { display: block; padding-bottom: 4px; }
.compare.missing { color: var(--red); background: var(--red-bg); }
.compare.added { color: var(--green); background: var(--green-bg); }
.compare p { margin-bottom: 0; font-size: 13px; overflow-wrap: anywhere; }
.message { border-radius: 10px; padding: 8px 10px; font-size: 13px; font-weight: 680; line-height: 1.4; display: flex; align-items: center; justify-content: space-between; gap: 5px 7px; }
.message.ok { color: var(--green); background: var(--green-bg); }
.message.error { color: var(--red); background: var(--red-bg); }
.notice { padding: 0 15px 6px; background: var(--bg); }
.notice.no-dock { padding-bottom: calc(6px + var(--safe-bottom)); }
.settings-actions { display: grid; gap: 7px; }
.access-heading { margin-top: 0; }
.access-heading .page-title { margin-bottom: 4px; }
[data-challenge] { min-height: 64px; }
@media (min-width: 650px) and (min-height: 700px) {
  .shell { margin-block: 16px; height: calc(100vh - 32px); height: calc(100dvh - 32px); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
  .top, .scroll, .dock { padding-inline: 19px; }
}
@media (max-width: 360px) {
  .top, .scroll, .dock { padding-inline: 10px; }
  .locations { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
