:root {
  --base: #f5f6fb; --surface: #ffffff; --ink: #161a2b; --muted: #64748b; --line: rgba(22,26,43,.1);
  --accent: #4f46e5; --accent-2: #0284c7; --alert: #e11d48; --success: #059669; --warn: #d97706; --progress: #7c3aed;
  --shadow: 0 1px 2px rgba(22,26,43,.05), 0 4px 16px rgba(22,26,43,.04);
  --radius: .625rem;
  --s1: #4f46e5; --s2: #0891b2;
  --on-accent: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --base: #10121c; --surface: #191c2c; --ink: #edeff7; --muted: #9aa3b8; --line: rgba(237,239,247,.1);
    --accent: #818cf8; --accent-2: #38bdf8; --alert: #fb7185; --success: #34d399; --warn: #fbbf24; --progress: #a78bfa;
    --s1: #7c7ff5; --s2: #0fa697;
    --on-accent: #10121c;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --base: #10121c; --surface: #191c2c; --ink: #edeff7; --muted: #9aa3b8; --line: rgba(237,239,247,.1);
  --accent: #818cf8; --accent-2: #38bdf8; --alert: #fb7185; --success: #34d399; --warn: #fbbf24; --progress: #a78bfa;
  --s1: #7c7ff5; --s2: #0fa697;
  --on-accent: #10121c;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--base); color: var(--ink); font: 14px/1.5 "Geist", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: "Geist", system-ui, sans-serif; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
.mono { font-family: "Geist Mono", ui-monospace, monospace; }
.muted { color: var(--muted); } .small { font-size: 12px; } .r { text-align: right; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Layout */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font-family: "Geist", system-ui, sans-serif; font-size: 1.3rem; font-weight: 600; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 16px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.nav a:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); text-decoration: none; }
.nav a.on { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side .foot { margin-top: auto; padding: 8px 10px; }
main { padding: 28px 32px 60px; min-width: 0; max-width: 1280px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 7px 13px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: color-mix(in srgb, var(--ink) 5%, var(--surface)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(79,70,229,.3); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--alert); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.f > span { text-transform: uppercase; letter-spacing: .05em; font-size: 11px; }
label.chk { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.form-grid .w2 { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 12px; font: inherit; color: var(--muted); cursor: pointer; }
.seg button.on { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { width: 260px; }
.toolbar select { width: auto; }

/* Cards & tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card h2 { margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.tile .v { font-size: 1.6rem; font-weight: 600; font-family: "Geist", system-ui, sans-serif; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--muted); font-size: 12px; }
.tile.alert .v { color: var(--alert); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
table.t th[data-sort] { cursor: pointer; } table.t th[data-sort]:hover { color: var(--ink); }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; } table.t tbody tr.click:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
table.t tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: color-mix(in srgb, var(--c, var(--muted)) 13%, transparent); color: var(--c, var(--muted)); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.paid { --c: var(--success); } .badge.unpaid { --c: var(--accent-2); } .badge.partial { --c: var(--progress); } .badge.overdue { --c: var(--alert); } .badge.cancelled { --c: var(--muted); }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--muted); margin-left: 6px; font-weight: 500; }
.pill { display: inline-block; font-family: "Geist Mono", ui-monospace, monospace; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); padding: 2px 10px; border-radius: 999px; font-weight: 500; }

/* Bars chart */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; height: 160px; margin-top: 8px; }
.bars .b { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; max-width: 34px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b span { font-size: 11px; color: var(--muted); }

/* Items editor */
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; padding: 4px 6px; font-weight: 600; }
.items td { padding: 3px 4px; vertical-align: middle; }
.items td.sum { text-align: right; font-variant-numeric: tabular-nums; padding-right: 8px; white-space: nowrap; }
.items input, .items select { padding: 6px 8px; }
.totals { margin-left: auto; width: min(340px, 100%); margin-top: 12px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 1.25rem; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }

/* Detail */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

/* Series settings */
.series { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; background: var(--surface); }
.series.off { opacity: .6; }
.series .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.series .row { display: grid; grid-template-columns: 1.3fr .7fr 1.6fr 1fr .8fr; gap: 10px; align-items: end; }
.tokens { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tokens button { font: 12px "Geist Mono", ui-monospace, monospace; border: 1px dashed var(--line); background: none; color: var(--accent); border-radius: 6px; padding: 2px 7px; cursor: pointer; }
.tokens button:hover { border-color: var(--accent); }
.preview { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.err { color: var(--alert); font-size: 12px; margin-top: 6px; }
.help { background: color-mix(in srgb, var(--accent-2) 8%, transparent); border-radius: var(--radius); padding: 12px 16px; font-size: 13px; }
.help code { font-family: "Geist Mono", ui-monospace, monospace; color: var(--accent); }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(16,18,28,.45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { padding: 18px 20px 0; display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 16px 20px; }
.modal footer { padding: 0 20px 18px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--base); padding: 10px 18px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.2); animation: fade .15s; max-width: calc(100vw - 32px); }
.toast.error { background: var(--alert); color: var(--on-accent); }
@keyframes fade { from { opacity: 0; } }
.ac { position: relative; }
.ac-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 260px; overflow: auto; margin-top: 4px; }
.ac-list div { padding: 7px 10px; cursor: pointer; } .ac-list div:hover, .ac-list div.on { background: color-mix(in srgb, var(--accent) 10%, transparent); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row; padding: 6px 8px; border-right: 0; border-top: 1px solid var(--line); z-index: 40; justify-content: space-around; }
  .brand, .side .foot { display: none; }
  .nav { display: contents; }
  .side { gap: 0; padding: 4px 2px; justify-content: stretch; }
  .nav a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 1px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
  main { padding: 18px 16px 90px; }
  .series .row { grid-template-columns: 1fr 1fr; }
  .toolbar input[type=search] { width: 100%; }
  .form-grid .w2 { grid-column: auto; }
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; border-bottom: 1px solid var(--line); padding: 6px 0; }
  .items td:first-child { grid-column: 1 / -1; }
}

/* Dashboard */
.dash { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.dash > * { min-width: 0; margin: 0 !important; }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }
.hero .k, .kpi .k { color: var(--muted); font-size: 13px; font-weight: 500; }
.hero .v { font: 600 52px/1.1 "Geist", system-ui, sans-serif; letter-spacing: -.02em; margin: 6px 0 8px; }
.hero .v small { font-size: 22px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.kpi .v { font: 600 24px/1.2 "Geist", system-ui, sans-serif; margin-top: 6px; letter-spacing: -.01em; }
.kpi .s, .hero .s { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.kpi { display: block; color: inherit; text-decoration: none !important; transition: border-color .15s; }
a.kpi:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.delta.up { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }
.delta.down { color: var(--alert); background: color-mix(in srgb, var(--alert) 12%, transparent); }
.delta.flat { color: var(--muted); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.kpi.alert .v { color: var(--alert); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart { position: relative; height: 240px; margin-left: 64px; }
.chart .grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.chart .grid span { position: absolute; right: calc(100% + 8px); top: -8px; font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart .cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(12, 1fr); }
.chart .col { position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 0 3px; cursor: default; }
.chart .col:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); border-radius: 6px 6px 0 0; }
.chart .col b { display: block; width: min(16px, 40%); border-radius: 4px 4px 0 0; min-height: 0; }
.chart .col b.cur { background: var(--s1); } .chart .col b.prev { background: var(--s2); }
.chart .col.future b.cur { opacity: .25; }
.chart .x { position: absolute; top: calc(100% + 6px); left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.chart-wrap { padding-bottom: 26px; }
.tip { position: fixed; z-index: 70; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.14); padding: 10px 12px; font-size: 12.5px; min-width: 190px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tip .row i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.hbar { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; }
.hbar .track { height: 12px; background: color-mix(in srgb, var(--ink) 5%, transparent); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--accent-2); }
.hbar .fill.bad { background: var(--alert); }
.hbar .val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.share { height: 6px; background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: 3px; margin-top: 4px; }
.share i { display: block; height: 100%; background: var(--s1); border-radius: 3px; }
.mini td { padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 13px; }
.mini tr:last-child td { border-bottom: 0; }
.mini { width: 100%; border-collapse: collapse; }
.mini tr.click { cursor: pointer; } .mini tr.click:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.steps { counter-reset: s; display: grid; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: center; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; font-size: 13px; flex: none; }
.steps li.done::before { content: "✓"; background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
@media (max-width: 1100px) { .c3 { grid-column: span 6; } .c4, .c5, .c7 { grid-column: span 6; } .c8 { grid-column: span 12; } }
@media (max-width: 720px) { .dash > * { grid-column: span 12 !important; } .hero .v { font-size: 40px; } .chart { margin-left: 52px; } }

/* Našeptávač */
.suggest { position: fixed; z-index: 80; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(16,18,28,.16); overflow: auto; padding: 4px; }
.sg-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 8px 10px 4px; }
.sg-item { padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.sg-item.on, .sg-item:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.sg-main { font-weight: 500; } .sg-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.sg-state { padding: 8px 10px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 4px; }
.sg-state:first-child { border-top: 0; margin-top: 0; }
.sg-sep { border-top: 1px solid var(--line); margin: 4px 0; }
.suggest mark { background: color-mix(in srgb, var(--accent) 20%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
input.filled { animation: filled 1.2s ease-out; }
@keyframes filled { from { background: color-mix(in srgb, var(--success) 18%, var(--surface)); } }

/* Přepínač firem */
.firm { padding: 0 2px 14px; }
.firm-btn { width: 100%; display: flex; align-items: center; gap: 8px; background: color-mix(in srgb, var(--ink) 4%, transparent); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; text-align: left; }
.firm-btn:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.firm-btn i, .firm-menu .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.firm-btn span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.firm-menu { position: fixed; z-index: 90; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(16,18,28,.18); padding: 4px; max-width: calc(100vw - 16px); }
.firm-menu .sg-item { display: flex; gap: 8px; align-items: center; }
.firmbar { display: none; }
.swatch { width: 28px; height: 28px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 2px var(--surface); }
.swatch.on { border-color: var(--ink); }
.firm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.firm-grid .card { margin: 0 !important; border-top: 4px solid var(--fc); }
.firm-card.current { box-shadow: 0 0 0 2px color-mix(in srgb, var(--fc) 35%, transparent), var(--shadow); }
@media (max-width: 860px) {
  .firm { display: none; }
  .firmbar { display: block; position: sticky; top: 0; z-index: 30; background: var(--base); padding: 10px 16px 0; }
  .firmbar .firm-btn { background: var(--surface); }
}

/* Přihlášení */
body.locked .app { display: none; }
#lock { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent), var(--base); }
.lock-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 60px rgba(16,18,28,.12); padding: 28px; }
.lock-form { display: grid; gap: 12px; margin-top: 14px; }
.lock-card .err:empty { display: none; }

/* Uživatel v menu */
.side .foot { display: grid; gap: 8px; }
#userbox { display: flex; align-items: center; gap: 6px; }
.userlink { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; color: var(--ink); text-decoration: none !important; }
.userlink > span:last-child { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.userlink b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }

/* Matice oprávnění */
.perm td, .perm th { vertical-align: middle; }
.perm th { text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--ink); }
.perm th .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.perm .rolepick { display: block; margin-top: 6px; font-size: 12px; padding: 4px 6px; width: auto; }
.perm-seg button { padding: 4px 9px; font-size: 12.5px; }

/* Telefon: uživatel je v menu přepínače firem; řádky mřížky bez roztahování */
@media (max-width: 860px) {
  .side .foot { display: none !important; }
  .app { align-content: start; }
}

/* ===== Barevný systém: každá část aplikace má svou barvu ===== */
:root {
  --m-dash: #4f46e5; --m-invoices: #1d4ed8; --m-expenses: #c2410c; --m-bank: #0f766e; --m-wealth: #15803d;
  --m-tax: #7e22ce; --m-clients: #0e7490; --m-settings: #475569;
  /* ověřená kategoriální paleta (čitelná i pro barvoslepé) */
  --c-1: #2a78d6; --c-2: #eb6834; --c-3: #1baf7a; --c-4: #eda100; --c-5: #e87ba4; --c-6: #008300; --c-7: #4a3aa7; --c-8: #e34948; --c-0: #94a3b8;
  --mod: var(--m-dash);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --m-dash: #818cf8; --m-invoices: #60a5fa; --m-expenses: #fb923c; --m-bank: #2dd4bf; --m-wealth: #4ade80;
    --m-tax: #c084fc; --m-clients: #22d3ee; --m-settings: #94a3b8;
    --c-1: #3987e5; --c-2: #d95926; --c-3: #199e70; --c-4: #c98500; --c-5: #d55181; --c-6: #008300; --c-7: #9085e9; --c-8: #e66767; --c-0: #64748b;
  }
}
:root[data-theme="dark"] {
  --m-dash: #818cf8; --m-invoices: #60a5fa; --m-expenses: #fb923c; --m-bank: #2dd4bf; --m-wealth: #4ade80;
  --m-tax: #c084fc; --m-clients: #22d3ee; --m-settings: #94a3b8;
  --c-1: #3987e5; --c-2: #d95926; --c-3: #199e70; --c-4: #c98500; --c-5: #d55181; --c-6: #008300; --c-7: #9085e9; --c-8: #e66767; --c-0: #64748b;
}
body[data-mod="dash"] { --mod: var(--m-dash); }
body[data-mod="invoices"] { --mod: var(--m-invoices); }
body[data-mod="expenses"] { --mod: var(--m-expenses); }
body[data-mod="bank"] { --mod: var(--m-bank); }
body[data-mod="wealth"] { --mod: var(--m-wealth); }
body[data-mod="tax"] { --mod: var(--m-tax); }
body[data-mod="clients"] { --mod: var(--m-clients); }
body[data-mod="settings"], body[data-mod="account"] { --mod: var(--m-settings); }

/* menu: barevné ikony, aktivní položka v barvě své části */
.nav a[data-r="dash"] { --c: var(--m-dash); } .nav a[data-r="invoices"] { --c: var(--m-invoices); } .nav a[data-r="expenses"] { --c: var(--m-expenses); }
.nav a[data-r="bank"] { --c: var(--m-bank); } .nav a[data-r="wealth"] { --c: var(--m-wealth); } .nav a[data-r="tax"] { --c: var(--m-tax); }
.nav a[data-r="clients"] { --c: var(--m-clients); } .nav a[data-r="settings"] { --c: var(--m-settings); }
.nav a svg { color: var(--c); }
.nav a.on { background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--c); }
.nav a.on::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

/* nadpis stránky s ikonou části */
.head h1 { display: flex; align-items: center; gap: 12px; }
.hicon { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; background: color-mix(in srgb, var(--mod) 14%, transparent); color: var(--mod); flex: none; }
.hicon svg { width: 20px; height: 20px; }

/* tlačítka, přepínače a karty v barvě části */
main .btn.primary { background: var(--mod); border-color: var(--mod); box-shadow: 0 1px 2px color-mix(in srgb, var(--mod) 35%, transparent); }
main .seg button.on { background: color-mix(in srgb, var(--mod) 13%, transparent); color: var(--mod); }
main .card.kpi, main .card.hero { border-top: 3px solid color-mix(in srgb, var(--kc, var(--mod)) 70%, transparent); }
main .card[href^="#/invoices"] { --kc: var(--m-invoices); } main .card[href^="#/expenses"] { --kc: var(--m-expenses); }
main .card[href^="#/tax"] { --kc: var(--m-tax); } main .card[href^="#/wealth"] { --kc: var(--m-wealth); } main .card[href^="#/bank"] { --kc: var(--m-bank); }
main .card.kpi.good { --kc: var(--success); } main .card.kpi.alert { --kc: var(--alert); } main .card.kpi.info { --kc: var(--m-tax); }
main .card.kpi.fx { --kc: var(--c-4); }
main table.t thead th { background: color-mix(in srgb, var(--mod) 5%, transparent); }
main .card h2 { display: flex; align-items: center; gap: 8px; }
.chart .col b.cur { background: var(--mod); }
body[data-mod="dash"] .chart .col b.cur { background: var(--s1); }
.hbar .fill:not(.bad) { background: var(--mod); }
main .pill { background: color-mix(in srgb, var(--mod) 12%, transparent); color: var(--mod); }
main a:not(.btn):not(.card):not(.hbar) { color: var(--mod); }

/* kategorie a druhy majetku: barevná tečka, text zůstává čitelný */
.cat { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 2px 9px 2px 7px; border-radius: 999px; background: color-mix(in srgb, var(--c, var(--c-0)) 12%, transparent); color: var(--ink); margin: 0 4px 2px 0; white-space: nowrap; }
.cat i, .dotc { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--c-0)); flex: none; display: inline-block; }
.hbar .fill.catfill { background: var(--c, var(--c-0)); }
/* složení majetku: vodorovný skládaný pruh s mezerami 2 px */
.stack { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; margin: 14px 0 8px; background: var(--surface); }
.stack span { background: var(--c); min-width: 3px; }
.stack span:first-child { border-radius: 4px 0 0 4px; } .stack span:last-child { border-radius: 0 4px 4px 0; }
.legend2 { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.legend2 b { color: var(--ink); font-weight: 600; margin-left: 4px; }
.kindhead { display: flex; align-items: center; gap: 8px; margin: 16px 0 6px; }
.kindhead .dotc { width: 10px; height: 10px; }

.delta { white-space: nowrap; }

/* =====================================================================
   Moderní vzhled (10/2026): Geist, měkčí plochy, jednotné ikony,
   segmentové přepínače, jemné animace. Přepisuje základní styly výše.
   ===================================================================== */
:root {
  --base: #f6f7fb; --surface: #ffffff; --surface-2: #f1f3f9; --ink: #0f1222; --muted: #687087; --line: rgba(15,18,34,.08); --line-strong: rgba(15,18,34,.14);
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 1px rgba(15,18,34,.03), 0 2px 6px rgba(15,18,34,.04), 0 12px 32px -12px rgba(15,18,34,.08);
  --shadow-lg: 0 24px 64px -16px rgba(15,18,34,.28), 0 2px 6px rgba(15,18,34,.06);
  --ease: cubic-bezier(.2,.8,.2,1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --base: #0d0f17; --surface: #151826; --surface-2: #1c2031; --ink: #eceef6; --muted: #9098b0; --line: rgba(236,238,246,.08); --line-strong: rgba(236,238,246,.16); --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px -12px rgba(0,0,0,.5); --shadow-lg: 0 24px 64px -16px rgba(0,0,0,.7); }
}
:root[data-theme="dark"] { --base: #0d0f17; --surface: #151826; --surface-2: #1c2031; --ink: #eceef6; --muted: #9098b0; --line: rgba(236,238,246,.08); --line-strong: rgba(236,238,246,.16); --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px -12px rgba(0,0,0,.5); --shadow-lg: 0 24px 64px -16px rgba(0,0,0,.7); }

body { font: 14px/1.55 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif; font-feature-settings: "ss01", "cv11"; letter-spacing: -.003em; }
h1, h2, h3 { font-family: "Geist", system-ui, sans-serif; font-weight: 650; letter-spacing: -.022em; }
h1 { font-size: 1.65rem; } h2 { font-size: 1.05rem; letter-spacing: -.012em; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 18%, transparent) transparent; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--mod, var(--accent)) 70%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ikony */
.i { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.btn .i { width: 15px; height: 15px; margin: 0 -1px; }
.btn.sm .i { width: 14px; height: 14px; }
.nav svg { stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

/* boční panel */
.side { background: color-mix(in srgb, var(--surface) 70%, var(--base)); backdrop-filter: saturate(1.4); padding: 18px 12px; }
.brand { font-family: "Geist", system-ui, sans-serif; font-weight: 700; letter-spacing: -.03em; font-size: 1.2rem; }
.brand .mark { border-radius: 10px; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #22d3ee)); box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255,255,255,.25); font-weight: 700; }
.nav a { padding: 8px 10px; border-radius: 10px; color: color-mix(in srgb, var(--ink) 82%, var(--muted)); transition: background .15s var(--ease), color .15s var(--ease); }
.nav a:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); }
.nav a.on { font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 18%, transparent); }
.nav a.on::after { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 20%, transparent); }
main { padding: 32px 36px 72px; }
.head { margin-bottom: 24px; }
.hicon { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(145deg, color-mix(in srgb, var(--mod) 20%, transparent), color-mix(in srgb, var(--mod) 8%, transparent)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mod) 18%, transparent); }
.hicon svg { stroke-linecap: round; stroke-linejoin: round; }

