:root {
    color-scheme: dark;
    --bg: #0b0f14;
    --bg-2: #10161f;
    --surface: rgba(16, 24, 34, 0.78);
    --surface-strong: rgba(21, 31, 44, 0.94);
    --surface-soft: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(56, 189, 248, 0.42);
    --text: #f8fafc;
    --muted: #94a3b8;
    --muted-2: #64748b;
    --primary: #38bdf8;
    --primary-rgb: 56, 189, 248;
    --primary-glow: rgba(56, 189, 248, 0.22);
    --secondary: #818cf8;
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    --font-primary: "Golos Text", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: "Outfit", "Golos Text", "Inter", sans-serif;
}

body[data-theme="light"] {
    color-scheme: light;
    --bg: #f8fafc;
    --bg-2: #ffffff;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: #ffffff;
    --surface-soft: rgba(15, 23, 42, 0.04);
    --border: rgba(15, 23, 42, 0.1);
    --border-strong: rgba(14, 165, 233, 0.5);
    --text: #0f172a;
    --muted: #475569;
    --muted-2: #64748b;
    --primary: #0284c7;
    --primary-rgb: 2, 132, 199;
    --primary-glow: rgba(2, 132, 199, 0.15);
    --secondary: #6366f1;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 10% 8%, rgba(56, 189, 248, 0.14), transparent 30%),
        radial-gradient(circle at 85% 15%, rgba(129, 140, 248, 0.12), transparent 32%),
        radial-gradient(circle at 50% 90%, rgba(52, 211, 153, 0.08), transparent 35%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-primary);
    line-height: 1.5;
    overflow-x: hidden;
    transition: background 0.25s ease, color 0.25s ease;
    -webkit-font-smoothing: antialiased;
}

body[data-theme="light"] {
    background:
        radial-gradient(circle at 10% 8%, rgba(2, 132, 199, 0.08), transparent 30%),
        radial-gradient(circle at 85% 15%, rgba(99, 102, 241, 0.06), transparent 32%),
        linear-gradient(180deg, #f8fafc, #f1f5f9 65%, #ffffff);
}

#bg-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    opacity: 0.45;
}

body[data-theme="light"] #bg-canvas {
    opacity: 0.18;
}

button, input {
    font: inherit;
}

button {
    cursor: pointer;
}

.topbar,
.app-shell,
.dashboard-footer {
    position: relative;
    z-index: 1;
}

