/* AlphaFin — paleta navazuje na RelAc (navy / modrá), akcent do tyrkysové kvůli odlišení. */
:root {
  --paper: #F5F7FA; --surface: #FFFFFF; --ink: #1A2233; --muted: #63708A;
  --line: #DEE4EC;
  --navy: #16304F; --accent: #0F7BC4; --accent-2: #2E9BDE; --accent-soft: #E2F0FA;
  --ok: #12855C; --ok-soft: #E1F2EA; --warn: #A9720B; --warn-soft: #FBF0D8;
  --bad: #C0392B; --bad-soft: #FAE4E1;
  --klient: #0F7BC4; --klient-soft: #E2F0FA;
  --lide: #7A4FBF; --lide-soft: #EFE8FA;
  --dodavatel: #A9720B; --dodavatel-soft: #FBF0D8;
  --stat: #566274; --stat-soft: #EDF0F4;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.5;
}
.hidden { display: none !important; }
button { cursor: pointer; font: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- login ---- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--navy) 0%, var(--accent) 100%); padding: 1rem;
}
.login-card {
  background: var(--surface); border-radius: 14px; padding: 2rem 2.2rem; width: min(94vw, 360px);
  display: flex; flex-direction: column; gap: .9rem; box-shadow: 0 20px 60px rgba(10,25,60,.35);
}
.login-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; color: var(--muted); font-weight: 600; }
.login-card input { font: inherit; padding: .58rem .75rem; border: 1px solid var(--line); border-radius: 9px; }
.login-error { color: var(--bad); font-size: .85rem; min-height: 1.2em; text-align: center; }

/* ---- shell ---- */
.topbar {
  display: flex; align-items: center; gap: 1.2rem; padding: .5rem 1.2rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(20,40,79,.06); position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brandbox { display: flex; flex-direction: column; line-height: 1.1; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--navy); letter-spacing: -.02em; }
.brand-sub { font-size: .7rem; color: var(--muted); }
.login-card .brand { font-size: 1.6rem; text-align: center; }
.login-card .brand-sub { text-align: center; margin-bottom: .5rem; }
#nav { display: flex; gap: .15rem; flex-wrap: wrap; }
#nav a {
  text-decoration: none; color: var(--muted); padding: .35rem .8rem; border-radius: 8px;
  font-weight: 600; font-size: .9rem;
}
#nav a:hover { background: var(--paper); color: var(--ink); }
#nav a.active { background: var(--accent-soft); color: var(--accent); }
.userbox { margin-left: auto; font-size: .78rem; color: var(--muted); }
main { max-width: 1320px; margin: 0 auto; padding: 1.4rem 1.2rem 4rem; }