/* tlačítka */
.btn { height: 36px; padding: 0 14px; gap: 7px; border-radius: var(--radius-sm); border-color: var(--line-strong); background: var(--surface); box-shadow: 0 1px 1px rgba(15,18,34,.04); transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .08s var(--ease); }
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--ink) 18%, transparent); }
.btn:active { transform: translateY(1px); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { box-shadow: none; }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn.sm:has(> .i:only-child) { width: 30px; padding: 0; justify-content: center; }
.btn.primary, main .btn.primary { color: var(--on-accent); border-color: transparent; background: linear-gradient(180deg, color-mix(in srgb, var(--mod, var(--accent)) 92%, white), var(--mod, var(--accent))); box-shadow: 0 1px 2px color-mix(in srgb, var(--mod, var(--accent)) 40%, transparent), inset 0 1px 0 rgba(255,255,255,.18); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--alert); }
.btn.danger:hover { background: color-mix(in srgb, var(--alert) 8%, var(--surface)); border-color: color-mix(in srgb, var(--alert) 35%, transparent); }

/* pole formulářů */
input, select, textarea { min-height: 38px; border-radius: var(--radius-sm); border-color: var(--line-strong); padding: 8px 11px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--ink) 24%, transparent); }
input:focus, select:focus, textarea:focus { border-color: var(--mod, var(--accent)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mod, var(--accent)) 14%, transparent); }
input[type=checkbox], input[type=radio] { min-height: 0; width: 16px; height: 16px; }
select { appearance: none; padding-right: 32px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23687087' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 15px; }
label.f > span { text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.items input, .items select { min-height: 34px; }

/* segmentový přepínač (pilulka s posuvným pozadím) */
.seg { gap: 2px; padding: 3px; border-radius: 12px; border: 0; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.seg button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; transition: background .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease); }
.seg button:hover { color: var(--ink); }
.seg button.on, main .seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15,18,34,.08), 0 0 0 1px var(--line); font-weight: 600; }

