/* ================================================================
   style.css — doma. · osobní finance, smlouvy, termíny, spotřeba
   Mobil napřed; od 900 px boční navigace.
   ================================================================ */

:root {
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --ink: #14213D;
  --muted: #56627A;
  --line: #E2E7EF;
  --line-2: #D3DAE5;
  --accent: #2C4C8C;
  --accent-ink: #1E3768;
  --accent-soft: #E7EEF8;
  --on-accent: #FFFFFF;
  --red: #C8102E;
  --red-ink: #A50D26;
  --red-soft: #FBE9EC;
  --green: #1F7A4A;
  --green-soft: #E3F4EA;
  --amber-ink: #8A4B00;
  --amber-soft: #FDF0DC;
  --hero: #14213D;
  --hero-ink: #FFFFFF;
  --hero-muted: #C9D3E6;
  --water: #2C6FB7;
  --heat: #B5461D;
  --ghost-bar: #C9D1DE;
  --shadow: 0 10px 30px rgba(20, 33, 61, .18);
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 22px;
  --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --digits: "Fira Sans Condensed", "Arial Narrow", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1521; --surface: #182131; --surface-2: #1D2839; --ink: #E6EBF3; --muted: #9AA6BA;
    --line: #263247; --line-2: #33405A; --accent: #8FB0F0; --accent-ink: #C7D6F7; --accent-soft: #1F2C45;
    --on-accent: #0F1521; --red: #FF6B81; --red-ink: #FF9AAA; --red-soft: #3A1C24; --green: #5FCB8F;
    --green-soft: #17322A; --amber-ink: #F2C072; --amber-soft: #3A2C14; --hero: #22304A; --hero-ink: #FFFFFF;
    --hero-muted: #B8C5DE; --water: #6AA8E8; --heat: #EE8456; --ghost-bar: #3A4760; --shadow: 0 10px 30px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ── Načítání ─────────────────────────────────────────────── */
.loading { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); padding: 24px; text-align: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Rozložení ────────────────────────────────────────────── */
.shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px 4px 20px; min-height: 60px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 4px; }
.logo { font-size: 24px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.logo i { font-style: normal; color: var(--red); }
.main { max-width: 820px; margin: 0 auto; padding: 4px 16px 112px; }

.icon-btn {
  position: relative; width: 44px; height: 44px; border: 0; border-radius: 22px; background: none;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink);
}
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 4px; background: var(--red); }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px 4px calc(10px + env(safe-area-inset-bottom));
}
.nav-btn {
  position: relative; border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 500; min-height: 52px;
}
.nav-btn .pill { width: 46px; height: 30px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.nav-btn[aria-current="page"] { color: var(--ink); font-weight: 600; }
.nav-btn[aria-current="page"] .pill { background: var(--accent-soft); color: var(--accent); }
.nav-btn .dot { position: absolute; top: 4px; left: calc(50% + 12px); width: 8px; height: 8px; border-radius: 4px; background: var(--red); }

.side-nav { display: none; }

@media (min-width: 900px) {
  .bottom-nav { display: none; }
  .side-nav {
    display: flex; flex-direction: column; gap: 4px; position: fixed; top: 0; bottom: 0; left: 0; width: 240px;
    background: var(--surface); border-right: 1px solid var(--line); padding: 22px 14px;
  }
  .side-nav .logo { padding: 0 10px 18px; }
  .side-nav .nav-btn { flex-direction: row; justify-content: flex-start; gap: 10px; font-size: 14px; padding: 0 8px; min-height: 46px; border-radius: 12px; }
  .side-nav .nav-btn .pill { width: 30px; height: 30px; }
  .side-nav .nav-btn[aria-current="page"] { background: var(--accent-soft); }
  .side-nav .nav-btn[aria-current="page"] .pill { background: none; }
  .side-nav .nav-btn .dot { position: static; margin-left: auto; }
  .side-nav .side-foot { margin-top: auto; }
  .shell { margin-left: 240px; }
  .topbar .logo { display: none; }
  .main { padding-bottom: 48px; }
}

/* ── Typografie a stránka ─────────────────────────────────── */
.page { display: flex; flex-direction: column; gap: 16px; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 0 4px; }
.eyebrow { font-size: 13px; color: var(--muted); }
.page-title { margin: 4px 0 0; font-size: 26px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.section-title { margin: 6px 4px 0; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--green); }
.neg { color: var(--red-ink); }

/* ── Karty ────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 16px 18px; }
.card-tight { padding: 4px 16px; }
.hero { background: var(--hero); color: var(--hero-ink); border-radius: var(--r-xl); padding: 18px; border: 0; }
.hero .muted, .hero .hero-muted { color: var(--hero-muted); }
.hero-value { font-size: 28px; font-weight: 700; line-height: 1.15; margin-top: 2px; }
.hero-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; margin-top: 14px; }
.hero-grid .label { font-size: 11px; color: var(--hero-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-grid .val { font-size: 15px; font-weight: 600; }
.hero-grid .val.neg { color: #FFB3BF; }

.todo {
  width: 100%; text-align: left; border: 0; border-radius: var(--r-xl); background: var(--accent-soft); color: var(--ink);
  padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 10px;
}
.todo .kicker { font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: .04em; }
.todo .big { font-size: 26px; font-weight: 500; line-height: 1.15; }
.todo .big strong { color: var(--red); font-weight: 700; }
.todo .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.round-go { width: 36px; height: 36px; border-radius: 18px; background: var(--red); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.tiles > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.tiles-3 > :last-child:nth-child(odd) { grid-column: auto; }
.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; text-align: left; color: var(--ink); }
.tile .label { font-size: 12px; color: var(--muted); }
.tile .val { font-size: 18px; font-weight: 700; margin-top: 2px; }
.tiles-3 .tile { padding: 12px 10px; }
.tiles-3 .tile .val { font-size: 16px; }
.tile .sub { font-size: 11px; color: var(--muted); }

.banner { border-radius: var(--r-md); padding: 12px 14px; font-size: 13px; line-height: 1.45; }
.banner-info { background: var(--accent-soft); color: var(--accent-ink); }
.banner-warn { background: var(--amber-soft); color: var(--amber-ink); }
.banner-red { background: var(--red-soft); color: var(--red-ink); }

/* ── Řádky seznamů ────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px; color: var(--ink); min-height: 60px;
}
button.item:hover, .item.clickable:hover { border-color: var(--line-2); }
.item.pink { background: var(--red-soft); border-color: transparent; }
.item.blue { background: var(--accent-soft); border-color: transparent; }
.item.amber { background: var(--amber-soft); border-color: transparent; }
.item .main-col { flex: 1 1 auto; min-width: 0; }
.item .name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item .right { flex: 0 0 auto; text-align: right; }
.item .amount { font-size: 15px; font-weight: 600; white-space: nowrap; }
.item .ico { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 12px; background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.item.pink .ico { color: var(--red); }
.item.amber .ico { color: var(--amber-ink); }
.dotc { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 5px; }
.date-box { flex: 0 0 48px; height: 52px; border-radius: 12px; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.item:not(.pink):not(.blue) .date-box { background: var(--bg); }
.date-box b { font-size: 18px; line-height: 1; }
.date-box span { font-size: 11px; color: var(--muted); margin-top: 2px; }

.rows > .row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); min-height: 56px; }
.rows > .row:first-child { border-top: 0; }
.rows > button.row { width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; color: var(--ink); }
.rows > .row .main-col { flex: 1 1 auto; min-width: 0; }
.rows .name { font-size: 14px; font-weight: 500; }
.rows .sub { font-size: 12px; color: var(--muted); }
.sign { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.sign.in { background: var(--green-soft); color: var(--green); }
.sign.out { background: var(--bg); color: var(--muted); }
.sign.tr { background: var(--accent-soft); color: var(--accent); }

.badge { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 6px; padding: 2px 7px; margin-top: 3px; white-space: nowrap; }
.badge.red { background: var(--red-soft); color: var(--red-ink); }
.badge.blue { background: var(--accent-soft); color: var(--accent-ink); }
.badge.grey { background: var(--bg); color: var(--muted); }

.reorder { display: flex; gap: 4px; flex: 0 0 auto; }
.reorder button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* ── Ovládací prvky ───────────────────────────────────────── */
.btn {
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-danger { background: none; border-color: transparent; color: var(--red-ink); padding: 0 8px; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: 999px; }
.btn-link { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13px; min-height: 40px; padding: 0 4px; }
.btn-dashed { width: 100%; min-height: 48px; border-radius: var(--r-md); border: 1.5px dashed var(--line-2); background: none; color: var(--accent); font-weight: 600; font-size: 14px; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 13px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1 1 0; min-height: 40px; font-size: 14px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ── Spotřeba ─────────────────────────────────────────────── */
.odo-wrap { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.odo { display: flex; gap: 3px; padding: 5px; background: #1C242B; border-radius: 10px; box-shadow: inset 0 2px 6px rgba(0,0,0,.5); }
.odo span { width: 24px; text-align: center; font: 600 30px/1.15 var(--digits); color: #F4F7F9; border-radius: 4px; background: linear-gradient(#2A333B, #1C242B 45%, #11171C); }
.odo span.red { background: linear-gradient(#DA3B3F, #C8262B 45%, #8E1418); }
.odo span.sep { width: 6px; background: none; }
.odo-unit { font-size: 16px; font-weight: 600; color: var(--muted); padding-bottom: 4px; }
.chart { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; align-items: end; height: 170px; }
.chart .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.chart .bars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; height: 140px; }
.chart .bar { width: 42%; max-width: 14px; border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .bar.prev { background: var(--ghost-bar); }
.chart .m { font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
table.yoy { width: 100%; border-collapse: collapse; font-size: 14px; }
.yoy th, .yoy td { padding: 9px 6px; text-align: right; white-space: nowrap; }
.yoy th:first-child, .yoy td:first-child { text-align: left; }
.yoy thead th { font-size: 12px; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); }
.yoy tbody tr + tr td { border-top: 1px solid var(--line); }
.scroll-x { overflow-x: auto; }

/* ── Sheet / modál ────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 21, 33, .5);
  display: flex; flex-direction: column; justify-content: flex-end; animation: ov .15s ease-out;
}
@keyframes ov { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  background: var(--surface); border-radius: 24px 24px 0 0; max-height: 92vh; overflow-y: auto;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(24px); } to { transform: none; } }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.sheet-close { flex: 0 0 auto; width: 44px; height: 44px; border: 0; border-radius: 22px; background: var(--bg); display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.sheet-foot { display: flex; align-items: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.sheet-foot .spacer { flex: 1 1 auto; }
@media (min-width: 640px) {
  .overlay { justify-content: center; align-items: center; padding: 24px; }
  .sheet { width: 100%; max-width: 540px; border-radius: 24px; max-height: 88vh; padding-bottom: 22px; }
  .sheet .grip { display: none; }
}

.form { display: flex; flex-direction: column; gap: 12px; }
.fld { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; }
.fld .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.inp {
  min-height: 44px; width: 100%; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px;
  background: var(--surface); font-size: 15px; font-weight: 400;
}
textarea.inp { padding: 10px 12px; min-height: 64px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.type-sel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.type-sel button { min-height: 42px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; font-size: 14px; }
.type-sel button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.fieldset { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 15px; font-weight: 600; min-height: 44px; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent); }
.colors { display: flex; flex-wrap: wrap; gap: 8px; }
.colors button { width: 34px; height: 34px; border-radius: 17px; border: 3px solid transparent; }
.colors button[aria-pressed="true"] { border-color: var(--ink); }

/* ── Toast ────────────────────────────────────────────────── */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow); max-width: 320px; text-align: center; }
.toast.err { background: var(--red); color: #fff; }

/* ── Přihlášení ───────────────────────────────────────────── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.login-brand { text-align: center; }
.login-brand .logo { font-size: 40px; }
.login-brand p { margin: 4px 0 0; color: var(--muted); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 18px; }
.login-alert { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.login-note { text-align: center; font-size: 12px; color: var(--muted); margin: 0; }
