/* Layout: provozní konzole. Nahoře stav (spojení, kill-switch, den), pod ním souhrn dne,
   strategie, křivka zisku a důvody nevstupu, události dne, log rozhodnutí. Jeden sloupec na
   telefonu, dva na širokém okně. Barvy jen přes tokeny; stav = pilulka, ne jen barva. */
:root {
  --bg: #f1f4f3;
  --surface: #ffffff;
  --surface-2: #e8eeec;
  --line: #d3dcd9;
  --fg: #16211f;
  --fg-2: #4d5d59;
  --fg-3: #74837f;
  --accent: #0b6e66;
  --accent-soft: #d6ebe8;
  --good: #17713f;
  --good-bg: #dcf0e3;
  --warn: #8f5600;
  --warn-bg: #f7ead0;
  --crit: #a8231b;
  --crit-bg: #f8dedb;
  --info: #34559c;
  --info-bg: #e1e8f6;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1514; --surface: #162120; --surface-2: #1d2b29; --line: #2a3b38;
    --fg: #e3ece9; --fg-2: #a2b4af; --fg-3: #7a8c88;
    --accent: #4fc0b3; --accent-soft: #163a38;
    --good: #5cc98a; --good-bg: #16301f; --warn: #e2ab4d; --warn-bg: #382a0e;
    --crit: #f1897f; --crit-bg: #3b1c1a; --info: #8fb0ee; --info-bg: #19243f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1514; --surface: #162120; --surface-2: #1d2b29; --line: #2a3b38;
  --fg: #e3ece9; --fg-2: #a2b4af; --fg-3: #7a8c88;
  --accent: #4fc0b3; --accent-soft: #163a38;
  --good: #5cc98a; --good-bg: #16301f; --warn: #e2ab4d; --warn-bg: #382a0e;
  --crit: #f1897f; --crit-bg: #3b1c1a; --info: #8fb0ee; --info-bg: #19243f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 14px;
  line-height: 1.45; margin: 0;
}
.app {
  max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
  padding-block: 14px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.loading { color: var(--fg-3); }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--fg-2); }
.mono { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.muted { color: var(--fg-3); }

/* horní lišta */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; justify-content: space-between; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.brand .sub { color: var(--fg-3); font-size: 13px; }
.status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--fg-2);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.crit { background: var(--crit-bg); color: var(--crit); }
.pill.info { background: var(--info-bg); color: var(--info); }
.banner {
  background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 8px 12px; font-size: 13px;
}
.banner b { font-weight: 600; }

/* souhrn */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.kpi { background: var(--surface); padding: 10px 14px; min-width: 0; }
.kpi .l { font-size: 11px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .07em; }
.kpi .v { font-family: var(--font-data); font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .n { font-size: 12px; color: var(--fg-3); }
.pos { color: var(--good); }
.neg { color: var(--crit); }

/* panely */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.panel > header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.panel > header .hint { color: var(--fg-3); font-size: 12px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--fg-3); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sid { font-weight: 500; }
.why { color: var(--fg-2); }
.why code { font-family: var(--font-data); font-size: 11px; color: var(--fg-3); display: block; }
.counts { display: flex; flex-wrap: wrap; gap: 2px 10px; font-family: var(--font-data); font-size: 12px; color: var(--fg-2); white-space: nowrap; }
.counts span b { font-weight: 500; color: var(--fg); }

/* graf */
.chart { position: relative; }
.chart svg { display: block; width: 100%; }
.chart .tip { position: absolute; pointer-events: none; background: var(--fg); color: var(--bg); border-radius: 6px;
  padding: 5px 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 2; }
.axis text { fill: var(--fg-3); font-family: var(--font-data); font-size: 10.5px; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.zero-line { stroke: var(--fg-3); stroke-width: 1; stroke-dasharray: 3 3; }
.line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.area { fill: var(--accent); opacity: .12; stroke: none; }
.dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.empty { color: var(--fg-3); padding: 14px 0; }

/* důvody */
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; }
.bar .name { min-width: 0; }
.bar .name code { font-family: var(--font-data); font-size: 11px; color: var(--fg-3); }
.bar .n { font-family: var(--font-data); font-size: 12px; color: var(--fg-2); text-align: right; }
.bar .track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 3px; }
.bar.bad .fill { background: var(--warn); }

/* události */
.events { display: flex; flex-direction: column; }
.event { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 0;
  border-bottom: 1px solid var(--line); align-items: baseline; }
