/* Split the Bill — mobile-first, jeden sloupec, velká tlačítka, sticky souhrn. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f4;
  --border: #dfe3e8;
  --text: #1a2027;
  --muted: #667085;
  --primary: #1f8a5f;
  --primary-d: #176b49;
  --danger: #c0392b;
  --accent: #2d6cdf;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
  --tap: 44px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a; --surface: #1e2226; --surface-2: #262b30; --border: #333a41;
    --text: #e6e9ec; --muted: #97a1ab; --primary: #2fae78;
    --primary-d: #1f8a5f; --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--primary); color: #fff;
  padding: env(safe-area-inset-top) 16px 0;
  height: calc(52px + env(safe-area-inset-top));
  display: flex; align-items: center;
  box-shadow: var(--shadow);
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.app { max-width: 640px; margin: 0 auto; padding: 16px 16px 120px; }

/* Karty a sekce */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card > h2 { margin: 0 0 12px; font-size: 1.05rem; }
.section-hint { color: var(--muted); font-size: .85rem; margin: -6px 0 12px; }

/* Formulářové prvky */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="number"], select {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="number"] { -moz-appearance: textfield; }

.btn {
  min-height: var(--tap); padding: 10px 16px; font-size: 1rem; font-weight: 600;
  border: none; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface-2); color: var(--text);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-d); }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 1.1rem; }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid transparent; padding: 8px; min-height: auto; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* Přepínač strategie */
.seg { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.seg button {
  flex: 1; min-height: 40px; border: none; border-radius: 9px; background: transparent;
  color: var(--muted); font-weight: 600; cursor: pointer; font-size: .95rem;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Řádky účastníků / položek */
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.row .grow { flex: 1; min-width: 0; }
.row-wrap { flex-wrap: wrap; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; font-size: .85rem;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; user-select: none;
}
.chip[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip input { width: 46px; min-height: 28px; padding: 2px 6px; text-align: center; }

.inline-fields { display: flex; gap: 8px; }
.inline-fields > div { flex: 1; }
.w-price { flex: 0 0 96px; }
.w-qty { flex: 0 0 64px; }

/* Výsledek */
.result-person {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border);
}
.result-person:first-child { border-top: none; }
.result-person .info { flex: 1; min-width: 0; }
.result-person .name { font-weight: 600; }
.result-person .amount { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; }
.result-person.is-settled .amount { text-decoration: line-through; color: var(--muted); }
.tag { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.payer { background: #e7f0ff; color: var(--accent); }
@media (prefers-color-scheme: dark) { .tag.payer { background: #1c2f52; } }

.qr-wrap { text-align: center; }
.qr-wrap canvas { width: 220px; max-width: 70vw; height: auto; image-rendering: pixelated; background: #fff; border-radius: 8px; padding: 8px; }
.qr-actions { display: flex; gap: 8px; margin-top: 10px; }

details.qr-detail { margin-top: 6px; }
details.qr-detail summary { cursor: pointer; color: var(--accent); font-size: .9rem; }

/* Sticky souhrn dole */
.summary {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(16,24,40,.06);
}
.summary-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.summary .total { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.summary .label { color: var(--muted); font-size: .8rem; }
.summary .breakdown { font-size: .78rem; color: var(--muted); }

/* Landing */
.hero { text-align: center; padding: 40px 8px; }
.hero h1 { font-size: 1.8rem; margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0 0 28px; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.status-dot.on { background: var(--primary); }
.status-dot.off { background: var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; z-index: 50; box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.undistributed { color: var(--danger); font-weight: 600; }
.spacer { height: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
