/* ===== Kvit — mobilní-first stylování + tmavý režim ===== */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { overscroll-behavior-y: contain; }

:root {
  /* Kvit brand palette — viz kvit-brand/README.md
     Purple Light #9B6FD4, Purple Dark #5A3E96 (primary), Purple Deep #2D1E50,
     Ink #1C1826, Off-white #F8F6F2, Gray 500 #64646E. */
  --primary: #5A3E96;
  --primary-light: #9B6FD4;
  --primary-deep: #2D1E50;
  --bg: #F8F6F2;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #f9fafb;
  --text: #1C1826;
  --muted: #64646E;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #ea580c;
  --info-bg: #ede9fe;
  --info-fg: #5A3E96;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(45, 30, 80, 0.06), 0 1px 3px rgba(45, 30, 80, 0.04);
  /* Z-index hierarchie — od nejnižší po nejvyšší vrstvu */
  --z-fab: 5;
  --z-tabs: 9;
  --z-topbar: 10;
  --z-modal-action: 11;
  --z-modal: 100;
  --z-toast: 200;
  --z-viewer: 300;
}

/* Tmavý režim — aktivuje se přes JS atributem data-theme="dark" na <html>.
   JS nastavuje atribut podle: 1) uživatelské volby (auto/light/dark) v localStorage,
   2) systémové preference, pokud je uživatelské nastavení "auto". */
:root[data-theme="dark"] {
  /* Kvit dark palette — primary se posune světleji pro kontrast na tmavém pozadí. */
  --primary: #9B6FD4;
  --primary-light: #B89AE0;
  --primary-deep: #2D1E50;
  --bg: #15101F;
  --surface: #241B33;
  --surface-2: #1A1428;
  --surface-3: #2E2342;
  --text: #F0EBFA;
  --muted: #A29DAE;
  --border: #3D2F58;
  --danger: #f87171;
  --success: #4ade80;
  --warning: #fb923c;
  --info-bg: #3D2F58;
  --info-fg: #C9B8E8;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.25);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }

/* ===== Login ===== */
#screen-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
}
/* Mini topbar nad login boxem — fialový pruh s logem */
.login-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow);
}
.login-topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: white;
  font-weight: 600;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background .15s;
}
.login-topbar-logo:hover {
  background: rgba(255,255,255,.15);
  text-decoration: none;
}
.login-topbar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: white;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.login-topbar-logo-icon svg {
  width: 20px;
  height: 20px;
}
.login-topbar-logo-text {
  letter-spacing: -0.01em;
  font-size: 17px;
}
/* Skrýt mini topbar v PWA standalone — uživatel je v PWA, není kde jít */
@media (display-mode: standalone) {
  .login-topbar { display: none; }
}
.login-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-box h1 {
  color: var(--primary);
  font-size: 32px;
  margin-bottom: 8px;
}
.subtitle {
  color: var(--muted);
  margin-bottom: 32px;
}
.invite-banner {
  background: var(--info-bg);
  color: var(--info-fg);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.private-warning {
  background: rgba(220, 38, 38, 0.08);
  border-left: 3px solid var(--danger);
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 20px;
  text-align: left;
  font-size: 13px;
  line-height: 1.5;
}
.private-warning-title {
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 6px;
  font-size: 13px;
}
.private-warning-cs,
.private-warning-en {
  margin: 4px 0;
  color: var(--text);
}
[data-theme="dark"] .private-warning {
  background: rgba(248, 113, 113, 0.10);
}

/* ===== Tlačítka ===== */
.btn {
  border: none;
  cursor: pointer;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  transition: opacity .15s, transform .05s;
  font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-light); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { color: var(--text); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  margin-right: auto;
}
.btn-danger:hover { background: rgba(220,38,38,.06); }
.btn-small {
  padding: 6px 12px;
  font-size: 14px;
}
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 24px;
  width: 100%;
  justify-content: center;
}
.btn-google:hover { background: var(--surface-3); }
/* ===== Zpět na landing kvit.it (login obrazovka) =====
   Pouze pro prohlížecí kontext — v PWA standalone režimu skryté. */
.login-back-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.login-back-link:hover {
  color: var(--primary);
  background: var(--surface-3);
  text-decoration: none;
}
@media (display-mode: standalone) {
  .login-back-link { display: none; }
}
.btn-share {
  width: 100%;
  background: var(--surface);
  color: var(--primary);
  border: 1px dashed var(--primary-light);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}