h1 { font-size: 1.5rem; margin: .3rem 0; letter-spacing: -.015em; }
h3 { margin: 1.4rem 0 .5rem; font-size: 1rem; }
h4 { margin: 1.1rem 0 .4rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.sub { color: var(--muted); font-size: .86rem; margin: 0 0 1.1rem; }
.note { background: var(--warn-soft); border-left: 3px solid var(--warn); padding: .6rem .85rem;
        border-radius: 0 8px 8px 0; font-size: .82rem; margin: .8rem 0; color: #6B4A06; }
.alert { background: var(--bad-soft); border-left: 3px solid var(--bad); padding: .6rem .85rem;
         border-radius: 0 8px 8px 0; font-size: .85rem; }

/* ---- controls ---- */
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: .38rem .85rem; font-size: .85rem; font-weight: 600;
}
.btn:hover { background: var(--paper); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { border: none; background: transparent; color: var(--muted); }
.seggroup { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seggroup .btn { border: none; border-right: 1px solid var(--line); border-radius: 0; }
.seggroup .btn:last-child { border-right: none; }
.seggroup .btn.on { background: var(--accent); color: #fff; }
input[type=search], input[type=text], select {
  font: inherit; font-size: .85rem; padding: .35rem .6rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink);
}
input[type=search] { min-width: 220px; }

/* ---- tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .85rem; margin-bottom: 1.3rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: .8rem 1rem;
        display: flex; flex-direction: column; gap: .1rem; }
.tile.clickable { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.tile.clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(15,123,196,.16); }
.tile .label { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; }
.tile .value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .hint { font-size: .74rem; color: var(--muted); }
.value.ok { color: var(--ok); } .value.warn { color: var(--warn); } .value.bad { color: var(--bad); }

/* ---- pills ---- */
.pill { display: inline-block; border-radius: 999px; padding: .05rem .6rem; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.pill.klient { background: var(--klient-soft); color: var(--klient); }
.pill.oboji { background: var(--ok-soft); color: var(--ok); }
.pill.lide { background: var(--lide-soft); color: var(--lide); }
.pill.dodavatel { background: var(--dodavatel-soft); color: var(--dodavatel); }
.pill.stat, .pill.interni, .pill.majitel, .pill.neznama { background: var(--stat-soft); color: var(--stat); }
.pill.zaplaceno { background: var(--ok-soft); color: var(--ok); }
.pill.nezaplaceno { background: var(--warn-soft); color: var(--warn); }
.pill.po_splatnosti { background: var(--bad-soft); color: var(--bad); }
.pill.VYSOKÁ { background: var(--bad-soft); color: var(--bad); }
.pill.STŘEDNÍ { background: var(--warn-soft); color: var(--warn); }
.pill.NÍZKÁ { background: var(--stat-soft); color: var(--stat); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th {
  text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  border-bottom: 2px solid var(--accent); padding: .5rem .7rem; white-space: nowrap;
  background: var(--surface); position: sticky; top: 0; z-index: 1;
}
td { border-bottom: 1px solid var(--line); padding: .45rem .7rem; vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--accent-soft); }
tr.dim td { color: var(--muted); font-style: italic; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono { font-family: Consolas, monospace; font-size: .8rem; }
.pos { color: var(--ok); font-weight: 600; } .neg { color: var(--bad); }
tfoot td { font-weight: 700; background: var(--paper); border-top: 2px solid var(--line); }
.wrap { white-space: normal; min-width: 260px; }
.tiny { font-size: .74rem; color: var(--muted); }

/* ---- dvousloupcovy layout pro grafy vedle sebe ---- */
.twocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.twocol .chartbox { margin-bottom: 0; }

/* ---- chart ---- */
.chartbox { background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
            padding: 1rem; margin-bottom: 1.2rem; overflow-x: auto; }
.legend { display: flex; gap: 1.2rem; font-size: .78rem; color: var(--muted); margin-top: .4rem; flex-wrap: wrap; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: .35rem; }

/* ---- bar ---- */
.bar { height: 7px; border-radius: 4px; background: var(--accent); display: block; min-width: 2px; }
.bar.neg { background: var(--bad); } .bar.pos { background: var(--ok); }

/* ---- razeni ---- */
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: ' ↕'; opacity: .3; }
th.sortable.asc::after { content: ' ↑'; opacity: 1; color: var(--accent); }
th.sortable.desc::after { content: ' ↓'; opacity: 1; color: var(--accent); }
th.sortable:hover { color: var(--accent); }

/* ---- verze a novinky ---- */
.btn.version { display: inline-flex; align-items: center; gap: .4rem; padding: .22rem .6rem;
               font-size: .78rem; border-radius: 999px; background: var(--accent-soft);
               border-color: transparent; color: var(--accent); font-weight: 700; }
.btn.version:hover { background: var(--accent); color: #fff; }
.btn.version:hover .version-hint { color: rgba(255,255,255,.85); }
.version-hint { font-weight: 600; font-size: .72rem; color: var(--muted); }
.changelog-ver { border-left: 3px solid var(--line); padding: .1rem 0 .9rem 1rem; margin-bottom: .5rem; }
.changelog-ver.current { border-left-color: var(--accent); }
.changelog-date { font-size: .78rem; color: var(--muted); font-weight: 700; margin: 0 0 .15rem;
                  text-transform: uppercase; letter-spacing: .05em; }
.changelog-date .tag { background: var(--accent-soft); color: var(--accent); border-radius: 999px;
                       padding: .05rem .5rem; font-size: .68rem; margin-left: .3rem;
                       text-transform: none; letter-spacing: 0; }
.changelog-summary { margin: 0 0 .6rem; font-weight: 600; }
.changelog-area { margin: .7rem 0 .2rem; font-size: .78rem; font-weight: 700; color: var(--muted); }
.changelog-list { margin: 0; padding-left: 1.1rem; font-size: .86rem; }
.changelog-list li { margin-bottom: .3rem; }

/* ---- podil na celku: skladany pruh ----
   Mezera mezi segmenty je 2px v barve povrchu, ne obrys kolem znacek. */
.share-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden;
             background: var(--paper); margin: .2rem 0 .7rem; }
/* Mezera mezi segmenty se dela pravym okrajem v barve povrchu, ne pres `gap`.
   Gap by se pricetl k sirkam v procentech, soucet by presahl 100 % a posledni
   segment by se oriznul. Takhle sirky sedi presne. */
.share-bar .seg { display: flex; align-items: center; justify-content: center;
                  min-width: 4px; box-sizing: border-box; transition: filter .12s;
                  border-right: 2px solid var(--surface); }
.share-bar .seg:last-child { border-right: none; }
.share-bar .seg:hover { filter: brightness(1.08); }
.share-bar .seg-in { font-size: .68rem; font-weight: 700; color: #fff;
                     text-shadow: 0 1px 2px rgba(0,0,0,.35); padding: 0 .3rem; }
.share-legend { display: grid; grid-template-columns: max-content 1fr max-content max-content;
                gap: .18rem .6rem; font-size: .82rem; align-items: baseline; }
.share-legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.share-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.share-pct { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .76rem; }

/* ---- formular pro planovanou platbu ---- */
.planform { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
            gap: .7rem; align-items: end; background: var(--paper); border: 1px solid var(--line);
            border-radius: 11px; padding: .9rem 1rem; margin-bottom: 1rem; }
.planform label { display: flex; flex-direction: column; gap: .25rem; font-size: .76rem;
                  color: var(--muted); font-weight: 600; }
.planform label.wide { grid-column: 1 / -1; }
.planform input, .planform select, .planform textarea {
  font: inherit; font-size: .85rem; padding: .38rem .55rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%; }
.planform textarea { resize: vertical; font-family: inherit; }
.planform button { align-self: end; }
td.nowrap { white-space: nowrap; }
td .btn.ghost { padding: .15rem .4rem; font-size: .95rem; line-height: 1; }

/* ---- zebricek (vodorovne pruhy) ---- */
.rank { display: flex; flex-direction: column; gap: .3rem; }
.rank-row { display: grid; grid-template-columns: minmax(120px, 240px) 1fr max-content;
            align-items: center; gap: .7rem; font-size: .84rem; }
.rank-row[data-party] { cursor: pointer; }
.rank-row[data-party]:hover .rank-label { color: var(--accent); }
.rank-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rank-bar { background: var(--paper); border-radius: 4px; height: 15px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 4px; }
.rank-val { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }

/* ---- modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(16,26,45,.55); display: flex;
                 align-items: flex-start; justify-content: center; z-index: 50; padding: 2rem 1rem; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 13px; width: min(96vw, 1000px);
         box-shadow: 0 24px 70px rgba(10,25,60,.4); }
.modal-head { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.3rem .6rem;
              border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); border-radius: 13px 13px 0 0; }
.modal-head h2 { margin: 0; font-size: 1.15rem; flex: 1; }
#modal-body { padding: 1rem 1.3rem 1.6rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .86rem; margin-bottom: .8rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
.doclist { display: flex; flex-wrap: wrap; gap: .4rem; margin: .3rem 0 .8rem; }
.doclink { display: inline-flex; align-items: center; gap: .35rem; text-decoration: none;
           border: 1px solid var(--line); border-radius: 8px; padding: .28rem .6rem; font-size: .8rem;
           background: var(--surface); color: var(--ink); font-weight: 600; }
.doclink:hover { background: var(--accent-soft); border-color: var(--accent); }
.doclink .ext { font-size: .66rem; text-transform: uppercase; color: var(--muted); }
