/* Public "Statistik & data" funnel — shared styling.
   Mirrors the Läsvärt (worthyofread) aesthetic and the brand design tokens. */

.stat-shell {
  background: linear-gradient(180deg, #f7f9fc 0%, #eef3f9 42%, #ffffff 100%);
  min-height: calc(100vh - 80px);
  padding: 7rem 0 3rem;
}

.stat-header {
  border: 1px solid #e3e9f1;
  border-radius: 1rem;
  background: #ffffff;
  box-shadow: 0 16px 36px rgba(16, 24, 40, 0.06);
  padding: 1.6rem;
  margin-bottom: 1.4rem;
}

.stat-kicker {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: #667085;
  font-weight: 700;
}

.stat-breadcrumbs {
  font-size: 0.85rem;
  margin-bottom: 0.9rem;
}
.stat-breadcrumbs a { color: #365f9d; text-decoration: none; }
.stat-breadcrumbs a:hover { text-decoration: underline; }
.stat-breadcrumbs .sep { color: #b6c0cf; margin: 0 0.4rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
@media (max-width: 992px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 576px) { .stat-grid { grid-template-columns: 1fr; } }
@media (max-width: 991px) { .stat-shell { padding-top: 6.4rem; } }

.stat-card {
  border: 1px solid #e4eaf2;
  border-radius: 0.9rem;
  padding: 1.15rem;
  background: #fff;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(16, 24, 40, 0.08);
  border-color: #cfd9e7;
}
.stat-card .stat-card-title { font-size: 1.05rem; font-weight: 700; color: #0b1627; margin-bottom: 0.35rem; }
.stat-card .stat-card-desc { color: #5a6472; font-size: 0.9rem; flex-grow: 1; }
.stat-card .stat-card-cta { margin-top: 0.9rem; color: #365f9d; font-weight: 600; font-size: 0.88rem; }

.stat-section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #667085;
  font-weight: 700;
  margin: 1.6rem 0 0.8rem;
}

.stat-badge {
  display: inline-block;
  border: 1px solid #afc8f0;
  color: #365f9d;
  background: #f4f8ff;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  border-radius: 999px;
}

.stat-panel {
  border: 1px solid #e3e9f1;
  border-radius: 1rem;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(16, 24, 40, 0.05);
  padding: 1.2rem;
  margin-bottom: 1.2rem;
}

.stat-empty {
  border: 1px dashed #ccd6e3;
  border-radius: 0.9rem;
  padding: 2rem;
  background: #f8fafc;
  color: #667085;
  text-align: center;
}

.stat-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  border-radius: 1rem;
  background: linear-gradient(120deg, #0d2a52 0%, #1f5fae 100%);
  color: #fff;
  padding: 1.5rem 1.6rem;
  margin-top: 1.4rem;
}
.stat-cta p { color: rgba(255, 255, 255, 0.82); }
.stat-cta-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.2rem; }
.stat-cta .btn { border-radius: 0.75rem; font-weight: 600; color: #0d2a52; }


/* ── Badges in the dataset header ─────────────────────────────────────── */
.stat-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.stat-badge--plain {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-color: #e3e9f1;
  background: #f8fafc;
  color: #4a5868;
}

/* ── Cards: count, freshness, value + sparkline ──────────────────────── */
.stat-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}
.stat-count,
.stat-fresh {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.stat-count { background: #f1f5fa; color: #4a5868; }
.stat-fresh { background: #e6f6ee; color: #17784c; }
.stat-card-figure {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.35rem 0 0.25rem;
}
.stat-card-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0b1627;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat-card-period { font-size: 0.75rem; color: #7a8799; }
.stat-spark {
  flex: 0 0 auto;
  width: 96px;
  height: 30px;
  overflow: visible;
}
.stat-spark path {
  fill: none;
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.stat-spark--up path { stroke: #17784c; }
.stat-spark--down path { stroke: #c2412f; }
.stat-spark--flat path { stroke: #5b8def; }
.stat-change {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
}
.stat-change span { font-weight: 400; color: #7a8799; }
.stat-change--up { color: #17784c; }
.stat-change--down { color: #c2412f; }
.stat-change--flat { color: #4a5868; }
.stat-card .stat-card-desc { margin-top: 0.15rem; }

.stat-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-grid--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1199px) { .stat-grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 576px) { .stat-grid--two, .stat-grid--four { grid-template-columns: 1fr; } }

/* ── Search ───────────────────────────────────────────────────────────── */
.stat-search { position: relative; max-width: 560px; }
.stat-header-search { flex: 0 1 360px; min-width: 240px; }
.stat-header-text { flex: 1 1 320px; }
.stat-search-icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: #7a8799;
  pointer-events: none;
}
.stat-search-input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.6rem;
  border: 1px solid #d4dbe6;
  border-radius: 0.8rem;
  background: #f8fafc;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.stat-search-input:focus {
  outline: none;
  background: #fff;
  border-color: #5b8def;
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.18);
}
.stat-search-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  max-height: 360px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e3e9f1;
  border-radius: 0.8rem;
  box-shadow: 0 18px 38px rgba(16, 24, 40, 0.12);
}
.stat-search-results a {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 0.55rem;
  text-decoration: none;
  color: inherit;
}
.stat-search-results a:hover,
.stat-search-results [aria-selected="true"] a { background: #eef4fd; }
.stat-search-name { display: block; font-weight: 600; color: #0b1627; font-size: 0.92rem; }
.stat-search-path { display: block; font-size: 0.76rem; color: #7a8799; }
.stat-search-empty,
.stat-search-more { padding: 0.6rem 0.7rem; font-size: 0.85rem; color: #7a8799; }
.stat-search-hint { margin: 0.5rem 0 0; font-size: 0.8rem; color: #7a8799; }

/* ── Dataset page: chart panel ────────────────────────────────────────── */
.stat-chart-panel { padding: 1.3rem; }

/* Toolbar pills — the public twin of .feed-tab in core_data/css/panel-head.css,
   which only loads inside the app (samfonyfetchbase.html), not on frontbase. */
.stat-toolbar { margin-bottom: 0.75rem; }
.stat-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid #eef2f7;
}
.stat-presets,
.stat-range,
.stat-pickers,
.stat-share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.stat-range label { font-size: 0.78rem; color: #667085; margin: 0 0.1rem 0 0.25rem; }
.stat-date {
  height: 32px;
  padding: 0 0.5rem;
  border: 1px solid #d4dbe6;
  border-radius: 0.55rem;
  font-size: 0.82rem;
  color: #0b1627;
  background: #fff;
}
.stat-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 32px;
  padding: 0 0.75rem;
  border: 1px solid #d9e1ec;
  border-radius: 999px;
  background: #fff;
  color: #2f3d4f;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.stat-tab:hover { background: #f3f7fc; border-color: #c4d2e5; }
.stat-tab:focus-visible { outline: 2px solid #5b8def; outline-offset: 2px; }
.stat-tab.active {
  background: #0d2a52;
  border-color: #0d2a52;
  color: #fff;
}
.stat-tab.is-done { background: #e6f6ee; border-color: #b9e3cc; color: #17784c; }
.stat-tab[hidden],
.dropdown[hidden] { display: none; }

.stat-dropdown { min-width: 260px; max-width: 340px; padding: 0.35rem; border-radius: 0.8rem; }
.stat-dropdown-scroll { max-height: 300px; overflow-y: auto; }
.stat-dropdown .dropdown-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.6rem 0.6rem 0.25rem;
  margin: 0;
}
.stat-dd-actions {
  display: flex;
  gap: 0.75rem;
  padding: 0.25rem 0.6rem 0.45rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid #eef2f7;
}
.stat-dd-link { border: 0; background: none; padding: 0; color: #1f5fae; font-size: 0.8rem; font-weight: 600; }
.stat-dd-link:hover { text-decoration: underline; }
.stat-dd-empty { padding: 0.5rem 0.6rem; font-size: 0.85rem; color: #7a8799; }
.stat-series-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  font-size: 0.86rem;
  cursor: pointer;
}
.stat-series-opt:hover { background: #f3f7fc; }
.stat-series-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; }
.stat-series-name { line-height: 1.3; }

.stat-controls { padding: 0.75rem 0 0.25rem; margin-top: 0; }
.stat-controls[hidden] { display: none; }
.stat-controls .form-select,
.stat-controls .form-control { border-color: #d4dbe6; }
.stat-note {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: 0.6rem;
  background: #fff8e6;
  color: #7a5f0e;
  font-size: 0.82rem;
}

/* Chart stage: overlays for loading / empty / error sit on top of the canvas. */
.stat-chart-stage {
  position: relative;
  height: clamp(280px, 48vh, 440px);
}
.stat-stage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 0.75rem;
}
.stat-stage-overlay[hidden] { display: none; }
.stat-stage-overlay.is-veil { background: rgba(255, 255, 255, 0.55); }
.stat-stage-overlay.is-message { background: #fafbfd; border: 1px dashed #d4dbe6; }
.stat-skeleton {
  width: 100%;
  height: 100%;
  border-radius: 0.75rem;
  background: linear-gradient(90deg, #f1f4f8 0%, #f8fafc 50%, #f1f4f8 100%);
  background-size: 200% 100%;
  animation: stat-shimmer 1.4s ease-in-out infinite;
}
@keyframes stat-shimmer { to { background-position: -200% 0; } }
.stat-empty-msg { text-align: center; padding: 1.5rem; color: #4a5868; }
.stat-empty-msg .bi { font-size: 1.5rem; color: #7a8799; }
.stat-empty-msg p { margin: 0.5rem 0 0.9rem; }
.stat-status { margin-top: 0.5rem; font-size: 0.8rem; color: #7a8799; }

/* ── Key figures ──────────────────────────────────────────────────────── */
.stat-kpis { margin-bottom: 0.9rem; }
.stat-kpis:empty { display: none; }
.stat-kpi-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
  color: #667085;
}
.stat-kpi-picker .form-select { width: auto; max-width: 320px; }
.stat-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}
.stat-kpi {
  min-width: 0;
  padding: 0.8rem 0.95rem;
  border: 1px solid #e8edf4;
  border-radius: 0.8rem;
  background: #fbfcfe;
}
.stat-kpi--lead { background: #f2f7ff; border-color: #d6e4f8; }
.stat-kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #667085;
}
.stat-kpi-value {
  margin-top: 0.2rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: #0b1627;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat-kpi-value--range { font-size: 1.05rem; padding-top: 0.25rem; }
.stat-kpi-value.stat-change--up { color: #17784c; }
.stat-kpi-value.stat-change--down { color: #c2412f; }
.stat-kpi-sub { margin-top: 0.1rem; font-size: 0.76rem; color: #7a8799; }
@media (max-width: 991px) { .stat-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── Table ────────────────────────────────────────────────────────────── */
.stat-table-wrap {
  margin-top: 0.9rem;
  max-height: 460px;
  overflow: auto;
  border: 1px solid #e8edf4;
  border-radius: 0.75rem;
}
.stat-table-wrap[hidden] { display: none; }
.stat-table { font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.stat-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f5f8fc;
  border-bottom: 1px solid #e3e9f1;
  white-space: nowrap;
}
.stat-table tbody th { font-weight: 600; white-space: nowrap; }
.stat-table tbody tr:nth-child(even) { background: #fbfcfe; }
.stat-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: #2f3d4f;
}
.stat-sort .bi { font-size: 0.75rem; color: #9aa5b1; }
.stat-table th[aria-sort="ascending"] .bi,
.stat-table th[aria-sort="descending"] .bi { color: #1f5fae; }

/* ── Om statistiken ───────────────────────────────────────────────────── */
.stat-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0 0 1rem;
  font-size: 0.88rem;
}
.stat-meta dt { color: #667085; font-weight: 600; }
.stat-meta dd { margin: 0; color: #0b1627; overflow-wrap: anywhere; }
.stat-meta a { color: #1f5fae; text-decoration: none; }
.stat-meta a:hover { text-decoration: underline; }

/* ── Phones ───────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .stat-chart-panel { padding: 1rem; }
  .stat-toolbar-row { justify-content: flex-start; }
  .stat-range { width: 100%; }
  .stat-date { flex: 1 1 120px; min-width: 0; }
  .stat-share { width: 100%; }
  .stat-kpi { padding: 0.65rem 0.75rem; }
  .stat-kpi-value { font-size: 1.1rem; }
  .stat-header-search { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .stat-skeleton { animation: none; }
  .stat-card, .stat-tab, .stat-search-input { transition: none; }
}
