/* Vina Martinovi: telefon na prvem mestu, ena kolona, spodnja navigacija.
   Barve skupin (rdečkasta, rdeča, bela, eko, posebna) so z vinske karte. */

:root {
  --bg: #f7f4f6;
  --surface: #ffffff;
  --surface-2: #f0ebee;
  --ink: #231c21;
  --muted: #6f6469;
  --line: #e3dce0;
  --accent: #7a1f3a;
  --accent-ink: #ffffff;
  --ok: #2f7a4d;   --ok-bg: #e4f2e9;
  --warn: #8f5400; --warn-bg: #fbeed0;
  --info: #35567f; --info-bg: #e6edf7;
  --bad: #a8231c;  --bad-bg: #fbe7e5;
  --shadow: 0 1px 2px rgba(35, 28, 33, .06), 0 8px 24px rgba(35, 28, 33, .08);
  --nav-h: 62px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161216; --surface: #211b21; --surface-2: #2a232a; --ink: #f2eaef; --muted: #a79ba3; --line: #3a313a;
    --accent: #e58aa7; --accent-ink: #2a0f19;
    --ok: #6fcf97;   --ok-bg: #1e3328;
    --warn: #f0b95a; --warn-bg: #3a2d14;
    --info: #8fb3e8; --info-bg: #1f2b3d;
    --bad: #f08b83;  --bad-bg: #3d1f1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161216; --surface: #211b21; --surface-2: #2a232a; --ink: #f2eaef; --muted: #a79ba3; --line: #3a313a;
  --accent: #e58aa7; --accent-ink: #2a0f19;
  --ok: #6fcf97;   --ok-bg: #1e3328;
  --warn: #f0b95a; --warn-bg: #3a2d14;
  --info: #8fb3e8; --info-bg: #1f2b3d;
  --bad: #f08b83;  --bad-bg: #3d1f1d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* Samo drsenje gor in dol: brez levo-desno in brez povečave (zoom). */
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; overscroll-behavior-x: none; touch-action: pan-y; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--font);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  font-variant-numeric: tabular-nums;
  touch-action: pan-y;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.pad { padding: 24px 0; }
[hidden] { display: none !important; }

.top, main, .tabs-in { max-width: 640px; margin-inline: auto; }
/* Naslov je pritrjen na vrhu s polnim ozadjem, da pod vrstico stanja (ura, baterija) nikoli ne drsi besedilo in se ne zamegli. */
.top { position: sticky; top: 0; z-index: 15; background: var(--bg); display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: calc(env(safe-area-inset-top, 0px) + 12px) 0 8px; }
.brand { font: italic 600 1.5rem/1.1 var(--font-display); letter-spacing: .01em; margin: 0; color: var(--accent); }
main { padding-bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; align-content: start; }

/* spodnja navigacija */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 0 max(8px, env(safe-area-inset-left, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-right, 0px));
}
.tabs button {
  display: grid; justify-items: center; gap: 2px; align-content: center;
  min-height: var(--nav-h); background: none; border: 0; color: var(--muted); font-size: .72rem; letter-spacing: .02em;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--accent); font-weight: 600; }