/* TOPBAR */
.topbar {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    align-items: center;
    width: min(1520px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 10px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    text-decoration: none;
    transition: border-color 0.2s, transform 0.2s;
}

.brand:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.brand img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    border-radius: 8px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    color: var(--text);
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.brand-title span {
    color: var(--primary);
    margin-left: 2px;
}

.brand-sub {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.topbar__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.topbar__meta h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(20px, 2.2vw, 30px);
    font-weight: 800;
    line-height: 1.15;
}

.topbar__meta p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-ghost-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.nav-ghost-link:hover {
    border-color: var(--border-strong);
    color: var(--primary);
    background: var(--surface);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.theme-toggle:hover {
    border-color: var(--border-strong);
}

.theme-toggle__icon {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

/* APP SHELL */
.app-shell {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 20px;
    width: min(1520px, calc(100% - 32px));
    margin: 0 auto;
    padding: 10px 0 40px;
}

.controls-panel,
.hero-panel,
.kpi-card,
.chart-card,
.insight-card,
.table-card,
.advantage-card,
.advantage-hero {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

/* CONTROLS PANEL */
.controls-panel {
    position: sticky;
    top: 16px;
    align-self: start;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 20px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-kicker {
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ghost-button {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.ghost-button:hover:not([disabled]) {
    color: var(--text);
    border-color: var(--primary);
}

.ghost-button[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.control-block {
    padding: 16px 0;
    border-top: 1px solid var(--border);
}

.control-block h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
}

.block-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.badge {
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.badge--primary {
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge--success {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.segmented {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 10px;
}

.segmented label {
    display: block;
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    display: flex;
    flex-direction: column;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 13px;
    transition: all 0.2s;
}

.segmented span strong {
    color: var(--text);
    font-size: 13px;
}

.segmented span small {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.segmented label:hover span {
    border-color: var(--border-strong);
}

.segmented input:checked + span {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.12);
    box-shadow: 0 0 14px var(--primary-glow);
}

.segmented input:checked + span strong {
    color: var(--primary);
}

/* CUSTOM SELECT */
.custom-select {
    position: relative;
    margin-top: 10px;
}

.custom-select__button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    transition: border-color 0.2s;
}

.custom-select__button:hover,
.custom-select__button[aria-expanded="true"] {
    border-color: var(--primary);
}

.custom-select__button i {
    border: solid var(--muted);
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 3px;
    transform: rotate(45deg);
    transition: transform 0.2s;
}

.custom-select__button[aria-expanded="true"] i {
    transform: rotate(-135deg);
}

.custom-select__menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
    display: none;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-strong);
    box-shadow: var(--shadow);
}

.custom-select.active .custom-select__menu {
    display: block;
}

.custom-select__menu button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    text-align: left;
    transition: background 0.15s;
}

.custom-select__menu button:hover {
    background: var(--surface-soft);
}

.custom-select__menu button[aria-selected="true"] {
    color: var(--primary);
    font-weight: 600;
    background: rgba(var(--primary-rgb), 0.12);
}

/* RANGE CONTROLS */
.control-grid {
    display: grid;
    gap: 14px;
}

.range-control {
    display: grid;
    gap: 6px;
}

.range-control span {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
}

.range-control strong {
    color: var(--text);
    font-size: 13px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    border: 2px solid #ffffff;
    cursor: pointer;
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.18);
}

.info-note {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.2);
    color: var(--primary);
    font-size: 11px;
    line-height: 1.35;
}

.info-note svg {
    flex-shrink: 0;
}

/* SPLIT BAR */
.split-bar-box {
    margin-top: 4px;
}

.split-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
}

.split-bar-label strong {
    color: var(--text);
}

.split-bar {
    width: 100%;
    height: 8px;
    background: rgba(248, 113, 113, 0.4);
    border-radius: 999px;
    overflow: hidden;
}

.split-bar__fill {
    height: 100%;
    background: var(--success);
    border-radius: 999px;
}

/* SWITCH TOGGLE */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.muted-text {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 2px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider.round {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--surface-soft);
    border: 1px solid var(--border);
    transition: 0.25s;
    border-radius: 24px;
}

.slider.round:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--muted);
    transition: 0.25s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: rgba(var(--primary-rgb), 0.25);
    border-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
    background-color: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.micro-note {
    margin: 6px 0 0;
    color: var(--muted-2);
    font-size: 11px;
    line-height: 1.35;
}

/* INFRA SUMMARY */
.infra-summary {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    font-size: 11px;
}

.infra-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.infra-row span {
    color: var(--muted);
}

.infra-row strong {
    color: var(--text);
}

.positive {
    color: var(--success) !important;
}

.highlight {
    color: var(--primary) !important;
}

/* MAIN DASHBOARD */
.dashboard {
    min-width: 0;
}

/* HERO PANEL */
.hero-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 22px 26px;
    margin-bottom: 18px;
}

.model-source {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-panel h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(20px, 2.3vw, 28px);
    font-weight: 800;
    line-height: 1.2;
}

.hero-panel p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    max-width: 720px;
    line-height: 1.5;
}

.hero-panel__stats {
    display: flex;
    gap: 14px;
    flex-shrink: 0;
}

.hero-stat-card {
    padding: 14px 18px;
    border-radius: 10px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    text-align: center;
    min-width: 140px;
}

.hero-stat-label {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-bottom: 4px;
}

.hero-stat-num {
    display: block;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    line-height: 1.1;
}

.hero-stat-note {
    display: block;
    color: var(--muted-2);
    font-size: 10px;
    margin-top: 4px;
}