.event:last-child { border-bottom: 0; }
.event.past { opacity: .6; }
.event .time { font-family: var(--font-data); color: var(--fg-2); }
.event .title { min-width: 0; }
.event .win { grid-column: 2 / -1; font-size: 12px; color: var(--fg-3); }

/* log rozhodnutí */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
select, button.chip {
  font: inherit; font-size: 12px; color: var(--fg); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; cursor: pointer;
}
button.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
select:focus-visible, button:focus-visible, tr.row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--surface-2); }
tr.detail td { background: var(--surface-2); }
.rules { display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--font-data); font-size: 12px; }
.rule { padding: 1px 7px; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); }
.rule.t { color: var(--good); }
.rule.f { color: var(--fg-3); }
.rule.n { color: var(--warn); }
.foot { color: var(--fg-3); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 16px; }

@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 0; min-width: 0; }
  table.stack td.num { text-align: left; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .06em; font-family: var(--font-body); }
  table.stack td.sid { grid-column: 1 / -1; font-size: 15px; }
  table.stack tr.detail { display: block; }
  table.stack tr.detail td { display: block; padding: 8px 0; }
  table.stack td:nth-child(4) { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: no-preference) {
  .bar .fill { transition: width .3s ease; }
}

/* ověření seance, souhrn dne */
.checks { display: flex; flex-direction: column; }
.check { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 4px 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check .body { min-width: 0; overflow-wrap: anywhere; }
.sumgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sumitem { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.sumitem .l { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-3); }
.sumitem .v { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-width: 640px) { .check { grid-template-columns: minmax(0, 1fr); } }

/* detail obchodu */
:root { --up: #0b6e66; --down: #a8231b; --held: rgba(52, 85, 156, .10); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --up: #4fc0b3; --down: #f1897f; --held: rgba(143, 176, 238, .12); } }
:root[data-theme="dark"] { --up: #4fc0b3; --down: #f1897f; --held: rgba(143, 176, 238, .12); }
.cup line { stroke: var(--up); stroke-width: 1.2; } .cup rect { fill: var(--surface); stroke: var(--up); stroke-width: 1.2; }
.cdn line { stroke: var(--down); stroke-width: 1.2; } .cdn rect { fill: var(--down); stroke: var(--down); stroke-width: 1.2; }
.held { fill: var(--held); }
.mk { stroke-width: 1.5; stroke-dasharray: 5 3; } .mk.in { stroke: var(--info); } .mk.out { stroke: var(--fg-2); }
.mk-label { font-size: 11px; font-weight: 600; } .mk-label.in { fill: var(--info); } .mk-label.out { fill: var(--fg-2); }
.legend-c { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--fg-2); margin-bottom: 6px; }
.legend-c span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 14px; display: inline-block; border: 1.5px solid; }
.lg.up { border-color: var(--up); background: var(--surface); } .lg.dn { border-color: var(--down); background: var(--down); }
.lg.held { border: 0; background: var(--held); width: 18px; }
.why-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-top: 12px; }
.why-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--surface); }
.why-card h3 { font-size: 14px; font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.rules-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rrow { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; font-size: 13px; }
.rrow .ri { font-weight: 700; text-align: center; }
.rrow.t .ri { color: var(--good); } .rrow.f .ri { color: var(--crit); } .rrow.n .ri { color: var(--fg-3); }
tr.pick { cursor: pointer; } tr.pick:hover { background: var(--surface-2); }

/* Ověření seance jako roleta: první řádka vždy ukazuje stav, při problému červeně */
details.ver { padding: 0; overflow: hidden; }
details.ver > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr) 14px; align-items: center; gap: 12px; padding: 11px 14px; }
details.ver > summary::-webkit-details-marker { display: none; }
.vh-title { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--fg-2); white-space: nowrap; }
.vh-text { min-width: 0; overflow-wrap: anywhere; }
.vh-chev { width: 8px; height: 8px; border-right: 2px solid var(--fg-3); border-bottom: 2px solid var(--fg-3); transform: rotate(45deg); transition: transform .15s; }
details.ver[open] .vh-chev { transform: rotate(-135deg); }
details.ver > .checks { padding: 0 14px 6px; border-top: 1px solid var(--line); }
details.ver.ok > summary .vh-text { color: var(--good); }
details.ver.warn > summary { background: var(--warn-bg); } details.ver.warn > summary .vh-text, details.ver.warn > summary .vh-title { color: var(--warn); font-weight: 600; }
details.ver.crit > summary { background: var(--crit); } details.ver.crit > summary .vh-text, details.ver.crit > summary .vh-title { color: #fff; font-weight: 700; }
details.ver.crit .vh-chev { border-color: #fff; }
.check.crit { background: var(--crit-bg); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.check.warn { background: var(--warn-bg); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
@media (max-width: 640px) { details.ver > summary { grid-template-columns: minmax(0, 1fr) 14px; } .vh-title { grid-column: 1 / -1; } }

/* náhradní den (dnes ještě nic nebylo zapsáno): čísla šedě, aby se nepletla s dneškem */
.kpis.stale .v { color: var(--fg-3) !important; }
.kpis.stale { opacity: .7; }

/* Seznam strategií: počet v záhlaví, nezabere celou stránku (posouvá se uvnitř, záhlaví zůstává vidět) */
.panel > header h2 .count { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; }
.vscroll { max-height: 460px; overflow-y: auto; }
.vscroll thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }

/* sbalovací lišty (objednávky, obchody dne) a statistika */
.foldpanel { padding: 0; overflow: hidden; }
details.fold { border-top: 1px solid var(--line); margin-top: 8px; }
.foldpanel > details.fold { border-top: 0; margin-top: 0; }
details.fold > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr) 14px; align-items: center; gap: 12px; padding: 11px 14px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold[open] .vh-chev { transform: rotate(-135deg); }
details.fold > .fold-body { padding: 0 14px 10px; }
.panel details.fold > .fold-body { padding: 0 0 6px; }
.panel details.fold > summary { padding-left: 0; padding-right: 0; }
.statgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 18px; margin: 10px 0 14px; }
.statgrid h3 { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--fg-2); margin-bottom: 6px; }
.calhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.calgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calh { text-align: center; font-size: 11px; color: var(--fg-3); }
.cal { min-height: 56px; border-radius: 6px; padding: 4px 6px; background: var(--surface-2); display: flex; flex-direction: column; gap: 1px; font-size: 11px; }
.cal .dn { color: var(--fg-3); font-size: 11px; }
.cal .cv { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-weight: 500; overflow-wrap: anywhere; }
.cal .cn { color: var(--fg-3); }
.cal.pos { background: var(--good-bg); } .cal.pos .cv { color: var(--good); }
.cal.neg { background: var(--crit-bg); } .cal.neg .cv { color: var(--crit); }
.cal.none { background: transparent; border: 1px dashed var(--line); opacity: .6; }
.bar.pos { fill: var(--good); } .bar.neg { fill: var(--crit); } .bar.cnt { fill: var(--accent); }
button.chip[disabled] { opacity: .4; cursor: default; }
@media (max-width: 760px) { .statgrid { grid-template-columns: minmax(0, 1fr); } .cal { min-height: 48px; padding: 3px 4px; } .cal .cn { display: none; } }

