:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --series-1: #2a78d6;  /* výnosy */
  --series-2: #eb6834;  /* náklady */
  --line: #0b0b0b;      /* výsledek */
  --good: #006300;
  --bad: #d03b3b;
  --hl: rgba(42, 120, 214, 0.08);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --brand-ink: #1f2b3a;  /* tmavě modrá z loga BOTAX */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --line: #ffffff;
    --good: #0ca30c;
    --bad: #e66767;
    --hl: rgba(57, 135, 229, 0.12);
    --brand-ink: #ffffff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --text: #ffffff; --text-2: #c3c2b7;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --accent: #3987e5;
  --series-1: #3987e5; --series-2: #d95926; --line: #ffffff; --good: #0ca30c; --bad: #e66767;
  --hl: rgba(57, 135, 229, 0.12); --brand-ink: #ffffff;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- rámec */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; width: auto; height: 32px; }
.brand-name { display: inline-flex; align-items: baseline; gap: 6px; font-size: 16px; line-height: 1; }
.brand-botax { font-weight: 800; letter-spacing: 0.08em; color: var(--brand-ink); }
.brand-product { font-weight: 500; color: var(--text-2); }
.topnav { display: flex; align-items: center; gap: 18px; }
.topnav .who { color: var(--text-2); }
.page { max-width: 1320px; margin: 0 auto; padding: 20px 24px 48px; }
.narrow { max-width: 440px; margin: 0 auto; padding: 64px 16px; }
.page-title { font-size: 22px; margin: 18px 0 4px; }
.page-title .muted { font-weight: 400; }
.period { margin: 0 0 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.empty { text-align: center; padding: 40px; }

/* ---------- ovládací prvky */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-quiet { border-color: transparent; color: var(--text-2); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--axis); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, .btn:focus-visible, .segmented > *:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; }