/* karty a tabulky */
.card { border-radius: var(--radius); border-color: var(--line); padding: 20px 22px; }
.table-wrap { border-radius: var(--radius); }
main .card.kpi, main .card.hero { border-top: 1px solid var(--line); position: relative; overflow: hidden; }
main .card.kpi::before, main .card.hero::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--kc, var(--mod)), color-mix(in srgb, var(--kc, var(--mod)) 30%, transparent)); }
a.kpi { transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease); }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 16px 32px -18px color-mix(in srgb, var(--kc, var(--mod)) 45%, transparent); }
.kpi .v, .hero .v { font-family: "Geist", system-ui, sans-serif; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tile .v { font-family: "Geist", system-ui, sans-serif; letter-spacing: -.03em; }
table.t th, main table.t thead th { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 500; color: var(--muted); background: color-mix(in srgb, var(--ink) 2.5%, transparent); padding: 10px 14px; }
table.t td { padding: 12px 14px; border-bottom-color: var(--line); }
table.t tbody tr { transition: background .12s var(--ease); }
table.t tbody tr.click:hover { background: color-mix(in srgb, var(--mod, var(--accent)) 5%, transparent); }
.badge { padding: 3px 10px 3px 9px; font-weight: 550; letter-spacing: -.005em; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, var(--muted)) 18%, transparent); }
.tag { border-radius: 6px; padding: 1px 7px; }
.cat { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, var(--c-0)) 16%, transparent); }
.help { border-radius: 12px; border: 1px solid color-mix(in srgb, var(--accent-2) 16%, transparent); }
.empty .i { width: 18px; height: 18px; color: var(--success); }