/* ovládání (ADR 0041) */
button.act { font: inherit; font-size: 12.5px; padding: 4px 11px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; min-height: 30px; }
button.act:hover:not(:disabled) { background: var(--surface-2); }
button.act:disabled { opacity: .5; cursor: default; }
button.act.danger { background: var(--crit-bg); color: var(--crit); border-color: var(--crit); font-weight: 600; }
button.act.ghost { background: transparent; }
td.acts { white-space: nowrap; }
td.acts button.act { margin-right: 6px; }
.dlg { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--fg); padding: 16px 18px; max-width: min(460px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(0, 0, 0, .45); }
.dlg h3 { font-size: 16px; margin-bottom: 8px; }
.dlg .dbody p { font-size: 13.5px; line-height: 1.45; margin-bottom: 8px; }
.dlg .fld { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; margin: 6px 0; }
.dlg .fld input, .dlg .fld select { font: inherit; padding: 3px 6px; background: var(--surface-2); color: var(--fg); border: 1px solid var(--line); border-radius: 5px; }
.dlg .dres { min-height: 18px; font-size: 13px; margin: 8px 0; white-space: pre-wrap; }
.dlg .dres.ok { color: var(--good); }
.dlg .dres.bad { color: var(--crit); }
.dlg .dbtns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
@media (max-width: 640px) { .desktop-only { display: none !important; } button.act { min-height: 40px; } td.acts { white-space: normal; } }

/* přihlášení */
.loginbox { max-width: 360px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 14px; }
.loginbox form { display: flex; flex-direction: column; gap: 10px; }
.loginbox .fld { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.loginbox .fld input { font: inherit; font-size: 16px; padding: 8px 10px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; }
.loginbox button.act { min-height: 42px; font-size: 14px; }
