/* ==========================================================================
   View: Analýza (#/s/:id/analysis) — owned by views/analysis.js. Prefix .an-
   Only app.css tokens are used; status colours appear only on status marks.
   ========================================================================== */

.an-view { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.an-view > .section-header { margin-bottom: 0; }
.an-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.an-panels { min-width: 0; }
.an-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.an-panel[hidden] { display: none; }
.an-panel.is-updating .chart-card,
.an-panel.is-updating .an-sens-table { opacity: 0.6; transition: opacity 0.2s; }

.an-tabs { border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.an-tabs .tab { padding-left: 10px; padding-right: 10px; }

.an-intro { margin: 0; max-width: 820px; color: var(--text-2); font-size: 14px; line-height: 1.55; }
.an-intro-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; min-width: 0; }
.an-intro-row > .an-intro { flex: 1 1 420px; min-width: 0; }

.an-note { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.an-note[hidden] { display: none; }

.an-busy { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.an-busy[hidden] { display: none; }

.an-error-slot:empty,
.an-verdict-slot:empty,
.an-insight-slot:empty,
.an-empty-slot:empty { display: none; }

.an-readonly-note { margin: 0; }

/* Plain-language explanation block */
.an-explain {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
  min-width: 0;
}
.an-explain-icon { display: flex; flex: none; margin-top: 1px; color: var(--muted); }
.an-explain-body { min-width: 0; overflow-wrap: anywhere; }
.an-explain-body strong { color: var(--text); font-weight: 650; }

/* Glossary (<details>) */
.an-glossary {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 0;
}
.an-glossary > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}
.an-glossary > summary::-webkit-details-marker { display: none; }
.an-glossary > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s;
}
.an-glossary[open] > summary::after { transform: rotate(-135deg) translateX(-2px); }
.an-glossary > summary:hover { color: var(--text); background: var(--surface-2); }
.an-glossary > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.an-glossary dl { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 10px 20px; margin: 0; padding: 4px 14px 14px; font-size: 13px; line-height: 1.5; }
.an-glossary dt { font-weight: 650; color: var(--text); }
.an-glossary dd { margin: 0; color: var(--text-2); }
@media (max-width: 640px) {
  .an-glossary dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .an-glossary dd { margin-bottom: 8px; }
}

/* Status pill (icon + text; colour never alone) */
.an-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.an-status .icon { flex: none; }
.an-status--good { background: var(--good-soft); color: var(--good-text); }
.an-status--good .icon { color: var(--good); }
.an-status--warning { background: var(--warning-soft); color: var(--warning-text); }
.an-status--warning .icon { color: var(--warning-text); }
.an-status--bad { background: var(--critical-soft); color: var(--critical-text); }
.an-status--bad .icon { color: var(--critical); }
.an-status--neutral { background: var(--surface-2); color: var(--text-2); }

/* Table cells with a secondary line (month, delta vs base) */
.an-cell-main { display: block; }
.an-cell-sub { display: block; margin-top: 1px; font-size: 12px; font-weight: 400; color: var(--text-2); }
.data-table .is-negative .an-cell-sub { color: var(--text-2); }
.data-table th.an-wrap-cell { white-space: normal; min-width: 180px; max-width: 320px; }
.data-table tr.an-row-base > * { background: var(--surface-2); }
.data-table tr.an-row-base th { font-weight: 650; }
.an-view .data-table tbody th { font-weight: 550; color: var(--text); }

.an-kpis .an-kpi-text .kpi-value { font-size: 16px; line-height: 1.3; }

.an-chart-grid { align-items: start; }
.an-toolbar-card .card-body { display: flex; flex-direction: column; gap: 12px; }

/* ---------------------------------------------------------------- 1. Čo ak… */

.an-whatif { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 16px; align-items: start; min-width: 0; }
.an-whatif-side, .an-whatif-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 1025px) and (min-height: 820px) {
  .an-whatif-side { position: sticky; top: calc(var(--header-h) + 12px); }
}
@media (max-width: 1024px) {
  .an-whatif { grid-template-columns: minmax(0, 1fr); }
}

.an-presets { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.an-presets-label { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-2); }
.an-presets .chip { white-space: nowrap; }

.an-sliders { display: flex; flex-direction: column; gap: 18px; }
.an-slider .slider-hint { line-height: 1.4; }
.an-whatif-controls .an-note { margin-top: 16px; padding: 10px 12px; border-radius: var(--radius); background: var(--accent-soft); color: var(--text); }

.an-verdict { margin-bottom: 14px; }
.an-compare-table th:first-child { min-width: 170px; }
.an-delta { font-weight: 600; }
.an-delta-inner { display: inline-flex; align-items: center; gap: 3px; justify-content: flex-end; }
.an-delta.muted { font-weight: 400; }

.an-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.an-actions-hint { margin-top: 8px; }
.an-compare-card .an-glossary { margin-top: 16px; }

/* ---------------------------------------------------------------- 2. Citlivosť */

.an-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; min-width: 0; }
.an-toolbar-field { flex: 0 1 300px; min-width: 0; }
.an-toolbar-field .segmented { max-width: 100%; }
.an-toolbar .an-busy { padding-bottom: 9px; }
.an-base-line { font-size: 14px; }
.an-base-line strong { font-weight: 650; }
.an-insight { margin: 0; }
.an-sens-table td.nowrap { color: var(--text-2); }