/* TAB NAVIGATION */
.tab-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.tab-button {
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab-button:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.tab-button.active {
    color: #ffffff;
    background: var(--surface-strong);
    border-color: var(--primary);
    box-shadow: 0 0 16px var(--primary-glow);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* KPI GRID */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.kpi-card {
    padding: 18px 20px;
    transition: transform 0.2s, border-color 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

.kpi-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.kpi-card strong {
    display: block;
    margin: 8px 0 4px;
    font-family: var(--font-display);
    font-size: clamp(22px, 2.4vw, 30px);
    font-weight: 800;
    line-height: 1.1;
    color: var(--text);
}

.kpi-card small {
    display: block;
    color: var(--muted-2);
    font-size: 11px;
}

.kpi-card--hot {
    border-color: rgba(var(--primary-rgb), 0.5);
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.14), var(--surface));
}

.kpi-card--hot strong {
    color: var(--primary);
}

/* CHARTS GRID */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.chart-card {
    padding: 20px;
}

.chart-card--wide {
    min-width: 0;
}

.card-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.card-title h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
}

.card-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.chart-legend {
    display: flex;
    gap: 14px;
    font-size: 11px;
    color: var(--muted);
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.legend-dot--blue { background: #38bdf8; }
.legend-dot--cyan { background: #818cf8; }
.legend-dot--green { background: #34d399; }

canvas {
    display: block;
    width: 100%;
}

.cost-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.cost-row {
    display: grid;
    gap: 4px;
    font-size: 11px;
}

.cost-row__meta {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
}

.cost-row__meta strong {
    color: var(--text);
}

.cost-row__bar {
    width: 100%;
    height: 5px;
    border-radius: 999px;
    background: var(--surface-soft);
    overflow: hidden;
}

.cost-row__bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

/* DETAIL GRIDS */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.insight-card {
    padding: 20px;
}

.status-box {
    padding: 14px 16px;
    border-radius: 8px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    margin-bottom: 14px;
    font-size: 13px;
    line-height: 1.45;
}

.status-box h4 {
    margin: 0 0 4px;
    font-size: 14px;
    color: var(--primary);
}

.recommendations {
    display: grid;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

.recommendation-item {
    display: flex;
    gap: 8px;
}

.recommendation-item svg {
    flex-shrink: 0;
    color: var(--primary);
    margin-top: 2px;
}

.mini-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

.mini-metric {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.mini-metric span {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

.mini-metric strong {
    display: block;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    margin-top: 2px;
}

/* RISK PROFILE */
.risk-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.risk-item {
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--surface-soft);
    border-left: 4px solid var(--border);
}

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

.risk-item strong {
    display: block;
    color: var(--text);
    font-size: 14px;
    margin: 3px 0 2px;
}

.risk-item small {
    display: block;
    color: var(--muted-2);
    font-size: 10px;
}

.risk-item--ok {
    border-left-color: var(--success);
}

.risk-item--warn {
    border-left-color: var(--warning);
}

.risk-item--bad {
    border-left-color: var(--danger);
}

/* COMPARISON & SENSITIVITY GRIDS */
.comparison-grid,
.sensitivity-grid {
    display: grid;
    gap: 8px;
}

.comparison-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    font-size: 12px;
}

.comparison-card.current {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
}

.comparison-card strong {
    color: var(--primary);
    font-size: 14px;
}

.sensitivity-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--surface-soft);
    font-size: 12px;
}

.sensitivity-row span {
    color: var(--muted);
}

/* ACTION STRIP */
.action-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding: 16px 20px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.action-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.action-button:hover {
    border-color: var(--border-strong);
    background: var(--surface-strong);
    transform: translateY(-1px);
}

.action-button--primary {
    background: var(--primary);
    color: #0b0f14 !important;
    border-color: var(--primary);
    box-shadow: 0 4px 14px var(--primary-glow);
}

.action-button--primary:hover {
    background: #7dd3fc;
    border-color: #7dd3fc;
}

.btn--sm {
    padding: 6px 12px;
    font-size: 12px;
}

#copy-status {
    color: var(--success);
    font-size: 12px;
    font-weight: 500;
}

/* TABLES */
.table-card {
    padding: 22px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-top: 14px;
}

.detail-table,
.horizontal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.detail-table th,
.horizontal-table th {
    padding: 12px 14px;
    background: var(--surface-soft);
    color: var(--muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.detail-table td,
.horizontal-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.detail-table tbody tr:hover,
.horizontal-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.horizontal-table th:first-child,
.horizontal-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface-strong);
    min-width: 200px;
    font-weight: 500;
}

.horizontal-table thead th:first-child {
    z-index: 3;
}

.horizontal-table td {
    white-space: nowrap;
    text-align: right;
}

.horizontal-table th {
    text-align: right;
}

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

.section-row td {
    background: rgba(var(--primary-rgb), 0.08) !important;
    color: var(--primary) !important;
    font-weight: 700;
    text-align: left !important;
    padding: 8px 14px;
}

.strong-row td {
    font-weight: 700;
    border-top: 1px solid var(--border-strong);
}

/* INVESTMENT EDIT */
.inv-edit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
}

.inv-edit input {
    width: 90px;
    border: none;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    text-align: right;
    outline: none;
}

.inv-edit i {
    color: var(--muted);
    font-style: normal;
}

.inv-edit--custom {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
}

.inv-badge {
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    font-size: 10px;
    font-weight: 600;
    margin-left: 6px;
}

.inv-reset {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    padding: 0 4px;
    cursor: pointer;
}

.inv-reset:hover {
    color: var(--text);
}

.stack-list {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.stack-row {
    display: grid;
    gap: 4px;
    font-size: 12px;
}

.stack-row__meta {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
}

.stack-row__meta strong {
    color: var(--text);
}

.stack-row__bar {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-soft);
    overflow: hidden;
}

.stack-row__bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

/* UNIT ECONOMICS BOX */
.unit-econ-box {
    display: grid;
    gap: 12px;
    padding: 10px 0;
}

.unit-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.unit-row span {
    color: var(--muted);
}

.unit-row strong {
    color: var(--text);
}

.unit-highlight {
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.unit-highlight span {
    display: block;
    color: var(--success);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.unit-highlight strong {
    display: block;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
    margin-top: 2px;
}

/* ADVANTAGES TAB */
.advantage-hero {
    padding: 26px;
    margin-bottom: 18px;
}

.advantage-hero h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(22px, 2.5vw, 30px);
    font-weight: 800;
}

.advantage-hero p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
    max-width: 820px;
    line-height: 1.55;
}

.advantage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.advantage-card {
    padding: 22px;
    position: relative;
}

.advantage-card__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 12px;
}

