:root {
  --bg: #f6f4ee;
  --panel: #fffefb;
  --panel-soft: #faf8f1;
  --panel-tint: #f3f0e6;
  --ink: #1e2620;
  --muted: #6f7268;
  --faint: #9a998f;
  --line: #e5e0d2;
  --line-strong: #cec7b3;
  --charcoal: #14201a;
  --charcoal-soft: #1b2a23;
  --teal: #24523f;
  --teal-deep: #173d2d;
  --teal-soft: #e4ede6;
  --gold: #a5822f;
  --gold-bright: #c8a44b;
  --gold-soft: #f2e9d3;
  --gold-line: rgba(165, 130, 47, 0.38);
  --green: #22714f;
  --green-soft: #e4f1e9;
  --amber: #a86405;
  --amber-soft: #fbefdc;
  --red: #b42318;
  --red-soft: #fbe8e6;
  --blue: #2563a8;
  --blue-soft: #e8eef7;
  --violet: #6952a8;
  --shadow: 0 14px 36px rgba(28, 38, 32, 0.08);
  --radius: 6px;
  --radius-pill: 999px;
  --sidebar-width: 280px;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
  --font-sans: Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 96px;
  opacity: 0.14;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
summary,
label[for] {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

a {
  color: inherit;
}

p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-serif);
  letter-spacing: 0.01em;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 100vh;
  padding: 24px 18px;
  background: var(--charcoal);
  color: #f5f4ec;
  border-right: 1px solid var(--gold-line);
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 4px 20px;
  border-bottom: 1px solid var(--gold-line);
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
  color: var(--charcoal);
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 800;
}

.brand-copy {
  min-width: 0;
}

