/* ========================================================================
   FVE Dashboard — Variant A "FinDash Solar" (dark + light)
   ----------------------------------------------------------------
   Breakpoints:
     mobile   (<720)  — bottom-nav, single column
     tablet   (720–1199) — collapsed sidebar (60px) + 2col KPI
     2k       (1200–2559) — full sidebar (240) + 4col KPI + AI panel (280)
     fhd      (2560–3839) — same layout, larger spacing/fonts
     4k       (≥3840)  — root font 21px, centered max-width 3600px
   ======================================================================== */

:root {
  /* BARVY ŽIJÍ VÝHRADNĚ v themes.css (theme tokeny + legacy bridge: bg-0..3,
     line, text, primary, green, blue…). Konkurenční sada, která tu bývala,
     byla smazána (fáze-2 úklid driftu, 2026-07-03) — themes.css se načítá
     poslední a stejně ji celou přebíjel. Tady jen strukturní utility. */

  /* radius */
  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;

  /* layout (fallback — bridge v themes.css mapuje na density tokeny) */
  --pad: 22px;
  --gap: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
}

html {
  font-size: 16px;
  background: var(--bg-0);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body, 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif);
  background: var(--bg-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01", "ss03";
}

/* ================== APP SHELL ==================
   Layout shell (rail/topbar/main/drawer) je v static/css/layout.css (Phase 3).
   Tato sekce drží jen reusable utility classes pro content area. */
.ic { width: 18px; height: 18px; flex-shrink: 0; }


/* ŽIVÉ — používá templates/asistent.html (input plného AI chatu) */
.ai-input {
  margin-top: auto;
  padding: 9px 12px;
  background: var(--bg-2);
  border-radius: var(--widget-radius);
  border: 1px solid var(--line);
  color: var(--text-3);
  font-size: 12px;
  display: flex;
  align-items: center;
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
}
/* Widget grid embed (settings cards na widget gridu, 2026-05-28) — widget
   body uz dodava bg/border, card jen padding/layout. */