.btn-share:hover { background: var(--surface-3); }

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.topbar h1 {
  flex: 1;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  margin: 0 12px;
  cursor: pointer;
}
.topbar-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-btn:hover { background: rgba(255,255,255,.1); }
.topbar-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* ===== Logo Kvit v topbaru — odkaz na landing kvit.it ===== */
.topbar-logo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  margin-right: 4px;
  border-radius: 8px;
  text-decoration: none;
  color: white;
  font-weight: 600;
  font-size: 16px;
  transition: background .15s;
}
.topbar-logo-link:hover {
  background: rgba(255,255,255,.12);
  text-decoration: none;
}
.topbar-logo-link .topbar-logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: white;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.topbar-logo-link .topbar-logo-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}
.topbar-logo-text {
  letter-spacing: -0.01em;
}
/* Na úzkém mobilu (<400px) skryjeme text, ať topbar nepřeteče */
@media (max-width: 420px) {
  .topbar-logo-text { display: none; }
}
/* V PWA standalone režimu logo skrýváme — uživatel je v PWA, ne na webu,
   a odkaz na landing v jeho kontextu nedává smysl. */
@media (display-mode: standalone) {
  .topbar-logo-link { display: none; }
}

/* Instalační tlačítko se zvýraznilo — ikona + text */
.topbar-btn-install {
  gap: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  background: rgba(255,255,255,.18);
  font-family: inherit;
}
.topbar-btn-install svg {
  width: 18px;
  height: 18px;
}
.topbar-btn-install:hover { background: rgba(255,255,255,.28); }

/* ===== View ===== */
.view {
  position: relative;
  padding: 16px;
  padding-bottom: 96px;
  min-height: calc(100vh - 56px);
}

/* ===== Seznamy a karty ===== */
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .05s;
}
.card:active { transform: scale(.99); }
.card-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-meta {
  font-size: 13px;
  color: var(--muted);
}
.card-meta-converted {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ===== Záloha (transfer) — odlišení od běžného výdaje =====
   Levý zelený proužek + jemně zelenavé pozadí + kurzíva v názvu + tag.
   Záměrně se to nemíchá s "amount" zelenou v účetních smyslech — jde
   čistě o vizuální značku, že karta je převod, ne náklad. */
.card-transfer {
  background: var(--transfer-bg, #f0fbf4);
  border-left: 3px solid var(--transfer-accent, #4caf7a);
}
.card-transfer .transfer-label {
  font-style: italic;
  font-weight: 500;
}
.card-transfer .amount.transfer-amount {
  font-style: italic;
  color: var(--transfer-accent, #4caf7a);
}
.transfer-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-radius: 999px;
  background: var(--transfer-accent, #4caf7a);
  color: #fff;
  vertical-align: middle;
  font-style: normal;
}

/* Tmavý režim — laděné tóny */
[data-theme="dark"] .card-transfer {
  background: var(--transfer-bg-dark, rgba(76, 175, 122, 0.10));
  border-left-color: var(--transfer-accent-dark, #6cc995);
}
[data-theme="dark"] .card-transfer .amount.transfer-amount {
  color: var(--transfer-accent-dark, #6cc995);
}
[data-theme="dark"] .transfer-tag {
  background: var(--transfer-accent-dark, #6cc995);
  color: #0b1f15;
}
.amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.amount-pos { color: var(--success); }
.amount-neg { color: var(--danger); }

/* Kategorie ikona v meta řádku */
.category-icon {
  display: inline-block;
  margin-right: 4px;
}

/* ===== Floating Action Button ===== */
.fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(31, 56, 100, 0.32), 0 2px 6px rgba(31, 56, 100, 0.18);
  z-index: var(--z-fab);
}
.fab:hover { background: var(--primary-light); }
.fab:active { transform: scale(.95); }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: var(--z-tabs);
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 16px 4px;     /* zvětšeno z 14 na 16 → větší dotyková plocha */
  min-height: 48px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  font-family: inherit;
}
.tab-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-pane {
  padding: 16px;
  padding-bottom: 96px;
  min-height: calc(100vh - 110px);
}

.section-title {
  margin: 24px 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ===== Empty state ===== */
.empty {
  text-align: center;
  padding: 32px 24px;
  color: var(--muted);
}
.empty p { margin-bottom: 8px; }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn .15s ease;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .25s ease;
  color: var(--text);
}
.modal-card h2 {
  font-size: 20px;
  margin-bottom: 16px;
}
.modal-card label {
  display: block;
  margin: 12px 0 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}
.modal-card input, .modal-card select {
  width: 100%;
  padding: 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color .15s, background .15s;
  min-height: 44px;       /* dotyková plocha */
}
.modal-card input:focus, .modal-card select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

/* Sticky tlačítka modalu — vždy viditelná i u dlouhých formulářů */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  position: sticky;
  bottom: -24px;          /* kompenzace paddingu modal-card */
  margin: 16px -24px -24px;
  padding: 16px 24px 24px;
  background: var(--surface);
  z-index: var(--z-modal-action);
}
.modal-actions::before {
  /* Měkký fade gradient nad tlačítky — naznačí, že obsah pokračuje */
  content: "";
  position: absolute;
  top: -16px;
  left: 0;
  right: 0;
  height: 16px;
  background: linear-gradient(to bottom, transparent, var(--surface));
  pointer-events: none;
}

.row-2col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}

.rate-info {
  margin-top: 6px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 13px;
}

/* ===== Split mode tabs ===== */
.split-mode-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
  margin-top: 4px;
  margin-bottom: 8px;
}
.split-mode-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 4px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
}
.split-mode-tab.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.split-mode-hint {
  font-size: 13px;
  margin-bottom: 8px;
}

/* ===== Split rows (participants) ===== */
.split-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
}
.split-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}
.split-row:last-child { border-bottom: none; }
.split-row-label {
  flex: 1;
  min-width: 0;          /* umožní text-overflow uvnitř */
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-weight: 400;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}
.split-row-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
  min-height: auto !important;
  padding: 0 !important;
  border: 1px solid var(--border) !important;
}
.split-row-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.split-row-input {
  width: 76px !important;
  padding: 6px 8px !important;
  font-size: 14px !important;
  text-align: right;
  min-height: auto !important;
  flex-shrink: 0;
}
.split-row-suffix {
  font-size: 12px;
  color: var(--muted);
  text-align: left;
  flex-shrink: 0;
  white-space: nowrap;
}
.split-sum {
  padding: 10px 12px;
  text-align: right;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface-3);
  border-radius: 0 0 8px 8px;
}
.split-sum.error { color: var(--danger); font-weight: 500; }
.split-sum.success { color: var(--success); }

