:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --topbar: rgba(245, 243, 238, 0.94);
  --paper: #ffffff;
  --paper-soft: #fbfaf6;
  --card: #ffffff;
  --card-soft: #fbfaf6;
  --ink: #1f2428;
  --muted: rgba(31, 36, 40, 0.72);
  --line: rgba(132, 92, 255, 0.16);
  --purple: #845cff;
  --purple-deep: #6f4de2;
  --green-soft: #edf8ef;
  --pink: #ff2d8e;
  --cyan: #aff3f3;
  --teal: #0a9fa8;
  --teal-soft: #e6fbfb;
  --amber: #f7bc37;
  --amber-soft: #fff6d9;
  --active-soft: #f0ebff;
  --info-soft: #eefdfc;
  --risk-soft: #fff0f4;
  --callout-bg: #1f2428;
  --callout-ink: #f5f3ee;
  --tooltip-bg: #1f2428;
  --tooltip-ink: #f5f3ee;
  --chart-grid: rgba(31, 36, 40, 0.12);
  --chart-axis: rgba(31, 36, 40, 0.38);
  --overlay-label-stroke: rgba(255, 255, 255, 0.84);
  --active-ink: #ffffff;
  --blue: #845cff;
  --rose: #ff2d8e;
  --green: #6cbf18;
  --shadow: 0 18px 34px rgba(31, 36, 40, 0.06), 0 8px 18px rgba(132, 92, 255, 0.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1214;
  --topbar: rgba(15, 18, 20, 0.94);
  --paper: #171b1e;
  --paper-soft: #121619;
  --card: #1d2226;
  --card-soft: #171d20;
  --ink: #e8eeea;
  --muted: rgba(232, 238, 234, 0.72);
  --line: rgba(132, 92, 255, 0.28);
  --green-soft: #14251a;
  --amber-soft: #33270d;
  --active-soft: #27223a;
  --info-soft: #112a2c;
  --risk-soft: #341621;
  --callout-bg: #dfe8e2;
  --callout-ink: #111416;
  --tooltip-bg: #e8eeea;
  --tooltip-ink: #111416;
  --chart-grid: rgba(232, 238, 234, 0.14);
  --chart-axis: rgba(232, 238, 234, 0.38);
  --overlay-label-stroke: rgba(15, 18, 20, 0.86);
  --active-ink: #ffffff;
  --shadow: 0 18px 34px rgba(0, 0, 0, 0.26), 0 8px 18px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

html {
  scroll-behavior: smooth;
}

[id] {
  scroll-margin-top: 150px;
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
}

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--purple);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 2px solid var(--purple);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1;
  background: var(--paper);
  white-space: nowrap;
  word-break: keep-all;
}

.brand-mark span {
  display: block;
  white-space: nowrap;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p {
  color: var(--muted);
  max-width: 850px;
  margin-top: 4px;
  line-height: 1.45;
}

.section-note {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.45;
}

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

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.main-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 800;
  padding: 9px 10px;
  border-radius: 6px;
}

.main-nav a:hover,
.main-nav a:focus {
  color: var(--ink);
  background: rgba(132, 92, 255, 0.08);
}

.button,
.segmented button,
.mode-option,
.theme-toggle {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  min-height: 40px;
  cursor: pointer;
}

.button {
  padding: 0 14px;
  border-radius: 6px;
}

.button.secondary:hover,
.segmented button:hover,
.mode-option:hover,
.theme-toggle:hover {
  border-color: var(--purple);
}

.theme-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  align-items: center;
  width: 70px;
  padding: 4px;
  border-radius: 999px;
}

.theme-toggle span {
  display: grid;
  place-items: center;
  min-height: 30px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

html:not([data-theme="dark"]) .theme-sun,
html[data-theme="dark"] .theme-moon {
  background: var(--purple);
  color: var(--active-ink);
}

main {
  display: grid;
  gap: 18px;
  padding: 18px clamp(14px, 3vw, 40px) 44px;
}

.band {
  width: min(1500px, 100%);
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 28px);
}

.controls-band {
  background: var(--paper-soft);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading h2,
.table-panel h2,
.source-band h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-heading p {
  color: var(--muted);
  max-width: 680px;
  line-height: 1.5;
  text-align: right;
}

.section-mini-title {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 800;
}

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

.control-group {
  display: grid;
  gap: 16px;
  align-content: start;
  --track: var(--purple);
  --track-soft: #b7a2ff;
}

.control-group:nth-child(2) {
  --track: var(--amber);
  --track-soft: #ffe18b;
}

.control-group:nth-child(3) {
  --track: var(--teal);
  --track-soft: var(--cyan);
}

.control {
  display: grid;
  gap: 8px;
}

.control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 760;
}