.settings-card-embed {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 14px 16px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;          /* šířka je daná → jen svislý posuvník, nikdy vodorovný */
  max-width: none !important;  /* drive byl inline max-width 600px na karte */
}
.settings-card-embed::-webkit-scrollbar { width: 6px; }
.settings-card-embed::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-title { font-size: 14px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.legend { display: flex; gap: 8px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
/* Chip-like styling: bg-3 surface, color border + tint on active, dim on off.
   .dim = vrstva vypnuta (skryta v chartu). Pri click handler updatuje class +
   localStorage; html attribute pre-paint pro range:czk/cumul/yoy uz nepouzivame
   (widget render aplikuje .dim z localStorage primo do template). */
.legend-item {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  color: var(--text-2);
  font-weight: 600;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.legend-item:hover { border-color: var(--line-2); color: var(--text); }
.legend-item.dim { opacity: .55; background: transparent; color: var(--text-3); }
.legend-item.dim .legend-dot { filter: grayscale(1); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.pill-select {
  padding: 6px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}

.chart-today {
  width: 100%;
  height: 240px;
}


/* ================== ROW 3 (table + activity) ================== */

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.compare-table th {
  text-align: right;
  padding: 8px 12px 10px;
  font-size: var(--fs-caption, 10px);  /* recept table th (S3-04) */
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.compare-table th:first-child { text-align: left; padding-left: 0; }
.compare-table th:last-child  { padding-right: 0; }
.compare-table th .unit {
  margin-left: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  opacity: 0.65;
}
.compare-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.compare-table td:first-child { font-weight: 600; padding-left: 0; }
.compare-table td:last-child  { padding-right: 0; }
.compare-table td.num { text-align: right; min-width: 92px; }
/* Vizuální separator mezi skupinami Včera (kWh+Kč) a Dnes (kWh+Kč) — 4. sloupec */
.compare-table th:nth-child(4),
.compare-table td:nth-child(4) {
  border-left: 1px solid var(--line-2);
  padding-left: 18px;
}
.compare-table tr.total td {
  border-top: 1px solid var(--line);
  border-bottom: none;
  padding-top: 12px;
  font-weight: 800;
  color: var(--green-2);
}
.delta { font-size: 11px; margin-left: 4px; }
.delta.up { color: var(--green-2); }
.delta.down { color: var(--red); }

.activity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.activity-row:last-child { border: none; padding-bottom: 0; }
.activity-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 12px;
}
.activity-row.ok   .activity-icon { background: color-mix(in srgb, var(--green-2) 18%, transparent); color: var(--green-2); }
.activity-row.warn .activity-icon { background: rgba(245,158,11,0.18); color: var(--amber); }
.activity-row.info .activity-icon { background: rgba(6,182,212,0.18); color: var(--cyan); }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-weight: 600; line-height: 1.3; }
.activity-sub {
  color: var(--text-3);
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-time {
  margin-left: auto;
  color: var(--text-3);
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}
.activity-row.err .activity-icon { background: rgba(239,68,68,0.18); color: var(--red); }
/* Sjednocení se zvonkem (2026-06-17): scrollovatelná historie + „Více" footer. */
.activity-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.activity-list { flex: 1; min-height: 0; overflow-y: auto; }
.activity-more {
  flex-shrink: 0;
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm, 8px);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.activity-more:hover { background: var(--bg-3); color: var(--text); border-color: var(--line-2); }

/* Lehký toast (save-as-default feedback ap.) */
.grid-toast {
  position: fixed; left: 50%; bottom: 84px;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); z-index: 9999; opacity: 0;
  transition: opacity .25s, transform .25s; pointer-events: none; max-width: 90vw;
}
.grid-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.grid-toast-err { border-color: var(--red); color: var(--red); }

/* ================== ALERTS ================== */
.alerts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--gap);
  margin-top: 0;
}
.alert {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.alert-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.alert h4 { margin: 0; font-size: 13px; font-weight: 700; }
.alert p { margin: 2px 0 0; font-size: 12px; color: var(--text-2); line-height: 1.4; }
.alert.ok    h4 { color: var(--green-2); }
.alert.ok    .alert-icon { background: color-mix(in srgb, var(--green-2) 18%, transparent); color: var(--green-2); }
.alert.warn  h4 { color: var(--amber); }
.alert.warn  .alert-icon { background: rgba(245, 158, 11, 0.18); color: var(--amber); }
.alert.info  h4 { color: var(--cyan); }
.alert.info  .alert-icon { background: rgba(6, 182, 212, 0.18); color: var(--cyan); }

/* =====================================================
   F3: HISTORIE & TRŽBY (30d bar, monthly bar, revenue, heatmap modal)
   ===================================================== */

.row-monthly {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: var(--gap);
  margin-bottom: 18px;
}
.chart-range {
  width: 100%;
  aspect-ratio: 16 / 5;
  min-height: 260px;
  margin-top: 8px;
}
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--widget-radius);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.btn-ghost:hover {
  border-color: var(--line-2);
  color: var(--text);
  background: var(--bg-3);
}
.btn-ghost .ic { width: 14px; height: 14px; }
.btn-primary {
  padding: 8px 16px;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--widget-radius);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--primary-2); }

/* .cta — primary call-to-action (uložit heslo, změnit heslo, přidat kvótu…).
   Dřív bez CSS pravidla → renderoval se jako šedé default tlačítko. Sjednoceno
   na náš standard (var(--primary)). Funguje pro <button> i <a class="cta">.
   Inline override (např. červené smazat v settings) má přednost. */
.cta {
  display: inline-block;
  padding: 10px 18px;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  line-height: 1.2;
  transition: background .15s;
}
.cta:hover { background: var(--primary-2); }

/* KPI strip nad chart-toolbar v Výroba a tržby kartě */
.range-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 12px 0 14px;
}
.rk-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--widget-radius);
  padding: 10px 12px;
  min-width: 0;
}
.rk-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rk-peak-date {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: none;
  letter-spacing: 0;
}
.rk-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
  line-height: 1.15;
  font-feature-settings: "tnum" 1;
}
.rk-value-green { color: var(--green-2); }
@media (max-width: 720px) {
  .range-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* Toolbar nad grafem: preset chipy vlevo + legend vpravo */
.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.range-presets {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--widget-radius);
  padding: 3px;
}
.rp-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.rp-btn:hover { color: var(--text); background: var(--bg-3); }
.rp-btn.active {
  background: var(--primary);
  color: #fff;
}
.rp-btn .ic { width: 13px; height: 13px; }
/* .rp-custom { font-style: italic; } — kurziva pryc, plain text vypada lepe */

