/* Gamera BI shell: primitive -> semantic -> component tokens. */
/* Deuda conocida: se conservan selectores de compatibilidad no instanciados
   hasta contar con regresión visual completa del shell y su iframe. */
:root {
  color-scheme: light;

  /* Primitive tokens */
  --p-white: #FFFFFF;
  --p-gray-025: #FAFBFC;
  --p-gray-050: #F4F6F8;
  --p-gray-100: #E9EDF2;
  --p-gray-200: #DCE3EB;
  --p-gray-300: #CED9E7;
  --p-gray-400: #A2B1C5;
  --p-gray-500: #718096;
  --p-gray-600: #536273;
  --p-gray-700: #3B4755;
  --p-gray-900: #17212B;
  --p-blue-025: #F7FAFD;
  --p-blue-050: #EDF4FB;
  --p-blue-100: #DCEAF7;
  --p-blue-500: #4779A8;
  --p-blue-600: #2F5F8F;
  --p-blue-700: #244B73;
  --p-blue-800: #173B5F;
  --p-green-050: #EDF8F2;
  --p-green-200: #B9DEC9;
  --p-green-700: #246443;
  --p-amber-050: #FFF8E7;
  --p-amber-200: #E8D198;
  --p-amber-800: #765410;
  --p-red-050: #FFF2F1;
  --p-red-200: #E7BCB8;
  --p-red-700: #8B352F;
  --p-focus: #0B66C3;
  --p-overlay: rgba(23, 33, 43, 0.42);
  --p-shadow-soft: rgba(32, 53, 75, 0.10);
  --p-shadow-strong: rgba(32, 53, 75, 0.18);
  --p-accent-soft: rgba(47, 95, 143, 0.12);
  --p-shimmer-clear: rgba(255, 255, 255, 0);
  --p-shimmer-light: rgba(255, 255, 255, 0.72);
  --p-font: Tahoma, "Segoe UI", Arial, sans-serif;
  --p-fs-11: 0.6875rem;
  --p-fs-12: 0.75rem;
  --p-fs-13: 0.8125rem;
  --p-fs-14: 0.875rem;
  --p-fs-16: 1rem;
  --p-fs-18: 1.125rem;
  --p-fs-22: 1.375rem;
  --p-fs-28: 1.75rem;
  --p-line-tight: 1.2;
  --p-line: 1.45;
  --p-s1: 0.125rem;
  --p-s2: 0.25rem;
  --p-s3: 0.375rem;
  --p-s4: 0.5rem;
  --p-s5: 0.75rem;
  --p-s6: 1rem;
  --p-s7: 1.25rem;
  --p-s8: 1.5rem;
  --p-s9: 2rem;
  --p-r3: 3px;
  --p-r4: 4px;
  --p-r6: 6px;
  --p-control: 2.125rem;
  --p-shell-max: 100rem;
  --p-fast: 120ms;
  --p-normal: 180ms;
  --p-ease: ease-out;
  --p-toolbar: linear-gradient(to bottom, #FFFFFF 0%, #F5F7FA 46%, #E6EBF1 100%);
  --p-button: linear-gradient(to bottom, #FFFFFF 0%, #EDF1F5 100%);
  --p-button-hover: linear-gradient(to bottom, #FFFFFF 0%, #E3ECF6 100%);
  --p-active: linear-gradient(to bottom, #F7FBFF 0%, #DCEAF7 100%);

  /* Semantic tokens */
  --color-canvas: var(--p-gray-050);
  --color-surface: var(--p-white);
  --color-surface-subtle: var(--p-gray-025);
  --color-surface-muted: var(--p-gray-100);
  --color-surface-accent: var(--p-blue-050);
  --color-border: var(--p-gray-300);
  --color-border-strong: var(--p-gray-400);
  --color-text: var(--p-gray-900);
  --color-text-muted: var(--p-gray-600);
  --color-text-soft: var(--p-gray-500);
  --color-heading: var(--p-blue-800);
  --color-accent: var(--p-blue-600);
  --color-accent-strong: var(--p-blue-700);
  --color-accent-soft: var(--p-blue-100);
  --color-success: var(--p-green-700);
  --color-success-bg: var(--p-green-050);
  --color-success-border: var(--p-green-200);
  --color-warning: var(--p-amber-800);
  --color-warning-bg: var(--p-amber-050);
  --color-warning-border: var(--p-amber-200);
  --color-danger: var(--p-red-700);
  --color-danger-bg: var(--p-red-050);
  --color-danger-border: var(--p-red-200);
  --color-focus: var(--p-focus);
  --font-interface: var(--p-font);
  --shadow-raised: 0 1px 3px var(--p-shadow-soft);
  --shadow-overlay: 0 8px 28px var(--p-shadow-strong);
  --interactive: color var(--p-fast) var(--p-ease), background-color var(--p-fast) var(--p-ease), border-color var(--p-fast) var(--p-ease), box-shadow var(--p-fast) var(--p-ease), transform var(--p-fast) var(--p-ease);

  /* Component tokens */
  --shell-bg: var(--color-canvas);
  --shell-frame: var(--color-border);
  --shell-frame-strong: var(--color-border-strong);
  --ribbon-bg: var(--p-toolbar);
  --ribbon-hover: var(--p-button-hover);
  --ribbon-active: var(--p-active);
  --button-bg: var(--p-button);
  --control-bg: var(--color-surface);
  --control-border: var(--color-border-strong);
  --card-bg: var(--color-surface);
  --card-border: var(--color-border);
  --panel-bg: var(--color-surface);
  --panel-header-bg: var(--p-toolbar);
  --table-header-bg: var(--color-surface-muted);
  --dialog-bg: var(--color-surface);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  min-width: 0;
  min-height: 100%;
  background: var(--shell-bg);
  color: var(--color-text);
  font-family: var(--font-interface);
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--shell-bg);
  color: var(--color-text);
  font-family: var(--font-interface);
  font-size: var(--p-fs-13);
  line-height: var(--p-line);
  text-rendering: optimizeLegibility;
}

button, select, input, textarea { color: inherit; font: inherit; }
button, select { min-width: 0; }
button:not(:disabled), select:not(:disabled) { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: 0.58; }
svg { display: block; flex: 0 0 auto; }
h1, h2, h3, p { margin-block-start: 0; }

:where(a, button, select, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--color-surface);
}

::selection { background: var(--color-accent-soft); color: var(--color-heading); }

.skip-link {
  position: fixed;
  inset-block-start: var(--p-s3);
  inset-inline-start: var(--p-s3);
  z-index: 1000;
  padding: var(--p-s4) var(--p-s6);
  border: 1px solid var(--color-accent-strong);
  border-radius: var(--p-r3);
  background: var(--color-surface);
  color: var(--color-accent-strong);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform var(--p-fast) var(--p-ease);
}
.skip-link:focus { transform: translateY(0); }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-shell {
  display: flex;
  min-width: 0;
  min-height: 100vh;
  flex-direction: column;
  background: var(--shell-bg);
}
.shell-inner { width: 100%; max-width: var(--p-shell-max); margin-inline: auto; }
.shell-chrome {
  position: relative;
  z-index: 10;
  min-width: 0;
  border-bottom: 1px solid var(--shell-frame-strong);
  background: var(--color-surface);
  box-shadow: var(--shadow-raised);
}

.ribbon-bar {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--p-s3);
  padding: var(--p-s3) var(--p-s4);
  border-bottom: 1px solid var(--shell-frame);
  background: var(--ribbon-bg);
}
.ribbon-brand {
  display: none;
  width: 2.125rem;
  min-height: 2.125rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-accent-strong);
  border-radius: var(--p-r4);
  background: var(--color-accent);
  color: var(--p-white);
  box-shadow: inset 0 1px 0 var(--p-accent-soft);
}
.brand-mark { width: 1.5rem; height: 1.5rem; }
.brand-mark rect { fill: none; stroke: currentColor; stroke-width: 1.5; }
.brand-mark path { fill: currentColor; }