.help-dot {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--purple);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  cursor: help;
  vertical-align: text-top;
}

.help-dot::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  width: min(310px, 72vw);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 60;
}

.help-dot:hover::after,
.help-dot:focus::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.control-label strong {
  color: var(--track);
  white-space: nowrap;
}

.control small {
  color: var(--muted);
  line-height: 1.35;
}

.control small.derived {
  color: var(--amber);
  font-weight: 700;
}

.input-row {
  display: flex;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  min-height: 46px;
}

.input-row:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(132, 92, 255, 0.14);
}

.input-row input {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 11px 12px;
  min-width: 0;
  color: var(--ink);
}

.input-row input:focus {
  outline: 0;
}

.unit {
  color: var(--muted);
  font-weight: 800;
  padding: 0 12px;
  border-left: 1px solid var(--line);
}

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: var(--track);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 50%;
  border: 3px solid var(--paper);
  background: var(--track);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--track);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid var(--paper);
  background: var(--track);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
}

.segmented {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.segmented.compact {
  flex-wrap: nowrap;
}

.segmented button {
  border-radius: 6px;
  padding: 0 12px;
  font-weight: 800;
}

.segmented button.active {
  color: var(--active-ink);
  background: var(--purple);
  border-color: var(--purple);
}

.mode-grid {
  display: grid;
  gap: 8px;
}

.mode-option {
  text-align: left;
  padding: 12px;
  border-radius: 8px;
  display: grid;
  gap: 4px;
}

.mode-option strong {
  color: var(--ink);
}

.mode-option span {
  color: var(--muted);
  line-height: 1.35;
}

.mode-option.active {
  background: var(--active-soft);
  border-color: var(--purple);
}

.insight-band {
  background: var(--callout-bg);
  color: var(--callout-ink);
  border-color: var(--callout-bg);
}

.insight-band p {
  font-size: clamp(1.03rem, 1.8vw, 1.28rem);
  line-height: 1.5;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  min-height: 128px;
  display: grid;
  align-content: space-between;
  background: var(--card);
}

.macro-explorer-band {
  background: var(--paper-soft);
}

.macro-explorer-band .section-heading {
  align-items: start;
}

.macro-explorer-band .section-heading p {
  text-align: left;
  margin-top: 8px;
}

.macro-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
  min-width: min(520px, 100%);
}

.toggle-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.toggle-chip input {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--chip-color);
  border-radius: 50%;
  margin: 0;
}

.toggle-chip input:checked {
  background: var(--chip-color);
  box-shadow: inset 0 0 0 2px var(--card);
}

.macro-explorer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
  align-items: stretch;
}

.macro-chart-panel,
.macro-explanation,
.macro-summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.macro-chart-panel {
  padding: 14px;
}

.macro-explanation {
  padding: 18px;
  display: grid;
  gap: 12px;
  align-content: start;
  border-color: rgba(10, 159, 168, 0.28);
  background: var(--info-soft);
}