/* Navigační šipky ◀ ▶ */
.rp-nav {
  padding: 6px 8px;
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.rp-nav:hover:not(:disabled) {
  background: var(--bg-3);
  color: var(--text);
}
.rp-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.rp-nav .ic { width: 14px; height: 14px; }

/* Custom date range row */
.custom-range {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  margin-top: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--widget-radius);
  flex-wrap: wrap;
}
.custom-range[hidden] { display: none; }
.custom-range label + label { margin-left: 2px; }
.custom-range input[type="date"] {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  min-width: 0;
  width: auto;
}
.custom-range #rangeApply { margin-left: 6px; }

/* Wrapper pro Vlastni a Porovnat formular — bezi vedle sebe v jednom radku
   (s wrap kdyz neni misto). Kazdy formular ma vlastni .custom-range / .compare-form
   styly. Drive byly pod sebou → user chtel uspornejsi layout. */
.range-forms-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}
/* margin-top je na wrapperu — uvnitr formy uz ho nepotrebuji,
   prazdny wrapper bez deti je collapsnut (oba formy hidden = padding nezhmotni) */
.range-forms-row:not(:empty) { margin-top: 8px; }
.range-forms-row > * { margin-top: 0 !important; }

/* Compare form — porovnani s vlastnim datumem od/do.
   Kompaktni single-radek: Od + Do datumy tesne vedle sebe, mensi paddingy. */
.compare-form {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  margin-top: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--widget-radius);
  flex-wrap: wrap;
}
.compare-form[hidden] { display: none; }
.compare-form label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 600;
}
/* Druhy label (Do) tesne navazuje na prvni — bez gap mezi nimi */
.compare-form label + label { margin-left: 2px; }
.compare-form input[type="date"] {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  /* Native date input je defaultne sirsi nez potreba; constrain na min width */
  min-width: 0;
  width: auto;
}
.compare-form #compareApply { margin-left: 6px; }
/* .custom-range label + input — sjednoceno s compare-form vyse (mensi padding, gap).
   color-scheme: dark/light pro native date picker - oba selectory. */
.custom-range label, .compare-form label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 600;
}
.custom-range input[type="date"],
.compare-form input[type="date"] {
  color-scheme: dark;
}
[data-theme="daylight"] .custom-range input[type="date"],
[data-theme="daylight"] .compare-form input[type="date"] { color-scheme: light; }
.custom-range-hint {
  color: var(--text-3);
  font-size: 11px;
  margin-left: auto;
}

/* Status legenda pod chart-range */
.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-2);
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-3);
}
.sl-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.sl-swatch {
  width: 14px; height: 12px;
  display: inline-block;
  border-radius: 2px;
  background: var(--text-2);
}
.sl-swatch.sl-final {
  background: var(--text-2);
  opacity: 1;
}
.sl-swatch.sl-preliminary {
  background: var(--text-2);
  opacity: 0.78;
  background-image: repeating-linear-gradient(135deg,
    transparent 0, transparent 2px,
    rgba(255,255,255,0.4) 2px, rgba(255,255,255,0.4) 3px);
}
.sl-swatch.sl-live {
  background: var(--text-2);
  opacity: 0.55;
}
.sl-swatch.sl-missing {
  background: transparent;
  border: 1px solid var(--red);
  opacity: 0.7;
}
/* Vypadek napeti — CEZ flagol interval status='outage'. Oranzovy badge. */
.sl-swatch.sl-outage {
  background: var(--amber, #f59e0b);
  opacity: 0.85;
}


/* Bottom row (Včera vs Dnes + Aktivita) — bývala .row3 s 3 sloupci, nyní 2 */
.row3-bottom {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--gap);
  margin-bottom: 18px;
}

