/* ==========================================================================
   Prehľad (dashboard view) — www/assets/js/views/dashboard.js
   All classes are prefixed .db-; colours only through app.css tokens.
   ========================================================================== */

.db {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.db-content,
.db-start {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.db-start { gap: 16px; }

/* ---------- Hero: headline figure + verdict ---------- */

.db-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px 24px;
  padding: 24px 28px 26px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: inset 4px 0 0 var(--axis), var(--shadow-sm);
}

/* Status edge (inset shadow follows the rounded corners and never clips the hint tooltip).
   The verdict is a state, so status colours are allowed here — always with badge + icon. */
.db-hero--good { box-shadow: inset 4px 0 0 var(--good), var(--shadow-sm); }
.db-hero--warning { box-shadow: inset 4px 0 0 var(--warning), var(--shadow-sm); }
.db-hero--bad { box-shadow: inset 4px 0 0 var(--critical), var(--shadow-sm); }

.db-hero-main { min-width: 0; }

.db-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-2);
}

.db-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.db-meta-item .icon { color: var(--muted); }
.db-meta-link { color: var(--link); }
.db-meta-link .icon { color: currentColor; }

.db-hero-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}

.db-hero-figure {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 4px;
}

/* Hero figure: same sans, proportional figures (never tabular at display size). */
.db-hero-value {
  font-size: 48px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-variant-numeric: proportional-nums;
  color: var(--text);
  overflow-wrap: anywhere;
}
.db-hero-value.is-negative { color: var(--critical-text); }

.db-hero-badge .badge { height: 26px; padding: 0 10px; font-size: 12.5px; }

.db-hero-verdict {
  max-width: 72ch;
  margin: 14px 0 0;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
}

.db-hero-note {
  max-width: 84ch;
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
}

.db-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Warnings + checklist ---------- */

.db-warnings:empty { display: none; }
.db-warnings { margin-top: -12px; }

.db-checklist-host { min-width: 0; }

.db-steps {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.db-step {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--grid);
}
.db-step:first-child { padding-top: 0; }
.db-step:last-child { padding-bottom: 0; border-bottom: 0; }

.db-step-status {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: start;
  margin-top: 1px;
}
.db-step.is-done .db-step-status { color: var(--good); }

.db-step-dot {
  display: block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--axis);
  border-radius: 50%;
}

.db-step-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  font-weight: 600;
}
.db-step.is-done .db-step-title { color: var(--text-2); }

.db-step-optional {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.db-step-text {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-2);
}

/* ---------- KPI groups ---------- */

.db-kpis { min-width: 0; }
.db-kpis > .section-header { margin-bottom: 16px; }

.db-kpi-groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.db-kpi-group { min-width: 0; }

.db-kpi-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-2);
}
.db-kpi-group-title .icon { color: var(--muted); }

/* Let long Slovak labels wrap instead of being cut off on narrow tiles. */
.db-kpis .kpi-label { align-items: flex-start; }
.db-kpis .kpi-label-text {
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  line-height: 1.35;
}
.db-kpis .kpi-hint { margin-top: 1px; }
.db-kpis .kpi-value { font-variant-numeric: proportional-nums; }

/* ---------- Charts: filter row, sections, grid ---------- */

.db-charts {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.db-toolbar {
  position: sticky;
  top: calc(var(--header-h) + 12px);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-width: 0;
  padding: 8px 10px 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.db-period {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-width: 0;
}

.db-toolbar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

.db-period-control { display: flex; min-width: 0; max-width: 100%; }

.db-jump {
  display: flex;
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.db-jump::-webkit-scrollbar { display: none; }

.db-jump-link {
  flex: none;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.db-jump-link:hover { background: var(--surface-3); color: var(--text); }

.db-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  scroll-margin-top: calc(var(--header-h) + 84px);
}
.db-section > .section-header { margin-bottom: 0; }
.db-section .section-title:focus { outline: none; }
.db-section .section-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }

.db-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}
.db-grid > .db-wide { grid-column: 1 / -1; }

.db-section-empty { min-width: 0; }

/* Note shown over the plot when a chart has nothing to show yet. */
.db-chart-empty {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.db-chart-empty-icon { display: flex; color: var(--muted); }
.db-chart-empty-text {
  max-width: 36ch;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-2);
}

/* Plain-language explanation under a chart (DSCR, EBITDA, odpisy). */
.db-chart-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--grid);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
}
.db-chart-note .icon { margin-top: 2px; color: var(--muted); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .db-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .db-hero {
    grid-template-columns: minmax(0, 1fr);
    padding: 18px 16px 20px 20px;
  }
  .db-actions { justify-content: flex-start; }
  .db-hero-value { font-size: 36px; }
  .db-hero-verdict { font-size: 16px; }

  /* A sticky two-row bar would eat a phone screen: keep it in the flow. */
  .db-toolbar { position: static; box-shadow: var(--shadow-sm); }
  .db-jump { flex-basis: 100%; justify-content: flex-start; margin: 0 -4px; }
  .db-section { scroll-margin-top: calc(var(--header-h) + 12px); }
}

@media (max-width: 480px) {
  .db-hero-value { font-size: 32px; }
  .db-period { width: 100%; }
  .db-period .segmented-item { padding: 0 7px; font-size: 12px; }
  .db-step { grid-template-columns: 22px minmax(0, 1fr); }
  .db-step-action { grid-column: 2; justify-self: start; }
}

/* ---------- Print: two charts per row, no breaks inside cards ---------- */

@media print {
  .db { gap: 12px; }
  .db-content, .db-charts { gap: 14px; }
  .db-toolbar, .db-actions, .db-step-action, .db-chart-empty .btn { display: none !important; }

  /* --shadow-sm is 'none' in print, and shadows are often not printed: use a border edge. */
  .db-hero { padding: 12px 14px 12px 16px; border-color: var(--border-strong); border-left: 4px solid var(--axis); box-shadow: none; }
  .db-hero--good { border-left-color: var(--good); box-shadow: none; }
  .db-hero--warning { border-left-color: var(--warning); box-shadow: none; }
  .db-hero--bad { border-left-color: var(--critical); box-shadow: none; }
  .db-hero-value { font-size: 30px; }
  .db-hero-verdict { font-size: 14px; margin-top: 8px; }
  .db-hero-note { font-size: 12px; }
  .db-hero, .db-warnings, .db-checklist, .db-kpi-group { break-inside: avoid; page-break-inside: avoid; }

  .db-kpis .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .db-kpis .kpi { padding: 8px 10px; }
  .db-kpis .kpi-value { font-size: 16px; }

  .db-section { gap: 8px; }
  .db-section > .section-header { break-after: avoid; page-break-after: avoid; }
  .db-section .section-title { font-size: 16px; }
  .db-section .section-subtitle { font-size: 12px; }

  .db-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .db-grid > .db-wide { grid-column: auto; }
  .db-card { padding: 10px; gap: 6px; break-inside: avoid; page-break-inside: avoid; }
  .db-card .chart-card__title { font-size: 13px; }
  .db-card .chart-card__subtitle { font-size: 11px; }
  .db-card .chart-card__plot { height: auto !important; }
  .db-chart-note { font-size: 10.5px; padding-top: 6px; }
  .db-chart-empty { position: static; min-height: 120px; }
}