/* gumbi */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 500;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn[disabled] { opacity: .5; }
.btn.on { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* skupine in vina */
.cat { display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.cat-h {
  margin: 0; padding: 9px 14px; background: var(--c); color: #fff;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
  font: 600 .95rem/1.2 var(--font-display); letter-spacing: .06em; text-transform: uppercase;
}
.cat-h small { font: italic .75rem var(--font-display); text-transform: none; letter-spacing: 0; opacity: .9; }
.wine {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: none; border: 0; border-top: 1px solid var(--line);
}
.cat-h + .wine { border-top: 0; }
.w-main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; flex: 1; }
.w-name { font-weight: 600; font-size: 1.05rem; flex-basis: 100%; }
.w-meta { color: var(--muted); font-size: .82rem; }
.w-stock { display: grid; justify-items: end; flex: none; }
.w-stock b { font-size: 1.05rem; line-height: 1.25; text-align: right; }
.w-stock small { color: var(--muted); font-size: .78rem; }
.wine.zero .w-stock b { color: var(--muted); font-weight: 500; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: normal; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }

.totals { color: var(--muted); font-size: .85rem; text-align: center; }

/* spodnji list */
dialog#sheet {
  border: 0; padding: 0; background: var(--surface); color: var(--ink);
  width: 100%; max-width: 560px; margin: auto auto 0; max-height: 92dvh; overflow: auto;
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
}
dialog#sheet::backdrop { background: rgba(10, 5, 10, .5); }
.sheet-in { padding: 16px max(16px, env(safe-area-inset-left, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; }
.sh-head { display: grid; gap: 2px; padding-left: 12px; border-left: 5px solid var(--c); }
.sh-head h2 { margin: 0; font: italic 600 1.35rem var(--font-display); }
.sh-head p { margin: 0; color: var(--muted); font-size: .85rem; }
.sh-descr { margin: 0; color: var(--muted); font-size: .85rem; }
.sh-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.sh-tabs button { min-height: 38px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-weight: 500; }
.sh-tabs button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.sh-close { justify-self: end; }
.sh-actions { display: flex; align-items: center; gap: 10px; }
.sh-actions .btn.primary { flex: 1 1 auto; min-width: 0; min-height: 52px; }
.sh-actions .sh-close { flex: 0 0 auto; min-height: 40px; padding: 0 14px; }

/* obrazci */
.form { display: grid; gap: 10px; }
.form label, .lbl { font-size: .82rem; color: var(--muted); font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
}
textarea { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field { display: grid; gap: 4px; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink) !important; font-size: 1rem !important; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.err { color: var(--bad); background: var(--bad-bg); padding: 8px 12px; border-radius: 10px; margin: 0; }
.ok { color: var(--ok); }

.kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; }
.chip span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); font-weight: 500; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip input:disabled + span { opacity: .45; }

.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; align-items: center; }
.stepper button { min-height: 48px; font-size: 1.4rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.stepper input { text-align: center; font-size: 1.3rem; font-weight: 600; min-height: 48px; }
.preview { margin: 0; color: var(--muted); font-size: .95rem; min-height: 1.4em; }
.preview.bad { color: var(--bad); font-weight: 600; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick .btn { flex: 1 1 140px; min-height: 48px; }
.hint { margin: 0; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* naročilo */
.ord-row { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; }
.ord-row.has { border-color: var(--accent); border-left-color: var(--c); box-shadow: 0 0 0 1px var(--accent) inset; }
.o-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.o-head b { font-size: 1.05rem; }
.o-sub { color: var(--muted); font-size: .8rem; margin-top: -4px; }
.o-ctl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.o-ctl .o-tsub { grid-column: 1 / -1; margin-top: 0; }
.stp { display: grid; gap: 3px; }
.stp > span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stp > div { display: grid; grid-template-columns: 40px 1fr 40px; }
.stp button { min-height: 44px; border: 1px solid var(--line); background: var(--surface-2); font-size: 1.2rem; }
.stp button:first-child { border-radius: 10px 0 0 10px; }
.stp button:last-child { border-radius: 0 10px 10px 0; }
.stp input { text-align: center; border-radius: 0; min-width: 0; padding: 0 2px; font-weight: 600; }
.o-price:empty { display: none; }
.o-price { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: 8px; min-height: 22px; }
.sum-bar {
  position: sticky; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom, 0px)); z-index: 5;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 14px; padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; box-shadow: var(--shadow);
}
.sum-bar .tot { font-size: 1.3rem; font-weight: 700; line-height: 1.1; }
.sum-bar small { display: block; color: var(--muted); font-size: .78rem; }
.sec-h { margin: 6px 0 -4px; font: italic 600 1.15rem var(--font-display); color: var(--ink); }
.order { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.order .o-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.order ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: .92rem; }
.order li { display: flex; justify-content: space-between; gap: 10px; }
.order li span:last-child { white-space: nowrap; }
.order .o-total, .form .o-total { display: flex; justify-content: space-between; font-weight: 700; border-top: 1px solid var(--line); padding-top: 6px; }
.owed { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-weight: 600; }

/* poraba */
.use-row { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.use-row .u-name { font-weight: 600; }
.use-row .u-sub { color: var(--muted); font-size: .82rem; }
.use-row .u-rate { text-align: right; white-space: nowrap; }
.use-row .u-rate b { display: block; }
.hist-day { margin: 8px 0 -6px; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.hist { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.hist-row { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); }
.hist-row:first-child { border-top: 0; }
.hist-row .h-time { color: var(--muted); font-size: .8rem; }
.hist-row .h-what { min-width: 0; }
.hist-row .h-what b { font-weight: 600; }
.hist-row .h-what small { display: block; color: var(--muted); }
.hist-row .h-n { font-weight: 700; text-align: right; }
.hist-row .h-n small { display: block; font-weight: 400; color: var(--muted); }
.h-n.neg { color: var(--bad); }
.h-n.pos { color: var(--ok); }
.hist-row .btn { grid-column: 2 / -1; justify-self: start; }

/* nastavitve */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 12px; }
.panel h2 { margin: 0; font: italic 600 1.15rem var(--font-display); }
.panel p { margin: 0; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.seg button { min-height: 40px; border: 0; border-radius: 9px; background: none; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.wine-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.wine-line:first-of-type { border-top: 0; }
.wine-line .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.wine-line .nm { flex: 1; min-width: 0; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-weight: 500; box-shadow: var(--shadow);
}
#toast.bad { background: var(--bad); color: #fff; }

/* prijava in namestitev */
body.plain { display: grid; align-items: center; min-height: 100dvh; }
.login { width: 100%; max-width: 380px; margin: 0 auto; padding: 28px 0; display: grid; gap: 14px; }
.login .brand { font-size: 2rem; }
.login p { margin: 0; }
.login .btn { width: 100%; }
.login code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

@media (prefers-reduced-motion: no-preference) {
  .wine, .btn { transition: background-color .12s; }
  .wine:active { background: var(--surface-2); }
}

/* izdaje na vrnitev */
.lr-line { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.lr-line:first-of-type { border-top: 0; padding-top: 0; }
.loan .l-who { font-weight: 700; font-size: 1.05rem; }
.loan .l-sub { display: block; color: var(--muted); font-size: .85rem; }
.loan li { align-items: baseline; }
.loan li > span:first-child { min-width: 0; }
.owed .l-sub { display: block; font-weight: 400; font-size: .85rem; }
.tabs button span { white-space: nowrap; }

/* različica in posodobitev */
.log { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.log summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.log ul { margin: 6px 0 2px; padding: 0; list-style: none; display: grid; gap: 8px; font-size: .9rem; }
input[type=file] { min-height: 44px; padding: 8px 0; max-width: 100%; }
input[type=file] { width: 100%; max-width: 100%; min-width: 0; }
dialog#sheet { overflow-x: hidden; touch-action: pan-y; }

/* skrita vrednost zaloge */
.valbox { margin: 0; text-align: center; }
.linkbtn { background: none; border: 0; color: var(--muted); font-size: .85rem; min-height: 40px; padding: 0 12px; text-decoration: underline; text-underline-offset: 3px; }
.valbox.open { display: grid; gap: 4px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.valbox .v-row { display: flex; justify-content: space-between; gap: 10px; }
.valbox .linkbtn { justify-self: end; }