.ribbon-nav {
  display: grid;
  min-width: 0;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--p-s2);
}
.ribbon-tab {
  display: flex;
  min-width: 0;
  min-height: 2.25rem;
  align-items: center;
  justify-content: flex-start;
  gap: var(--p-s3);
  padding: var(--p-s3) var(--p-s4);
  border: 1px solid transparent;
  border-radius: var(--p-r3);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--p-fs-12);
  font-weight: 700;
  line-height: var(--p-line-tight);
  text-align: left;
  transition: var(--interactive);
}
.ribbon-tab svg, .toolbar-button svg, .icon-button svg, .state-action svg {
  width: 1.0625rem;
  height: 1.0625rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}
.ribbon-tab span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ribbon-tab:hover { border-color: var(--shell-frame); background: var(--ribbon-hover); color: var(--color-heading); }
.ribbon-tab:active { transform: translateY(1px); }
.ribbon-tab.is-active, .ribbon-tab[aria-pressed="true"] {
  border-color: var(--color-border-strong);
  background: var(--ribbon-active);
  color: var(--color-accent-strong);
  box-shadow: inset 0 2px 0 var(--color-accent);
}

.ribbon-actions {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--p-s2);
}
.toolbar-button, .icon-button, .state-action {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--p-r3);
  background: var(--button-bg);
  color: var(--color-text);
  box-shadow: inset 0 1px 0 var(--color-surface);
  transition: var(--interactive);
}
.toolbar-button {
  display: inline-flex;
  min-height: var(--p-control);
  align-items: center;
  justify-content: center;
  gap: var(--p-s3);
  padding: var(--p-s3) var(--p-s5);
  font-size: var(--p-fs-12);
  font-weight: 700;
  white-space: nowrap;
}
.toolbar-button:hover, .icon-button:hover, .state-action:hover {
  border-color: var(--color-accent);
  background: var(--ribbon-hover);
  color: var(--color-accent-strong);
}
.toolbar-button:active, .icon-button:active, .state-action:active {
  box-shadow: inset 0 1px 2px var(--p-shadow-strong);
  transform: translateY(1px);
}

