* { box-sizing: border-box; margin: 0; padding: 0; }
[x-cloak] { display: none !important; }
html { overflow-y: scroll; scrollbar-gutter: stable; }
body { font-family: "Manrope", "Segoe UI", "Helvetica Neue", Arial, sans-serif; background: #f3f6fb; color: #1f2937; padding: 16px; }
.page-shell { width: 100%; }

.header {
  display: grid;
  grid-template-columns: 170px 1fr 170px;
  align-items: center;
  column-gap: 12px;
  min-height: 88px;
  margin-bottom: 8px;
}
.header-logo {
  height: 108px;
  width: 150px;
  object-fit: contain;
  display: block;
  justify-self: start;
}
h1 {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 88px;
  line-height: 1;
  margin: 0;
}
h1 .title-text {
  display: inline-flex;
  align-items: center;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: clamp(1.4rem, 2.1vw, 1.9rem);
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #0b2545;
  white-space: nowrap;
}
.top-actions {
  display: flex;
  justify-content: flex-end;
  justify-self: end;
  margin: 0;
}
#sign-out-btn {
  border: 1px solid #bbb;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  padding: 6px 12px;
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
#sign-out-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}
#sign-out-btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

@keyframes section-spin { to { transform: rotate(360deg); } }
.section-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
}
.section-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e2e8f0;
  border-top-color: #0b2545;
  border-radius: 50%;
  animation: section-spin 0.7s linear infinite;
}
.section-error {
  padding: 16px;
  color: #b91c1c;
  font-size: 0.88em;
  font-weight: 600;
}
.section-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.section-hdr h4 { margin-bottom: 0; flex: 1; min-width: 0; font-size: 0.88rem; }
.section-hdr-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding-top: 1px;
}
.section-age {
  font-size: 0.72em;
  color: #94a3b8;
  font-weight: 500;
  white-space: nowrap;
}
.section-revalidating-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7em;
  color: #94a3b8;
  font-weight: 500;
  margin-left: 6px;
  vertical-align: middle;
}
.section-revalidating-badge::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  border: 2px solid #e2e8f0;
  border-top-color: #94a3b8;
  border-radius: 50%;
  animation: section-spin 0.8s linear infinite;
}
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid #d3d3d3;
  padding-bottom: 6px;
}
.tab-btn {
  border: 1px solid #bbb;
  background: #fff;
  color: #334155;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tab-btn:hover:not(.active) {
  background: #f1f5f9;
  border-color: #94a3b8;
}
.tab-btn.active {
  background: #0b2545;
  color: #fff;
  border-color: #0b2545;
}
.tab-btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}
.tab-bar--sub {
  margin-top: -6px;
  margin-bottom: 12px;
  border-bottom: none;
  padding-bottom: 0;
}
.tab-btn--sub {
  font-size: 0.8em;
  padding: 5px 12px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: #64748b;
}
.tab-btn--sub:hover:not(.active) { color: #0b2545; background: #f1f5f9; }
.tab-btn--sub.active { color: #0b2545; font-weight: 700; background: #e2e8f0; border: none; }

.grid-container {
  display: grid;
  gap: 14px;
  align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  margin-bottom: 16px;
}
.grid-container.wide {
  grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
}
#layer-grids {
  grid-template-columns: minmax(860px, 1.15fr) minmax(620px, 0.85fr);
}
@media (max-width: 1600px) {
  #layer-grids {
    grid-template-columns: minmax(760px, 1.1fr) minmax(560px, 0.9fr);
  }
}
@media (max-width: 1300px) {
  #layer-grids {
    grid-template-columns: 1fr;
  }
}
.layer-right-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.grid-item {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  border: 1px solid #e5e7eb;
}
.grid-item h4 {
  margin-bottom: 12px;
  font-size: 0.97em;
  font-weight: 700;
  color: #0b2545;
  letter-spacing: 0.2px;
  padding-left: 10px;
  border-left: 3px solid #0b2545;
  line-height: 1.6;
}
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.summary-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
}
.summary-card .k {
  display: block;
  font-size: 0.72em;
  color: #64748b;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.summary-card .v {
  font-size: 0.95em;
  font-weight: 700;
  color: #0f172a;
}
.layer-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.layer-controls input,
.layer-controls select {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.85em;
  background: #fff;
  transition: border-color 0.15s;
}
.layer-controls input { flex: 1; min-width: 180px; }
.layer-controls input:focus,
.layer-controls select:focus {
  outline: none;
  border-color: #0b2545;
  box-shadow: 0 0 0 2px rgba(11, 37, 69, 0.12);
}
.layer-section {
  margin-top: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px 10px;
  background: transparent;
}
.layer-section summary {
  cursor: pointer;
  font-size: 0.88em;
  font-weight: 700;
  color: #0b2545;
  padding: 2px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.layer-section summary::-webkit-details-marker { display: none; }
.layer-section summary::before {
  content: '\25B6';
  font-size: 0.65em;
  color: #64748b;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.layer-section[open] > summary::before { transform: rotate(90deg); }
.layer-subtitle {
  margin: 12px 0 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
}
.layer-subtitle::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}
.state-details details {
  margin-top: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px 8px;
  background: transparent;
}
.state-details summary {
  cursor: pointer;
  font-size: 0.82em;
  font-weight: 700;
  color: #334155;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
  user-select: none;
}
.state-details summary::-webkit-details-marker { display: none; }
.state-details summary::before {
  content: '\25B6';
  font-size: 0.6em;
  color: #94a3b8;
  transition: transform 0.15s;
}
.state-details details[open] > summary::before { transform: rotate(90deg); }
.age-delta {
  font-size: 0.9em;
  font-weight: 700;
  margin-left: 3px;
}
.age-delta-positive { color: #b91c1c; }
.age-delta-negative { color: #166534; }
.age-delta-neutral  { color: #475569; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
}
table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.83em;
  table-layout: auto;
}
thead tr { background: #0b2545; color: #f8fafc; font-weight: 600; }
thead th { padding: 9px 12px; text-align: left; font-size: 0.88em; letter-spacing: 0.2px; }
thead th.sortable-th { cursor: pointer; user-select: none; }
thead th.sortable-th:hover { background: #1e3a5f; }
.sort-indicator { margin-left: 5px; font-size: 0.78em; opacity: 0.55; }
tbody tr:nth-child(odd) { background: #f8fafc; }
tbody tr:nth-child(even) { background: #ffffff; }
tbody tr { transition: background 0.1s; }
tbody tr:hover td { background: #eff6ff; }
tbody td {
  padding: 9px 12px;
  border-top: 1px solid #e2e8f0;
  color: #334155;
}
thead th, tbody td {
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.status-ok, .status-pass {
  background: #166534 !important;
  color: #fff;
  font-weight: 600;
}
.status-fail {
  background: #b91c1c !important;
  color: #fff;
  font-weight: 600;
}
.status-warn {
  background: #b45309 !important;
  color: #fff;
  font-weight: 600;
}
.status-na {
  background: #64748b !important;
  color: #fff;
  font-weight: 600;
}
td.status-ok,
td.status-pass,
td.status-fail,
td.status-warn,
td.status-na {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  text-align: center;
  vertical-align: middle;
}
th.col-status {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  text-align: center;
}

.pass-label {
  display: inline-block;
  background: #166534;
  color: #fff;
  font-weight: 700;
  font-size: 0.78em;
  letter-spacing: 0.4px;
  padding: 1px 7px;
  border-radius: 99px;
  vertical-align: middle;
}
.fail-label {
  display: inline-block;
  background: #b91c1c;
  color: #fff;
  font-weight: 700;
  font-size: 0.78em;
  letter-spacing: 0.4px;
  padding: 1px 7px;
  border-radius: 99px;
  vertical-align: middle;
}
.warn-label {
  display: inline-block;
  background: #b45309;
  color: #fff;
  font-weight: 700;
  font-size: 0.78em;
  letter-spacing: 0.4px;
  padding: 1px 7px;
  border-radius: 99px;
  vertical-align: middle;
}
.neutral-label {
  display: inline-block;
  background: #64748b;
  color: #fff;
  font-weight: 700;
  font-size: 0.78em;
  letter-spacing: 0.4px;
  padding: 1px 7px;
  border-radius: 99px;
  vertical-align: middle;
}

.health-groups {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: start;
}
.health-group {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  position: relative;
}
.health-group-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 10px 10px 0 0;
}
.health-group-hdr--clickable { cursor: pointer; user-select: none; }
.health-group-hdr--clickable:hover { background: #f8fafc; }
.health-group-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #0b2545;
}
.health-row {
  display: grid;
  grid-template-columns: 8px 1fr 52px 52px;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 0;
  padding: 9px 16px;
  border-bottom: 1px solid #f8fafc;
}
.health-row:last-child { border-bottom: none; }
.health-row-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cbd5e1;
  justify-self: center;
}
.health-row--pass .health-row-dot { background: #16a34a; }
.health-row--fail .health-row-dot { background: #dc2626; }
.health-row--warn .health-row-dot { background: #d97706; }
.health-row-name {
  font-size: 0.85em;
  font-weight: 600;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 5px;
}
.health-row-latency {
  font-size: 0.73em;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-align: right;
}
.health-row-status {
  justify-self: end;
}
.health-row-error {
  grid-column: 2 / -1;
  grid-row: 2;
  font-size: 0.72em;
  color: #b91c1c;
  font-weight: 500;
  padding-top: 3px;
}

.sfn-groups {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  align-items: start;
}
.sfn-group-hdr-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sfn-chevron {
  font-size: 10px;
  color: #94a3b8;
}
.sfn-failure {
  border-bottom: 1px solid #f1f5f9;
}
.sfn-failure:last-child { border-bottom: none; }
.sfn-failure-hdr {
  display: grid;
  grid-template-columns: auto minmax(120px, 260px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  user-select: none;
}
.sfn-failure-hdr:hover { background: #f8fafc; }
.sfn-failure-time {
  font-size: 0.75em;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sfn-failure-state {
  font-size: 0.76em;
  font-weight: 600;
  color: #0b2545;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sfn-failure-cause {
  font-size: 0.75em;
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sfn-failure-detail {
  padding: 10px 16px 12px;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
}
.sfn-failure-kv {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 4px;
  font-size: 0.78em;
}
.sfn-failure-kv-label {
  font-weight: 600;
  color: #64748b;
  min-width: 70px;
}
.sfn-failure-kv-val {
  font-family: "JetBrains Mono", "Fira Code", "Menlo", monospace;
  color: #1f2937;
  word-break: break-all;
}
.sfn-failure-block {
  margin-top: 8px;
}
.sfn-failure-block-label {
  font-size: 0.72em;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.sfn-failure-json {
  font-family: "JetBrains Mono", "Fira Code", "Menlo", monospace;
  font-size: 0.72em;
  color: #1e293b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0;
  overflow-x: auto;
  white-space: pre;
  max-height: 200px;
  overflow-y: auto;
}
.sfn-no-failures {
  padding: 12px 16px;
  font-size: 0.82em;
  color: #64748b;
}

#error-banner {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  color: #b91c1c;
  font-weight: 600;
  font-size: 0.9em;
}
/* Stats page layout */
.stats-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stats-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Page header */
.stats-page-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-height: 28px;
}
.stats-page-error {
  flex: 1;
  margin: 0;
  color: #b91c1c;
  font-size: 0.84em;
  font-weight: 600;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 6px 12px;
}
.stats-page-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.stats-refresh-btn {
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  color: #475569;
  padding: 3px 10px;
  font-size: 0.76em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.stats-refresh-btn:hover { background: #f1f5f9; border-color: #94a3b8; }
.stats-refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.stats-export-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.25);
  z-index: 50; display: flex; align-items: center; justify-content: center;
}
.stats-export-overlay-panel {
  background: #fff; border-radius: 10px; padding: 24px 28px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  width: clamp(360px, 40vw, 760px); max-width: 92vw;
  max-height: 88vh; overflow-y: auto;
}
.stats-export-overlay-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.stats-export-overlay-header h3 {
  font-size: 1rem; font-weight: 700; color: #0b2545; margin: 0;
}
.stats-export-overlay-close {
  background: none; border: none; font-size: 1.4rem; color: #94a3b8;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.stats-export-overlay-close:hover { color: #475569; }
.stats-export-form {
  display: flex; flex-direction: column; gap: 12px;
}
.stats-export-label {
  font-size: 0.78rem; font-weight: 600; color: #475569;
  display: flex; flex-direction: column; gap: 4px;
}
.stats-export-label select { width: 100%; }
.stats-export-row { display: flex; gap: 10px; margin-bottom: 8px; }
.stats-export-row label { font-size: 0.78em; font-weight: 600; color: #475569; }
.stats-export-warn { font-size: 0.74em; color: #d97706; margin: 6px 0; }
.stats-export-checks {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  justify-content: center;
  gap: 4px 28px;
  padding: 2px 0;
}
.stats-export-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78em;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
}
.stats-export-check input[type="checkbox"] {
  margin: 0;
  accent-color: #0b2545;
}

.stats-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  font-size: 0.6rem;
  font-weight: 700;
  cursor: help;
  margin-left: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}
.stats-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: normal;
  padding: 6px 10px;
  border-radius: 5px;
  white-space: normal;
  width: max-content;
  max-width: 220px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 20;
}
.stats-tip:hover::after { opacity: 1; }

/* KPI strip */
.stats-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 900px) {
  .stats-kpi-strip { grid-template-columns: repeat(2, 1fr); }
}
.stats-kpi-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  position: relative;
}
.stats-kpi-card-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stats-kpi-card-value {
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: #0b2545;
  line-height: 1.1;
}
.stats-kpi-card-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.stats-kpi-card-breakdown {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  color: #94a3b8;
}
.stats-kpi-card-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Chart row */
.stats-chart-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}
.stats-chart-row--wide { grid-template-columns: 3fr 1fr; }
@media (max-width: 1000px) {
  .stats-chart-row, .stats-chart-row--wide { grid-template-columns: 1fr; }
}
.stats-chart-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  position: relative;
  min-height: 340px;
  display: flex;
  flex-direction: column;
}
.stats-chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.stats-chart-card-header--flush { margin-bottom: 0; }
.stats-chart-card-header h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0b2545;
  margin: 0;
}
.stats-controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stats-month-select {
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 0.78em;
  font-weight: 600;
  color: #334155;
  background: #fff;
  cursor: pointer;
}
.stats-month-select:focus {
  outline: none;
  border-color: #0b2545;
  box-shadow: 0 0 0 2px rgba(11, 37, 69, 0.12);
}
.stats-chart-host { width: 100%; height: 260px; }
.stats-chart-host--tall { height: 320px; flex: 3; }
.stats-chart-host--map { height: 320px; flex: 1.2; min-width: 220px; }
.stats-chart-flex { display: flex; gap: 0; }
.stats-ranking-card--scroll { max-height: 380px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }
.stats-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  z-index: 2;
  pointer-events: none;
}
.stats-age { font-size: 0.72em; color: #94a3b8; font-weight: 500; white-space: nowrap; }

.stats-section-title {
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: #0b2545;
  letter-spacing: 0.02em;
  margin: 4px 0 12px 0;
  padding-left: 2px;
}

.stats-ranking-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  position: relative;
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
  display: flex;
  flex-direction: column;
}
.stats-ranking-card:hover {
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  border-color: #cbd5e1;
}
.stats-ranking-card-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #0b2545;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.stats-ranking-card-title--inline {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.stats-detail-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 8px 0;
}
.stats-detail-card-title--sm { font-size: 0.68rem; }
.stats-kpi-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.stats-kpi-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  flex: 1;
  min-width: 90px;
}
.stats-kpi-chip-label {
  font-size: 0.74em;
  font-weight: 600;
  color: #64748b;
}
.stats-kpi-chip-value {
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #0b2545;
}
.stats-kpi-chip-pct {
  font-size: 0.7em;
  font-weight: 600;
  color: #94a3b8;
}
.stats-trend-up { color: #166534; font-size: 0.72em; font-weight: 700; }
.stats-trend-down { color: #b91c1c; font-size: 0.72em; font-weight: 700; }
.stats-rank-change {
  font-size: 0.68em;
  font-weight: 700;
  margin-left: 4px;
  white-space: nowrap;
}
.stats-rank-change--up { color: #166534; }
.stats-rank-change--down { color: #b91c1c; }
.stats-rank-change--new { color: #1d6a96; font-style: italic; }

/* Stacked horizontal bar */
.stats-stacked-bar {
  display: flex;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  background: #f1f5f9;
}
.stats-stacked-bar-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72em;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  min-width: 0;
  transition: flex 0.3s;
}
.stats-stacked-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
}
.stats-stacked-bar-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74em;
  color: #475569;
}
.stats-stacked-bar-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.stats-stacked-bar-legend-value {
  font-weight: 600;
  color: #0b2545;
}
.stats-empty-msg {
  font-size: 0.82em;
  color: #94a3b8;
  font-style: italic;
  text-align: center;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 16px;
  margin: 0;
}

.stats-ranking-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.stats-ranking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}
.stats-ranking-item:not(:last-child) { border-bottom: 1px solid #f8fafc; }
.stats-ranking-bar-wrap { flex: 1; min-width: 0; }
.stats-ranking-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.stats-ranking-label-row .stats-ranking-label { margin-bottom: 0; }
.stats-route-module-tag {
  flex-shrink: 0;
  font-size: 0.64em;
  font-weight: 700;
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.03em;
}
.stats-ranking-label {
  font-size: 0.8em;
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.stats-ranking-bar {
  height: 5px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
}
.stats-ranking-bar-fill {
  height: 100%;
  background: #0b2545;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.stats-ranking-value {
  font-size: 0.76em;
  font-weight: 700;
  color: #0b2545;
  white-space: nowrap;
  min-width: 44px;
  text-align: right;
  flex-shrink: 0;
}
.stats-ranking-list--compact .stats-ranking-item { padding: 4px 0; }
.stats-ranking-list--compact .stats-ranking-label { font-size: 0.76em; }
.stats-ranking-list--compact .stats-ranking-bar { height: 4px; }
.stats-ranking-list--compact .stats-ranking-value { font-size: 0.72em; min-width: 38px; }

/* Engagement divider */
.stats-engagement-divider {
  border: none;
  border-top: 1px solid #f1f5f9;
  margin: 12px 0;
}

/* Measure breakdown */
.stats-measure-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Layers section: each card sizes to its content; columns top-align. */
.stats-layers-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}
.stats-layers-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
@media (max-width: 1100px) {
  .stats-layers-row { grid-template-columns: 1fr; }
}

.stats-rankings-row--2col { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 1100px) {
  .stats-rankings-row--2col { grid-template-columns: 1fr; }
}

.stats-chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats-chip-grid--3 { grid-template-columns: repeat(3, 1fr); }

/* Timeslider charts */
.stats-timeslider-pie-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stats-timeslider-pie-host { width: 100%; height: 280px; }
