:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #e8ecf1;
  --text: #111827;
  --text-muted: #4b5563;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --green: #047857;
  --red: #b91c1c;
  --amber: #b45309;
  --border: #d1d5db;
  --section: #d4e3f3;
  --subtotal: #d1fae5;
  --driver: #fef9c3;
  --radius: 8px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "Consolas", "Liberation Mono", monospace;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

html {
  color-scheme: light;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.logo {
  width: 36px;
  height: 36px;
  display: block;
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.22);
}

.topbar h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #111827;
}

.subtitle {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modes {
  display: flex;
  gap: 2px;
  background: var(--surface-3);
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.modes button {
  background: transparent;
  border: none;
  color: #4b5563;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

.modes button.active {
  background: #fff;
  color: #2563eb;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.modes button:hover:not(.active) {
  color: #111827;
  background: #fff;
}

.plan-years {
  display: flex;
  gap: 2px;
  background: var(--surface-3);
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.plan-years[hidden] {
  display: none !important;
}

.plan-years button {
  background: transparent;
  border: none;
  color: #4b5563;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
}

.plan-years button.active {
  background: #fff;
  color: #2563eb;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.plan-years button:hover:not(.active) {
  color: #111827;
  background: #fff;
}

.plan-sheets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
}

.plan-sheets[hidden] {
  display: none !important;
}

.plan-sheets button {
  background: transparent;
  border: none;
  color: #92400e;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
}

.plan-sheets button.active {
  background: #f59e0b;
  color: #111827;
  box-shadow: var(--shadow-sm);
}

.plan-editor-lead {
  padding: 0.7rem 0.9rem;
  background: #fffbeb;
  border-bottom: 2px solid #f59e0b;
  color: #78350f;
  font-size: 0.92rem;
  line-height: 1.4;
  flex-shrink: 0;
}

.plan-editor-lead[hidden] {
  display: none !important;
}

.funnel-why {
  padding: 0.75rem 0.95rem;
  background: #eef4ff;
  border-bottom: 3px solid #2563eb;
  color: #1e3a8a;
  font-size: 0.92rem;
  line-height: 1.45;
  flex-shrink: 0;
}
.funnel-why strong {
  color: #1d4ed8;
}
.funnel-why[hidden] {
  display: none !important;
}

.sku-row-actions {
  display: inline-flex;
  gap: 0.25rem;
  margin-left: 0.45rem;
}
.sku-row-actions button {
  appearance: none;
  border: 1px solid #93c5fd;
  background: #fff;
  color: #1d4ed8;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
}
.sku-row-actions button:hover {
  background: #dbeafe;
}
.sku-warn {
  margin-left: 0.4rem;
  color: #b45309;
  font-size: 0.75rem;
  font-weight: 650;
}
.sku-add-link {
  color: #1d4ed8;
  font-weight: 650;
  cursor: pointer;
}

.plan-help-dock {
  flex-shrink: 0;
  border-top: 1px solid #c5d4e3;
  background: #f8fafc;
  max-height: 42vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.plan-help-dock[hidden] {
  display: none !important;
}
.plan-help-dock-toggle {
  appearance: none;
  border: 0;
  background: #eef2ff;
  color: #1e3a8a;
  font: inherit;
  font-weight: 650;
  text-align: left;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid #c7d2fe;
}
.plan-help-dock-toggle:hover {
  background: #e0e7ff;
}
.plan-help-dock-body {
  overflow-y: auto;
  padding: 0.65rem 1rem 1rem;
  min-height: 0;
}
.plan-help-dock-body[hidden] {
  display: none !important;
}
.plan-guide h2,
.plan-hint-lexicon h2 {
  margin: 0.2rem 0 0.45rem;
  font-size: 0.95rem;
}
.plan-guide-lead,
.plan-hint-short {
  margin: 0 0 0.35rem;
  color: #4b5563;
  font-size: 0.86rem;
}
.plan-guide-list {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #1f2937;
}
.plan-guide-list li {
  margin: 0.35rem 0;
}
.plan-hint-dl {
  display: grid;
  gap: 0.65rem;
}
.plan-hint-item {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}
.plan-hint-item dt {
  font-weight: 650;
  font-size: 0.9rem;
  color: #111827;
}
.plan-hint-item dd {
  margin: 0.25rem 0 0;
  font-size: 0.86rem;
  line-height: 1.4;
  color: #374151;
}
.plan-hint-item dd p {
  margin: 0.2rem 0 0;
}

.plan-intro-list {
  margin: 0.4rem 0 0.2rem;
  padding-left: 1.1rem;
  color: #374151;
  font-size: 0.86rem;
  line-height: 1.45;
}

.badge-edit {
  flex-shrink: 0;
  background: #f59e0b;
  color: #111827;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.layout-modes {
  display: flex;
  gap: 2px;
  background: var(--surface-3);
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.layout-modes[hidden] {
  display: none !important;
}

.layout-modes button {
  background: transparent;
  border: none;
  color: #4b5563;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
}

.layout-modes button.active {
  background: #fff;
  color: #111827;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.period-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #4b5563;
}

.period-bar input[type="month"] {
  background: #fff;
  border: 1px solid var(--border);
  color: #111827;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-family: inherit;
}

.period-bar label {
  font-weight: 500;
  color: #374151;
}

.tool-btn {
  background: #fff;
  border: 1px solid var(--border);
  color: #4b5563;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
}

.tool-btn:hover {
  color: #111827;
  border-color: #2563eb;
  background: var(--accent-soft);
}

#btn-period,
.tool-btn-apply {
  background: #1d4ed8;
  color: #fff;
  border-color: #1e40af;
  font-weight: 650;
  padding: 0.4rem 0.95rem;
  box-shadow: 0 1px 2px rgba(29, 78, 216, 0.35);
}

#btn-period:hover,
.tool-btn-apply:hover {
  background: #1e40af;
  color: #fff;
  border-color: #1e3a8a;
}

.toolbar {
  display: flex;
  gap: 0.35rem;
}

.plan-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.plan-toolbar[hidden] {
  display: none !important;
}

.plan-compare-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.25rem 0;
}

.plan-compare-bar[hidden] {
  display: none !important;
}

.plan-compare-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1f4e79;
}

#plan-compare-a,
#plan-compare-b {
  max-width: 240px;
  font-size: 0.8rem;
}

body.page-finmodel .kpi-group .kpi-compare {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #4b5563;
  margin-top: 0.1rem;
}

body.mode-plan .sheet-opt-check:has(#plan-funnel) {
  display: none !important;
}

#plan-variant {
  max-width: 220px;
  font-size: 0.8rem;
}

.status {
  margin-left: auto;
  color: #6b7280;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ── KPI ── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  padding: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.kpi-card {
  background: #fff;
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 0.7rem 1.1rem;
}

.kpi-card:last-child {
  border-right: none;
}

.kpi-card .kpi-label {
  font-size: 0.7rem;
  color: #6b7280;
  margin-bottom: 0.15rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.kpi-card .kpi-value {
  font-size: 1.15rem;
  font-weight: 650;
  font-family: var(--mono);
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.kpi-card.is-neg .kpi-value {
  color: #b91c1c;
}

@media (max-width: 1100px) {
  .kpi-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .kpi-card:nth-child(3) {
    border-right: none;
  }
}

/* ── Legend ── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.45rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: #6b7280;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid #d1d5db;
}

.swatch-driver { background: #fef9c3; }
.swatch-subtotal { background: #d1fae5; }
.swatch-section { background: #d4e3f3; }

/* ── Grid container ── */
.grid {
  height: auto;
  width: 100%;
}

html:has(body.page-finmodel) {
  height: auto;
  min-height: 100%;
  overflow-y: auto;
}

body.page-finmodel {
  --fm-gutter: 0.45rem;
  --fm-label-w: 22rem;
  --fm-scale: 1;
  height: auto;
  max-height: none;
  min-height: 100dvh;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: var(--fm-gutter);
  box-sizing: border-box;
  background: #e8edf3;
}

body.page-finmodel .site-foot {
  display: none !important;
}

body.page-finmodel .app-nav {
  flex-shrink: 0;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

body.page-finmodel .topbar {
  border: none;
  border-bottom: 1px solid #c5d4e3;
  box-shadow: none;
  flex-shrink: 0;
  padding: 0.4rem 0.7rem;
  row-gap: 0.35rem;
}

body.page-finmodel .kpi-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.55rem 0.85rem;
  background: #cfe2f3;
  border-bottom: 1px solid #9fc5e8;
  flex-shrink: 0;
}

body.page-finmodel .kpi-values {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  flex: 1;
  min-width: 0;
}

body.page-finmodel .period-badge {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 16rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.25;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

body.page-finmodel .period-badge strong {
  font-size: 1.02rem;
  font-weight: 700;
}

body.page-finmodel .period-badge span {
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0.92;
}

body.page-finmodel .period-badge.is-closed {
  background: #14532d;
}

body.page-finmodel .period-badge.is-preview {
  background: #9a3412;
}

body.page-finmodel .kpi-card,
body.page-finmodel .kpi-group {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  min-width: 0;
}

body.page-finmodel .kpi-label {
  font-size: 0.75rem;
  color: #1f4e79;
  margin-bottom: 0.1rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

body.page-finmodel .kpi-value {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  color: #111827;
  font-variant-numeric: tabular-nums;
}

body.page-finmodel .kpi-sub {
  font-size: 0.85rem;
  font-weight: 500;
  color: #4b5563;
  margin-left: 0.35rem;
}

body.page-finmodel .kpi-group.is-neg .kpi-value {
  color: #b91c1c;
}

.finmodel-sheet {
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #c5d4e3;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: visible;
}

body.page-finmodel .grid {
  flex: 0 0 auto;
  min-height: 0;
  height: auto;
}

.grid-stage {
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: visible;
}

.grid-fs-bar {
  display: none;
}

body.grid-is-fs {
  overflow: hidden;
  height: 100dvh;
  max-height: 100dvh;
}

body.grid-is-fs .finmodel-sheet {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

body.grid-is-fs .grid-stage {
  position: fixed;
  inset: 0;
  z-index: 2400;
  background: #fff;
  padding: 0;
  border: none;
  border-radius: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

body.grid-is-fs .grid-fs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 0.5rem 1rem 0.5rem 1.25rem;
  background: #1f4e79;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  box-sizing: border-box;
}

body.grid-is-fs .grid-fs-bar[hidden] {
  display: flex !important;
}

body.grid-is-fs .grid-fs-bar .tool-btn {
  background: #fff;
  color: #1f4e79;
}

body.grid-is-fs #grid {
  flex: 1 1 auto;
  min-height: 0;
  height: 100% !important;
}

.sheet-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: #4b5563;
  white-space: nowrap;
}

.sheet-opt select {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  padding: 0.28rem 0.4rem;
  color: #111827;
}

.sheet-opt-check {
  cursor: pointer;
  user-select: none;
}

.sheet-opt-check input {
  margin: 0;
}

body.page-finmodel.has-banner .grid,
body.page-finmodel.no-kpi .grid {
  height: auto;
}

.fact-banner {
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fact-banner.warn {
  background: #fffbeb;
  color: #92400e;
}

.fact-banner.ok {
  background: #ecfdf5;
  color: #047857;
}

/* Label cell renderer */
.cell-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow: hidden;
  color: inherit;
  min-width: 0;
}

.cell-label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.cell-label.is-section {
  padding-left: 2px;
}

.cell-label.is-sub {
  padding-left: 10px;
  cursor: pointer;
}

.cell-label.is-sub .chevron.is-empty {
  cursor: default;
}

.cell-label.is-sub.is-nested {
  padding-left: 22px;
}

.cell-label.is-sub.is-nested-2 {
  padding-left: 34px;
}

.cell-label.is-divider {
  padding-left: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.cell-label.is-total-sub .cell-label-text {
  font-weight: 600;
  color: #1c1917;
}

.cell-label .chevron {
  flex-shrink: 0;
  width: 16px;
  color: inherit;
  font-size: 0.9rem;
  line-height: 1;
}

.cell-label .indent {
  flex-shrink: 0;
  display: inline-block;
}

.insights {
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.insights-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.85rem;
  background: #f6f7f9;
}

.insights-toggle {
  border: none;
  background: transparent;
  color: #1f4e79;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0;
}

.insights-toggle .chevron {
  width: 14px;
  text-align: center;
  font-weight: 600;
}

.insights-hint {
  color: #6b7280;
  font-size: 0.75rem;
}

.insights-filter-btn {
  margin-left: auto;
}

.insights-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  padding: 0.4rem 0.85rem 0.5rem;
  border-top: 1px solid #e5e7eb;
  background: #fafbfc;
}

.insights-filters[hidden],
.insights-body[hidden],
.insights[hidden] {
  display: none !important;
}

.insights-filters label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: #1f4e79;
  cursor: pointer;
  white-space: nowrap;
}

.insights-body {
  overflow: auto;
  max-height: 240px;
  border-top: 1px solid #e5e7eb;
}

.insights-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.insights-table th,
.insights-table td {
  border-right: 1px solid #c5d4e3;
  border-bottom: 1px solid #c5d4e3;
  padding: 0.22rem 0.45rem;
  vertical-align: middle;
  background: #fff;
}

.insights-table th:first-child,
.insights-table td:first-child {
  border-left: none;
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  width: 16rem;
  min-width: 14rem;
}

.insights-table thead th {
  background: #cfe2f3;
  color: #1f4e79;
  font-weight: 600;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
}

.insights-table thead th:first-child {
  z-index: 3;
  text-align: left;
}

.insights-table .col-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  min-width: 0;
  width: auto;
}

.insights-table tbody tr:nth-child(even) td {
  background: #f8fbfd;
}

.insights-table tbody tr:nth-child(even) td:first-child {
  background: #f8fbfd;
}

.insights-table tr.is-desired td {
  background: #fffbeb !important;
}

.insights-table tr.is-min td {
  background: #fde8e8 !important;
  font-weight: 600;
}

.insights-table td.is-neg {
  color: #b91c1c;
}

.insights-table .col-total {
  background: #eef6fc !important;
  font-weight: 600;
}

.insights-table tr.is-desired td.col-total,
.insights-table tr.is-min td.col-total {
  filter: brightness(0.97);
}

.insights-table input.insights-input.is-bad {
  border-color: #b91c1c;
  background: #fef2f2;
}

.cell-label.is-sub.is-leaf {
  cursor: default;
}

.insights-table .cell-note {
  color: #6b7280;
  font-size: 0.72rem;
  font-weight: 400;
  margin-left: 0.35rem;
}

.fm-metric-tip {
  position: fixed;
  z-index: 40;
  min-width: 220px;
  max-width: 340px;
  padding: 8px 10px 9px;
  border: 1px solid #9fc5e8;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(31, 78, 121, 0.16);
  color: #111827;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
}

.fm-metric-tip .tip-head {
  margin-bottom: 6px;
  color: #1f4e79;
  font-weight: 600;
  font-size: 11px;
  text-transform: capitalize;
}

.fm-metric-tip .tip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.fm-metric-tip .tip-row + .tip-row {
  margin-top: 3px;
}

.fm-metric-tip .tip-lab {
  color: #4b5563;
  min-width: 0;
}

.fm-metric-tip .tip-val {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.fm-metric-tip .tip-pct {
  margin-left: 6px;
  color: #6b7280;
  font-weight: 500;
  font-size: 10px;
}

.fm-metric-tip .tip-pct.is-neg {
  color: #b91c1c;
}

.fm-metric-tip .tip-pct.is-better,
.fm-metric-tip .tip-val.is-better {
  color: #047857;
}

.fm-metric-tip .tip-pct.is-worse,
.fm-metric-tip .tip-val.is-worse {
  color: #b91c1c;
}

.fm-metric-tip .tip-hint {
  margin-top: 6px;
  color: #6b7280;
  font-size: 11px;
  line-height: 1.35;
}

.plan-dialog {
  width: min(420px, 92vw);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: #fff;
  color: #111827;
}
.plan-dialog::backdrop {
  background: rgba(17, 24, 39, 0.35);
}
.plan-dialog h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}
.plan-dialog h4 {
  margin: 1rem 0 0.35rem;
  font-size: 0.85rem;
}
.plan-dialog form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.plan-dialog label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: #374151;
}
.plan-dialog label[hidden] {
  display: none !important;
}
.plan-dialog input,
.plan-dialog select {
  font: inherit;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.plan-dialog .muted {
  margin: 0;
  color: #6b7280;
  font-size: 0.78rem;
  line-height: 1.35;
}
.wiz-warn {
  margin: 0;
  padding: 0.45rem 0.6rem;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  font-size: 0.8rem;
  line-height: 1.35;
}
.wiz-warn[hidden],
.fot-choice[hidden] {
  display: none !important;
}
.plan-dialog .fot-choice {
  margin: 0;
  padding: 0.5rem 0.65rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.plan-dialog .fot-choice legend {
  padding: 0 0.3rem;
  font-size: 0.8rem;
  font-weight: 650;
  color: #111827;
}
.plan-dialog .fot-choice-opt {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.35;
  cursor: pointer;
}
.plan-dialog .fot-choice-opt input {
  margin: 0.15rem 0 0;
  padding: 0;
  flex-shrink: 0;
}
.plan-dialog .fot-choice-opt strong {
  color: #111827;
}
.wiz-range {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.plan-dialog .dialog-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.3rem;
}
.plan-inst-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 180px;
  overflow: auto;
}
.plan-inst-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.metrics-fact { padding: 8px 16px 24px; }
.metrics-fact-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.metrics-fact .seg { display: inline-flex; border: 1px solid var(--line, #d6dbe3); border-radius: 8px; overflow: hidden; }
.metrics-fact .seg button { border: 0; background: #fff; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: #344054; }
.metrics-fact .seg button + button { border-left: 1px solid var(--line, #d6dbe3); }
.metrics-fact .seg button.active { background: #1f3b64; color: #fff; }
.metrics-sync-status { font-size: 12px; }
.metrics-notes { background: #fff7e6; border: 1px solid #f3d38a; border-radius: 8px; padding: 6px 12px; margin-bottom: 10px; font-size: 13px; }
.metrics-notes p { margin: 3px 0; }
.metrics-table-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line, #d6dbe3); border-radius: 8px; background: #fff; }
.metrics-table { border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; width: max-content; min-width: 100%; }
.metrics-table th, .metrics-table td { padding: 5px 10px; border-bottom: 1px solid #eef0f4; text-align: right; white-space: nowrap; min-width: 84px; }
.metrics-table thead th { position: sticky; top: 0; z-index: 2; background: #f5f7fa; font-weight: 600; color: #475467; }
.metrics-table .mt-label { position: sticky; left: 0; z-index: 1; background: #fff; text-align: left; min-width: 300px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.metrics-table thead .mt-label { z-index: 3; background: #f5f7fa; }
.metrics-table .mt-total { background: #f8fafc; font-weight: 600; }
.metrics-table tr.mt-block { cursor: pointer; }
.metrics-table tr.mt-block th, .metrics-table tr.mt-block td { font-weight: 600; background: #f0f4fa; }
.metrics-table tr.mt-cab th, .metrics-table tr.mt-cab td { background: #e3ebf7; color: #1f3b64; }
.metrics-table tr.mt-block .chevron { display: inline-block; width: 14px; color: #667085; }
.metrics-table .mt-sub { font-weight: 400; color: #667085; font-size: 12px; margin-left: 6px; }
.metrics-table tr.mt-row .mt-label { padding-left: 30px; color: #344054; }
.metrics-table tr.mt-pct td { color: #475467; }
.metrics-dialog { width: min(980px, 96vw); }
.metrics-dialog .md-sec { border-top: 1px solid #eef0f4; padding-top: 10px; margin-top: 10px; }
.metrics-dialog .md-sec:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.metrics-dialog h4 { margin: 0 0 6px; font-size: 15px; }
.metrics-dialog .md-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 6px 0; }
.metrics-dialog .md-help { font-size: 12px; margin: 6px 0; }
.metrics-dialog .md-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.metrics-dialog .md-table th, .metrics-dialog .md-table td { padding: 4px 8px; border-bottom: 1px solid #eef0f4; text-align: left; }
.metrics-dialog .md-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.metrics-dialog .md-table input { width: 80px; }
.ag-theme-quartz .cell-rate-auto { color: #667085; font-style: italic; }
body.metrics-fact-mode .mf-hide { display: none !important; }
.metrics-ladder-hint { margin: 12px 4px 0; color: #57534e; font-size: 0.88rem; }
.metrics-ladder-head { margin: 48px 0 12px; padding: 14px 18px; border-top: 3px solid #1f4e79; background: #fff; border-radius: 10px; }
.metrics-ladder-head h2 { margin: 0 0 4px; font-size: 1.1rem; color: #1f4e79; }
.metrics-ladder-head p { margin: 0; color: #57534e; font-size: 0.88rem; }
