:root {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --ink: #1b2420;
  --muted: #6d746f;
  --line: #e6e2d9;
  --nav: #182420;
  --accent: #1f5c45;
  --red: #b4322f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(24,36,32,.06), 0 6px 18px rgba(24,36,32,.05);
  /* kategorie */
  --c1: #7d8f2a; --c1-bg: #f1f4dc;   /* Prosecco */
  --c2: #b98a12; --c2-bg: #fbf0cf;   /* Prosecco lepší */
  --c3: #8a2342; --c3-bg: #f8e3ea;   /* Šampaňské */
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
.boot { padding: 40px; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1100px 600px at 20% 0%, #2b3d35 0%, var(--nav) 65%); }
.login-card { width: min(380px, 92vw); background: var(--panel); border-radius: 18px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.35); text-align: center; }
.login-ico { font-size: 40px; }
.login-card h1 { margin: 6px 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card .btn { width: 100%; margin-top: 12px; justify-content: center; }
.login-err { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 10px; }

/* ---------- Header ---------- */
.top { background: var(--nav); color: #fff; position: sticky; top: 0; z-index: 10; }
.top-in { max-width: 1180px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 14px; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: #2b3d35; display: grid; place-items: center; }
.brand small { color: #a8b5ae; font-weight: 500; }
.search { width: min(300px, 40vw); padding: 8px 12px; border-radius: 9px; border: 1px solid #34463e; background: #22312b; color: #fff; font: inherit; }
.search::placeholder { color: #8d9b94; }
.top .btn-ghost { color: #d3dcd7; border-color: #34463e; }
.top .btn-ghost:hover { background: #22312b; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 80px; }

/* ---------- Buttons & inputs ---------- */
.btn { appearance: none; border: 1px solid transparent; background: var(--accent); color: #fff; padding: 9px 16px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #ecE8df; filter: none; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-link { background: none; border: 0; color: var(--muted); padding: 4px 6px; cursor: pointer; font: inherit; font-size: 13px; }
.btn-link:hover { color: var(--ink); text-decoration: underline; }
.btn-link.danger:hover { color: var(--red); }
.inp { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: #fff; }
.inp:focus, .cell:focus, .quick:focus, .p-name:focus, .price:focus { outline: 2px solid rgba(31,92,69,.25); border-color: var(--accent); }
.lbl { color: var(--muted); font-size: 12px; white-space: nowrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty { padding: 16px 4px; color: var(--muted); font-size: 14px; }
.card.empty { padding: 28px; text-align: center; }
.card.empty.big { padding: 48px; font-size: 16px; }

/* ---------- Kategorie ---------- */
.chips { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; flex-shrink: 0; }
.chip { appearance: none; border: 0; border-right: 1px solid var(--line); background: #fff; color: var(--muted); padding: 6px 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip:last-child { border-right: 0; }
.chip:hover { background: #f6f4ef; }
.chip.c-prosecco.on { background: var(--c1); color: #fff; }
.chip.c-prosecco_plus.on { background: var(--c2); color: #fff; }
.chip.c-champagne.on { background: var(--c3); color: #fff; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.c-prosecco { background: var(--c1-bg); color: var(--c1); }
.pill.c-prosecco_plus { background: var(--c2-bg); color: #8a6608; }
.pill.c-champagne { background: var(--c3-bg); color: var(--c3); }
.pill.muted { background: #efede7; color: var(--muted); }

/* ---------- Souhrn ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr) 1.2fr; gap: 14px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; border-top: 5px solid var(--muted); transition: transform .08s; }
.tile:hover { transform: translateY(-1px); }
.tile.c-prosecco { border-top-color: var(--c1); }
.tile.c-prosecco_plus { border-top-color: var(--c2); }
.tile.c-champagne { border-top-color: var(--c3); }
.tile.on.c-prosecco { background: var(--c1-bg); }
.tile.on.c-prosecco_plus { background: var(--c2-bg); }
.tile.on.c-champagne { background: var(--c3-bg); }
.tile.total { border-top-color: var(--nav); cursor: default; }
.tile.total:hover { transform: none; }
.t-lbl { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.t-val { font-size: 30px; font-weight: 750; margin: 2px 0 6px; }
.t-val small { font-size: 14px; color: var(--muted); font-weight: 500; }
.t-price { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.t-price span { color: var(--ink); font-weight: 600; }
.price { width: 76px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 13px; background: rgba(255,255,255,.8); }
.t-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.t-sub b { color: var(--ink); }
.progress { height: 6px; background: #ece9e1; border-radius: 9px; margin: 8px 0 2px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }

/* ---------- Přidání partnera ---------- */
.addp { padding: 12px; margin-bottom: 14px; }
.addp form { display: flex; gap: 10px; align-items: center; }
.addp .inp { flex: 1; }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 0 2px 12px; flex-wrap: wrap; }
.tgl { font-size: 14px; display: flex; gap: 6px; align-items: center; cursor: pointer; }

/* ---------- Partner ---------- */
.partner { margin-bottom: 12px; overflow: hidden; }
.p-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #faf8f4; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.collapsed .p-head { border-bottom: 0; }
.caret { border: 0; background: none; cursor: pointer; font-size: 16px; color: var(--muted); transition: transform .15s; padding: 2px 4px; }
.collapsed .caret { transform: rotate(-90deg); }
.collapsed .p-body { display: none; }
.p-name { font: inherit; font-size: 17px; font-weight: 700; border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 4px 6px; min-width: 120px; width: auto; field-sizing: content; max-width: 360px; }
.p-name:hover { border-color: var(--line); background: #fff; }
.p-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.p-actions { display: flex; align-items: center; gap: 6px; }
.p-actions .chip { padding: 4px 8px; font-size: 12px; }
.p-body { padding: 6px 14px 12px; }

.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 28px minmax(140px, 1.2fr) minmax(120px, 1fr) auto auto 72px 28px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.row.handed .f-name, .row.handed .f-position { color: var(--muted); text-decoration: line-through; }
.row.handed .cell::placeholder { color: transparent; }
.cell { font: inherit; border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 6px 8px; width: 100%; }
.cell:hover { border-color: var(--line); background: #fff; }
.f-name { font-weight: 600; }
.f-position { color: var(--muted); font-size: 14px; }
.hand { position: relative; width: 22px; height: 22px; cursor: pointer; }
.hand input { position: absolute; opacity: 0; }
.hand span { position: absolute; inset: 0; border: 2px solid #c9c4b8; border-radius: 6px; background: #fff; }
.hand input:checked + span { background: var(--accent); border-color: var(--accent); }
.hand input:checked + span::after { content: "✓"; color: #fff; font-size: 14px; font-weight: 800; position: absolute; inset: 0; display: grid; place-items: center; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty .num { min-width: 18px; text-align: center; font-weight: 700; }
.q-btn { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 15px; line-height: 1; color: var(--muted); }
.q-btn:hover { color: var(--ink); background: #f6f4ef; }
.del { border: 0; background: none; color: #b8b2a6; font-size: 20px; cursor: pointer; border-radius: 6px; }
.del:hover { color: var(--red); background: #fbecec; }

.quick-wrap { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.quick { flex: 1; padding: 10px 12px; border: 1px dashed #cfc9bb; border-radius: 9px; font: inherit; background: #fdfcf9; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--nav); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; font-size: 14px; z-index: 50; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--red); }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .addp form { flex-wrap: wrap; }
  .addp .inp { flex-basis: 100%; }
  .row { grid-template-columns: 28px 1fr auto; row-gap: 4px; padding: 8px 0; }
  .row .hand { grid-column: 1; grid-row: 1; }
  .row .f-name { grid-column: 2; grid-row: 1; }
  .row .del { grid-column: 3; grid-row: 1; justify-self: end; }
  .row .who { grid-column: 2 / -1; grid-row: 4; text-align: left; padding-left: 8px; }
  .row .f-position { grid-column: 2 / -1; grid-row: 2; }
  .row .f-cat { grid-column: 1 / 3; grid-row: 3; justify-self: start; }
  .row .qty { grid-column: 3; grid-row: 3; }
  .row .chip, .p-actions .chip { padding: 6px 8px; font-size: 12px; }
  .p-actions { flex-wrap: wrap; }
  .p-head { gap: 6px; }
  .quick-wrap { flex-wrap: wrap; }
  .quick { flex-basis: 100%; }
  .search { display: none; }
  .brand small { display: none; }
}

/* ---------- Tisk ---------- */
@media print {
  .top, .addp, .toolbar, .p-actions, .quick-wrap, .del, .q-btn, .caret, .price, .empty { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .card, .tile { box-shadow: none; }
  .collapsed .p-body { display: block; }
  .partner { break-inside: avoid; }
  .chip:not(.on) { display: none; }
  .chips { border: 0; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
}
.row.handed .cell:placeholder-shown { text-decoration: none; }

.who { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.handed .who { color: var(--accent); font-weight: 600; }
.me { color: #c9d4ce; font-size: 13px; }
.me::before { content: "👤 "; }
@media print { .who, .me { display: none; } }
