:root {
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --border: #e0ded8;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #eb6834;
  --accent-ink: #fff;
  --grid: #e6e4de;
  --danger: #c62828;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4b00;
  --ok: #1b7f3b;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #33332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #94938b;
    --accent: #d95926;
    --grid: #2c2c29;
    --danger: #ef6b6b;
    --warn-bg: #3a2f12;
    --warn-ink: #f5d68a;
    --ok: #5cc27c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  max-width: 720px; margin: 0 auto;
}
.top h1 { font-size: 20px; margin: 0; display: flex; gap: 8px; align-items: center; }
main { max-width: 720px; margin: 0 auto; padding: 0 16px 16px; }
h2 { font-size: 18px; margin: 18px 0 10px; }
h3 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; margin: 6px 0 4px; }
@media (min-width: 520px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat .label { font-size: 12px; color: var(--text-2); }
.stat .value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 12px; font-weight: 500; color: var(--text-2); margin-left: 2px; }

/* graf */
.chart { position: relative; margin-top: 10px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .bar { transition: opacity .15s; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar.on { opacity: .75; }
.tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%);
  background: var(--text); color: var(--surface); padding: 5px 8px; border-radius: 8px;
  font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
details.table summary { cursor: pointer; font-size: 13px; color: var(--text-2); margin-top: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }

/* formuláre */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input[type=color] { padding: 2px; width: 56px; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }

button {
  font: inherit; border: 0; border-radius: 12px; padding: 12px 16px; min-height: 44px;
  background: var(--surface-2); color: var(--text); cursor: pointer;
}
button.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.block { display: block; width: 100%; }
button.link { background: none; color: var(--text-2); padding: 6px 4px; min-height: 0; text-decoration: underline; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; }
.big-cam {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 160px; font-size: 18px; font-weight: 650;
  background: var(--accent); color: var(--accent-ink); border-radius: var(--radius);
}
.big-cam .ico { font-size: 44px; line-height: 1; }

.preview { width: 100%; max-height: 320px; object-fit: contain; border-radius: 10px; background: var(--surface-2); }
.found { border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.found .what { font-size: 13px; color: var(--text-2); margin: 6px 0 0; }
.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.badge.low { background: var(--warn-bg); color: var(--warn-ink); }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* história */
.hist-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.hist-item:last-child { border-bottom: 0; }
.hist-item img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; flex: none; }
.hist-item .ph { width: 48px; height: 48px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); flex: none; }
.hist-item .main { flex: 1; min-width: 0; }
.hist-item .val { font-weight: 650; font-variant-numeric: tabular-nums; }
.delta { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.delta.neg { color: var(--danger); }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; }
.chip { flex: none; padding: 6px 12px; min-height: 36px; border-radius: 999px; font-size: 14px; }
.chip.on { background: var(--text); color: var(--surface); }

/* spodná navigácia */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 5;
}
.tabs button {
  flex: 1; max-width: 160px; background: none; display: flex; flex-direction: column; align-items: center;
  gap: 2px; font-size: 20px; padding: 6px 2px; color: var(--text-2);
}
.tabs button span { font-size: 11px; }
.tabs button.active { color: var(--text); }
.tabs button.active span { font-weight: 700; }
.tabs button.primary span { color: var(--accent); font-weight: 700; }

#toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 12px;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); z-index: 10;
}
#toast.show { opacity: 1; }