.module-header {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--p-s5);
  padding: var(--p-s6) var(--p-s5) var(--p-s5);
  background: var(--color-surface);
}
.module-heading { display: flex; min-width: 0; align-items: center; gap: var(--p-s5); }
.module-symbol {
  display: flex;
  width: 2.5rem;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--p-r4);
  background: var(--color-surface-accent);
  color: var(--color-accent);
}
.module-symbol svg { width: 1.75rem; height: 1.75rem; fill: currentColor; }
.module-symbol path:last-child { fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.5; }
.module-copy { min-width: 0; }
.module-kicker, .view-kicker, .dialog-kicker {
  margin-bottom: var(--p-s2);
  color: var(--color-accent);
  font-size: var(--p-fs-11);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: var(--p-line-tight);
}
#app-title { margin-bottom: var(--p-s2); color: var(--color-heading); font-size: var(--p-fs-22); line-height: var(--p-line-tight); }
#app-subtitle { margin-bottom: 0; color: var(--color-text-muted); font-size: var(--p-fs-13); }
.environment-badge {
  display: inline-flex;
  width: fit-content;
  min-height: 1.75rem;
  align-items: center;
  padding: var(--p-s2) var(--p-s4);
  border: 1px solid var(--color-warning-border);
  border-radius: var(--p-r4);
  background: var(--color-warning-bg);
  color: var(--color-warning);
  font-size: var(--p-fs-11);
  font-weight: 700;
  letter-spacing: 0.035em;
  white-space: nowrap;
}

.filter-toolbar {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--p-s4);
  padding: var(--p-s4) var(--p-s5);
  border-top: 1px solid var(--shell-frame);
  background: var(--color-surface-subtle);
}
.filter-field {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(5.5rem, auto) minmax(0, 1fr);
  align-items: center;
  gap: var(--p-s4);
}
.filter-field label { color: var(--color-text-muted); font-size: var(--p-fs-12); font-weight: 700; white-space: nowrap; }
.select-control { position: relative; min-width: 0; }
.select-control select {
  width: 100%;
  min-height: var(--p-control);
  padding: var(--p-s3) 2rem var(--p-s3) var(--p-s4);
  overflow: hidden;
  border: 1px solid var(--control-border);
  border-radius: var(--p-r3);
  appearance: none;
  background: var(--control-bg);
  color: var(--color-text);
  font-size: var(--p-fs-12);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select-control select:hover { border-color: var(--color-accent); }
.select-control svg {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: var(--p-s4);
  width: 0.875rem;
  height: 0.875rem;
  pointer-events: none;
  fill: none;
  stroke: var(--color-text-muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transform: translateY(-50%);
}

.main-content {
  display: block;
  min-width: 0;
  width: 100%;
  flex: 1 0 auto;
  padding: var(--p-s5);
  outline: none;
}
.view-root { min-width: 0; min-height: 20rem; }
.view-header {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--p-s4);
  margin-bottom: var(--p-s5);
  padding-bottom: var(--p-s4);
  border-bottom: 1px solid var(--color-border);
}
.view-header h2, .view-header h1 {
  margin-bottom: var(--p-s2);
  color: var(--color-heading);
  font-size: var(--p-fs-18);
  line-height: var(--p-line-tight);
}
.view-description { max-width: 70rem; margin-bottom: 0; color: var(--color-text-muted); font-size: var(--p-fs-13); }

.layout-grid, .dashboard-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--p-s5);
}
.layout-grid > *, .dashboard-grid > * { min-width: 0; grid-column: 1 / -1; }

