/* ==========================================================================
   Porovnávač cien potravín — MVP demo
   Tmavý „dátový" vzhľad: hustý, ale s dýchaním. Žiadne externé fonty ani CDN,
   celé offline. Tabulárne číslice všade, kde sú čísla, aby sa dali čítať v stĺpci.
   ========================================================================== */

:root {
  --bg:          #0a0e14;
  --bg-elev:     #0f151e;
  --panel:       #111926;
  --panel-2:     #16202f;
  --line:        #1e2a3a;
  --line-soft:   #182231;

  --text:        #e7eef7;
  --text-dim:    #a9b8ca;
  --muted:       #7d8fa5;

  --accent:      #4c8dff;   /* jediná akcentová farba */
  --accent-dim:  rgba(76, 141, 255, 0.14);
  --good:        #2fd07f;   /* úspora / akcia */
  --good-dim:    rgba(47, 208, 127, 0.13);
  --warn:        #f2b53c;   /* varovania o dátach */
  --warn-dim:    rgba(242, 181, 60, 0.12);
  --bad:         #ff6b6b;
  --bad-dim:     rgba(255, 107, 107, 0.13);

  --radius:      12px;
  --radius-sm:   8px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 12% -10%, rgba(76, 141, 255, 0.09), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.05rem; }
h2 { font-size: 0.95rem; }
p  { margin: 0; }

.mono { font-family: var(--mono); font-size: 0.85em; }
.muted { color: var(--muted); }
.num, .data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- focus: vždy viditeľný ------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 50;
  background: var(--accent); color: #06101f; padding: 8px 14px;
  border-radius: 0 0 var(--radius-sm) 0; font-weight: 600; text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ── Hlavička a navigácia ────────────────────────────────────────────────── */
/* Hlavičku vykresľuje shell.js do prázdneho #shell — je spoločná pre všetky
   podstránky, takže sa nesmie líšiť medzi HTML súbormi. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 10px 20px;
  align-items: center;
  padding: 10px 22px;
  background: rgba(10, 14, 20, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  color: inherit; text-decoration: none;
}
.brand .logo {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--accent), #2f6ad9);
  color: #04101f; font-weight: 800; font-size: 1.05rem;
}
.brand-text { min-width: 0; display: flex; flex-direction: column; }
.brand-name { font-size: 0.95rem; font-weight: 650; letter-spacing: -0.01em; }
.sub { font-size: 0.75rem; color: var(--muted); }
.sub strong { color: var(--text-dim); font-weight: 600; }

/* Karty podstránok. Nie sú bezpečnostná hranica — tou je auth.require_admin. */
.nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: 8px; }
.nav-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px;
  font-size: 0.84rem; font-weight: 600; text-decoration: none;
  color: var(--text-dim); border: 1px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--panel); border-color: var(--line); }
.nav-item--active {
  color: var(--text); background: var(--accent-dim);
  border-color: rgba(76, 141, 255, 0.38);
}
.nav-item--admin { color: var(--muted); }
.nav-item--admin.nav-item--active {
  background: var(--warn-dim); border-color: rgba(242, 181, 60, 0.38); color: var(--text);
}
.nav-tag {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 4px;
  background: var(--warn-dim); color: var(--warn); border: 1px solid rgba(242, 181, 60, 0.3);
}

.shell-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.status-pill--ok  { border-color: rgba(47, 208, 127, 0.3); }
.status-pill--bad { border-color: rgba(255, 107, 107, 0.3); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.dot--ok      { background: var(--good); box-shadow: 0 0 0 3px var(--good-dim); }
.dot--bad     { background: var(--bad);  box-shadow: 0 0 0 3px var(--bad-dim); }
.dot--warn,
.dot--unknown { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-dim); }

/* ── Layout podstránok ───────────────────────────────────────────────────── */
.page { padding: 18px 22px 40px; max-width: 1680px; margin: 0 auto; }
/* Chat: jeden čitateľný stĺpec, nie roztiahnutý na 1680 px. */
.page--narrow { max-width: 900px; }
/* Chat s históriou: zoznam vľavo, konverzácia vpravo. */
.page--chat {
  display: grid; align-items: start; gap: 16px;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  max-width: 1320px;
}
/* Nákupný zoznam: zadanie vľavo, výsledok vpravo. */
.page--split {
  display: grid; align-items: start; gap: 16px;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
}
/* Diagnostika: hustý dátový layout cez celú šírku. */
.page--wide { display: flex; flex-direction: column; gap: 16px; }

