:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1c2430; --muted: #67707e;
  --line: #e3e6eb; --accent: #2b6cb0; --accent-ink: #fff;
  --pos: #157347; --neg: #b02a37; --warn-bg: #fff8e6;
  --chip: #eef1f5; --hl: #eef6ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f; --card: #1d232d; --ink: #e8ecf2; --muted: #98a2b0;
    --line: #2c3440; --accent: #4c8fd6; --pos: #4cc38a; --neg: #ef7a85;
    --warn-bg: #3a3323; --chip: #262e3a; --hl: #223146;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
header {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .6rem 1.2rem; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 1.05rem; }
nav { display: flex; gap: .3rem; }
nav button {
  border: none; background: none; color: var(--muted); padding: .45rem .8rem;
  border-radius: 8px; cursor: pointer; font: inherit;
}
nav button.active { background: var(--accent); color: var(--accent-ink); }
main { max-width: 1240px; margin: 1rem auto; padding: 0 1rem 4rem; }
/* the price list editor needs the full window width — no horizontal scroll */
main:has(#view-pricelist:not([hidden])) { max-width: 1720px; }
#pl-tables table.data td, #pl-tables table.data th { padding: .25rem .35rem; }
#pl-tables td.num input { text-align: right; }
#pl-tables td:nth-child(1) input { width: 6.5rem; }
#pl-tables td:nth-child(2) input { width: 11rem; }
#pl-tables td:nth-child(3) input { width: 100%; min-width: 17rem; }
#pl-tables td:nth-child(4) input { width: 4rem; }
#pl-tables input.num { width: 6.5rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.2rem; margin-bottom: 1rem;
}
.card.narrow { max-width: 640px; }
.row { display: flex; align-items: center; gap: 1rem; margin: .5rem 0; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
input, select {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: .4rem .55rem;
}
input.num { text-align: right; width: 7.5rem; }
button, .button {
  font: inherit; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); border-radius: 8px; padding: .45rem .9rem; cursor: pointer;
  text-decoration: none; display: inline-block;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button:disabled { opacity: .55; cursor: wait; }
button.mini { padding: .15rem .5rem; font-size: .8rem; }
button.danger { color: var(--neg); border-color: var(--neg); background: none; }
button.mini.danger { color: var(--neg); }
button.x { border: none; background: none; padding: 0 .1rem; color: var(--muted); cursor: pointer; }

.month-label input { font-size: 1rem; }
.dropzone {
  flex: 1; min-width: 260px; border: 2px dashed var(--line); border-radius: 12px;
  padding: .8rem 1rem; cursor: pointer; transition: border-color .15s;
}
.dropzone.drag { border-color: var(--accent); background: var(--hl); }
.dropzone .hint { display: block; }
.filelist { margin-top: .4rem; display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  background: var(--chip); border-radius: 999px; padding: .15rem .6rem;
  font-size: .8rem; display: inline-flex; align-items: center; gap: .2rem;
}
.hint { color: var(--muted); font-size: .82rem; }
.error {
  background: #fdecee; color: #8f1d28; border: 1px solid #f2b8bf;
  padding: .6rem .9rem; border-radius: 8px; margin-top: .6rem; white-space: pre-wrap;
}
@media (prefers-color-scheme: dark) {
  .error { background: #3a2226; color: #f2b8bf; border-color: #6e3540; }
}

.summary-strip, .kpis { display: flex; flex-wrap: wrap; gap: .6rem; margin: .8rem 0; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: .5rem .9rem; display: flex; flex-direction: column; min-width: 130px;
}
.stat small { color: var(--muted); font-size: .72rem; }
.stat strong { font-size: 1.02rem; white-space: nowrap; }
.stat.pos strong, .pos { color: var(--pos); }
.stat strong.second { font-size: .88rem; font-weight: 600; }
.stat.neg strong, .neg { color: var(--neg); }
.stat.clickable { cursor: pointer; }
.stat.clickable.active { outline: 2px solid var(--accent); }

.tabbar { display: flex; gap: .3rem; border-bottom: 2px solid var(--line); margin: 1rem 0 .8rem; }
.tabbar button {
  border: none; border-radius: 8px 8px 0 0; background: none; color: var(--muted);
  padding: .5rem 1rem;
}
.tabbar button.active { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px var(--accent); }
.pane-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.pane-head h3 { margin: .2rem 0; }
.dl a { margin-left: .5rem; font-size: .85rem; }
.dl-label { color: var(--muted); font-size: .8rem; }
.dl-group { display: inline-flex; flex-wrap: wrap; gap: .2rem .6rem; align-items: baseline; }

.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin: .6rem 0 1rem; }
table.data { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.data th, table.data td { padding: .4rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-weight: 600; white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.warn td { background: var(--warn-bg); }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--hl); }
table.data tr.detail td { background: var(--hl); }
table.data tfoot td, td.b { font-weight: 700; }
table.data tr.sep td { border-top: 2px solid var(--line); }
table.data tr.hl td { background: var(--hl); }
table.statement td:first-child { width: 70%; }
table.statement tr.subrow td:first-child { padding-left: 2.4rem; color: var(--muted); }
table.statement tr.subrow td { font-size: .82rem; }
.popover { }
.popover::before { left: var(--arrow-left, 34px); }
.orders-detail { display: flex; flex-wrap: wrap; gap: .3rem; padding: .2rem 0; }

.badge { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; background: var(--chip); white-space: nowrap; }
.badge.ok { background: #d9f0e5; color: #0f5132; }
.badge.soft { background: #e7ecf7; color: #33518f; }
.badge.bad { background: #fbdce0; color: #8f1d28; }
.badge.seg-free { background: #e7ecf7; color: #33518f; }
.badge.seg-paid { background: #d9f0e5; color: #0f5132; }
.badge.seg-vratka { background: #fbdce0; color: #8f1d28; }
@media (prefers-color-scheme: dark) {
  .badge.ok, .badge.seg-paid { background: #1d3a2d; color: #4cc38a; }
  .badge.soft, .badge.seg-free { background: #22304a; color: #8fb4e8; }
  .badge.bad, .badge.seg-vratka { background: #46262b; color: #ef7a85; }
}

.kvgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .5rem; margin: .8rem 0; }
.kv {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: .45rem .7rem; display: flex; flex-direction: column; gap: .1rem;
}
.kv span { color: var(--muted); font-size: .75rem; }
.kv.ok strong { color: var(--pos); }
.kv.bad strong { color: var(--neg); }
.kv.warn strong { color: #b8860b; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4rem 1rem 2rem; overflow-y: auto;
}
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.2rem; max-width: 880px; width: 100%; box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
.modal.narrow { max-width: 560px; }

.popover-backdrop { position: fixed; inset: 0; z-index: 29; }
.popover {
  position: absolute; z-index: 30; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem .5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
.popover::before {
  content: ""; position: absolute; top: -7px; left: 34px; width: 12px; height: 12px;
  background: var(--card); border-left: 1px solid var(--line);
  border-top: 1px solid var(--line); transform: rotate(45deg);
}
.popgrid {
  display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: .6rem;
}
.popgrid .stat { min-width: 0; }
.push-right { margin-left: auto; }
.modal h3 { margin: 0; }
table.data tr.month-row td {
  font-weight: 700; background: var(--hl); border-top: 2px solid var(--line);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem 1rem; margin: .8rem 0; }
.grid2 .span2 { grid-column: span 2; }
.checkline { flex-direction: row; align-items: center; gap: .5rem; }
.note { color: var(--muted); }
a.mini { font-size: .78rem; }
h4 { margin: 1rem 0 .3rem; }

.bell { position: relative; border: none; background: none; font-size: 1.1rem;
  cursor: pointer; margin-left: auto; padding: .3rem .5rem; }
.bell-badge { position: absolute; top: 0; right: 0; background: var(--neg);
  color: #fff; font-size: .65rem; font-weight: 700; border-radius: 999px;
  padding: 0 .3rem; min-width: 1rem; text-align: center; }
.notif-row { border: 1px solid var(--line); border-radius: 10px;
  padding: .7rem .9rem; margin: .5rem 0; }
.notif-row p { margin: .2rem 0; }

.brand-logo { width: 22px; height: 22px; border-radius: 6px; vertical-align: -5px; margin-right: .2rem; }

/* the opened row shares the inspect window's colour and both are framed */
table.data tr.expanded td {
  background: var(--hl);
  border-top: 2px solid var(--accent);
  border-bottom: none;
}
table.data tr.expanded td:first-child { border-left: 2px solid var(--accent); }
table.data tr.expanded td:last-child { border-right: 2px solid var(--accent); }
table.data tr.detail td {
  border-bottom: 2px solid var(--accent);
}
table.data tr.detail td:first-child { border-left: 2px solid var(--accent); }
table.data tr.detail td:last-child { border-right: 2px solid var(--accent); }

/* Order overview cards: uniform grid so every bracket is the same size */
#pane-tab2 .kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .6rem;
}
#pane-tab2 .kpis .stat { min-width: 0; }
