:root {
  --bg: #16181c;
  --surface: #20232a;
  --surface2: #2a2e37;
  --line: #3a3f4a;
  --text: #f2f3f5;
  --muted: #9aa1ad;
  --accent: #3d8bfd;
  --ok: #1fae5b;
  --over: #f08c00;
  --bad: #e03131;
  --radius: 18px;
  font-family: "Noto Sans Georgian", "BPG Arial", "Sylfaen", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body { user-select: none; -webkit-user-select: none; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.screen.scroll, .scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 64px; }
.brand { font-weight: 700; font-size: 20px; letter-spacing: .5px; color: var(--muted); }
.bar-title { font-size: 20px; font-weight: 600; }
.bar .today { margin-left: auto; }
.today { color: var(--muted); font-size: 16px; }

.icon-btn { position: relative; width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--surface); font-size: 24px; display: grid; place-items: center; }
.gear .ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.gear .ring circle { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 101; stroke-dashoffset: 101; }
.gear.hold .ring circle { transition: stroke-dashoffset 1.5s linear; stroke-dashoffset: 0; }

.back { border: 0; background: var(--surface); border-radius: 14px; padding: 14px 20px; font-size: 18px; min-height: 52px; }

.ask { font-size: clamp(24px, 4vw, 36px); font-weight: 600; margin: 8px 16px 16px; text-align: center; }

.tiles { flex: 1; display: grid; gap: 16px; padding: 0 16px 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); align-content: start; overflow-y: auto; }
.tile { border: 2px solid transparent; background: var(--surface); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 20px 12px; min-height: 180px; font-size: clamp(18px, 2.4vw, 22px); font-weight: 600; text-align: center; }
.tile:active { border-color: var(--accent); background: var(--surface2); }
.tile svg { width: 96px; height: 96px; }
.tile .sub { font-size: 15px; font-weight: 400; color: var(--muted); }
.tile .swatch { width: 72px; height: 72px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); }
.tile.disabled { opacity: .45; }

/* counting layout: camera left, panel right (landscape); stacked in portrait */
.count-layout { flex: 1; display: flex; min-height: 0; }
.view { flex: 1; position: relative; display: grid; place-items: center; background: #000; min-width: 0; min-height: 0; }
.view canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; }
.view-msg { position: absolute; inset: auto 16px 16px; background: rgba(0,0,0,.75); padding: 16px; border-radius: 14px; font-size: 18px; text-align: center; }
.test-badge { position: absolute; top: 12px; left: 12px; background: var(--over); color: #000; font-weight: 700; padding: 6px 12px; border-radius: 10px; }

.panel { width: 340px; flex: none; background: var(--surface); display: flex; flex-direction: column; gap: 16px; padding: 16px;
  transition: background-color .25s; }
.panel-top { display: flex; align-items: center; gap: 12px; }
.product { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.product .dot { width: 18px; height: 18px; border-radius: 50%; flex: none; border: 2px solid rgba(255,255,255,.3); }

.big { text-align: center; line-height: 1; margin-top: 8px; }
.big .num { font-size: clamp(88px, 14vw, 150px); font-weight: 700; font-variant-numeric: tabular-nums; }
.big .of { font-size: 32px; color: var(--muted); margin-left: 8px; }
.big.small .num { font-size: 72px; }
.big.small .of { font-size: 20px; }
.panel.unstable .big .num { opacity: .45; }

.status { font-size: 24px; font-weight: 600; text-align: center; min-height: 2.6em; display: grid; place-items: center; }

.panel.ok { background: var(--ok); }
.panel.over { background: var(--over); color: #111; }
.panel.bad { background: var(--bad); }
.panel.ok .of, .panel.bad .of, .panel.ok .today, .panel.bad .today { color: rgba(255,255,255,.8); }
.panel.over .of, .panel.over .today { color: rgba(0,0,0,.65); }
.panel.ok .back, .panel.over .back, .panel.bad .back,
.panel.ok .targets button, .panel.over .targets button, .panel.bad .targets button { background: rgba(0,0,0,.18); }

.targets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: auto; }
.targets button { border: 3px solid transparent; background: var(--surface2); border-radius: 14px; font-size: 26px; font-weight: 700; padding: 18px 0; }
.targets button.on { border-color: currentColor; }
.panel .today { text-align: center; }

@media (orientation: portrait) {
  .count-layout { flex-direction: column; }
  .panel { width: auto; gap: 10px; }
  .big .num { font-size: clamp(72px, 20vw, 130px); }
  .status { font-size: 21px; min-height: 2.4em; }
  .targets button { padding: 14px 0; }
  .panel.scroll { max-height: 55vh; }
}

/* admin */
.admin { padding: 0 16px 48px; max-width: 760px; width: 100%; margin: 0 auto; }
.admin h2 { font-size: 20px; margin: 28px 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.hint { color: var(--muted); font-size: 15px; margin: 6px 0 12px; line-height: 1.45; }
.row { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-size: 16px; }
.row.check { flex-direction: row; align-items: center; gap: 12px; }
.row.check input { width: 26px; height: 26px; }
.row input[type=range] { width: 100%; height: 32px; }
.row select, .row input[type=text] { background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.row input[type=color] { width: 80px; height: 48px; border: 0; background: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px;
  background: var(--surface2); padding: 14px 20px; font-size: 17px; min-height: 52px; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: #ff8787; }
.btn.sm { padding: 10px 14px; min-height: 44px; font-size: 15px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg button { border: 3px solid transparent; background: var(--surface); border-radius: 14px; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 18px; cursor: pointer; }
.seg button small { color: var(--muted); font-size: 14px; }
.seg button.on { border-color: var(--accent); background: var(--surface2); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.prow { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 14px; padding: 12px; margin: 8px 0; flex-wrap: wrap; }
.prow .dot { width: 28px; height: 28px; border-radius: 50%; flex: none; border: 2px solid rgba(255,255,255,.25); }
.prow .name { flex: 1; min-width: 140px; }
.prow .name small { display: block; color: var(--muted); }
.prow .name small.okc { color: #69db7c; }
.prow .name small.noc { color: #ffa94d; }
.ptype { margin-top: 16px; color: var(--muted); font-size: 15px; display: flex; align-items: center; justify-content: space-between; }

.steps { margin: 0; padding-left: 22px; line-height: 1.5; color: var(--muted); }
.steps b { color: var(--text); }
.ver { margin-top: 32px; font-size: 13px; }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg { padding: 20px; }
.dlg h3 { margin: 0 0 8px; }
