:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #17202a;
  --muted: #5d6b7a;
  --line: #dde3ea;
  --brand: #0f61a1;
  --brand-ink: #ffffff;
  --sel: #e3effa;
  --ok: #1e7a3c;
  --warn: #9a6200;
  --bad: #b3261e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --card: #1a2129;
    --text: #e6ebf0;
    --muted: #9aa8b6;
    --line: #2c3640;
    --brand: #4d9de0;
    --brand-ink: #0b1218;
    --sel: #1d3347;
    --ok: #5cc27e;
    --warn: #e3a83a;
    --bad: #ff8a80;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--card); }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink);
}
.brand { font-weight: 700; }
.who { font-size: 14px; display: flex; gap: 8px; align-items: center; min-width: 0; }
.who #agent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .link { color: var(--brand-ink); }
.link { background: none; border: 0; padding: 6px 4px; text-decoration: underline; color: var(--brand); }

.banner { margin: 12px 16px 0; padding: 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--bad); color: var(--bad); }
.banner a, .banner button { color: inherit; font-weight: 600; }

.setup { margin: 12px 16px 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.setup summary { padding: 12px 14px; font-weight: 600; cursor: pointer; }
.grid { display: grid; gap: 12px; padding: 0 14px 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); position: relative; }
.field em { font-style: normal; opacity: .8; }
.field input, .field select, #user-search {
  min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%;
}
.dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 4; margin: 2px 0 0; padding: 4px 0; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; max-height: 280px; overflow: auto;
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
}
.dropdown li { padding: 12px; color: var(--text); cursor: pointer; }
.dropdown li:hover, .dropdown li.active { background: var(--sel); }

.tabs { display: flex; gap: 4px; margin: 12px 16px 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.tabs button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: none; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); }
.pill { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 99px; font-size: 12px; background: rgba(127,127,127,.25); }
.pill:empty { display: none; }

main { padding: 12px 16px 40px; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 2px 12px; }
.muted { color: var(--muted); font-size: 14px; }
h2 { font-size: 16px; margin: 0; }
.pane-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 8px; }

.scan-box { display: flex; gap: 8px; }
.scan-box input {
  flex: 1; min-width: 0; min-height: 52px; padding: 10px 14px; font-size: 18px;
  border: 2px solid var(--brand); border-radius: 10px;
}
.icon { min-width: 52px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 20px; }
.icon[aria-pressed="true"] { background: var(--sel); border-color: var(--brand); }

.list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.list .main { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }
.list .sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.list .empty { justify-content: center; color: var(--muted); border-style: dashed; }
.selectable li[data-id] { cursor: pointer; user-select: none; }
.selectable li.selected { background: var(--sel); border-color: var(--brand); }
.check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 14px; }
.selected .check { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.users li { cursor: pointer; }
.users li:hover, .users li.drop { background: var(--sel); border-color: var(--brand); }
.users.disabled li { cursor: default; opacity: .6; }

.status { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; white-space: nowrap; border: 1px solid currentColor; }
.s-pending, .s-working { color: var(--muted); }
.s-done { color: var(--ok); }
.s-duplicate, .s-conflict { color: var(--warn); }
.s-error { color: var(--bad); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.btn { min-height: 36px; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-size: 14px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.assign-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .assign-grid { grid-template-columns: 1fr 1fr; } }
#user-search { margin-bottom: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 10;
}

.mode { display: flex; gap: 6px; margin-bottom: 10px; }
.mode button { flex: 1; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 14px; font-weight: 600; color: var(--muted); }
.mode button[aria-checked="true"] { border-color: var(--brand); background: var(--sel); color: var(--text); }
.pick { margin: 4px 0 14px; padding: 12px; border: 2px solid var(--brand); border-radius: 12px; background: var(--card); }
.pick #single-search { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; }

/* Camera scanner */
.camera { position: fixed; inset: 0; z-index: 20; background: #000; color: #fff; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-frame {
  position: absolute; left: 8%; right: 8%; top: 38%; height: 18%;
  border: 3px solid #fff; border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45);
}
.camera.hit .cam-frame { border-color: #5cc27e; }
.cam-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(16px + env(safe-area-inset-top)) 16px 16px; text-align: center; font-weight: 600; }
.cam-bottom { position: absolute; bottom: 0; left: 0; right: 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.cam-actions { display: flex; gap: 10px; justify-content: center; }
.cam-actions .btn { min-height: 48px; min-width: 120px; font-size: 16px; color: var(--text); }
.cam-confirm { background: rgba(0,0,0,.75); border-radius: 12px; padding: 12px; text-align: center; }
.cam-read { margin-bottom: 10px; font-size: 18px; overflow-wrap: anywhere; }
.cam-actions .btn.primary { color: var(--brand-ink); }

.batch { margin: 8px 2px 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.batch .link { font-size: 14px; }

/* Next313 attribution, pinned to the bottom (same block as the Next313 platform). */
.built-by {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center; gap: 5px; flex-wrap: wrap;
  padding: 6px 16px calc(6px + env(safe-area-inset-bottom));
  font-size: 0.68rem; color: var(--muted);
  background: var(--bg); border-top: 1px solid var(--line);
}
.built-by a { display: inline-flex; line-height: 0; }
.built-by .n313-badge { width: 24px; height: 24px; display: block; transition: transform 0.15s; }
.built-by a:hover .n313-badge { transform: scale(1.12); }
.built-by .built-meta { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Keep the last list item and the toast clear of the pinned footer. */
main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.toast { bottom: calc(56px + env(safe-area-inset-bottom)); }
