:root {
  --green: #25a340;
  --button: #1d8a36;
  --red: #c62828;
  --bg: #ffffff;
  --surface: #f2f2f0;
  --text: #1b1b1b;
  --muted: #6b6b6b;
  --line: #d9d9d6;
  --warn-bg: #fff3e0;
  --warn: #b25b00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --button: #4cc764;
    --bg: #121212;
    --surface: #232323;
    --text: #f0f0f0;
    --muted: #a0a0a0;
    --line: #3a3a3a;
    --warn-bg: #3a2a12;
    --warn: #ffb74d;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  background: var(--bg);
  color: var(--text);
  padding: calc(env(safe-area-inset-top) + 40px) 16px calc(env(safe-area-inset-bottom) + 84px);
}
h1 { font-size: 24px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 24px 0 8px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); font-size: 15px; }
.error { color: var(--red); }

/* ---------- status line on top ---------- */
#status {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px;
}
#status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); flex: none; }
#status.waiting #status-dot { background: #f0a020; }
#status.problem #status-dot { background: var(--red); }
#status.problem { color: var(--red); }

/* ---------- inputs ---------- */
label { display: block; font-size: 15px; color: var(--muted); margin: 12px 0; }
input, textarea {
  display: block; width: 100%; margin-top: 4px;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
input:focus, textarea:focus { outline: 2px solid var(--green); border-color: transparent; }
textarea { resize: vertical; margin: 12px 0; }
input.customer { font-size: 26px; font-weight: 600; text-align: center; letter-spacing: 1px; padding: 14px; }

button {
  font: inherit; font-weight: 600; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; background: var(--surface); color: var(--text);
}
button.primary { background: var(--button); border-color: var(--button); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary { color: #0b2a12; } }
button.wide { display: block; width: 100%; margin: 12px 0; }
button:active { transform: scale(0.97); }
.row { display: flex; gap: 12px; align-items: center; }
.row.two > * { flex: 1; }

/* ---------- timer ---------- */
.timer-area { display: flex; flex-direction: column; align-items: center; margin: 28px 0 12px; }
.timer {
  width: 200px; height: 200px; border-radius: 50%; border: none;
  font-size: 34px; letter-spacing: 2px; color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.timer.start { background: var(--green); }
.timer.stop { background: var(--red); }
.timer-info { margin-top: 14px; font-size: 20px; text-align: center; min-height: 28px; }
.timer-info .since { text-decoration: underline dotted; }
.timer-info .elapsed { display: block; font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
#timer-extras[hidden] { display: none; }

.photo-button {
  display: inline-block; margin: 0; padding: 12px 18px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); font-weight: 600; font-size: 17px;
}
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; }

/* ---------- lists ---------- */
.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px;
}
.history li .state { flex: none; width: 22px; text-align: center; }
.history li .what { flex: 1; overflow-wrap: anywhere; }
.history li button { padding: 6px 10px; font-size: 14px; flex: none; }

/* ---------- stock ---------- */
#scan-video { width: 100%; border-radius: 12px; background: #000; margin-top: 12px; }
.article { font-size: 20px; font-weight: 600; margin: 16px 0; padding: 14px; background: var(--surface); border-radius: 12px; }
.article small { display: block; font-size: 15px; font-weight: 400; color: var(--muted); }
.qty { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 12px 0; }
.qty input { width: 110px; text-align: center; font-size: 26px; font-weight: 600; margin: 0; }
button.round { width: 56px; height: 56px; border-radius: 50%; font-size: 28px; padding: 0; }

/* ---------- tab bar ---------- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button {
  flex: 1; border: none; border-radius: 0; background: none; padding: 8px 0 10px;
  font-size: 12px; font-weight: 500; color: var(--muted); display: flex; flex-direction: column; align-items: center;
}
#tabs button span { font-size: 24px; line-height: 30px; }
#tabs button.active { color: var(--green); font-weight: 700; }
body.login #tabs { display: none; }

/* ---------- toast + dialog ---------- */
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 9;
  background: var(--text); color: var(--bg); padding: 14px 16px; border-radius: 12px; font-weight: 600;
  text-align: center;
}
dialog { border: none; border-radius: 16px; padding: 20px; width: min(90vw, 360px); background: var(--bg); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog input { font-size: 26px; text-align: center; margin-bottom: 16px; }
.warn { background: var(--warn-bg); color: var(--warn); padding: 12px; border-radius: 12px; font-size: 15px; }