.kpi-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--p-s4);
  margin-bottom: var(--p-s5);
}
.kpi-card {
  position: relative;
  min-width: 0;
  min-height: 7.25rem;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: var(--p-r4);
  background: var(--card-bg);
  box-shadow: var(--shadow-raised);
}
.kpi-card::before {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 3px;
  background: var(--color-accent);
  content: "";
}
.kpi-card:focus-within { border-color: var(--color-focus); }
.kpi-button {
  display: flex;
  width: 100%;
  min-height: 7.25rem;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--p-s4);
  padding: var(--p-s5);
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background-color var(--p-fast) var(--p-ease);
}
.kpi-button:hover { background: var(--color-surface-accent); }
.kpi-label { display: block; color: var(--color-text-muted); font-size: var(--p-fs-12); font-weight: 700; line-height: var(--p-line-tight); }
.kpi-value {
  display: block;
  max-width: 100%;
  color: var(--color-heading);
  font-family: var(--font-interface);
  font-size: var(--p-fs-28);
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1;
  overflow-wrap: anywhere;
}
.kpi-context {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: var(--p-s3);
  color: var(--color-text-muted);
  font-size: var(--p-fs-11);
}
.trend, .status-chip {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: var(--p-s2);
  padding: var(--p-s1) var(--p-s3);
  border: 1px solid var(--color-border);
  border-radius: var(--p-r3);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: var(--p-fs-11);
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 700;
  white-space: nowrap;
}
.trend-positive, .status-success, .status-chip[data-tone="positive"] {
  border-color: var(--color-success-border); background: var(--color-success-bg); color: var(--color-success);
}
.trend-warning, .status-warning, .status-chip[data-tone="warning"] {
  border-color: var(--color-warning-border); background: var(--color-warning-bg); color: var(--color-warning);
}
.trend-negative, .status-danger, .status-chip[data-tone="negative"] {
  border-color: var(--color-danger-border); background: var(--color-danger-bg); color: var(--color-danger);
}

.panel-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--p-s5);
  margin-bottom: var(--p-s5);
}
.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: var(--p-r4);
  background: var(--panel-bg);
  box-shadow: var(--shadow-raised);
}
.panel-header {
  display: flex;
  min-width: 0;
  min-height: 2.625rem;
  align-items: center;
  justify-content: space-between;
  gap: var(--p-s4);
  padding: var(--p-s4) var(--p-s5);
  border-bottom: 1px solid var(--color-border);
  background: var(--panel-header-bg);
}
.panel-header > * { min-width: 0; }
.panel-header h2, .panel-header h3, .panel-title {
  margin-bottom: 0;
  color: var(--color-heading);
  font-size: var(--p-fs-13);
  font-weight: 700;
  line-height: var(--p-line-tight);
}
.panel-subtitle { margin: var(--p-s1) 0 0; color: var(--color-text-muted); font-size: var(--p-fs-11); }
.panel-body { min-width: 0; padding: var(--p-s5); }

