:root {
  --brand: #fde101;
  --brand-ink: #1b1b1b;
  --bg: #f6f6f4;
  --card: #ffffff;
  --ink: #1b1b1b;
  --muted: #6b6a66;
  --line: #e3e2dd;
  --primary: #1b1b1b;
  --primary-ink: #ffffff;
  --link: #1f4fd8;
  --good: #1b7f4b;
  --bad: #c0392b;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211; --card: #1c1c1a; --ink: #f1f0ec; --muted: #a09f98; --line: #2f2f2c;
    --primary: #fde101; --primary-ink: #1b1b1b; --link: #8aa8ff; --good: #5fcf94; --bad: #ff8576;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
.boot { text-align: center; margin-top: 30vh; color: var(--muted); }

/* shell */
.topbar { background: var(--brand); color: var(--brand-ink); display: flex; align-items: center; gap: 10px; padding: 10px 16px; position: sticky; top: 0; z-index: 5; }
.topbar img { width: 34px; height: 34px; border-radius: 8px; }
.topbar .name { font-weight: 700; font-size: 18px; flex: 1; }
.topbar .who { font-size: 13px; opacity: .8; }
main { max-width: 760px; margin: 0 auto; padding: 14px 14px 90px; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; z-index: 5; padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; text-align: center; padding: 10px 4px; font-size: 13px; color: var(--muted); text-decoration: none; }
.nav a.on { color: var(--ink); font-weight: 700; box-shadow: inset 0 3px 0 var(--brand); }
@media (min-width: 860px) {
  .nav { position: sticky; top: 54px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); justify-content: center; }
  .nav a { flex: 0 0 120px; }
  main { padding-bottom: 40px; }
}

/* type + layout */
h1 { font-size: 24px; margin: 14px 0 6px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
h3 { font-size: 16px; margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.primary-text { color: var(--link); font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.grow { flex: 1; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 22px 0 6px; }

/* cards + lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.cards > .card + .card { margin-top: 10px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; }
.stat b { font-size: 22px; }
.big { font-size: 44px; font-weight: 800; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.kv span:first-child { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); }
.list-item { padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }

/* controls */
button, .btn { font: inherit; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 600; }
button.link { border: 0; background: none; color: var(--link); padding: 6px 8px; }
button.chip { border-radius: 99px; padding: 6px 12px; font-size: 14px; }
button.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }
.full { width: 100%; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel], input[type=number], input[type=date] {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type=file] { width: 100%; }
.tabs { display: flex; gap: 6px; margin: 0 0 14px; }
.msg { padding: 10px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); margin: 10px 0; }
.msg.err { border-color: var(--bad); color: var(--bad); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--ink); animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login { max-width: 420px; margin: 0 auto; padding: 36px 18px; }
.login .logo { width: 72px; height: 72px; border-radius: 16px; display: block; margin: 0 auto 8px; }
.login h1 { text-align: center; }

/* pdf viewer + scan tray */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; display: flex; flex-direction: column; }
.viewer .bar { background: var(--card); padding: 8px 12px; display: flex; gap: 8px; align-items: center; }
.viewer iframe, .viewer object { flex: 1; border: 0; background: #fff; width: 100%; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.thumbs .t { position: relative; width: 74px; height: 98px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumbs button { position: absolute; top: 2px; right: 2px; padding: 0 6px; border-radius: 99px; font-size: 14px; line-height: 20px; }
.file-lbl { display: inline-block; }
.file-lbl input { display: none; }

.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.center { text-align: center; }

.row input[type=number] { width: 90px; }

textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; }
.bad { color: var(--bad); }