/* =====================================================
   MODAL (Heatmap)
   ===================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}
.modal-panel {
  position: relative;
  width: min(1400px, 95vw);
  max-height: 92vh;
  overflow: auto;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-head-actions .btn-ghost { padding: 7px 12px; font-size: 12px; }
.modal-head-actions .btn-ghost[disabled] { opacity: .45; pointer-events: none; }
.modal-close {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--widget-radius);
  background: var(--bg-2);
  border: 1px solid var(--line);
  cursor: pointer;
  color: var(--text-2);
}
.modal-close:hover { color: var(--text); border-color: var(--text-3); }
.modal-close .ic { width: 16px; height: 16px; }

/* Data table modal — tabulkovy prehled. Sticky header, zebra stripes, hover row. */
.data-table-wrap {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  max-height: calc(92vh - 110px);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: var(--text);
}
.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-3);
  color: var(--text-2);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--line);
  z-index: 1;
}
.data-table thead th.num { text-align: right; }
.data-table tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.data-table tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.data-table tfoot td {
  padding: 12px 14px;
  background: var(--bg-3);
  font-weight: 700;
  border-top: 2px solid var(--line);
}
.data-table tfoot td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* Status badge ve sloupci Status — barevny chip podle stavu */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text-2);
}
.status-badge.status-final {
  background: color-mix(in srgb, var(--green-2) 18%, transparent);
  border-color: var(--green-2);
  color: var(--green-2);
}
.status-badge.status-preliminary {
  background: var(--bg-3);
  color: var(--text-3);
  /* dashed border evokuje pre-paint dim pattern */
  border-style: dashed;
}
.status-badge.status-outage {
  background: color-mix(in srgb, var(--amber) 20%, transparent);
  border-color: var(--amber);
  color: var(--amber);
}
.status-badge.status-live {
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  border-color: var(--primary);
  color: var(--primary-2, var(--primary));
}
.status-badge.status-missing {
  background: transparent;
  border-color: var(--red);
  color: var(--red);
}

.modal-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.metric-toggle {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--widget-radius);
  padding: 3px;
  gap: 2px;
}
.mt-btn {
  padding: 6px 14px;
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all .15s;
}
.mt-btn:hover { color: var(--text); }
.mt-btn.active {
  background: var(--primary);
  color: #fff;
}
.years-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.years-pick[hidden] { display: none; }

.chart-heatmap {
  width: 100%;
  aspect-ratio: 12 / 7;
  min-height: 380px;
}
.modal-foot p { margin: 0; }

/* =====================================================
   RESPONSIVE — TABLET (720–1199)
   ===================================================== */
@media (max-width: 1199px) {
  :root {
    --pad: 16px;
  }
  .row-monthly {
    grid-template-columns: 1fr;
  }
  .row3-bottom {
    grid-template-columns: 1fr 1fr;
  }
  .alerts { grid-template-columns: 1fr 1fr 1fr; }
}

/* =====================================================
   RESPONSIVE — MOBILE (<720)
   Layout-shell behaviors (rail hide, hamburger, drawer) jsou v layout.css.
   ===================================================== */
@media (max-width: 719px) {
  :root { --pad: 12px; --gap: 10px; }

  .row3-bottom { grid-template-columns: 1fr; }
  .row-monthly { grid-template-columns: 1fr; }
  .alerts { grid-template-columns: 1fr; }
  .chart-today { height: 220px; }
  .chart-range { aspect-ratio: auto; height: 260px; }
  .chart-heatmap { aspect-ratio: auto; min-height: 420px; }
  .chart-toolbar { flex-direction: column; align-items: flex-start; }
  .range-presets { flex-wrap: wrap; }
  .content-header h1 { font-size: 18px; }
  .content-header .content-sub { display: none; }
}

/* =====================================================
   RESPONSIVE — FHD desktop (2560–3839)
   ===================================================== */
@media (min-width: 2560px) and (max-width: 3839px) {
  :root {
    --pad: 32px;
    --gap: 18px;
  }
  html { font-size: 17px; }
  .content-header h1 { font-size: 26px; }
  .chart-today { height: 320px; }
}

/* =====================================================
   RESPONSIVE — 4K TV (≥3840)
   ===================================================== */
@media (min-width: 3840px) {
  :root {
    --pad: 48px;
    --gap: 24px;
    --r-lg: 22px;
  }
  html { font-size: 21px; }
  .content-header h1 { font-size: 32px; }
  .chart-today { height: 480px; }
  .ic-lg { width: 28px; height: 28px; }
}

/* =====================================================
   Misc
   ===================================================== */
button { font: inherit; }
button.icon-btn { background: var(--bg-2); }

/* loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
  color: transparent;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* hide if user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* =====================================================
   F5: FINANCE / TRŽBY — 2x2 widget grid + focus mode
   ===================================================== */