.filters { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.field > span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.field select { min-width: 220px; }
.field select.short { min-width: 0; }
.freshness { display: flex; align-items: center; gap: 10px; }

.segmented { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; overflow: hidden; }
.segmented > * { padding: 7px 12px; background: var(--surface); color: var(--text-2); border: 0; font: inherit; cursor: pointer; }
.segmented > * + * { border-left: 1px solid var(--axis); }
.segmented > *:hover { background: var(--surface-2); text-decoration: none; }
.segmented > [aria-current] { background: var(--text); color: var(--surface); font-weight: 600; }
.controls { display: flex; gap: 10px; align-items: center; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid var(--border); background: var(--surface); }
.flash-ok { border-left: 4px solid var(--good); }
.flash-error { border-left: 4px solid var(--bad); }
.flash-info { border-left: 4px solid var(--accent); }

/* ---------- dlaždice */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.fn-ref { margin-left: 2px; color: var(--text-2); }
.footnote { margin: 0 0 16px; font-size: 12px; color: var(--muted); max-width: 980px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.tile-label { color: var(--text-2); font-size: 13px; }
.tile-value { font-size: clamp(22px, 2.2vw, 28px); font-weight: 600; margin: 4px 0 6px; white-space: nowrap; }
.tile-hero .tile-value { font-size: clamp(22px, 2.2vw, 30px); }
.tile-value.loss { color: var(--bad); }  /* ztráta červeně, zisk černě */
.tile-delta { font-size: 12.5px; }
.tile-delta.good > span:first-child, .tile-delta.good { color: var(--good); }
.tile-delta.bad { color: var(--bad); }
.tile-delta .muted { margin-left: 4px; }

/* ---------- graf */
.legend { display: flex; gap: 16px; color: var(--text-2); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; flex: none; }
.key-bar { width: 10px; height: 10px; border-radius: 2px; }
.key-bar.s1 { background: var(--series-1); }
.key-bar.s2 { background: var(--series-2); }
.key-line { width: 14px; height: 2px; background: var(--line); border-radius: 1px; position: relative; }
.key-line::after { content: ""; position: absolute; left: 4px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: var(--line); }

.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .tick.future { opacity: 0.5; }
.chart .bar.s1 { fill: var(--series-1); }
.chart .bar.s2 { fill: var(--series-2); }
.chart .line { fill: none; stroke: var(--line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--line); stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart .band-hl { fill: var(--hl); }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); min-width: 220px; font-size: 13px; z-index: 5; }
.tip-title { font-weight: 600; margin-bottom: 6px; }
.tip-row { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; }
.tip-row span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tip-row b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- výsledovka */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.pl { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
table.pl th, table.pl td { padding: 7px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.pl thead th { position: sticky; top: 0; background: var(--surface); color: var(--text-2); font-weight: 500; font-size: 12.5px; border-bottom: 1px solid var(--axis); }
table.pl .lbl { position: sticky; left: 0; background: var(--surface); text-align: left; font-weight: 400; min-width: 280px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; z-index: 1; }
table.pl .num { text-align: right; }
table.pl .total { font-weight: 600; border-left: 1px solid var(--grid); }
table.pl .future { color: var(--muted); }
table.pl .zero { color: var(--muted); }
table.pl .row-section > *, table.pl .row-section .lbl { background: var(--surface-2); font-weight: 600; }
table.pl tbody + tbody .row-section > * { border-top: 12px solid var(--surface); }
table.pl .row-group button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
table.pl .row-group:hover > * { background: var(--hl); }
table.pl .row-group:hover .lbl { background: color-mix(in srgb, var(--surface) 92%, var(--accent)); }
table.pl .caret { width: 0; height: 0; border-left: 5px solid var(--text-2); border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform 0.15s; }
table.pl [aria-expanded="true"] .caret { transform: rotate(90deg); }
table.pl .row-account > * { color: var(--text-2); font-size: 13px; }
table.pl .row-account .lbl { padding-left: 32px; }
table.pl .acc-code { color: var(--muted); margin-right: 4px; }
table.pl .row-result > *, table.pl .row-result .lbl { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 0; }
table.pl .row-result .neg { color: var(--bad); }  /* ztráta červeně, zisk zůstává černý */
table.pl .col-hl { background: var(--hl); }

/* ---------- administrace */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 12.5px; border-bottom: 1px solid var(--axis); padding: 6px 8px; }
table.list td { border-bottom: 1px solid var(--grid); padding: 10px 8px; vertical-align: top; }
table.list tr.inactive td { opacity: 0.55; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.inline-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.inline-form select { min-width: 320px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1 1 240px; }
.grow input { width: 100%; }
.checks { border: 1px solid var(--grid); border-radius: 8px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.checks legend { color: var(--text-2); font-size: 12px; padding: 0 4px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; }
.checks.compact { border: 0; padding: 0; align-items: center; }
.pill { display: inline-block; margin: 4px 4px 0 0; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); font-size: 11.5px; }
.status { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; color: #fff; font-size: 10px; font-weight: 700; }
.status.good { background: var(--good); }
.status.bad { background: var(--bad); }
.mail pre { white-space: pre-wrap; font: 13px/1.5 var(--font); margin: 0; color: var(--text-2); }

.auth-card h1 { font-size: 22px; margin-bottom: 8px; }
.auth-card form { display: grid; gap: 10px; margin-top: 16px; }
.auth-card label { font-size: 13px; color: var(--text-2); }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
  .topnav .who { display: none; }
  .tiles { grid-template-columns: 1fr; }
  .field select, .inline-form select { min-width: 0; width: 100%; }
  .filter-form, .field { width: 100%; }
  table.pl .lbl { min-width: 180px; max-width: 200px; }
  .table-wrap { margin: 0 -20px; }
}

/* ---------- pohyby (proklik z výsledovky) */
.hint { margin: 2px 0 0; }
table.pl tr[data-acc] td.num:not(.future) { cursor: pointer; }
table.pl tr[data-acc] td.num:not(.future):hover { background: var(--hl); box-shadow: inset 0 -2px 0 var(--accent); }
table.pl .acc-btn { all: unset; cursor: pointer; }
table.pl .acc-btn:hover { color: var(--accent); text-decoration: underline; }
table.pl .acc-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body.no-scroll { overflow: hidden; }
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer[hidden] { display: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--surface); border-left: 1px solid var(--border); box-shadow: -12px 0 32px rgba(0, 0, 0, 0.15); display: flex; flex-direction: column; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 10px; }
.drawer-head h2 { font-size: 17px; }
.drawer-head p { margin: 4px 0 0; }
.drawer-months { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 12px; border-bottom: 1px solid var(--grid); }
.chip { font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--axis); background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip.empty { color: var(--muted); border-color: var(--grid); }
.chip[aria-current] { background: var(--text); border-color: var(--text); color: var(--surface); font-weight: 600; }
.drawer-body { overflow: auto; padding: 0 20px 24px; flex: 1; }
.empty-note { padding: 24px 0; }
table.moves { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.moves th, table.moves td { padding: 8px 6px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
table.moves thead th { position: sticky; top: 0; background: var(--surface); color: var(--text-2); font-weight: 500; font-size: 12px; border-bottom: 1px solid var(--axis); }
table.moves .num { text-align: right; white-space: nowrap; }
table.moves .date, table.moves .doc { white-space: nowrap; }
table.moves .text { width: 100%; }
table.moves .subtotal > * { background: var(--surface-2); font-weight: 600; font-size: 12.5px; }
table.moves tfoot > tr > * { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 0; }
@media (max-width: 560px) {
  .drawer-head, .drawer-months, .drawer-body { padding-left: 16px; padding-right: 16px; }
  table.moves .doc .small { display: none; }
}

/* ---------- dlaždice Chybějící doklady (otevírá seznam) */
.tile-action { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.tile-action > span { display: block; }
.tile-action:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-more { float: right; color: var(--accent); font-size: 12.5px; }
table.moves .income { color: var(--good); }

/* ---------- upozornění při prvním přihlášení */
.disclaimer-page { padding: 0; }
.modal-backdrop { min-height: calc(100vh - 49px); display: grid; place-items: center; padding: 32px 16px;
  background: radial-gradient(ellipse at top, var(--hl), transparent 60%), var(--page); }
.modal { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px 32px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.14); }
.modal h1 { font-size: 22px; margin: 2px 0 14px; }
.modal p { margin: 0 0 12px; line-height: 1.55; }
.modal-kicker { display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); background: var(--hl); border-radius: 99px; padding: 3px 10px; }
.modal-form { margin-top: 18px; border-top: 1px solid var(--grid); padding-top: 18px; }
.modal-check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 12px; border-radius: 10px; background: var(--surface-2); }
.modal-check input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.modal-check.has-error { outline: 2px solid var(--bad); }
.modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.modal-accepted { color: var(--good); font-weight: 500; margin-top: 18px !important; }
@media (max-width: 560px) { .modal { padding: 22px 18px; } .modal-actions .btn { width: 100%; justify-content: center; } }
.fieldset-note { flex-basis: 100%; margin: 0 0 4px; }
