:root {
  --bg: #f4efe4;
  --surface: #fffdf8;
  --text: #22261f;
  --muted: #6b6f63;
  --line: #e2dccd;
  --accent: #2f6b3f;
  --accent-ink: #ffffff;
  --accent-soft: #e3eedf;
  --warn: #b3261e;
  --sale: #c4571b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 35, 20, .06), 0 4px 14px rgba(40, 35, 20, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171a16;
    --surface: #20241f;
    --text: #ecebe4;
    --muted: #a1a497;
    --line: #33382f;
    --accent: #6fb782;
    --accent-ink: #10150f;
    --accent-soft: #2a3a2c;
    --warn: #ff8a80;
    --sale: #f0a36b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }

button, input { font: inherit; color: inherit; }
input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  min-width: 0;
  width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .5; cursor: default; }
.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 600;
  white-space: nowrap;
}
.primary.small { padding: 6px 14px; border-radius: 999px; }
.ghost {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--surface);
  white-space: nowrap;
}
.small { font-size: 14px; }
.small-text { font-size: 13px; }
.muted { color: var(--muted); }
.error { color: var(--warn); margin: 8px 0 0; min-height: 1em; font-size: 14px; }
.error:empty { display: none; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Prihlásenie */
.screen { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 12px; text-align: center; padding: 28px 20px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 0; }
.login-icon { width: 56px; height: 56px; margin: 0 auto; }

/* Horná lišta */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand img { width: 28px; height: 28px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: 15px; color: var(--muted); }
.tab.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
#user-btn:disabled { opacity: 1; }
@media (max-width: 520px) { .brand span { display: none; } .topbar { gap: 8px; } }

.content { max-width: 760px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }

/* Pridanie */
.add-card { display: grid; gap: 8px; }
.add-row { display: grid; grid-template-columns: 1fr 64px auto; gap: 8px; }
.add-row input[type=number] { text-align: center; padding-left: 4px; padding-right: 4px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
@media (max-width: 480px) {
  .add-row { grid-template-columns: 1fr 64px; }
  .add-row .primary { grid-column: 1 / -1; }
}

/* Súhrn */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
@media (max-width: 480px) { .stat-val { font-size: 16px; } .summary .label { font-size: 11px; } }

/* Skupiny */
.group { display: grid; gap: 8px; }
.group .empty { margin: 0; padding: 2px 0 8px; font-size: 14px; }
.count { font-weight: 400; color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.section-head h2 { font-size: 16px; margin: 0; }

/* Položky */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.item[data-status=in_cart] { border-left: 4px solid var(--accent); }
.item[data-status=bought] { opacity: .75; }
.thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: #fff; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.info { min-width: 0; }
.name { font-weight: 600; text-decoration: none; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
a.name[href]:hover { text-decoration: underline; }
.meta { font-size: 13px; }
.right { display: grid; justify-items: end; gap: 4px; }
.price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.price .sale { color: var(--sale); }
.price .unit { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.qty { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; }
.qty button { width: 28px; height: 28px; font-size: 17px; line-height: 1; }
.qty-val { min-width: 24px; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; }
.qty.readonly { border-color: transparent; }
.qty.readonly button { display: none; }
.actions { display: flex; gap: 4px; }
.actions:empty { display: none; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 15px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--bg); }
.icon-btn.go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.icon-btn.danger { color: var(--muted); }
.icon-btn.danger:hover { color: var(--warn); }

@media (max-width: 520px) {
  .item { grid-template-columns: 44px 1fr auto; grid-template-areas: "t i i" "r r a"; row-gap: 8px; }
  .thumb { grid-area: t; width: 44px; height: 44px; }
  .info { grid-area: i; }
  .right { grid-area: r; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .price .unit { display: inline; margin-left: 6px; }
  .actions { grid-area: a; }
}

/* Archív */
.page-title { font-size: 20px !important; }
.archive-list { display: grid; gap: 10px; }
.archive-entry { padding: 0; }
.archive-entry summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.archive-entry summary::-webkit-details-marker { display: none; }
.archive-entry summary::before { content: "▸"; color: var(--muted); }
.archive-entry[open] summary::before { content: "▾"; }
.archive-entry summary > div:first-of-type { flex: 1; min-width: 0; }
.archive-title { font-weight: 600; }
.archive-total { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.archive-items { list-style: none; margin: 0; padding: 0 16px 8px; border-top: 1px solid var(--line); }
.archive-items li { display: grid; grid-template-columns: 1fr auto 40px 90px; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; align-items: baseline; }
.archive-items li:last-child { border-bottom: 0; }
.archive-items a { text-decoration: none; }
.archive-items a:hover { text-decoration: underline; }
.archive-items .num { text-align: right; font-variant-numeric: tabular-nums; }
.archive-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 8px 16px 14px; }
@media (max-width: 520px) {
  .archive-items li { grid-template-columns: 1fr 34px 80px; }
  .archive-items li > .muted { display: none; }
}

.empty { text-align: center; padding: 24px 0; }

.footer {
  max-width: 760px; margin: 0 auto; padding: 8px 16px 32px;
  display: flex; align-items: center; gap: 8px;
}
.footer .ghost { margin-left: auto; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: #3fa45b; }
.dot.off { background: var(--warn); }