.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.page-note {
  color: var(--muted); font-size: 0.78rem; margin-top: 16px;
  border-top: 1px solid var(--line-soft); padding-top: 12px;
}
.page-note--wide { max-width: 1680px; margin: 0 auto; padding: 12px 22px 40px; border-top: 0; }

/* ── Karty ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card--warnish { border-color: rgba(242, 181, 60, 0.28); background: linear-gradient(180deg, var(--warn-dim), transparent 42%), var(--panel); }
.card--footer  { background: var(--bg-elev); }
.card--chat    { display: flex; flex-direction: column; gap: 12px; }

.card-head {
  display: flex; flex-wrap: wrap; gap: 8px 12px;
  align-items: center; justify-content: space-between;
  padding-bottom: 10px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.head-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-label { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.tag {
  padding: 3px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.01em;
  border: 1px solid transparent; white-space: nowrap;
}
.tag--plain { background: var(--panel-2); color: var(--text-dim); border-color: var(--line); }
.tag--warn  { background: var(--warn-dim); color: var(--warn); border-color: rgba(242, 181, 60, 0.3); }
.tag--good  { background: var(--good-dim); color: var(--good); border-color: rgba(47, 208, 127, 0.3); }
.tag--bad   { background: var(--bad-dim);  color: var(--bad);  border-color: rgba(255, 107, 107, 0.3); }

.empty { color: var(--muted); font-size: 0.85rem; }
.help, .hint { color: var(--muted); font-size: 0.76rem; }
.note { color: var(--text-dim); font-size: 0.8rem; margin-top: 10px; }
.note strong { color: var(--warn); }

/* ── Formuláre ───────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > label {
  font-size: 0.74rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
}

textarea, input, select {
  font: inherit; color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; line-height: 1.55; }
#list-text { font-family: var(--mono); font-size: 0.86rem; }
input[type="number"] { font-variant-numeric: tabular-nums; }
select { appearance: none; cursor: pointer; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.head-controls select { width: auto; padding: 5px 26px 5px 9px; font-size: 0.8rem; }
textarea:hover, input:hover, select:hover { border-color: #2a3a4f; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions--between { justify-content: space-between; }
.actions .hint { flex: 1 1 180px; }

.btn {
  font: inherit; font-weight: 600;
  border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  padding: 9px 16px; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #33465f; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #04101f; }
.btn--primary:hover { background: #6ba0ff; border-color: #6ba0ff; }
.btn--ghost { background: transparent; color: var(--text-dim); }
.btn--sm { padding: 5px 10px; font-size: 0.78rem; }
.btn[disabled] { opacity: 0.5; cursor: progress; }

.status { font-size: 0.8rem; color: var(--text-dim); min-height: 1.2em; margin-top: 4px; }
.status--err  { color: var(--bad); }
.status--warn { color: var(--warn); }
.status--ok   { color: var(--good); }
.status--busy { color: var(--accent); }

/* ── Tabuľka plánu ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.data-table thead th {
  position: sticky; top: 0;
  background: var(--panel-2);
  text-align: left; font-size: 0.7rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
  padding: 8px 10px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(76, 141, 255, 0.05); }
.data-table--compact td, .data-table--compact thead th { padding: 6px 10px; }
.data-table .nowrap { white-space: nowrap; }
.price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.price--promo { color: var(--good); font-weight: 650; }

.link-btn {
  font: inherit; font-weight: 600; text-align: left;
  background: none; border: 0; padding: 0; margin: 0;
  color: var(--text); cursor: pointer;
  border-bottom: 1px dashed rgba(76, 141, 255, 0.5);
}
.link-btn:hover { color: #9dc0ff; }

.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 650; letter-spacing: 0.01em; white-space: nowrap;
  border: 1px solid transparent;
}
.badge--promo { background: var(--good-dim); color: var(--good); border-color: rgba(47, 208, 127, 0.32); }
.badge--warn  { background: var(--warn-dim); color: var(--warn); border-color: rgba(242, 181, 60, 0.32); }
.badge--bad   { background: var(--bad-dim);  color: var(--bad);  border-color: rgba(255, 107, 107, 0.32); }
.badge--low   { background: var(--accent-dim); color: #9dc0ff; border-color: rgba(76, 141, 255, 0.32); }

/* Farebný chip reťazca — farba prichádza z /api/bootstrap (chain.color) */
.chain-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chain {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px 2px 7px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 0.76rem; font-weight: 600; white-space: nowrap;
}
.chain .swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; background: var(--accent); }

.plan-label { font-size: 0.82rem; color: var(--accent); font-weight: 650; }