/* ===== Invite link box ===== */
.invite-link-box {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.invite-link-box input {
  flex: 1;
  font-size: 13px !important;
  padding: 8px !important;
}
.invite-link-box button {
  padding: 8px 14px;
  font-size: 14px;
  white-space: nowrap;
}

/* ===== Účtenky (receipts) ===== */
.btn-receipt-add {
  width: 100%;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  color: var(--muted);
  padding: 14px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}
.btn-receipt-add:hover {
  background: var(--surface-3);
  color: var(--text);
}
.receipt-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.receipt-preview img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  cursor: pointer;
  object-fit: contain;
  background: var(--surface-2);
}
.receipt-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.receipt-progress {
  padding: 10px;
  background: var(--info-bg);
  color: var(--info-fg);
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
}
.receipt-offline-hint {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--warn-bg, #fff3cd);
  color: var(--warn-fg, #664d03);
  border: 1px solid var(--warn-border, #ffe69c);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.receipt-icon {
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
  color: var(--muted);
}
.receipt-icon svg {
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

.receipt-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-viewer);
  animation: fadeIn 0.2s;
}
.receipt-viewer img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
}
.receipt-viewer-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}
.receipt-viewer-close:hover { background: rgba(255, 255, 255, 0.25); }

/* ===== Expense metadata (kdo a kdy vytvořil/upravil) ===== */
.expense-meta {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* ===== Statistiky ===== */
.stats-summary {
  cursor: default !important;
}
.stats-summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  text-align: center;
}
.stats-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.stats-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.stats-value-lg {
  font-size: 22px;
}

/* ===== Přehledová karta — mřížka 2 (široké) + 3 metriky =====
   Layout: dvě široké buňky (utraceno celkem, dlužník), pak řada se třemi
   menšími (členů / výdajů / převodů). */