/* ---------------------------------------------------------------- 3. Bod zlomu */

.an-group { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.an-group + .an-group { margin-top: 8px; }
.an-group-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 6px 16px; }
.an-group-titles { flex: 1 1 380px; min-width: 0; }
.an-group-title { margin: 0; font-size: 16px; font-weight: 650; }
.an-group-subtitle { margin: 2px 0 0; font-size: 13px; color: var(--text-2); max-width: 720px; }
.an-group-base { margin: 0; font-size: 13.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.an-be-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 12px; min-width: 0; }
.an-be-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: opacity 0.2s;
}
.an-be-card.is-updating { opacity: 0.55; }
.an-be-head { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.an-be-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--surface-2); color: var(--text-2); }
.an-be-title { margin: 0; flex: 1 1 auto; min-width: 0; font-size: 14px; font-weight: 650; }
.an-be-status { display: inline-flex; margin-left: auto; }
.an-be-figure { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.an-be-value { font-size: 24px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.15; color: var(--text); }
.an-be-caption { font-size: 12.5px; color: var(--text-2); }
.an-be-statement { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--text); min-height: 2.9em; overflow-wrap: anywhere; }
.an-be-note { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--text-2); }
.an-be-note:empty { display: none; }

/* Meter: fill carries the status, track is the soft step of the same status. */
.an-meter { padding: 2px 0; }
.an-meter-track { position: relative; display: block; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.an-meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 999px; background: var(--muted); transition: width 0.35s ease-out; }
.an-meter-tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--surface); opacity: 0.9; }
.an-meter-tick[hidden] { display: none; }
.an-meter--good .an-meter-track { background: var(--good-soft); }
.an-meter--good .an-meter-fill { background: var(--good); }
.an-meter--warning .an-meter-track { background: var(--warning-soft); }
.an-meter--warning .an-meter-fill { background: var(--warning); }
.an-meter--bad .an-meter-track { background: var(--critical-soft); }
.an-meter--bad .an-meter-fill { background: var(--critical); }
.an-meter-scale { display: flex; justify-content: space-between; gap: 8px; margin-top: -4px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.an-skel-pill { display: inline-block; width: 84px; height: 20px; border-radius: 999px; }
.an-skel-value { display: inline-block; width: 96px; height: 26px; }
.an-skel-line { display: block; width: 100%; margin-bottom: 6px; }
.an-skel-line--short { display: block; width: 60%; height: 12px; border-radius: 6px; }

/* ---------------------------------------------------------------- 4. Stresové testy */

.an-test-cell { min-width: 220px; }
.an-test-label { display: block; font-weight: 650; }
.an-test-desc { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; line-height: 1.4; color: var(--text-2); }
.an-status-cell { text-align: left; }
.data-table td.an-status-cell { text-align: left; }
.an-status-cell .an-cell-sub { margin-top: 3px; }

/* ---------------------------------------------------------------- 5. Monte Carlo */

.an-mc-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 16px 20px; align-items: start; }
.an-mc-form .segmented { max-width: 100%; }
.an-seed { display: flex; gap: 8px; min-width: 0; }
.an-seed .input-affix { flex: 1 1 auto; }
.an-mc-run { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 18px; }
.an-progress { display: flex; flex-direction: column; gap: 6px; flex: 1 1 260px; min-width: 0; }
.an-progress[hidden] { display: none; }
.an-progress-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.an-progress-text { flex: 1 1 auto; min-width: 0; }
.an-progress-bar { position: relative; height: 3px; overflow: hidden; border-radius: 3px; background: var(--grid); max-width: 360px; }
.an-progress-bar span { position: absolute; top: 0; bottom: 0; left: 0; width: 35%; border-radius: 3px; background: var(--accent); animation: an-progress 1.1s ease-in-out infinite; }
@keyframes an-progress { 0% { transform: translateX(-110%); } 100% { transform: translateX(300%); } }

.an-mc-results { display: flex; flex-direction: column; gap: 16px; min-width: 0; transition: opacity 0.2s; }
.an-mc-results[hidden] { display: none; }
.an-mc-results.an-stale { opacity: 0.55; }
.an-mc-params { margin-bottom: -4px; }
.an-stale-alert[hidden] { display: none; }
.an-pct-table th:first-child { min-width: 170px; }

@media (prefers-reduced-motion: reduce) {
  .an-progress-bar span { animation: none; width: 100%; opacity: 0.5; }
  .an-meter-fill { transition: none; }
}

/* ---------------------------------------------------------------- phones */

@media (max-width: 640px) {
  .an-view, .an-body, .an-panel { gap: 12px; }
  .an-be-value { font-size: 21px; }
  .an-be-statement { min-height: 0; }
  .an-group-base { white-space: normal; }
  .an-toolbar-field { flex: 1 1 100%; }
  .an-actions .btn { flex: 1 1 auto; }
  .data-table th.an-wrap-cell { min-width: 150px; max-width: 220px; }
  .an-test-cell { min-width: 170px; }
}

@media print {
  .an-tabs, .an-actions, .an-mc-run, .an-presets, .an-glossary { display: none !important; }
  .an-panel[hidden] { display: none !important; }
}