/* ── Rozklad sumy ────────────────────────────────────────────────────────── */
.sum-block {
  margin-top: 14px; padding: 12px 14px;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.sum-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 4px 0; font-size: 0.85rem; color: var(--text-dim);
}
.sum-row .k { display: flex; align-items: baseline; gap: 8px; }
.sum-row .v { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.sum-row--total {
  margin-top: 6px; padding-top: 9px; border-top: 1px solid var(--line);
  font-size: 1rem; font-weight: 700; color: var(--text);
}
.sum-row--total .v { font-size: 1.25rem; }
.sum-row .sub-k { font-size: 0.74rem; color: var(--muted); font-weight: 400; }

.compare-block { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 0.83rem; border: 1px solid var(--line); background: var(--bg-elev);
}
.callout--good { border-color: rgba(47, 208, 127, 0.3); background: var(--good-dim); color: #bdf1d6; }
.callout--warn { border-color: rgba(242, 181, 60, 0.3); background: var(--warn-dim); color: #f6dfae; }
.callout--bad  { border-color: rgba(255, 107, 107, 0.3); background: var(--bad-dim); color: #ffd0d0; }
.callout strong { color: inherit; }
.callout .big { font-variant-numeric: tabular-nums; font-weight: 700; }

.reco { margin-top: 12px; font-size: 0.85rem; color: var(--text-dim); border-left: 2px solid var(--accent); padding-left: 10px; }
.assumptions { margin-top: 12px; font-size: 0.74rem; color: var(--muted); font-variant-numeric: tabular-nums; }

details.alt { margin-top: 12px; }
details > summary {
  cursor: pointer; font-size: 0.8rem; font-weight: 600; color: var(--text-dim);
  padding: 6px 8px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; color: var(--accent); }
details[open] > summary::before { content: "▾ "; }
details > summary:hover { border-color: #33465f; }
details .details-body { padding: 10px 2px 2px; }

/* ── Panel „Čo nemáme" ───────────────────────────────────────────────────── */
.gap-group { margin-bottom: 12px; }
.gap-group:last-child { margin-bottom: 0; }
.gap-title { font-size: 0.78rem; font-weight: 650; color: var(--text-dim); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.gap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.gap-list li { font-size: 0.81rem; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.gap-list li .what { color: var(--text); font-weight: 600; }
.gap-ok { font-size: 0.83rem; color: var(--good); }

/* ── Chat ────────────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 0.78rem; text-align: left;
  background: var(--panel-2); color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--text); }

/* Konverzácia NEMÁ vlastný scroll kontajner. Keby ho mala, hlavička „Spýtaj sa"
   a čipy by natrvalo držali kus výšky nad malým okienkom správ. Takto rastie
   stránka a hlavička odskroluje preč — miesto na zvislej osi zostane správam. */
.chat-log {
  display: flex; flex-direction: column; gap: 12px;
  min-height: 200px;
  padding: 4px 2px;
}
.msg { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.msg-role { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 650; }
.bubble {
  padding: 10px 12px; border-radius: 10px;
  font-size: 0.87rem; border: 1px solid var(--line);
  overflow-wrap: break-word;
}
.msg--user .bubble { background: var(--accent-dim); border-color: rgba(76, 141, 255, 0.3); }
.msg--bot  .bubble { background: var(--bg-elev); }
.msg--err  .bubble { background: var(--bad-dim); border-color: rgba(255, 107, 107, 0.3); }
.bubble p { margin: 0 0 7px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 0 0 7px; padding-left: 18px; }
.bubble li { margin-bottom: 3px; }
.bubble strong { color: #fff; }
.bubble .tnum { font-variant-numeric: tabular-nums; }
.msg-meta { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.thinking { display: inline-flex; gap: 5px; align-items: center; color: var(--accent); font-size: 0.85rem; }
.thinking .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .thinking .pulse { animation: none; } }

/* ── História konverzácií (bočný panel) ──────────────────────────────────── */
/* Panel je `sticky`, aby zoznam ostal po ruke aj pri dlhej konverzácii —
   samotná stránka sa skroluje, tento stĺpec nie. */
.card--history {
  position: sticky; top: 74px;
  max-height: calc(100vh - 96px);
  display: flex; flex-direction: column;
}
.history-list {
  display: flex; flex-direction: column; gap: 3px;
  overflow-y: auto; margin: 0 -6px; padding: 0 6px;
}
.history-item {
  display: flex; align-items: stretch; gap: 2px;
  border-radius: var(--radius-sm);
}
.history-item:hover { background: var(--panel-2); }
.history-item--active { background: var(--accent-dim); }

.history-open {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  font: inherit; text-align: left; cursor: pointer;
  background: none; border: 0; padding: 7px 8px; color: var(--text-dim);
}
.history-item--active .history-open { color: var(--text); }
.history-title {
  font-size: 0.82rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-meta { font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.history-del {
  flex: none; width: 26px;
  font: inherit; font-size: 1rem; line-height: 1; cursor: pointer;
  background: none; border: 0; color: var(--muted); border-radius: var(--radius-sm);
  opacity: 0; transition: opacity 0.12s;
}
.history-item:hover .history-del,
.history-del:focus-visible { opacity: 1; }
.history-del:hover { color: var(--bad); background: var(--bad-dim); }

.conversation-label {
  font-size: 0.78rem; max-width: 45ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Streamovaný text odpovede. Formátuje sa až po dostreamovaní, dovtedy je
   surový — inak by sa odseky preskupovali pod rukami počas čítania. */
.stream-text { white-space: pre-wrap; overflow-wrap: break-word; }
.stream-text:empty::after {
  content: "…"; color: var(--muted);
}

/* ── Živý panel: čo model práve robí (len ladiaci režim) ─────────────────── */
.activity {
  border: 1px solid var(--line-soft); border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-elev); padding: 8px 10px; margin-bottom: 6px;
}
.activity--done { border-left-color: var(--line); }
.activity-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 0.78rem; color: var(--text-dim);
}
.activity-state { font-weight: 600; }
.activity-meta {
  margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
}

/* Spotreba tokenov. Dva ukazovatele, lebo sú to dva rôzne limity:
   „kontext" sa míňa históriou konverzácie, „odpoveď" uvažovaním modelu. */
.tokens { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.gauge { display: flex; align-items: center; gap: 8px; font-size: 0.72rem; }
.gauge-k { color: var(--muted); min-width: 52px; }
.gauge-track {
  flex: 1 1 auto; height: 5px; border-radius: 3px;
  background: var(--panel-2); border: 1px solid var(--line-soft); overflow: hidden;
}
.gauge-fill { display: block; height: 100%; background: var(--accent); }
.gauge-fill--hot { background: var(--bad); }
.gauge-v {
  color: var(--text-dim); font-variant-numeric: tabular-nums;
  min-width: 130px; text-align: right;
}

/* Uvažovanie modelu. Zámerne v pevnej výške so scrollom — inak by dlhá úvaha
   vytlačila samotnú odpoveď mimo obrazovku. */
.think { margin-top: 8px; }
.think > summary { font-size: 0.75rem; padding: 4px 7px; }
.think-body {
  max-height: 190px; overflow-y: auto;
  margin-top: 6px; padding: 7px 9px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 6px;
  font-family: var(--mono); font-size: 0.73rem; line-height: 1.5;
  color: var(--muted); white-space: pre-wrap; overflow-wrap: break-word;
}

/* Volania nástrojov, pribúdajú počas behu */
.tools { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.tools:empty { display: none; }
.tool > summary {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.76rem; padding: 4px 8px; font-weight: 500;
}
.tool > summary::before { content: none; }
.tool-name { font-weight: 650; color: #9dc0ff; }
.tool-ms { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.tool-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--muted); }
.tool--running > summary .tool-dot { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.tool--ok      > summary .tool-dot { background: var(--good); }
.tool--err     > summary .tool-dot { background: var(--bad); }
.tool--err     > summary .tool-name { color: var(--bad); }
.tool pre {
  margin: 6px 0 0; padding: 7px 8px; overflow-x: auto;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 6px;
  font-family: var(--mono); font-size: 0.74rem; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word;
}
.trace-summary { font-size: 0.78rem; color: var(--text-dim); margin-top: 5px; }
.trace-summary:empty { display: none; }

.notices:empty { display: none; }
.notice-row { font-size: 0.75rem; color: var(--warn); margin-top: 6px; }

.msg--warn .bubble { border-color: rgba(242, 181, 60, 0.35); }

@media (prefers-reduced-motion: reduce) {
  .tool--running > summary .tool-dot { animation: none; }
}

/* Písacie pole drží spodok obrazovky, kým je karta v zábere. Bez toho by sa
   pri dlhej konverzácii muselo skrolovať dole zakaždým, keď chceš napísať
   ďalšiu otázku. Nepriehľadné pozadie je nutné — správy sa skrolujú POD ním. */
.composer {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--panel);
  padding-bottom: 4px;
}
.chat-form { border-top: 1px solid var(--line-soft); padding-top: 12px; }
.chat-form .field { margin-bottom: 8px; }
.composer .status { margin-top: 2px; min-height: 0; }

/* ── Graf histórie ───────────────────────────────────────────────────────── */
.verdict { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.verdict-main { font-size: 1rem; font-weight: 700; }
.verdict-main.v-good { color: var(--good); }
.verdict-main.v-mid  { color: var(--text); }
.verdict-main.v-high { color: var(--warn); }
.verdict-sub { font-size: 0.82rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  margin-top: 6px; font-size: 0.74rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend .key { width: 12px; height: 3px; border-radius: 2px; background: var(--accent); }
.chart-legend .key--band { height: 9px; background: rgba(76, 141, 255, 0.16); border: 1px solid rgba(76, 141, 255, 0.35); }
.chart-legend .key--promo { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px; margin-top: 14px;
}
.stat {
  padding: 9px 11px; background: var(--bg-elev);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}
.stat .stat-k { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat .stat-v { font-size: 0.98rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .stat-v.small { font-size: 0.85rem; font-weight: 600; }
.stat .stat-sub { font-size: 0.72rem; color: var(--muted); margin-top: 3px; }
/* Stavová farba dlaždice ide do ľavého okraja — plocha by pri ôsmich dlaždiciach
   vedľa seba prekričala samotné čísla. */
.stat--ok   { border-left: 3px solid var(--good); }
.stat--warn { border-left: 3px solid var(--warn); }
.stat--bad  { border-left: 3px solid var(--bad); }
.stat-grid--tight { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-top: 10px; }

/* ══ Admin: diagnostika ═══════════════════════════════════════════════════ */

.admin-bar {
  display: flex; flex-wrap: wrap; gap: 12px 20px;
  align-items: flex-end; justify-content: space-between;
}
.admin-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.015em; }
.admin-bar-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.admin-bar-controls .status { margin-top: 0; min-width: 150px; }

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 0.8rem; color: var(--text-dim); }
.check input { width: auto; margin: 0; accent-color: var(--accent); cursor: pointer; }

/* Otvorený beh. Zelený = má aktivitu, červený = záznam visí bez stiahnutej stránky. */
.run-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-elev); padding: 11px 13px; margin-bottom: 10px;
}
.run-card:last-child { margin-bottom: 0; }
.run-card--live    { border-left: 3px solid var(--good); }
.run-card--stalled { border-left: 3px solid var(--bad); }
.run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.86rem; }
.run-spacer { flex: 1 1 auto; }
.run-note { font-size: 0.8rem; color: var(--text-dim); margin-top: 6px; }
.run-facts {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 7px;
  font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.run-note-cell { max-width: 420px; font-size: 0.76rem; }
.url-cell { max-width: 360px; overflow-wrap: anywhere; }

/* Zdroj dát */
.source-card {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--bg-elev); padding: 13px 14px; margin-top: 12px;
}
.source-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; }
.source-name { font-size: 0.95rem; font-weight: 650; }
.source-head-right { text-align: right; font-size: 0.72rem; }
.source-metric { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Kalendár pokrytia: jedna bunka = jeden deň. Tri stavy, tri farby. */
.cal { display: flex; gap: 2px; margin-top: 12px; }
.cal-day { flex: 1 1 0; min-width: 4px; height: 26px; border-radius: 3px; }
.cal-day--data      { background: var(--accent); }
/* Beh prebehol, ceny nepriniesol — to je porucha, nie prázdny plán. */
.cal-day--empty-run { background: var(--warn-dim); border: 1px solid rgba(242, 181, 60, 0.45); }
.cal-day--none      { background: var(--panel-2); border: 1px solid var(--line-soft); }
.cal-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 7px;
  font-size: 0.73rem; color: var(--muted);
}
.cal-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.cal-key { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.chip-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-top: 10px; font-size: 0.76rem;
}

/* ── Responzívne: pod 1100 px sa nákupný zoznam zloží pod seba ───────────── */
@media (max-width: 1100px) {
  .page--split { grid-template-columns: minmax(0, 1fr); }
}

/* Pod 820 px sa história presunie nad chat a prestane byť prilepená. */
@media (max-width: 820px) {
  .page--chat { grid-template-columns: minmax(0, 1fr); }
  .card--history { position: static; max-height: 320px; }
}

@media (max-width: 900px) {
  .page { padding: 14px 14px 30px; }
  .page-note--wide { padding: 12px 14px 30px; }
  .topbar { padding: 10px 14px; }
  .shell-meta { margin-left: 0; }
  .nav { margin-left: 0; width: 100%; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .chat-log { min-height: 160px; }
  .sum-row--total .v { font-size: 1.1rem; }
  .run-note-cell, .url-cell { max-width: 200px; }
}