.macro-explanation h3 {
  margin: 0;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.macro-explanation p {
  color: var(--muted);
  line-height: 1.55;
}

.macro-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.macro-summary-card {
  padding: 15px;
  display: grid;
  gap: 7px;
}

.macro-summary-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.macro-summary-card strong {
  font-size: 1.45rem;
}

.macro-summary-card p {
  color: var(--muted);
  line-height: 1.4;
}

.metric span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.metric strong {
  font-size: clamp(1.1rem, 1.8vw, 1.55rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

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

.metric.highlight {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.metric.good {
  border-color: rgba(108, 191, 24, 0.32);
  background: var(--green-soft);
}

.rental-band {
  display: grid;
  gap: 18px;
  background: var(--card);
}

.area-audit-band {
  display: grid;
  gap: 18px;
  background: var(--paper-soft);
}

.area-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.plan-panel {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  padding: 12px;
  overflow: hidden;
}

.plan-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.plan-toggle {
  --chip-color: var(--purple);
}

.mini-range {
  display: inline-grid;
  gap: 4px;
  min-width: 160px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.mini-range input {
  --track: var(--purple);
  --track-soft: var(--cyan);
}

.plan-canvas {
  position: relative;
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.plan-canvas img {
  display: block;
  width: 100%;
  min-width: 720px;
  height: auto;
  transition: opacity 140ms ease;
}

.area-overlay {
  position: absolute;
  inset: 0;
  width: max(100%, 720px);
  height: 100%;
  min-height: 100%;
  overflow: visible;
}

.area-shape {
  cursor: pointer;
  outline: none;
}

.area-shape rect {
  fill: var(--area-color);
  fill-opacity: calc(var(--area-fill) * 0.5);
  stroke: var(--area-color);
  stroke-width: 0.75;
  vector-effect: non-scaling-stroke;
  transition: fill-opacity 120ms ease, stroke-width 120ms ease, filter 120ms ease;
}

.area-shape.subtract rect {
  fill-opacity: calc(var(--area-fill) * 0.32);
  stroke-dasharray: 2 1.4;
}

.area-shape text {
  fill: var(--ink);
  font-size: 2.1px;
  font-weight: 850;
  paint-order: stroke;
  stroke: var(--overlay-label-stroke);
  stroke-width: 0.7px;
  pointer-events: none;
}

.area-shape:hover rect,
.area-shape.hover rect,
.area-shape:focus rect,
.area-shape.active rect {
  fill-opacity: calc(var(--area-fill) * 0.72);
  stroke-width: 1.45;
  filter: saturate(1.25);
}

.area-shape.active rect {
  stroke: var(--ink);
}

.plan-canvas.overlay-hidden .area-overlay {
  display: none;
}

.plan-panel figcaption {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  margin-top: 10px;
}

.area-side {
  display: grid;
  gap: 12px;
}

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

.area-metric-grid .metric {
  min-height: 118px;
}

.area-method {
  border: 1px solid rgba(10, 159, 168, 0.28);
  border-radius: 8px;
  padding: 15px;
  background: var(--info-soft);
}

.area-method h3 {
  margin: 0 0 8px;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.area-method p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.area-method a {
  color: var(--purple);
  font-weight: 800;
}

.area-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: -1px;
}

.area-selected-card,
.room-totals {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--card);
}

.area-selected-card h3,
.room-totals h3 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.area-selected-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.area-selected-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
}

.area-selected-card dt {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.area-selected-card dd {
  margin: 2px 0 0;
  font-weight: 800;
}

.room-total-list {
  display: grid;
  gap: 8px;
}

.room-total {
  border-left: 5px solid var(--room-color);
  background: var(--card-soft);
  padding: 9px 10px;
  border-radius: 6px;
}

.room-total span,
.room-total small {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
}

.room-total strong {
  display: block;
  margin: 3px 0;
  font-size: 1.05rem;
}

.panel-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.panel-title-row p {
  color: var(--muted);
  line-height: 1.45;
  margin-top: 8px;
  max-width: 820px;
}

.area-table input,
.area-table select {
  width: 84px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 7px;
  text-align: right;
  background: var(--card);
  color: var(--ink);
}

.area-table select {
  width: 124px;
  text-align: left;
}

.area-table .area-label-input {
  width: 250px;
  text-align: left;
}

.area-table .area-source-input {
  width: 138px;
  text-align: left;
}

.area-table tr.active,
.area-table tr.hover {
  background: rgba(132, 92, 255, 0.08);
}

.area-row-button,
.area-delete-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

.area-row-button:hover,
.area-delete-button:hover {
  border-color: var(--purple);
}

.area-delete-button {
  color: var(--pink);
  font-size: 1.2rem;
  line-height: 1;
}

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

.rental-scenario {
  display: grid;
  gap: 12px;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--card-soft);
}

.rental-scenario.active {
  border-color: var(--purple);
  background: var(--active-soft);
}

.rental-scenario strong,
.rental-controls h3,
.rental-results h3 {
  display: block;
  font-size: 0.9rem;
}

.rental-scenario span {
  color: var(--muted);
  display: block;
  margin-top: 5px;
  line-height: 1.35;
}

.rental-scenario button {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 6px;
  min-height: 36px;
  font-weight: 800;
  cursor: pointer;
}

.rental-scenario button:hover {
  border-color: var(--purple);
}

.rental-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.rental-controls,
.rental-results {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--paper-soft);
}

.rental-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.rental-control-grid .control {
  --track: var(--green);
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 760;
  background: var(--paper);
}

.toggle-line input {
  width: 17px;
  height: 17px;
  accent-color: var(--purple);
}

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

.rental-metric-grid .metric {
  min-height: 108px;
}

.rental-explain {
  margin-top: 12px;
  border: 1px solid rgba(10, 159, 168, 0.28);
  border-radius: 8px;
  padding: 14px;
  background: var(--info-soft);
}

.rental-explain p {
  color: var(--muted);
  line-height: 1.5;
  margin-top: 8px;
}

.rental-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.rental-source-panel {
  box-shadow: none;
}

.metric.risk {
  border-color: rgba(190, 18, 60, 0.32);
  background: var(--risk-soft);
}

.visual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.chart-panel,
.table-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: var(--shadow);
}

figure.chart-panel {
  margin: 0;
}

.chart-panel.wide,
.table-panel.wide {
  grid-column: 1 / -1;
}

figcaption {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

figcaption strong {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.86rem;
}

figcaption span {
  color: var(--muted);
  line-height: 1.35;
}

.chart {
  width: 100%;
  min-height: 260px;
}

.chart-wrap {
  position: relative;
  min-height: 300px;
}

.chart-html-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 28px;
  margin: 0 0 2px 4px;
}

.chart-key {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.chart-key i {
  width: 16px;
  height: 5px;
  border-radius: 999px;
  display: inline-block;
}

.chart-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart-grid.vertical {
  opacity: 0.45;
}

.chart-axis {
  stroke: var(--chart-axis);
  stroke-width: 1.2;
}

.chart-tick,
.chart-legend {
  fill: var(--muted);
  font-size: 12px;
}

.chart-series path {
  fill: none;
  stroke: var(--series-color);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-series circle {
  fill: var(--series-color);
  stroke: var(--card);
  stroke-width: 2;
}

.chart-hotspot {
  cursor: crosshair;
  outline: none;
}

.chart-hotspot:hover,
.chart-hotspot:focus {
  filter: brightness(0.94);
}

.chart-series .chart-dot:hover,
.chart-series .chart-dot:focus {
  r: 6;
}

.chart-bar {
  transition: opacity 150ms ease, filter 150ms ease;
}

.chart-bar:hover,
.chart-bar:focus {
  opacity: 0.85;
  filter: saturate(1.1);
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  max-width: min(330px, calc(100% - 28px));
  padding: 9px 11px;
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.35;
  box-shadow: 0 14px 30px rgba(38, 50, 56, 0.22);
  transform: translate(-50%, calc(-100% - 12px));
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.chart-tooltip.visible {
  opacity: 1;
}

.empty-chart {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  border: 1px dashed var(--line);
}

.tables-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.table-panel {
  display: grid;
  gap: 14px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  text-align: right;
  border-bottom: 1px solid var(--line);
  padding: 10px 9px;
  vertical-align: top;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td {
  font-variant-numeric: tabular-nums;
}

.source-band {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 22px;
  align-items: start;
}

.source-band p {
  color: var(--muted);
  line-height: 1.55;
  margin-top: 10px;
}

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

.macro-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.macro-item span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.macro-item strong {
  display: block;
  margin-top: 5px;
}

.source-list {
  padding-left: 18px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.source-list a {
  color: var(--purple);
}

.source-note {
  font-size: 0.92rem;
}

.site-footer {
  width: min(1500px, calc(100% - clamp(28px, 6vw, 80px)));
  margin: 0 auto 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.86rem;
}

.site-footer strong {
  color: var(--ink);
  letter-spacing: 0.04em;
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--purple);
  color: var(--active-ink);
  box-shadow: 0 16px 32px rgba(38, 50, 56, 0.2);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 20;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

@media (max-width: 1120px) {
  .control-layout,
  .source-band,
  .macro-explorer-layout,
  .rental-layout,
  .area-layout {
    grid-template-columns: 1fr;
  }

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

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

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .section-heading p {
    text-align: left;
  }

  .macro-actions {
    justify-items: start;
    min-width: 0;
  }

  .toggle-row {
    justify-content: flex-start;
  }

  .panel-title-row {
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 48px;
    height: 44px;
    font-size: 0.95rem;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .main-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .metric-grid,
  .visual-grid,
  .tables-grid,
  .macro-grid,
  .macro-summary-grid,
  .area-metric-grid,
  .rental-scenarios,
  .rental-control-grid,
  .rental-metric-grid,
  .rental-chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-panel.wide,
  .table-panel.wide {
    grid-column: auto;
  }

  .band,
  .chart-panel,
  .table-panel {
    padding: 16px;
  }

  .control-label {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .plan-canvas img,
  .area-overlay {
    min-width: 620px;
  }

  .area-selected-card dl {
    grid-template-columns: 1fr;
  }
}