.finance-grid {
  display: grid;
  /* auto-fit: na laptop 2 sloupce (2×2 default), na ultrawide 3–4 v řadě,
     na úzkém okně 1 sloupec — bez tvrdých breakpointů. */
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  grid-auto-rows: minmax(220px, auto);
  gap: var(--gap);
  margin-bottom: 18px;
}
.fwidget {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: transform .25s ease, opacity .25s ease;
}
/* Widget grid embed (finance widgets na widget gridu, 2026-05-28) —
   widget body uz dodava bg/border, fwidget jen layout. */
.fwidget-embedded {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 12px 14px;
  height: 100%;
}
.fw-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.fw-title { font-size: 13px; font-weight: 700; }
.fw-sub   { font-size: 11px; color: var(--text-3); margin-top: 1px; }
/* Focus mode: víc breathing room */
.fw-focused              { padding: 16px 18px; }
.fw-focused .fw-head     { padding-bottom: 12px; margin-bottom: 14px; }
.fw-focused .fw-title    { font-size: 15px; }
.fw-focused .fw-sub      { font-size: 12px; margin-top: 2px; }
.fw-head-actions { display: flex; gap: 6px; }
.fw-expand, .fw-edit {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.fw-expand:hover, .fw-edit:hover {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--line-2);
}
.fw-edit[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.fw-expand .ic, .fw-edit .ic { width: 14px; height: 14px; }

.fw-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.fw-scroll { overflow: auto; }
.fw-chart  { flex: 1; min-height: 120px; }

/* Windfall KPIs */
.fw-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.fw-kpi {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fw-kpi-total {
  background: linear-gradient(180deg, rgba(124,92,255,0.15), rgba(124,92,255,0.05));
  border-color: var(--primary);
}
.fw-k-label { font-size: 10px; color: var(--text-3); line-height: 1.1; }
.fw-k-value {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.fw-kpi-total .fw-k-value { color: var(--primary-2); }
/* Focus mode: větší KPI */
.fw-focused .fw-kpis     { gap: 10px; }
.fw-focused .fw-kpi      { padding: 10px 12px; gap: 4px; border-radius: var(--r-md); }
.fw-focused .fw-k-label  { font-size: 11px; }
.fw-focused .fw-k-value  { font-size: 20px; }

/* ── Tržby — období + porovnání (fin-revenue widget) ── */
.fin-rev .fw-head { align-items: flex-start; }
.fin-rev-metrics { flex-wrap: wrap; }
.fin-rev-metrics .mt-btn { padding: 4px 12px; font-size: 11px; }
.fin-rev-kpis { margin-bottom: 8px; }
/* date inputy (existující .rev-range styluje jen datetime-local) */
.rev-range input[type="date"] {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 4px;
  padding: 3px 6px;
  font: inherit;
  font-size: 12px;
  color-scheme: dark;
}
[data-theme="daylight"] .rev-range input[type="date"] { color-scheme: light; }
/* Porovnat chip — zapnutý (bez .dim) = primární zvýraznění */
.rev-compare-chip { gap: 5px; }
.rev-compare-chip:not(.dim) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.rev-compare-chip:not(.dim):hover { background: var(--primary); color: #fff; }
.rev-custom-compare { border-style: dashed; }
/* Delta barvy (specificita kvůli .fw-kpi-total .fw-k-value) */
.fin-rev-kpis .fw-k-value.fw-delta-up   { color: var(--green-2); }
.fin-rev-kpis .fw-k-value.fw-delta-down { color: var(--red); }

/* Rate card table */
.fw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.fw-table th, .fw-table td {
  text-align: right;
  padding: 6px 8px;
  border-bottom: 1px dashed var(--line);
  white-space: nowrap;
}
.fw-table th:first-child, .fw-table td:first-child {
  text-align: left;
  font-weight: 600;
}
.fw-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-1);
  color: var(--text-2);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
.fw-table td.num { font-variant-numeric: tabular-nums; }
.fw-table td.editable { cursor: text; }
.fw-table td.editable:hover { background: var(--bg-2); }
.fw-table td input.cell-edit {
  width: 90%;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--primary);
  border-radius: 4px;
  padding: 2px 4px;
  text-align: right;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.fw-year-pick {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-size: 12px;
  margin-left: 4px;
}

/* Focus mode: jeden widget na hlavní plochu, ostatní do mini-strip */
.finance-grid.focused {
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(540px, calc(100vh - 220px));
}
.finance-grid.focused .fwidget:not(.fw-focused) {
  display: none;
}
.finance-grid.focused .fw-chart { min-height: 360px; }
.fw-focused .fw-expand {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.fw-mini-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.fw-mini {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.fw-mini:hover { background: var(--bg-3); color: var(--text); }
.fw-mini.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.fw-mini-close { margin-left: auto; }

/* ===== Bell button — topbar notifikační panel ===== */
.bell-wrap { position: relative; }
.bell-panel {
  position: fixed;           /* fix vůči viewportu, ne bell-wrap → nikdy nevyjede z obrazovky */
  top: 64px;                 /* pod topbarem */
  right: 16px;               /* okraj viewportu */
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  overflow: hidden;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.bell-panel[hidden] { display: none; }
.bell-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.bell-head h4 { margin: 0; font-size: 13px; font-weight: 700; color: var(--text); }
.bell-ack-all {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: var(--r-sm);
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.bell-ack-all:hover { background: var(--bg-3); color: var(--text); }
.bell-list { overflow: auto; max-height: 420px; }
.bell-empty { padding: 24px 14px; text-align: center; color: var(--text-3); font-size: 12px; }
.bell-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  transition: background .15s;
}
.bell-row:hover { background: var(--bg-2); }
.bell-row:last-child { border-bottom: none; }
.bell-row.bell-acked { opacity: 0.55; }
.bell-icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 13px;
}
.bell-row.sev-warn .bell-icon { color: var(--amber); }
.bell-row.sev-err  .bell-icon { color: var(--red); }
.bell-row.sev-ok   .bell-icon { color: var(--green-2); }
.bell-row.sev-info .bell-icon { color: var(--cyan); }
.bell-main { flex: 1; min-width: 0; }
.bell-title { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.3; }
.bell-body  { font-size: 11px; color: var(--text-2); margin-top: 2px; word-break: break-word; }
.bell-time  { font-size: 10px; color: var(--text-3); margin-top: 4px; }
.bell-ack, .bell-unack {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 50%;
  width: 22px; height: 22px;
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
}
.bell-ack:hover   { background: var(--green-2); color: white; border-color: var(--green-2); }
.bell-unack:hover { background: var(--amber);   color: white; border-color: var(--amber); }

/* KPI degradace na úzké obrazovce (auto-fit už řeší samotný grid) */
@media (max-width: 600px) {
  .fw-kpis { grid-template-columns: 1fr; }
}

/* ===== Výkup widget — toolbar (presety + plant filter) + custom range ===== */
.rev-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.rev-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.rev-chip {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rev-chip:hover { background: var(--bg-3); color: var(--text); }
.rev-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.rev-chip .ic { width: 11px; height: 11px; }
.rev-chip-custom { font-style: italic; }

.rev-plants { display: flex; gap: 4px; position: relative; }
.rev-plant {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-3);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
  opacity: .5;
}
.rev-plant:hover { opacity: .75; }
.rev-plant.active { opacity: 1; }
.rev-plant.rev-plant-pp.active { background: color-mix(in srgb, var(--plant-pp) 18%, transparent); color: var(--plant-pp); border-color: var(--plant-pp); }
.rev-plant.rev-plant-ag.active { background: color-mix(in srgb, var(--plant-ag) 18%, transparent); color: var(--plant-ag); border-color: var(--plant-ag); }
.rev-plant.rev-plant-ns.active { background: color-mix(in srgb, var(--plant-ns) 18%, transparent); color: var(--plant-ns); border-color: var(--plant-ns); }

/* PlantPicker dropdown mode (≥7 plants) */
.rpd-trigger {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, border-color .15s;
}
.rpd-trigger:hover { background: var(--bg-3); border-color: var(--line-2); }
.rpd-trigger[aria-expanded="true"] { background: var(--bg-3); border-color: var(--primary); }
.rpd-count { font-weight: 700; color: var(--primary-2); }
.rpd-arrow { color: var(--text-3); font-size: 10px; }

.rpd-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  min-width: 280px;
  max-width: 480px;
  max-height: 360px;
  overflow: auto;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.32);
  padding: 8px;
}
.rpd-panel[hidden] { display: none; }
.rpd-head {
  display: flex;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.rpd-all, .rpd-none {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: var(--r-sm);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.rpd-all:hover, .rpd-none:hover { background: var(--bg-3); color: var(--text); }
.rpd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 4px;
}
.rpd-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
}
.rpd-item:hover { background: var(--bg-2); }
.rpd-item input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--primary);
}

.rev-custom {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
}
.rev-custom[hidden] { display: none; }   /* class má vyšší specificity než [hidden], musíme explicit */
.rev-range { display: flex; gap: 10px; flex-wrap: wrap; }
.rev-range label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-2);
}
.rev-range input[type="datetime-local"] {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 4px;
  padding: 3px 6px;
  font: inherit;
  font-size: 12px;
  color-scheme: dark;
}
.rev-range-compare {
  padding-top: 6px; border-top: 1px dashed var(--line);
}
.rev-compare-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-2);
  cursor: pointer;
}

