:root {
  --bg: #f6f6f4; --card: #ffffff; --fg: #1d1d1b; --muted: #6b6b66; --line: #dcdcd6;
  --accent: #2f6fed; --accent-fg: #ffffff; --accent-soft: #e6eefd;
  --ok: #1f8a4c; --warn: #b26a00; --err: #c0392b;
  --tabs-h: 60px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413; --card: #1f1f1d; --fg: #ececea; --muted: #9a9a94; --line: #33332f;
    --accent: #6b9bff; --accent-fg: #0d1526; --accent-soft: #1d2a45;
    --ok: #4cc27f; --warn: #f0a640; --err: #ff6b5b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: -.01em; }
main { max-width: 560px; margin: 0 auto; padding: 14px 16px 24px; }
h2 { font-size: 16px; margin: 16px 0 6px; }
h2:first-child { margin-top: 0; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 12px;
}
.center { text-align: center; }
label, .label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
.card > label:first-child, .card > .label:first-child, .card > div:first-child > label { margin-top: 0; }
input, select {
  width: 100%; font: inherit; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg); min-height: 44px;
}
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button {
  font: inherit; font-weight: 600; border-radius: 12px; min-height: 48px; padding: 0 16px;
  width: 100%; cursor: pointer; border: 1px solid transparent; margin-top: 10px;
}
button.primary { background: var(--accent); color: var(--accent-fg); }
button.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
button.danger { background: transparent; color: var(--err); border-color: var(--line); }
button.small { width: auto; min-height: 44px; margin-top: 0; font-weight: 500; }
button:disabled { opacity: .45; cursor: default; }
button:active:not(:disabled) { transform: scale(.99); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  flex: 1; margin: 0; border: 0; border-radius: 0; min-height: 42px; font-weight: 500;
  background: var(--bg); color: var(--fg);
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }

.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.error { color: var(--err); font-size: 14px; margin: 8px 0; white-space: pre-wrap; }
.error.warn { color: var(--warn); }
.card.error { margin: 0 0 12px; border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.printer .details { margin-top: 10px; }
.ok { color: var(--ok); }
.big { font-size: 18px; font-weight: 600; margin: 12px 0 4px; }

.spinner {
  width: 34px; height: 34px; margin: 8px auto 0; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.steps { text-align: left; margin: 12px 0 0; padding-left: 22px; color: var(--muted); font-size: 14px; }
.steps li:last-child { color: var(--fg); font-weight: 500; }

.file-name { font-weight: 600; margin: 0 0 10px; word-break: break-word; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats .num { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats .unit { font-size: 12px; color: var(--muted); }
.details { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; word-break: break-word; }
.details dd.changed { color: var(--warn); font-weight: 600; }
.check { display: flex; gap: 12px; align-items: flex-start; color: var(--fg); font-size: 15px; margin: 0; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 1px 0 0; flex: none; accent-color: var(--accent); }

.list { list-style: none; margin: 0; padding: 0; }
.job { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.job .main { flex: 1; min-width: 0; }
.job .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .meta { font-size: 13px; color: var(--muted); }
.badge {
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent);
}
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.err { background: color-mix(in srgb, var(--err) 15%, transparent); color: var(--err); }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); color: var(--err); }

.printer h2 { margin: 0; }
.printer .state { font-size: 14px; color: var(--muted); margin: 2px 0 10px; }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 6px 0; }
.bar > span { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 11px; min-width: 0;
}
.tabs svg { width: 24px; height: 24px; fill: currentColor; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* pairing QR code: always dark on white, whatever the theme, so every camera reads it */
.qr { background: #fff; border-radius: 12px; padding: 12px; margin: 14px auto 0; width: max-content; max-width: 100%; }
.qr svg { display: block; width: 240px; max-width: 100%; height: auto; }
#pair-manual { word-break: break-all; }

.profiles { margin-top: 12px; }
.profiles li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.profiles .main { flex: 1; min-width: 0; }
.profiles .name { font-weight: 600; word-break: break-word; }
.profiles .meta { font-size: 13px; color: var(--muted); }
.profiles button { width: auto; margin: 0; min-height: 40px; }
