:root {
  --navy: #1F3864; --gold: #F2A900; --bg: #f3f5f9; --card: #fff; --text: #1b2333;
  --muted: #5f6b80; --line: #d9dfe9; --flag: #fff3c4; --flag-line: #e6b800;
  --ok: #1d7a46; --err: #b3261e; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1420; --card: #182033; --text: #e8ecf4; --muted: #9aa6bd; --line: #2b3550;
          --flag: #4a3d08; --flag-line: #c99a00; --ok: #4cc283; --err: #ff8a80; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.hidden { display: none !important; }
.bar { 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(--navy); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.bar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: transparent; border: 0; color: #fff; font-size: 22px; padding: 4px 8px; cursor: pointer; }
.badge { background: var(--gold); color: #1b2333; border-radius: 99px; padding: 3px 10px; font-size: 13px; font-weight: 600; }
.screen { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(40px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
h1 { margin: 0 0 6px; font-size: 22px; } h2 { margin: 0 0 8px; font-size: 18px; }
.muted { color: var(--muted); } .small { font-size: 14px; margin-top: 0; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
label.check input { width: auto; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy); outline-offset: 1px; }
input[name="serial"], input[name="assetTag"], input[name="otherIds"] { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; }
.flagged { background: var(--flag) !important; border-color: var(--flag-line) !important; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
button, .btn { font: inherit; font-weight: 600; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; text-align: center; }
.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.danger { color: var(--err); }
.wide { flex: 1 1 auto; width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }
.file-btn { flex: 1 1 140px; margin: 0; font-size: 16px; }
.file-btn.primary { color: #fff; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 10px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; padding: 0; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff; border: 0; font-size: 16px; line-height: 28px; }
.thumb .bc { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.msg { min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.msg.ok { color: var(--ok); } .msg.err { color: var(--err); }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.recent li:first-child { border-top: 0; }
.recent .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.sheet { width: 100%; max-width: 480px; margin: 0; }
#viewer { align-items: center; background: rgba(0,0,0,.9); }
#viewer img { max-width: 100%; max-height: 100%; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: #1b2333; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
input[type="file"], [hidden] { display: none !important; }
.btn-row .wide { width: auto; flex: 1 1 60%; }
#readBtn.wide { width: 100%; }
.next-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; justify-content: center; }
.next-bar button { width: 100%; max-width: 728px; font-size: 18px; padding: 15px; }
#app { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.warn { color: #b07d00; font-weight: 600; }
.recent li.st-reading, .recent li.st-waiting { opacity: .8; }
.recent li.st-error { color: var(--err); }