.rev-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
  margin-bottom: 4px;
}
.rev-total {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rev-total-net {
  background: linear-gradient(180deg, color-mix(in srgb, var(--green-2) 15%, transparent), color-mix(in srgb, var(--green-2) 5%, transparent));
  border-color: var(--green-2);
}
.rev-t-label { font-size: 10px; color: var(--text-3); line-height: 1.1; }
.rev-t-value { font-family: var(--font-display); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.rev-t-tax { color: var(--red); }
.rev-total-net .rev-t-value { color: var(--green-2); }

/* Focus mode: větší typografie */
.fw-focused .rev-totals    { gap: 10px; }
.fw-focused .rev-total     { padding: 10px 12px; gap: 4px; border-radius: var(--r-md); }
.fw-focused .rev-t-label   { font-size: 11px; }
.fw-focused .rev-t-value   { font-size: 18px; }

/* =========================================
   F7 — AI ASISTENT
   ========================================= */
.ai-page {
  display: flex;
  justify-content: center;
  padding: 16px 24px 24px;
}
.ai-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 1100px;
  height: calc(100vh - 160px);
  min-height: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Widget grid embed mode (asistent v widget gridu, 2026-05-28) — naplni
   widget body, ne viewport. */
.ai-page-embedded {
  padding: 0;
  height: 100%;
}
.ai-page-embedded .ai-card {
  height: 100%;
  min-height: 0;
  max-width: none;
  border: none;
  border-radius: 0;
}

/* === Warning + quota header === */
.ai-warn {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(234, 179, 8, 0.08), rgba(234, 179, 8, 0.02));
  border-bottom: 1px solid var(--line);
}
.ai-warn-icon { font-size: 20px; flex-shrink: 0; }
.ai-warn-body { flex: 1; min-width: 0; }
/* Lead = přesunutý podtitulek stránky ("Ptej se na svá data — …") do warn bloku */
.ai-warn-lead { font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 5px; }
.ai-warn-title { font-size: 13px; color: var(--text-2); font-weight: 500; margin-bottom: 4px; }

/* /asistent: velikost AI okna řídí výhradně grid (resize až 8×8). Dřív tu byl
   tvrdý strop max-width:860/max-height:640px (proti „obřímu" 4-wide widgetu na 4K),
   ale ten uživateli BRÁNIL okno zvětšit → odstraněno (user 2026-06-24). Pokud bude
   na 4K příliš velké, zmenší se přes resize grip. */
.ai-warn-quota {
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}
.ai-warn-quota strong { color: var(--text); }
.ai-warn-fve { color: var(--text-3); font-size: 12px; }
.ai-warn-admin {
  display: inline-block;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-right: 6px;
}
.ai-quota-warn strong { color: #fbbf24; }
.ai-quota-exhausted strong { color: var(--red); }

.ai-plant-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-2);
}
.ai-plant-picker label { color: var(--text-3); }
.ai-plant-picker select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.ai-plant-fixed {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  font-size: 13px;
  color: var(--text);
}