.brand-name {
  overflow: hidden;
  color: #fff;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-subtitle {
  margin-top: 2px;
  color: rgba(245, 244, 236, 0.6);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-item {
  width: 100%;
  min-width: 0;
  min-height: 43px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(245, 244, 236, 0.72);
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.nav-item > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active,
.nav-item.is-active,
.nav-item[aria-current="page"] {
  background: rgba(200, 164, 75, 0.12);
  box-shadow: inset 3px 0 0 var(--gold);
  color: #fff;
}

.nav-index {
  color: rgba(245, 244, 236, 0.44);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  transition: color 0.18s ease;
}

.nav-item:hover .nav-index,
.nav-item.active .nav-index,
.nav-item.is-active .nav-index,
.nav-item[aria-current="page"] .nav-index {
  color: var(--gold-bright);
}

.sidebar-note {
  margin-top: auto;
  padding: 13px 14px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  color: rgba(245, 244, 236, 0.72);
  display: grid;
  gap: 7px;
  font-size: 12px;
}

.sidebar-note strong {
  color: #fff;
  font-family: var(--font-serif);
  letter-spacing: 0.02em;
}

.sidebar-note small {
  padding-top: 7px;
  border-top: 1px solid rgba(200, 164, 75, 0.2);
  color: rgba(245, 244, 236, 0.52);
  font-size: 10px;
  line-height: 1.55;
}

.site-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.site-links a {
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(245, 244, 236, 0.84);
  font-size: 11px;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.site-links a:hover {
  background: rgba(200, 164, 75, 0.14);
  border-color: var(--gold-bright);
  color: #fff;
}

/* ---------- Workspace / global controls ---------- */
.workspace {
  min-width: 0;
  padding: 32px 40px 48px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 20px;
}

.title-cluster {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 700;
  line-height: 1.22;
}

h2 {
  font-size: 18px;
  line-height: 1.35;
}

h3 {
  font-size: 15px;
  line-height: 1.4;
}

.top-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.control,
.field {
  min-width: 144px;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.product-control {
  min-width: min(300px, 32vw);
}

input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0 11px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
  min-height: 106px;
  padding-top: 10px;
  padding-bottom: 10px;
  line-height: 1.55;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(36, 82, 63, 0.14);
}

.button,
.btn,
.reset-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 680;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.button:hover,
.btn:hover,
.reset-button:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.button:active,
.btn:active,
.reset-button:active {
  transform: translateY(1px);
}

.button.primary,
.btn.primary,
.btn-primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.button.primary:hover,
.btn.primary:hover,
.btn-primary:hover {
  border-color: var(--teal-deep);
  background: var(--teal-deep);
}

.button.danger,
.btn.danger {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--red);
}

.button.ghost,
.btn.ghost {
  background: transparent;
}

.nav-item:focus-visible,
.site-links a:focus-visible,
.button:focus-visible,
.btn:focus-visible,
.tab:focus-visible,
.tab-button:focus-visible,
.segment-button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(200, 164, 75, 0.3);
  outline-offset: 2px;
}

.context-bar {
  min-width: 0;
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid var(--gold-line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--gold-soft), rgba(255, 254, 251, 0.72));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.context-main {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.context-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.context-main strong {
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-serif);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.context-chip,
.chip,
.badge,
.tag {
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-pill);
  background: rgba(255, 254, 251, 0.7);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
}

.context-chip.muted,
.chip.muted,
.badge.muted {
  color: var(--muted);
}

.badge.success,
.chip.success,
.status-good {
  border-color: rgba(34, 113, 79, 0.24);
  background: var(--green-soft);
  color: var(--green);
}

.badge.warning,
.chip.warning,
.status-warning {
  border-color: rgba(168, 100, 5, 0.24);
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.danger,
.chip.danger,
.status-danger {
  border-color: rgba(180, 35, 24, 0.24);
  background: var(--red-soft);
  color: var(--red);
}

/* ---------- Layout primitives ---------- */
.page-root {
  min-width: 0;
  display: grid;
  gap: 20px;
}

.metric-grid,
.metric-strip,
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.metric-card,
.kpi-card {
  min-width: 0;
  min-height: 108px;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 2px solid var(--gold-line);
  border-radius: var(--radius);
  background: var(--panel);
}

.metric.accent,
.metric-card.accent,
.kpi-card.accent {
  border-top-color: var(--gold);
}

.metric-label,
.kpi-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.03em;
}

.metric-value,
.kpi-value {
  margin-top: 9px;
  overflow-wrap: anywhere;
  font-family: var(--font-serif);
  font-size: clamp(23px, 2.3vw, 29px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.08;
}

.metric-foot,
.metric-meta,
.kpi-foot {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.metric-delta,
.delta,
.trend {
  margin-left: 5px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.positive,
.delta.positive,
.trend.up {
  color: var(--green);
}

.negative,
.delta.negative,
.trend.down {
  color: var(--red);
}

.neutral,
.delta.neutral {
  color: var(--muted);
}

.panel,
.section,
.card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel.soft,
.section.soft,
.card.soft {
  background: var(--panel-soft);
}

.panel-head,
.section-head,
.section-header,
.card-head {
  min-width: 0;
  margin: -1px 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-title,
.section-title,
.card-title {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.panel-title p,
.section-title p,
.card-title p,
.section-subtitle {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-sans);
}

.panel-actions,
.section-actions,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.grid-2,
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.grid-2.equal,
.two-col.equal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3,
.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stack {
  display: grid;
  gap: 14px;
}

.split-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- Charts / SVG ---------- */
.chart,
.chart-wrap,
.chart-card,
.svg-chart {
  min-width: 0;
  width: 100%;
}

.chart-wrap,
.svg-chart {
  position: relative;
  min-height: 260px;
  padding: 12px 4px 2px;
  overflow-x: auto;
  overflow-y: hidden;
}

.chart-wrap.compact,
.svg-chart.compact {
  min-height: 190px;
}

.chart svg,
.chart-wrap svg,
.svg-chart svg {
  width: 100%;
  min-width: 520px;
  height: auto;
  display: block;
  overflow: visible;
}

.chart text,
.chart-wrap text,
.svg-chart text,
.axis-label,
.chart-label {
  fill: var(--muted);
  font-family: var(--font-sans);
  font-size: 11px;
}

.chart .grid-line,
.chart .grid,
.svg-chart .grid-line,
.svg-chart .grid {
  stroke: var(--line);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart .axis,
.svg-chart .axis {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.chart .series,
.chart .line-series,
.svg-chart .series,
.svg-chart .line-series {
  fill: none;
  stroke: var(--teal);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.chart .series.secondary,
.svg-chart .series.secondary {
  stroke: var(--gold);
}

.chart .area,
.svg-chart .area {
  fill: rgba(36, 82, 63, 0.12);
}

.chart .bar,
.svg-chart .bar {
  fill: var(--teal);
}

.chart .bar.gold,
.svg-chart .bar.gold {
  fill: var(--gold);
}

.chart .point,
.svg-chart .point {
  fill: var(--panel);
  stroke: var(--teal);
  stroke-width: 2;
}

.chart-legend,
.legend {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--teal);
}

.chart-tooltip,
.tooltip {
  position: fixed;
  z-index: 90;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--radius);
  background: rgba(20, 32, 26, 0.96);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(88px, 0.35fr) minmax(120px, 1fr) minmax(54px, auto);
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.bar-track,
.track {
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--panel-tint);
}

.bar-fill,
.fill {
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.bar-fill.gold,
.fill.gold {
  background: var(--gold);
}

.bar-fill.negative,
.fill.negative {
  background: var(--red);
}

/* ---------- Tables ---------- */
.table-wrap,
.table-scroll {
  width: 100%;
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

td {
  font-size: 12px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: rgba(242, 233, 211, 0.28);
}

td.number,
th.number,
.number {
  text-align: right;
}

.cell-main {
  color: var(--ink);
  font-weight: 680;
}

.cell-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

/* ---------- Tabs / segmented controls ---------- */
.tabs,
.tab-list {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.tab,
.tab-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}

.tab:hover,
.tab-button:hover {
  color: var(--ink);
}

.tab.active,
.tab.is-active,
.tab[aria-selected="true"],
.tab-button.active,
.tab-button.is-active,
.tab-button[aria-selected="true"] {
  border-color: var(--line);
  background: var(--panel);
  color: var(--teal);
  box-shadow: 0 1px 2px rgba(20, 32, 26, 0.05);
}

.segmented,
.segment-control {
  display: inline-flex;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--panel-soft);
  overflow-x: auto;
}

.segment-button,
.segmented button {
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}

.segment-button.active,
.segment-button.is-active,
.segment-button[aria-pressed="true"],
.segmented button.active,
.segmented button[aria-pressed="true"] {
  background: var(--teal);
  color: #fff;
}

/* ---------- Forms / alert editor ---------- */
.form-grid,
.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.field.full,
.field-full {
  grid-column: 1 / -1;
}

.field > span:first-child,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field-help,
.help-text {
  color: var(--faint);
  font-size: 11px;
}

.check-row,
.radio-row {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 12px;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.alert-editor {
  padding: 18px;
  border: 1px solid var(--gold-line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  background: var(--panel-soft);
  display: grid;
  gap: 15px;
}

.alert-editor.danger {
  border-color: rgba(180, 35, 24, 0.28);
  border-left-color: var(--red);
}

.alert-row,
.alert-card {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  display: grid;
  gap: 8px;
}

.alert-row.red,
.alert-card.red,
.alert-row.danger,
.alert-card.danger {
  border-left: 3px solid var(--red);
}

.alert-row.amber,
.alert-card.amber,
.alert-row.warning,
.alert-card.warning {
  border-left: 3px solid var(--amber);
}

/* ---------- Heatmap / insight ---------- */
.heatmap,
.heatmap-grid {
  min-width: 620px;
  display: grid;
  gap: 3px;
}

.heatmap-cell {
  min-height: 38px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 3px;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.heatmap-cell.level-0 { background: #f1f1eb; }
.heatmap-cell.level-1 { background: #dfeae1; }
.heatmap-cell.level-2 { background: #b9d2c0; }
.heatmap-cell.level-3 { background: #77a989; color: #10251b; }
.heatmap-cell.level-4 { background: var(--teal); color: #fff; }
.heatmap-cell.negative-1 { background: #f7dedb; }
.heatmap-cell.negative-2 { background: #eeb6b0; }
.heatmap-cell.negative-3 { background: #d76e64; color: #fff; }
.heatmap-cell.negative-4 { background: var(--red); color: #fff; }

.insight,
.insight-card,
.callout {
  padding: 15px 16px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--gold-soft), var(--panel));
  display: grid;
  gap: 8px;
}

.insight::before,
.insight-card::before {
  content: "INSIGHT";
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.insight.teal,
.insight-card.teal,
.callout.teal {
  border-color: rgba(36, 82, 63, 0.24);
  background: linear-gradient(135deg, var(--teal-soft), var(--panel));
}

.insight-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 7px;
}

.insight-list strong {
  color: var(--ink);
}

/* ---------- Details / disclosure ---------- */
details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: clip;
}

details + details {
  margin-top: 9px;
}

summary {
  min-height: 46px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-weight: 700;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  color: var(--gold);
  font-size: 18px;
  font-weight: 500;
}

details[open] summary {
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

details[open] summary::after {
  content: "−";
}

.details-body,
.detail-body {
  padding: 14px;
  color: var(--muted);
}

/* ---------- States / toast ---------- */
.loading-state,
.empty-state,
.error-state {
  min-height: 220px;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 254, 251, 0.62);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.loading-mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.error-state {
  border-color: rgba(180, 35, 24, 0.3);
  background: var(--red-soft);
  color: var(--red);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 110;
  max-width: min(380px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  background: var(--charcoal);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show,
.toast.is-visible,
.toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.toast.success {
  border-color: rgba(93, 187, 139, 0.5);
}

.toast.error {
  border-color: rgba(238, 134, 125, 0.55);
}

/* ---------- Retail Analytics rendered components ---------- */
.metric-card > strong {
  display: block;
  margin-top: 9px;
  overflow-wrap: anywhere;
  font-family: var(--font-serif);
  font-size: clamp(23px, 2.3vw, 29px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.08;
}

.metric-card.tone-success {
  border-top-color: var(--green);
  background: linear-gradient(145deg, var(--panel), var(--green-soft));
}

.metric-card.tone-warning {
  border-top-color: var(--amber);
  background: linear-gradient(145deg, var(--panel), var(--amber-soft));
}

.metric-card.tone-danger {
  border-top-color: var(--red);
  background: linear-gradient(145deg, var(--panel), var(--red-soft));
}

.metric-card.tone-success > strong,
.metric-delta.success {
  color: var(--green);
}

.metric-card.tone-warning > strong,
.metric-delta.warning {
  color: var(--amber);
}

.metric-card.tone-danger > strong,
.metric-delta.danger {
  color: var(--red);
}

.section-head > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.section-head h2 {
  color: var(--ink);
  font-size: 17px;
  line-height: 1.35;
}

.section-head p {
  max-width: 76ch;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.section-kicker {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.content-grid {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.content-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.content-grid.split-main {
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.7fr);
  align-items: start;
}

.filter-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  background: var(--panel-soft);
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-panel.compact {
  width: fit-content;
  max-width: 100%;
  padding: 10px 12px;
}

.filter-panel .control {
  min-width: 170px;
  flex: 1 1 180px;
}

.filter-panel.compact .control {
  min-width: min(260px, 100%);
  flex: 0 1 300px;
}

.filter-panel fieldset {
  margin: 0;
}

.check-control {
  min-height: 60px;
  padding: 7px 10px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 12px;
}

.check-control legend {
  padding: 0 3px;
  color: var(--muted);
  font-size: 11px;
}

.check-control label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}

.inline-control {
  width: min(520px, 100%);
  margin-bottom: 14px;
}

.multiselect-control {
  width: min(560px, 100%);
  margin-bottom: 14px;
}

.multiselect-control select {
  min-height: 142px;
  padding: 6px;
}

.multiselect-control option {
  padding: 5px 7px;
  border-radius: 3px;
}

.control.disabled {
  opacity: 0.56;
}

.control.disabled select {
  background: var(--panel-tint);
}

.context-inline {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.hbars {
  min-width: 0;
  display: grid;
  gap: 11px;
}

.hbar-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(150px, 1fr) minmax(64px, auto);
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.hbar-row > span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbar-row > strong {
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hbar-track {
  height: 10px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--panel-tint);
}

.hbar-track > i {
  min-width: 2px;
  height: 100%;
  display: block;
  border-radius: inherit;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.chart-stack {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.chart-stack > .chart-wrap + .chart-legend,
.chart-stack > .chart-legend + .chart-wrap {
  margin-top: -8px;
}

.chart-svg {
  width: 100%;
  min-width: 520px;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-axis,
.chart-axis-title,
.chart-label,
.chart-value {
  fill: var(--muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-axis-title {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.chart-label {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.chart-value {
  fill: var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-zero {
  stroke: var(--line-strong);
  stroke-width: 1.2;
  shape-rendering: crispEdges;
}

.chart-reference {
  stroke: var(--gold);
  stroke-width: 1;
  stroke-dasharray: 5 5;
  opacity: 0.72;
}

.chart-line {
  fill: none;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  stroke: var(--panel);
  stroke-width: 1.4;
  transition: r 0.16s ease, stroke-width 0.16s ease;
}

.chart-point:hover {
  r: 5px;
  stroke-width: 2px;
}

.chart-point-dense {
  stroke-width: 0;
}

.chart-point-dense:hover {
  r: 3px;
  stroke-width: 1.2px;
}

.chart-bar {
  transition: opacity 0.16s ease;
}

.chart-bar:hover {
  opacity: 0.78;
}

.chart-bubble {
  stroke: rgba(255, 254, 251, 0.92);
  stroke-width: 1.5;
  opacity: 0.84;
}

.chart-bubble.selected {
  stroke: var(--gold-bright);
  stroke-width: 4;
  opacity: 1;
}

.chart-connector {
  stroke: var(--line-strong);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-connector.solid {
  stroke: var(--charcoal);
  stroke-width: 2;
  stroke-dasharray: none;
}

.chart-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.chart-legend > span > i {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  display: inline-block;
  border-radius: 2px;
}

.chart-legend .legend-title {
  color: var(--ink);
  font-weight: 750;
}

.legend-symbol {
  --legend-color: var(--teal);
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  display: inline-block;
  background: var(--legend-color);
}

.legend-symbol.circle {
  border-radius: 50%;
}

.legend-symbol.square,
.legend-symbol.swatch,
.legend-symbol.bar {
  border-radius: 2px;
}

.legend-symbol.diamond {
  width: 9px;
  height: 9px;
  margin: 0 1px;
  border-radius: 1px;
  transform: rotate(45deg);
}

.legend-symbol.triangle {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.legend-symbol.line {
  width: 18px;
  height: 3px;
  border-radius: var(--radius-pill);
}

.legend-symbol.selected-ring {
  border: 3px solid var(--gold-bright);
  border-radius: 50%;
  background: transparent;
}

.legend-symbol.bubble-size {
  width: 13px;
  height: 13px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: transparent;
}

.legend-symbol.median-line {
  width: 18px;
  height: 0;
  border-top: 2px dashed var(--gold);
  background: transparent;
}

.channel-type-legend {
  margin: 0 0 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.channel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.chart-symbol {
  outline: none;
}

.chart-symbol:hover .chart-bubble,
.chart-symbol:focus-visible .chart-bubble {
  opacity: 1;
  filter: brightness(1.06);
}

.chart-symbol:focus-visible .chart-bubble {
  stroke: var(--charcoal);
  stroke-width: 3;
}

.chart-label.selected {
  fill: var(--teal-deep);
  font-weight: 800;
}

/* ---------- Management story ---------- */
.management-brief {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  background: var(--panel);
  display: grid;
  gap: 15px;
}

.management-brief > header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.management-brief > header > div {
  display: grid;
  gap: 5px;
}

.management-brief > header > p {
  max-width: 54ch;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: right;
}

.management-brief .section-kicker {
  color: var(--teal);
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.brief-grid article {
  min-width: 0;
  min-height: 142px;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 2px solid var(--teal);
  border-radius: var(--radius);
  background: var(--panel-soft);
  display: grid;
  align-content: start;
  gap: 8px;
}

.brief-grid article.action {
  border-top-color: var(--gold);
  background: linear-gradient(145deg, var(--gold-soft), var(--panel));
}

.brief-grid article > span {
  color: var(--teal);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brief-grid article > strong {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.65;
}

.brief-grid article > small {
  margin-top: auto;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.scenario-card {
  min-width: 0;
  min-height: 168px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--ink);
  display: grid;
  align-content: start;
  gap: 8px;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.scenario-card:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
  transform: translateY(-1px);
}

.scenario-card:focus-visible {
  outline: 3px solid rgba(200, 164, 75, 0.3);
  outline-offset: 2px;
}

.scenario-card > span {
  color: var(--teal);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 750;
}

.scenario-card > strong,
.scenario-card > p,
.scenario-card > small {
  font-size: 11px;
  line-height: 1.55;
}

.scenario-card > strong {
  color: var(--ink);
}

.scenario-card > p {
  color: var(--muted);
}

.scenario-card > small {
  margin-top: auto;
  color: var(--teal);
  font-weight: 720;
}

.gap-grid {
  margin: 0 16px 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.gap-grid article {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  display: grid;
  gap: 5px;
}

.gap-grid article > strong {
  color: var(--ink);
  font-size: 12px;
}

.gap-grid article > p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.action-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 2px solid var(--gold-line);
  border-radius: var(--radius);
  background: var(--panel);
  display: grid;
  gap: 7px;
}

.action-card > span {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.action-card > strong {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.4;
}

.action-card > p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.priority-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.priority-list h3 {
  margin-bottom: 2px;
  font-size: 14px;
}

.priority-item {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
}

.priority-item > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.priority-item strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.priority-item span {
  color: var(--muted);
  font-size: 11px;
}

.level-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px rgba(154, 153, 143, 0.14);
}

.level-dot.red {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.13);
}

.level-dot.yellow {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(168, 100, 5, 0.14);
}

.level-badge {
  min-height: 23px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 760;
  line-height: 1;
}

.level-badge.red {
  border-color: rgba(180, 35, 24, 0.24);
  background: var(--red-soft);
  color: var(--red);
}

.level-badge.yellow {
  border-color: rgba(168, 100, 5, 0.26);
  background: var(--amber-soft);
  color: var(--amber);
}

.drill-banner {
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--gold-line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  background: var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drill-banner > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.drill-banner strong {
  font-size: 12px;
}

.drill-banner span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drill-card {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.drill-card > div {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.drill-card p,
.drill-card small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.drill-window {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--gold);
  background: var(--gold-soft);
  color: var(--muted);
  font-size: 11px;
}

.button.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
}

.button.wide {
  width: 100%;
}

.table-wrap.alert-editor {
  padding: 0;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  display: block;
  background: var(--panel);
  overflow: auto;
}

.alert-editor table {
  min-width: 980px;
}

.alert-editor th:nth-child(1) { min-width: 138px; }
.alert-editor th:nth-child(2) { min-width: 260px; }
.alert-editor th:nth-child(3) { min-width: 120px; }
.alert-editor th:nth-child(4) { min-width: 130px; }
.alert-editor th:nth-child(5) { min-width: 210px; }

.alert-editor td > strong,
.alert-editor td > span {
  display: block;
}

.alert-editor td > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.alert-editor input,
.alert-editor select {
  min-width: 118px;
  min-height: 34px;
  font-size: 12px;
}

.panel-actions > span {
  color: var(--muted);
  font-size: 11px;
}

.stacked-bars {
  min-width: 0;
  display: grid;
  gap: 11px;
}

.stacked-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(88px, 0.34fr) minmax(160px, 1fr) 44px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.stacked-row > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stacked-row > div {
  height: 13px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--panel-tint);
  display: flex;
}

.stacked-row > div > i {
  min-width: 0;
  height: 100%;
  display: block;
}

.stacked-row > strong {
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
}

.heatmap-grid {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 2px 2px 8px;
  grid-template-columns: 84px repeat(6, minmax(64px, 1fr));
  align-items: stretch;
}

.heatmap-scroll {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.heatmap-corner,
.heatmap-axis {
  min-width: 0;
  min-height: 34px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.heatmap-axis.top {
  border-bottom: 1px solid var(--gold-line);
  color: var(--gold);
}

.heatmap-axis.side {
  justify-items: end;
  padding-right: 10px;
  border-right: 1px solid var(--gold-line);
  color: var(--ink);
}

.heatmap-cell {
  min-width: 60px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.heatmap-cell:hover {
  z-index: 1;
  border-color: var(--gold-bright);
  transform: translateY(-1px);
}

.heatmap-cell.selected {
  z-index: 2;
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--gold);
}

.heatmap-cell > strong,
.heatmap-cell > span {
  display: block;
  line-height: 1.2;
}

.heatmap-cell > span {
  margin-top: 3px;
  font-size: 9px;
  opacity: 0.78;
}

.toggle-control {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-control > span {
  position: relative;
  width: 34px;
  height: 19px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--panel-tint);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.toggle-control > span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(20, 32, 26, 0.24);
  transition: transform 0.18s ease;
}

.toggle-control input:checked + span {
  border-color: var(--teal);
  background: var(--teal);
}

.toggle-control input:checked + span::after {
  transform: translateX(15px);
}

.toggle-control input:focus-visible + span {
  outline: 3px solid rgba(36, 82, 63, 0.2);
  outline-offset: 2px;
}

.benchmark-toggle {
  margin-bottom: 12px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.selection-summary {
  margin: 2px 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  background: var(--gold-soft);
  color: var(--muted);
  font-size: 12px;
}

.selection-summary strong {
  color: var(--ink);
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.mini-metrics article {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  display: grid;
  gap: 6px;
}

.mini-metrics article > span {
  color: var(--muted);
  font-size: 11px;
}

.mini-metrics article > strong {
  font-family: var(--font-serif);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.insight.normal,
.insight.risk,
.insight.warn {
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
}

.insight.normal::before,
.insight.risk::before,
.insight.warn::before {
  content: none;
}

.insight-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 700;
}

.insight p {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.insight p strong {
  color: var(--ink);
}

.insight.risk {
  border-color: rgba(180, 35, 24, 0.27);
  background: linear-gradient(135deg, var(--red-soft), var(--panel));
}

.insight.risk .insight-mark {
  background: var(--red);
}

.insight.warn {
  border-color: rgba(168, 100, 5, 0.28);
  background: linear-gradient(135deg, var(--amber-soft), var(--panel));
}

.insight.warn .insight-mark {
  background: var(--amber);
}

.success-box,
.warning-box {
  padding: 11px 13px;
  border: 1px solid rgba(34, 113, 79, 0.24);
  border-radius: var(--radius);
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
}

.warning-box {
  border-color: rgba(168, 100, 5, 0.27);
  background: var(--amber-soft);
  color: var(--amber);
}

.context-chip.success {
  border-color: rgba(34, 113, 79, 0.24);
  background: var(--green-soft);
  color: var(--green);
}

.context-chip.warning {
  border-color: rgba(168, 100, 5, 0.26);
  background: var(--amber-soft);
  color: var(--amber);
}

.details-panel {
  padding: 0;
}

.details-panel > summary {
  padding: 13px 16px;
}

.details-panel > .table-wrap {
  margin: 0 16px 16px;
  width: calc(100% - 32px);
}

.details-panel > .caption,
.details-panel > .detail-copy {
  margin: 0 16px 16px;
}

.inline-details {
  margin-top: 12px;
  background: rgba(255, 254, 251, 0.72);
}

.inline-details > .table-wrap {
  margin: 0 12px 12px;
  width: calc(100% - 24px);
}

.data-note {
  border-style: dashed;
  border-color: var(--line-strong);
  background: rgba(250, 248, 241, 0.72);
}

.data-note summary {
  min-height: 40px;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 11px;
}

.data-note > p {
  padding: 11px 12px 13px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.caption,
.detail-copy {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.report-preview {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 44px);
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.report-preview > header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--gold-line);
}

.report-preview > header > span {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.report-preview > header h2 {
  margin-top: 8px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.3;
}

.report-preview > header p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.report-preview > section {
  padding: 19px 0;
  border-bottom: 1px solid var(--line);
}

.report-preview > section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.report-preview > section h3 {
  margin-bottom: 9px;
  color: var(--teal);
  font-size: 15px;
}

.report-preview ul,
.report-preview ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  display: grid;
  gap: 7px;
}

.report-preview li,
.report-preview section > p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.report-preview strong {
  color: var(--ink);
}

/* ---------- Entry animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  animation: rise 1.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.reveal.d1 { animation-delay: 0.08s; }
.reveal.d2 { animation-delay: 0.2s; }
.reveal.d3 { animation-delay: 0.32s; }
.reveal.d4 { animation-delay: 0.44s; }

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .metric-grid,
  .metric-strip,
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2,
  .two-col {
    grid-template-columns: 1fr;
  }

  .content-grid.two-col,
  .content-grid.split-main {
    grid-template-columns: 1fr;
  }

  .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3,
  .three-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brief-grid,
  .scenario-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-control {
    min-width: 220px;
  }
}

@media (max-width: 980px) {
  .workspace {
    padding-right: 24px;
    padding-left: 24px;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .control,
  .product-control {
    min-width: 180px;
    flex: 1 1 180px;
  }

  .filter-panel.compact {
    width: 100%;
  }
}

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

  .sidebar {
    position: static;
    z-index: auto;
    width: auto;
    height: auto;
    padding: 20px 16px;
    overflow: visible;
    box-shadow: none;
    transform: none;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-note {
    display: none;
  }

  .workspace {
    padding: 20px 16px 32px;
  }

  .management-brief > header {
    display: grid;
  }

  .management-brief > header > p {
    max-width: 70ch;
    text-align: left;
  }

  .context-bar {
    align-items: flex-start;
  }

  .context-main {
    display: grid;
    gap: 3px;
  }

  .context-main strong {
    white-space: normal;
  }

  .filter-panel {
    align-items: stretch;
  }

  .filter-panel .control,
  .filter-panel.compact .control {
    min-width: min(220px, 100%);
    flex: 1 1 220px;
  }

  .drill-banner {
    align-items: flex-start;
  }
}

@media (max-width: 620px) {
  .topbar {
    gap: 16px;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .control,
  .product-control {
    min-width: 0;
  }

  .product-control {
    grid-column: 1 / -1;
  }

  .reset-button {
    width: 100%;
    grid-column: 1 / -1;
  }

  .context-bar {
    display: grid;
  }

  .context-meta {
    justify-content: flex-start;
  }

  .metric-grid,
  .metric-strip,
  .kpi-grid,
  .brief-grid,
  .scenario-grid,
  .gap-grid,
  .grid-3,
  .three-col,
  .grid-2.equal,
  .two-col.equal,
  .form-grid,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .section,
  .card {
    padding: 16px;
  }

  .details-panel {
    padding: 0;
  }

  .management-brief {
    padding: 16px;
  }

  .brief-grid article {
    min-height: 0;
  }

  .scenario-card {
    min-height: 0;
  }

  .gap-grid {
    margin: 0 12px 12px;
  }

  .panel-head,
  .section-head,
  .section-header,
  .card-head {
    display: grid;
  }

  .panel-actions,
  .section-actions,
  .toolbar {
    justify-content: flex-start;
  }

  .filter-panel,
  .filter-panel.compact {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .filter-panel .control,
  .filter-panel.compact .control,
  .check-control,
  .inline-control,
  .multiselect-control {
    width: 100%;
    min-width: 0;
  }

  .segmented {
    width: 100%;
    border-radius: var(--radius);
  }

  .segmented button {
    flex: 1 1 0;
  }

  .action-grid,
  .mini-metrics {
    grid-template-columns: 1fr;
  }

  .hbar-row {
    grid-template-columns: minmax(94px, 0.55fr) minmax(90px, 1fr) auto;
    gap: 7px;
  }

  .stacked-row {
    grid-template-columns: minmax(78px, 0.44fr) minmax(100px, 1fr) 38px;
    gap: 7px;
  }

  .drill-banner,
  .drill-card {
    display: grid;
  }

  .drill-banner .button,
  .drill-card .button {
    width: 100%;
  }

  .priority-item strong,
  .drill-banner span {
    white-space: normal;
  }

  .report-preview {
    padding: 21px 17px;
  }

  .details-panel > .table-wrap,
  .details-panel > .caption,
  .details-panel > .detail-copy {
    margin-right: 12px;
    margin-left: 12px;
  }

  .details-panel > .table-wrap {
    width: calc(100% - 24px);
  }

  .chart-wrap,
  .svg-chart {
    min-height: 0;
    padding-right: 0;
    padding-left: 0;
    overflow-x: hidden;
  }

  .chart svg,
  .chart-wrap svg,
  .svg-chart svg,
  .chart-svg {
    min-width: 0;
  }

  .chart-axis,
  .chart-axis-title,
  .chart-label {
    font-size: 12px;
  }

  .chart-value {
    font-size: 11px;
  }

  .chart-legend {
    gap: 9px 11px;
    line-height: 1.45;
  }

  .channel-type-legend {
    align-items: flex-start;
  }

  .table-wrap,
  .table-scroll,
  .heatmap-scroll {
    touch-action: pan-x pan-y;
  }

  table {
    min-width: 620px;
  }

  th,
  td {
    padding: 9px 10px;
  }

  .heatmap-grid {
    min-width: 318px;
    grid-template-columns: 54px repeat(6, minmax(42px, 1fr));
    gap: 2px;
  }

  .heatmap-cell {
    min-width: 0;
    min-height: 48px;
    padding: 3px;
    font-size: 10px;
  }

  .heatmap-axis.side {
    position: sticky;
    left: 0;
    z-index: 2;
    padding-right: 5px;
    background: var(--panel);
  }

  .heatmap-corner {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--panel);
  }

  .alert-editor table,
  .alert-editor tbody,
  .alert-editor tr,
  .alert-editor td {
    width: 100%;
    min-width: 0;
    display: block;
  }

  .alert-editor thead {
    display: none;
  }

  .alert-editor tbody {
    padding: 11px;
    display: grid;
    gap: 11px;
  }

  .alert-editor tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-left: 3px solid var(--gold);
    border-radius: var(--radius);
    background: var(--panel);
  }

  .alert-editor td {
    padding: 10px 11px;
    border-bottom: 1px solid var(--line);
  }

  .alert-editor td:last-child {
    border-bottom: 0;
  }

  .alert-editor td::before {
    content: attr(data-label);
    margin-bottom: 5px;
    display: block;
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .alert-editor input,
  .alert-editor select {
    width: 100%;
    min-width: 0;
    font-size: 16px;
  }

  .nav-item,
  .site-links a,
  .button,
  .reset-button,
  .tab-button,
  .segmented button,
  .toggle-control,
  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="date"],
  select {
    min-height: 44px;
  }

  .button.small {
    min-height: 44px;
  }

  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px;
  }

  .bar-row {
    grid-template-columns: minmax(76px, 0.5fr) minmax(90px, 1fr) auto;
    gap: 7px;
  }

  .toast {
    right: 16px;
    bottom: 16px;
    left: 16px;
    max-width: none;
  }
}

@media (max-width: 520px) {
  .nav-list {
    grid-template-columns: 1fr;
  }

  .top-actions {
    grid-template-columns: 1fr;
  }

  .product-control {
    grid-column: auto;
  }

  .reset-button {
    grid-column: auto;
  }
}

@media (max-width: 420px) {
  .workspace {
    padding-right: 12px;
    padding-left: 12px;
  }

  .panel,
  .section,
  .card {
    padding: 14px;
  }

  .details-panel {
    padding: 0;
  }

  .management-brief {
    padding: 14px;
  }

  .site-links a {
    min-height: 44px;
  }

  .hbar-row,
  .stacked-row {
    grid-template-columns: 1fr auto;
  }

  .hbar-track,
  .stacked-row > div {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .hbar-row > strong,
  .stacked-row > strong {
    grid-column: 2;
    grid-row: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