.chart-wrap {
  position: relative;
  min-width: 0;
  width: 100%;
  min-height: 12rem;
  overflow: hidden;
  padding: var(--p-s4);
}
.chart-wrap svg { width: 100%; height: auto; max-height: 21rem; overflow: visible; }
.chart-grid, .chart-grid line, .chart-grid path {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.chart-line {
  fill: none;
  stroke: var(--color-accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.25;
  vector-effect: non-scaling-stroke;
}
.chart-point {
  fill: var(--color-surface);
  stroke: var(--color-accent-strong);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.chart-bar { fill: var(--p-blue-500); }
.chart-area { fill: var(--p-accent-soft); }
.chart-label {
  fill: var(--color-text-muted);
  font-family: var(--font-interface);
  font-size: var(--p-fs-11);
  font-variant-numeric: tabular-nums lining-nums;
}
.chart-summary {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: var(--p-s3) var(--p-s5);
  padding: var(--p-s4) var(--p-s5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
  color: var(--color-text-muted);
  font-size: var(--p-fs-11);
}
.chart-summary strong { color: var(--color-text); font-variant-numeric: tabular-nums lining-nums; }

.data-table-wrap {
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--p-r3);
  background: var(--color-surface);
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}
.data-table {
  width: 100%;
  min-width: 36rem;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--color-text);
  font-size: var(--p-fs-12);
}
.data-table th, .data-table td {
  min-width: 0;
  padding: var(--p-s4) var(--p-s5);
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: middle;
}
.data-table th {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  background: var(--table-header-bg);
  color: var(--color-text-muted);
  font-size: var(--p-fs-11);
  font-weight: 700;
  letter-spacing: 0.025em;
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:nth-child(even) { background: var(--color-surface-subtle); }
.data-table tbody tr:hover { background: var(--color-surface-accent); }
.data-table td[data-type="number"], .data-table th[data-type="number"], .numeric {
  font-variant-numeric: tabular-nums lining-nums;
  text-align: right;
  white-space: nowrap;
}

.insights-grid, .findings-list {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--p-s4);
}
.insight-card, .finding-card {
  position: relative;
  min-width: 0;
  padding: var(--p-s5);
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: var(--p-r4);
  background: var(--card-bg);
}
.insight-card::before, .finding-card::before {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 3px;
  background: var(--color-accent);
  content: "";
}
.insight-card[data-tone="positive"]::before, .finding-card.is-positive::before { background: var(--color-success); }
.insight-card[data-tone="warning"]::before, .finding-card.is-warning::before { background: var(--color-warning); }
.insight-card[data-tone="negative"]::before, .finding-card.is-critical::before { background: var(--color-danger); }
.insight-card h3, .finding-card h3 { margin-bottom: var(--p-s3); color: var(--color-heading); font-size: var(--p-fs-13); }
.insight-card p, .finding-card p { margin-bottom: 0; color: var(--color-text-muted); font-size: var(--p-fs-12); }

.empty-state, .error-state, .loading-state {
  display: flex;
  min-width: 0;
  min-height: 10rem;
  align-items: center;
  justify-content: center;
  gap: var(--p-s5);
  padding: var(--p-s8);
  border: 1px solid var(--color-border);
  border-radius: var(--p-r4);
  background: var(--color-surface);
  color: var(--color-text-muted);
  text-align: left;
}
.empty-state > svg, .error-state > svg, .loading-state > svg {
  width: 2rem;
  height: 2rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}
.empty-state h2, .empty-state h3, .error-state h2, .error-state h3, .loading-state h2, .loading-state h3 {
  margin-bottom: var(--p-s2);
  color: var(--color-heading);
  font-size: var(--p-fs-14);
}
.empty-state p, .error-state p, .loading-state p { margin-bottom: 0; font-size: var(--p-fs-12); }
.error-state { border-color: var(--color-danger-border); background: var(--color-danger-bg); color: var(--color-danger); }
.boot-loading { display: block; border-color: transparent; background: transparent; padding: 0; }

.skeleton-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--p-s4);
}
.skeleton {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--p-r4);
  background: var(--color-surface-muted);
}
.skeleton::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--p-shimmer-clear), var(--p-shimmer-light), var(--p-shimmer-clear));
  content: "";
  transform: translateX(-100%);
  animation: skeleton-shimmer 1.35s infinite;
}
.skeleton-heading { width: min(24rem, 72%); height: 1.75rem; margin-bottom: var(--p-s5); }
.skeleton-card { min-height: 7.25rem; }

.state-action {
  display: inline-flex;
  min-height: var(--p-control);
  align-items: center;
  justify-content: center;
  gap: var(--p-s3);
  margin-top: var(--p-s4);
  padding: var(--p-s3) var(--p-s5);
  font-size: var(--p-fs-12);
  font-weight: 700;
}
.metric-definition { margin: 0; }
.metric-definition dt {
  margin-top: var(--p-s5);
  color: var(--color-heading);
  font-size: var(--p-fs-12);
  font-weight: 700;
}
.metric-definition dt:first-child { margin-top: 0; }
.metric-definition dd { margin: var(--p-s2) 0 0; color: var(--color-text-muted); font-size: var(--p-fs-12); }

.app-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--shell-frame);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: var(--p-fs-11);
}
.footer-inner {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--p-s2);
  padding: var(--p-s4) var(--p-s5);
}
.footer-separator { display: none; width: 1px; height: 0.75rem; background: var(--color-border-strong); }