.ai-hint {
  color: var(--text-3);
  font-style: italic;
}

/* === Message stream === */
.ai-stream {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.ai-msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 90%;
  animation: ai-fade-in 0.18s ease-out;
}
@keyframes ai-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ai-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.ai-msg-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: 0.5px;
}
.ai-msg-user .ai-msg-avatar {
  background: linear-gradient(135deg, color-mix(in srgb, var(--green-2) 18%, transparent), color-mix(in srgb, var(--green-2) 8%, transparent));
  color: var(--green-2);
  border-color: color-mix(in srgb, var(--green-2) 30%, transparent);
}
.ai-msg-assistant .ai-msg-avatar {
  background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(99,102,241,0.08));
  color: #a5b4fc;
  border-color: rgba(99,102,241,0.3);
}

.ai-msg-body {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.ai-msg-user .ai-msg-body {
  background: linear-gradient(135deg, color-mix(in srgb, var(--green-2) 12%, transparent), color-mix(in srgb, var(--green-2) 4%, transparent));
  border-color: color-mix(in srgb, var(--green-2) 25%, transparent);
}
.ai-msg-body strong { color: var(--text); font-weight: 700; }

/* AI widget builder Fáze 2 — inline náhled grafu v chatu + „Přidat graf" */
/* Karta = samostatný full-width blok v .ai-stream (flex column → align-items:stretch),
   tj. LANDSCAPE graf POD textem od leva. NENÍ flex-sourozenec v .ai-msg → žádný
   overflow doprava (předchozí flex-wrap přístup byl křehký). */
.ai-chart-card {
  align-self: stretch; margin: 4px 0 2px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px 10px;
}
.ai-chart-host { width: 100%; height: 280px; }
.ai-chart-actions {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid var(--line);
}
.ai-chart-add-lbl { color: var(--text-3); font-size: 12px; font-weight: 600; margin-right: auto; }
.ai-chart-add {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.ai-chart-add:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-2); }
.ai-chart-plus { font-size: 14px; line-height: 1; }