.stats-overview {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: default;
}
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px 16px;
}
.overview-cell-wide {
  grid-column: span 3;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.overview-cell-wide .stats-label {
  margin-bottom: 0;
}
.overview-cell {
  text-align: center;
}
.overview-debtor-name {
  font-weight: 600;
  margin-right: 6px;
}
.overview-debtor-amount {
  color: var(--danger, #c62828);
  font-weight: 600;
}
[data-theme="dark"] .overview-debtor-amount {
  color: #ff8a80;
}

/* ===== Členské kartičky =====
   Mřížka kartiček, každá: avatar + jméno + 4 řádky (zaplatil, utratil,
   převody, saldo). Saldo je obarvené podle znaménka. */
.stats-members {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.member-stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.member-stat-card.member-inactive {
  opacity: .6;
}
.member-stat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.member-stat-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-stat-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.member-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.member-stat-balance {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 6px;
  font-weight: 600;
  font-size: 14px;
}
.balance-positive { color: var(--success, #2e7d32); }
.balance-negative { color: var(--danger, #c62828); }
.balance-zero     { color: var(--muted); }
[data-theme="dark"] .balance-positive { color: #81c784; }
[data-theme="dark"] .balance-negative { color: #ff8a80; }
.chart-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  max-width: 360px;
  margin: 0 auto 12px;
}
.chart-wrap-bar {
  max-width: 100%;
}
.chart-wrap canvas {
  max-height: 280px;
}
.stats-legend {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 8px 4px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  font-size: 14px;
}
.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-label {
  flex: 1;
  color: var(--text);
}
.legend-value {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ===== PWA install instructions ===== */
.install-steps {
  margin: 12px 0;
  padding-left: 24px;
  line-height: 1.7;
}
.install-steps li {
  margin-bottom: 8px;
}

/* ===== Color picker (barva skupiny) ===== */
.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding: 4px 0;
}
.color-swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform .1s, border-color .1s;
  padding: 0;
  flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.06); }
.color-swatch.active {
  border-color: var(--text);
  transform: scale(1.08);
}

/* ===== Group card s barevným pruhem + hvězdou ===== */
.group-card {
  position: relative;
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-star {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--muted);
  flex-shrink: 0;
  font-family: inherit;
  line-height: 1;
  transition: color .15s, transform .1s;
}
.card-star.active { color: #f59e0b; }
.card-star:active { transform: scale(1.2); }
.card-star:hover { color: var(--text); }
.group-card .card-star.active:hover { color: #d97706; }

.group-card-content {
  flex: 1;
  min-width: 0;
}
.group-card-arrow {
  font-size: 20px;
  color: var(--muted);
  flex-shrink: 0;
}

/* Banner pro neaktivní skupiny */
.inactivity-banner {
  background: var(--info-bg);
  color: var(--info-fg);
  border-left: 3px solid var(--warning);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.inactivity-banner.danger {
  background: rgba(220,38,38,.08);
  color: var(--danger);
  border-left-color: var(--danger);
}

/* ===== Checkbox row v modalu (např. „neaktivní člen") ===== */
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin-top: 12px !important;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.checkbox-row input[type="checkbox"] {
  width: 18px !important;
  height: 18px !important;
  min-height: auto !important;
  padding: 0 !important;
  flex-shrink: 0;
  border: 1px solid var(--border) !important;
}

/* ===== QR kód kontejner ===== */
.qr-container {
  display: flex;
  justify-content: center;
  margin: 20px 0;
  background: white;
  padding: 16px;
  border-radius: 8px;
}
.qr-container img,
.qr-container svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ===== Theme options v Help modalu ===== */
.theme-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}
.theme-option {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  margin: 0 !important;
  font-weight: 400 !important;
}
.theme-option input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

/* ===== QR + Settle tlačítko v vyrovnání ===== */
.settle-card {
  cursor: default !important;
}
.settle-qr-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--primary);
  font-family: inherit;
  margin-left: 8px;
  white-space: nowrap;
}
.settle-qr-btn:hover { background: var(--surface-3); }

.invite-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ===== Avatary členů ===== */
.member-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.member-avatar-sm {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

/* ===== Settle (vyrovnání) — DONE button ===== */
.settle-done-btn {
  background: var(--success);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  margin-left: 8px;
  white-space: nowrap;
}
.settle-done-btn:hover { opacity: 0.9; }
.settle-done-btn:active { transform: scale(0.97); }

/* ===== Pull-to-refresh indikátor ===== */
.pull-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -60px);
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  pointer-events: none;
  transition: transform 0.15s ease-out;
}
.pull-indicator svg {
  width: 22px;
  height: 22px;
  transition: transform 0.2s;
}
.pull-indicator.ready {
  background: var(--success);
}
.pull-indicator.ready svg {
  transform: rotate(180deg);
}
.pull-indicator.spinning svg {
  animation: spin 0.8s infinite linear;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Inactive member badge */
.member-inactive-badge {
  display: inline-block;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.member-admin-badge {
  display: inline-block;
  font-size: 11px;
  background: rgba(217, 119, 6, 0.15);
  color: #b8870a;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 500;
  white-space: nowrap;
}
[data-theme="dark"] .member-admin-badge {
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
}

/* ===== Help modal ===== */
.help-modal-card {
  max-width: 600px;
}
.help-content h3 {
  margin-top: 24px;
  margin-bottom: 8px;
  font-size: 16px;
  color: var(--primary);
  font-weight: 600;
}
.help-content h3:first-child { margin-top: 0; }
.help-content p {
  margin: 8px 0;
  line-height: 1.6;
  font-size: 15px;
  color: var(--text);
}
.help-content ul, .help-content ol {
  margin: 8px 0 12px 22px;
  line-height: 1.7;
  font-size: 15px;
  color: var(--text);
}
.help-content li {
  margin-bottom: 6px;
}
.help-content code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: Consolas, monospace;
}
.help-tip {
  background: var(--info-bg);
  color: var(--info-fg);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  margin: 12px 0;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.5;
}
/* Speciální zvýraznění pro AI tip nahoře v nápovědě */
.help-ai-tip {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(168, 85, 247, 0.08));
  border-left-color: #6366f1;
  margin-bottom: 20px;
}
[data-theme="dark"] .help-ai-tip {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.18));
}

/* ===== Donate / podpora — modal styly ===== */
.donate-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin: 10px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: transform .05s, border-color .15s, box-shadow .15s;
  cursor: pointer;
}
.donate-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(90, 62, 150, 0.12);
}
.donate-btn:active { transform: scale(.99); }
.donate-btn-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--surface-3);
}
.donate-btn-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.donate-btn-title {
  font-weight: 600;
  font-size: 15px;
}
.donate-btn-sub {
  font-size: 12px;
  color: var(--muted);
}
.donate-btn-arrow {
  font-size: 20px;
  color: var(--muted);
  flex-shrink: 0;
}
/* Brand barvy jednotlivých služeb */
.donate-btn-kofi .donate-btn-icon { background: #FF5E5B; color: white; }
.donate-btn-revolut .donate-btn-icon { background: #0075EB; color: white; }
.donate-btn-paypal .donate-btn-icon {
  background: #003087;
  color: #FFC439;
  font-weight: bold;
  font-size: 22px;
}

/* QR sekce */
.donate-qr-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.donate-qr-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.donate-qr-section .muted {
  font-size: 13px;
  margin-bottom: 12px;
}
.donate-qr-wrap {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: white;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.donate-qr-wrap svg,
.donate-qr-img {
  max-width: 240px;
  width: 100%;
  height: auto;
  display: block;
}
[data-theme="dark"] .donate-qr-wrap {
  background: white; /* QR vždy na bílém — banky to očekávají */
}
.donate-qr-account {
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

/* ===== Safe area pro iOS standalone (notch) ===== */
@supports (padding: env(safe-area-inset-top)) {
  .topbar {
    padding-top: calc(14px + env(safe-area-inset-top));
  }
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ===== Větší obrazovky ===== */
@media (min-width: 600px) {
  .view, .tab-pane { max-width: 720px; margin: 0 auto; }
  .modal { align-items: center; }
  .modal-card { border-radius: var(--radius); }
  .topbar h1 { text-align: left; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: var(--z-toast);
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  animation: fadeIn .2s;
  max-width: 90%;
  text-align: center;
}
.toast.error { background: var(--danger); color: white; }
.toast.success { background: var(--success, #2e7d32); color: white; }

/* ===== Rodiny (podskupiny) ===== */
.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.family-intro {
  font-size: 13px;
  margin: -4px 0 8px;
  line-height: 1.4;
}
.btn-add-family {
  margin: 8px 0 16px;
}
.family-card {
  cursor: pointer;
}
.family-color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);
}
.family-tag {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
}
.family-tag-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* ===== Settle mode tabs ===== */
#settle-mode-tabs {
  margin-bottom: 12px;
}
.settle-pick-amount {
  font-size: 18px;
  font-weight: 600;
  padding: 10px;
  background: var(--info-bg);
  color: var(--info-fg);
  border-radius: 8px;
  text-align: center;
  margin: 8px 0 16px;
}