.metric-dialog {
  width: min(34rem, calc(100vw - 1.25rem));
  max-width: 100%;
  max-height: min(80vh, 42rem);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--p-r6);
  background: var(--dialog-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-overlay);
}
.metric-dialog:not([open]) { display: none; }
.metric-dialog[open] { animation: dialog-enter var(--p-normal) var(--p-ease); }
.metric-dialog::backdrop { background: var(--p-overlay); }
.dialog-shell { display: flex; max-height: min(80vh, 42rem); flex-direction: column; }
.dialog-header {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--p-s5);
  padding: var(--p-s5) var(--p-s5) var(--p-s4);
  border-bottom: 1px solid var(--color-border);
  background: var(--panel-header-bg);
}
.dialog-header h2 { margin-bottom: 0; color: var(--color-heading); font-size: var(--p-fs-16); line-height: var(--p-line-tight); }
.icon-button {
  display: inline-flex;
  width: var(--p-control);
  height: var(--p-control);
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.dialog-body { min-width: 0; padding: var(--p-s6); overflow: auto; overscroll-behavior: contain; }
.dialog-body > :last-child { margin-bottom: 0; }

@keyframes skeleton-shimmer { to { transform: translateX(100%); } }
@keyframes dialog-enter {
  from { opacity: 0; transform: translateY(-0.375rem) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Compact frames below 768px use the base rules. */
@media (max-width: 47.99rem) {
  .ribbon-tab span { white-space: normal; }
  .module-heading { align-items: flex-start; }
  .module-symbol { width: 2.25rem; height: 2.25rem; }
  .empty-state, .error-state, .loading-state { flex-direction: column; align-items: flex-start; padding: var(--p-s6); }
  .data-table { min-width: 32rem; }
}

/* 768px and wider. */
@media (min-width: 48rem) {
  .ribbon-bar { padding-inline: var(--p-s5); }
  .ribbon-brand { display: flex; }
  .ribbon-nav {
    width: auto;
    flex: 1 1 calc(100% - 3rem);
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .ribbon-actions { width: auto; margin-inline-start: 2.5rem; }
  .module-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-inline: var(--p-s6);
  }
  .filter-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-inline: var(--p-s6); }
  .filter-field { grid-template-columns: 1fr; gap: var(--p-s2); }
  .main-content { padding: var(--p-s6); }
  .view-header { flex-direction: row; align-items: flex-end; justify-content: space-between; }
  .kpi-grid, .skeleton-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insights-grid, .findings-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-inner {
    flex-direction: row;
    align-items: center;
    gap: var(--p-s4);
    padding-inline: var(--p-s6);
  }
  .footer-separator { display: block; }
}

/* 1024px and wider. */
@media (min-width: 64rem) {
  .ribbon-bar { flex-wrap: nowrap; }
  .ribbon-nav { flex-basis: auto; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .ribbon-actions { flex: 0 0 auto; margin-inline-start: var(--p-s2); }
  .ribbon-tab { justify-content: center; padding-inline: var(--p-s3); font-size: var(--p-fs-11); }
  .filter-field { grid-template-columns: minmax(5.5rem, auto) minmax(0, 1fr); gap: var(--p-s4); }
  .kpi-grid, .skeleton-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .panel-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .panel-grid > .panel { grid-column: span 6; }
  .panel-grid > .panel-wide { grid-column: span 8; }
  .panel-grid > .panel-narrow { grid-column: span 4; }
  .panel-grid > .panel-full { grid-column: 1 / -1; }
  .span-3 { grid-column: span 3; }
  .span-4 { grid-column: span 4; }
  .span-6 { grid-column: span 6; }
  .span-8 { grid-column: span 8; }
  .span-9 { grid-column: span 9; }
  .span-12 { grid-column: 1 / -1; }
}

/* 1280px and wider. */
@media (min-width: 80rem) {
  .ribbon-tab {
    justify-content: flex-start;
    gap: var(--p-s4);
    padding-inline: var(--p-s5);
    font-size: var(--p-fs-12);
  }
  .module-header, .filter-toolbar, .main-content { padding-inline: var(--p-s8); }
  .kpi-grid, .skeleton-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .insights-grid, .findings-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .skeleton::after { display: none; }
}

@media (forced-colors: active) {
  .ribbon-tab.is-active, .ribbon-tab[aria-pressed="true"], .kpi-card, .panel, .insight-card, .finding-card {
    border: 1px solid CanvasText;
  }
  :where(a, button, select, input, textarea, [tabindex]):focus-visible { outline: 2px solid Highlight; }
}