/* Model + cena za dotaz (levý panel asistenta) */
.aichat-modelinfo { margin-top: 14px; }
.ai-model-name { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.ai-model-cost { font-size: 12px; color: var(--text-3); }
.ai-msg-body em     { color: var(--text-2); }
.ai-msg-body code {
  background: var(--bg-3);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: #a5b4fc;
}
.ai-msg-body ul, .ai-msg-body ol {
  margin: 6px 0;
  padding-left: 22px;
}
.ai-msg-body li { margin: 2px 0; }

/* F8 — Tool use indicator */
.ai-tool-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(99,102,241,0.10);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: #a5b4fc;
  font-style: italic;
  animation: ai-fade-in 0.2s ease-out;
}
.ai-tool-indicator.ai-tool-done {
  background: color-mix(in srgb, var(--green-2) 10%, transparent);
  border-color: color-mix(in srgb, var(--green-2) 25%, transparent);
  color: var(--green-2);
  font-style: normal;
}
.ai-tool-indicator.ai-tool-err {
  background: rgba(239,68,68,0.10);
  border-color: rgba(239,68,68,0.25);
  color: var(--red);
  font-style: normal;
}
.ai-tool-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(99,102,241,0.3);
  border-top-color: #a5b4fc;
  border-radius: 50%;
  animation: ai-spin 0.7s linear infinite;
}
@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

/* Typing indicator */
.ai-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 18px;
}
.ai-typing > span {
  width: 6px;
  height: 6px;
  background: var(--text-3);
  border-radius: 50%;
  animation: ai-typing-bounce 1.2s infinite ease-in-out;
}
.ai-typing > span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing > span:nth-child(3) { animation-delay: 0.30s; }
@keyframes ai-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* === Presets === */
.ai-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 24px 0;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
}
.ai-preset {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ai-preset:hover:not(:disabled) {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--line-2);
}
.ai-preset:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Input form === */
.ai-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 24px;
  background: var(--bg-1);
}
.ai-input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  max-height: 200px;
}
.ai-input:focus  { border-color: var(--primary); }  /* zřetelná focus náhrada (outline:none) — sjednoceno s widgets.css */
.ai-input:disabled { opacity: 0.5; cursor: not-allowed; }

.ai-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border: none;
  border-radius: var(--r-md);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, box-shadow 0.15s;
}
.ai-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}
.ai-send:disabled { opacity: 0.4; cursor: not-allowed; }
.ai-send svg { width: 18px; height: 18px; }

/* === Footer === */
.ai-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 24px 12px;
  font-size: 12px;
  color: var(--text-3);
}
.ai-quota { font-variant-numeric: tabular-nums; }
.ai-reset-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-3);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ai-reset-btn:hover { color: var(--text); border-color: var(--line-2); }

/* Mobile */
@media (max-width: 720px) {
  .ai-page { padding: 8px 12px 12px; }
  .ai-card { height: calc(100vh - 220px); }
  .ai-stream { padding: 14px 16px; gap: 12px; }
  .ai-presets, .ai-form, .ai-footer { padding-left: 14px; padding-right: 14px; }
  .ai-msg { max-width: 100%; }
}