/* dialogy, oznámení, našeptávač */
.modal-bg { background: color-mix(in srgb, #0b0d18 42%, transparent); backdrop-filter: blur(6px) saturate(1.2); -webkit-backdrop-filter: blur(6px) saturate(1.2); animation: fade .16s var(--ease); }
.modal { border-radius: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: pop .2s var(--ease); }
.modal header { padding: 20px 22px 2px; }
.modal .body { padding: 16px 22px; }
.modal footer { padding: 14px 22px 18px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--ink) 2%, transparent); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.toast { border-radius: 12px; padding: 11px 18px; font-weight: 500; box-shadow: var(--shadow-lg); animation: rise .22s var(--ease); display: flex; align-items: center; gap: 8px; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }
.suggest, .firm-menu, .tip { border-radius: 14px; box-shadow: var(--shadow-lg); border-color: var(--line); }
.sg-item { border-radius: 9px; }
.firm-btn { border-radius: 12px; background: var(--surface); box-shadow: 0 1px 1px rgba(15,18,34,.04); }

/* přihlášení */
#lock { background: radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent), radial-gradient(700px 500px at 110% 110%, color-mix(in srgb, #22d3ee 14%, transparent), transparent), var(--base); }
.lock-card { border-radius: 20px; box-shadow: var(--shadow-lg); padding: 32px; }
.lock-card .btn.primary { height: 42px; }

/* úrovně oprávnění: šedá = nic, modrá = číst, zelená = upravovat */
.lvl { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 999px; font-size: 12.5px; font-weight: 550; white-space: nowrap; margin: 2px 4px 2px 0;
  color: var(--lc); background: color-mix(in srgb, var(--lc) 11%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--lc) 20%, transparent); }