.advantage-card h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 700;
}

.advantage-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

/* MODAL */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    padding: 16px;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-dialog {
    width: min(480px, 100%);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface-strong);
    box-shadow: var(--shadow);
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.modal-header h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.modal-body {
    display: grid;
    gap: 14px;
}

.modal-field {
    display: grid;
    gap: 6px;
}

.modal-field span {
    font-size: 12px;
    color: var(--muted);
}

.modal-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    outline: none;
}

.modal-field input:focus {
    border-color: var(--primary);
}

.modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

/* FOOTER */
.dashboard-footer {
    width: min(1520px, calc(100% - 32px));
    margin: 10px auto 40px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

.footer-brand-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.footer-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
}

.footer-logo img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.footer-links {
    display: flex;
    gap: 16px;
    font-size: 12px;
}

.footer-links a {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

.disclaimer {
    margin: 0;
    color: var(--muted-2);
    font-size: 11px;
    line-height: 1.5;
    text-align: justify;
}

/* PRINT STYLES */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    #bg-canvas,
    .controls-panel,
    .tab-nav,
    .action-strip,
    .theme-toggle,
    .modal-backdrop,
    .topbar__actions {
        display: none !important;
    }
    .app-shell {
        grid-template-columns: 1fr !important;
        width: 100% !important;
        padding: 0 !important;
    }
    .tab-panel {
        display: block !important;
        page-break-after: always;
    }
    .kpi-card, .chart-card, .table-card, .insight-card {
        box-shadow: none !important;
        border: 1px solid #cccccc !important;
        background: #ffffff !important;
        color: #000000 !important;
    }
    .kpi-card strong, .chart-card h3 {
        color: #000000 !important;
    }
}

/* RESPONSIVE */
@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .controls-panel {
        position: static;
        max-height: none;
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .topbar {
        grid-template-columns: 1fr;
    }
    .hero-panel {
        flex-direction: column;
        align-items: flex-start;
    }
    .hero-panel__stats {
        width: 100%;
    }
    .hero-stat-card {
        flex: 1;
    }
    .hide-mobile {
        display: none !important;
    }
}