.lvl .i { width: 13px; height: 13px; vertical-align: 0; }
.lvl.none { --lc: var(--muted); background: transparent; box-shadow: none; padding-left: 0; }
.lvl.none .i { display: none; }
.lvl.read { --lc: var(--accent-2); }
.lvl.write { --lc: var(--success); }
.permline { display: flex; flex-wrap: wrap; align-items: center; gap: 0; margin: 2px 0; }
.permline .firmname { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; margin-right: 8px; }
.permline .dot, .perm th .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.perm-seg { flex-wrap: nowrap; }
.perm-seg button { padding: 5px 10px; font-size: 12.5px; }
.perm-seg button .i { width: 14px; height: 14px; }
.perm-seg button.on[data-l="none"] { color: var(--ink); }
.perm-seg button.on[data-l="read"] { color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 12%, var(--surface)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-2) 28%, transparent); }
.perm-seg button.on[data-l="write"] { color: var(--success); background: color-mix(in srgb, var(--success) 12%, var(--surface)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--success) 28%, transparent); }
.perm td:first-child b { font-weight: 600; }
@media (max-width: 1100px) { .perm-seg button span { display: none; } .perm-seg button { padding: 6px 9px; } }

@media (max-width: 860px) {
  main { padding: 18px 16px 96px; }
  .side { backdrop-filter: blur(14px) saturate(1.5); -webkit-backdrop-filter: blur(14px) saturate(1.5); background: color-mix(in srgb, var(--surface) 82%, transparent); }
  .nav a { border-radius: 10px; }
  .nav a.on::after { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
/* nastavení: hlavní tlačítka v barvě aplikace (šedá působila jako neaktivní) */
body[data-mod="settings"], body[data-mod="account"] { --mod: var(--accent); }
.perm .rolepick { min-width: 160px; min-height: 32px; padding-top: 4px; padding-bottom: 4px; }
.cols > .card, .tiles > .card { margin-top: 0 !important; }
@media (max-width: 860px) {
  .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: none; }
  .nav a { font-size: 9.5px; letter-spacing: -.02em; padding: 6px 0; }
  table.t td:first-child { min-width: 150px; }
}
.test-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.test-row input { flex: 1 1 220px; max-width: 340px; }
@media (max-width: 860px) {
  .side { padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); }
}
