:root {
    color-scheme: light;
    --ink: #18231d;
    --ink-soft: #4c5c52;
    --muted: #7a8980;
    --paper: #f6f5ef;
    --panel: rgba(255, 255, 252, 0.96);
    --canvas: #f0efe7;
    --line: #dde1d9;
    --line-strong: #c9d0c7;
    --green: #166b4a;
    --green-2: #21865f;
    --green-pale: #e2f2e8;
    --lime: #c9ed7a;
    --amber: #d99122;
    --amber-pale: #fff1d4;
    --red: #c64d45;
    --red-pale: #fde7e4;
    --blue: #2e6eae;
    --blue-pale: #e3eef8;
    --violet: #6f61a8;
    --shadow-border: 0 0 0 1px rgba(21, 38, 28, 0.07), 0 1px 2px -1px rgba(21, 38, 28, 0.08), 0 8px 24px -15px rgba(21, 38, 28, 0.14);
    --shadow-border-hover: 0 0 0 1px rgba(21, 38, 28, 0.12), 0 2px 5px -2px rgba(21, 38, 28, 0.13), 0 12px 28px -14px rgba(21, 38, 28, 0.17);
    --shadow-float: 0 0 0 1px rgba(21, 38, 28, 0.08), 0 12px 32px rgba(21, 38, 28, 0.13);
}

* { box-sizing: border-box; }

html {
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-width: 0;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.mobile-panel-nav { display: none; }
.diagnostic-action { width: 100%; text-align: left; font: inherit; border: 0; }
.diagnostic-action small { display: block; margin-top: 8px; color: var(--green); }
h1, h2, h3 { margin: 0; font-family: inherit; text-wrap: balance; }
p { text-wrap: pretty; }
svg { display: block; }

button,
.import-label {
    -webkit-tap-highlight-color: transparent;
}

button:not(:disabled),
.import-label { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
.import-label:focus-within {
    outline: 3px solid rgba(33, 134, 95, 0.22);
    outline-offset: 2px;
}

.app-shell {
    display: grid;
    grid-template-rows: 64px minmax(0, 1fr) 34px;
    height: 100%;
}

.topbar {
    position: relative;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: rgba(250, 249, 244, 0.94);
    border-bottom: 1px solid rgba(24, 35, 29, 0.09);
    backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand .site-home-link { font-family: Lora, serif; font-size: 20px; font-weight: 500; white-space: nowrap; color: inherit; text-decoration: none; }
.tool-identity { padding-left: 16px; border-left: 1px solid var(--line); }

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 12px;
    background: var(--ink);
    color: var(--lime);
    box-shadow: 0 5px 14px rgba(24, 35, 29, 0.16);
}

.brand-mark svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.brand-name { font-family: inherit; font-weight: 600; font-size: 14px; letter-spacing: -0.02em; }
.brand-subtitle { margin-top: 1px; color: var(--muted); font-size: 10.5px; font-weight: 500; }

.topbar-center { text-align: center; min-width: 170px; }
.study-name { font-size: 13px; font-weight: 650; }
.save-state { margin-top: 1px; color: var(--muted); font-size: 10.5px; }

.topbar-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }

.icon-button,
.secondary-button,
.solve-button,
.primary-light-button,
.help-button,
.text-button,
.modal-action {
    min-height: 40px;
    border: 0;
    transition-property: scale, background-color, box-shadow, color, opacity;
    transition-duration: 150ms;
    transition-timing-function: ease-out;
}

.icon-button:active:not(:disabled),
.secondary-button:active,
.solve-button:active,
.primary-light-button:active,
.help-button:active,
.text-button:active,
.palette-item:active,
.model-row:active,
.example-option:active { scale: 0.96; }

.icon-button {
    display: grid;
    place-items: center;
    width: 40px;
    padding: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--ink-soft);
}

.icon-button:hover:not(:disabled) { background: rgba(24, 35, 29, 0.06); color: var(--ink); }
.icon-button:disabled { opacity: .28; cursor: default; }
.icon-button svg, .secondary-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.secondary-button {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 14px 0 15px;
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-border);
    font-size: 12px;
    font-weight: 650;
}

.secondary-button:hover { box-shadow: var(--shadow-border-hover); }
.documentation-button { color: var(--green); }
.documentation-button svg { color: var(--green); }

.solve-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 0 14px;
    border-radius: 12px;
    background: var(--green);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(8, 74, 47, .2), 0 7px 18px rgba(22, 107, 74, .21);
    font-size: 12px;
    font-weight: 700;
}

.solve-button:hover { background: #115d40; box-shadow: 0 0 0 1px rgba(8, 74, 47, .24), 0 9px 22px rgba(22, 107, 74, .26); }
.solve-button.solving { opacity: .74; pointer-events: none; }
.solve-button.solved .solve-icon-play { opacity: 0; scale: .25; filter: blur(4px); }
.solve-button.solved .solve-icon-check { opacity: 1; scale: 1; filter: blur(0); }

.solve-icon-stack { position: relative; width: 17px; height: 17px; }
.solve-icon { position: absolute; inset: 0; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition-property: opacity, scale, filter; transition-duration: 300ms; transition-timing-function: cubic-bezier(.2, 0, 0, 1); }
.solve-icon-play { margin-left: 1px; }
.solve-icon-check { opacity: 0; scale: .25; filter: blur(4px); }
.solve-mobile-label { display: none; }

.workspace {
    display: grid;
    grid-template-columns: 270px minmax(500px, 1fr) 310px;
    min-height: 0;
}

.panel { position: relative; z-index: 8; min-height: 0; background: var(--panel); }
.left-panel { display: flex; flex-direction: column; border-right: 1px solid rgba(24, 35, 29, .09); overflow-y: auto; }
.right-panel { border-left: 1px solid rgba(24, 35, 29, .09); overflow: hidden; }

.panel-section { padding: 20px 18px; border-bottom: 1px solid rgba(24, 35, 29, .08); }
.palette-section { padding-top: 19px; }
.section-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.section-heading-row.compact { align-items: center; }
.eyebrow { margin-bottom: 4px; color: var(--green-2); font-size: 9.5px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.panel-section h2 { font-size: 16px; line-height: 1.15; letter-spacing: -.025em; }
.section-copy { margin: 8px 0 14px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.help-button {
    width: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 50%;
    background: var(--green-pale);
    color: var(--green);
    font-weight: 800;
}
.help-button:hover { background: #d3eadc; }

.palette-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette-item {
    min-height: 90px;
    padding: 11px;
    border: 0;
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow-border);
    text-align: left;
    transition-property: scale, box-shadow, background-color;
    transition-duration: 150ms;
    transition-timing-function: ease-out;
}
.palette-item:hover { background: #fefefb; box-shadow: var(--shadow-border-hover); }
.palette-item.active { background: var(--green-pale); box-shadow: 0 0 0 1px rgba(22, 107, 74, .2); }
.palette-item > span:last-child { display: block; margin-top: 9px; }
.palette-item strong { display: block; font-size: 11.5px; font-weight: 700; }
.palette-item small { display: block; margin-top: 2px; color: var(--muted); font-size: 9.5px; line-height: 1.2; }
.palette-icon { display: grid; place-items: center; width: 29px; height: 29px; color: var(--green); }
.palette-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bus-icon i { display: block; width: 27px; height: 5px; border-radius: 3px; background: currentColor; box-shadow: -7px 7px 0 -2px currentColor; }

.model-section { flex: 1 0 auto; padding-bottom: 12px; }
.text-button { min-height: 40px; margin: -9px -7px -9px 0; padding: 0 8px; background: transparent; color: var(--muted); font-size: 10.5px; font-weight: 650; }
.text-button:hover { color: var(--red); }
.model-counts { display: flex; gap: 8px; margin: 10px 0 11px; color: var(--muted); font-size: 9.5px; }
.model-counts span { padding: 4px 7px; border-radius: 8px; background: rgba(24, 35, 29, .045); }
.model-tree { display: grid; gap: 3px; }
.tree-group-label { margin: 9px 8px 4px; color: var(--muted); font-size: 8.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.model-row {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 6px 8px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    text-align: left;
    transition-property: scale, background-color, color;
    transition-duration: 140ms;
    transition-timing-function: ease-out;
}
.model-row:hover { background: rgba(24, 35, 29, .045); }
.model-row.active { background: var(--green-pale); color: var(--green); }
.model-row-icon { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 7px; background: #fff; box-shadow: 0 0 0 1px rgba(24, 35, 29, .08); font-size: 9px; font-weight: 800; }
.model-row-text { min-width: 0; flex: 1; }
.model-row-text strong, .model-row-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-row-text strong { font-size: 10.5px; }
.model-row-text small { margin-top: 1px; color: var(--muted); font-size: 8.5px; }
.model-row-value { color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; }

.settings-section { padding-top: 12px; padding-bottom: 12px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; min-height: 43px; color: var(--ink-soft); font-size: 10.5px; }
.input-with-unit { display: flex; align-items: center; overflow: hidden; min-height: 38px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.input-with-unit input { width: 82px; height: 36px; padding: 0 8px 0 10px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.input-with-unit span { padding-right: 9px; color: var(--muted); font-size: 9px; }
.small-input input { width: 58px; text-align: right; }

.switch { position: relative; width: 42px; height: 24px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: #d5dad3; transition-property: background-color; transition-duration: 160ms; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(24,35,29,.2); transition-property: transform; transition-duration: 180ms; transition-timing-function: cubic-bezier(.2, 0, 0, 1); }
.switch input:checked + span { background: var(--green-2); }
.switch input:checked + span::after { transform: translateX(18px); }

.canvas-shell { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--canvas); }
.network-canvas { width: 100%; height: 100%; color: #9fa99f; touch-action: none; user-select: none; }
.canvas-grid { pointer-events: none; }
.canvas-toolbar { position: absolute; z-index: 7; top: 16px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.mode-pill, .zoom-controls { pointer-events: auto; box-shadow: var(--shadow-float); backdrop-filter: blur(12px); }
.mode-pill { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 7px 0 12px; border-radius: 13px; background: rgba(255,255,252,.91); color: var(--ink-soft); font-size: 10.5px; }
.mode-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green-2); box-shadow: 0 0 0 4px rgba(33,134,95,.1); }
.mode-pill.connecting .mode-dot { background: var(--amber); box-shadow: 0 0 0 4px rgba(217,145,34,.13); }
.mode-pill button { min-width: 34px; min-height: 28px; padding: 0 7px; border: 0; border-radius: 8px; background: rgba(24,35,29,.055); color: var(--muted); font-size: 9px; }

.zoom-controls { display: flex; align-items: center; height: 38px; padding: 3px; border-radius: 13px; background: rgba(255,255,252,.91); }
.zoom-controls button { display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--ink-soft); font-size: 17px; transition-property: background-color, scale; transition-duration: 140ms; }
.zoom-controls button:hover { background: rgba(24,35,29,.06); }
.zoom-controls button:active { scale: .96; }
.zoom-controls span { width: 48px; text-align: center; color: var(--muted); font-size: 9.5px; font-variant-numeric: tabular-nums; }
.zoom-controls svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.branch-hit { fill: none; stroke: transparent; stroke-width: 20; pointer-events: stroke; cursor: pointer; }
.branch-line { fill: none; stroke: #7d8a82; stroke-width: 3; stroke-linecap: round; pointer-events: none; transition-property: stroke, stroke-width, opacity; transition-duration: 180ms; }
.branch-line.selected { stroke: var(--green); stroke-width: 4.5; }
.branch-line.warning { stroke: var(--amber); }
.branch-line.violation { stroke: var(--red); stroke-width: 4; }
.branch-flow { fill: none; stroke: var(--green-2); stroke-width: 1.6; stroke-dasharray: 3 8; stroke-linecap: round; marker-end: url(#flowArrow); pointer-events: none; opacity: .8; }
.branch-flow.reverse { marker-start: url(#flowArrow); marker-end: none; }
.branch-flow.no-result { display: none; }
.branch-label-bg { fill: rgba(255,255,252,.96); stroke: rgba(24,35,29,.09); stroke-width: 1; }
.branch-label { fill: var(--ink-soft); font: 600 10px "Inter", sans-serif; text-anchor: middle; font-variant-numeric: tabular-nums; pointer-events: none; }
.branch-label.secondary { fill: var(--muted); font-size: 8.5px; font-weight: 500; }

.bus-node { cursor: grab; }
.bus-node.dragging { cursor: grabbing; }
.bus-card { fill: rgba(255,255,252,.98); stroke: rgba(24,35,29,.08); stroke-width: 1; filter: url(#nodeShadow); transition-property: stroke, fill; transition-duration: 160ms; }
.bus-node:hover .bus-card { stroke: rgba(22,107,74,.22); }
.bus-node.selected .bus-card { stroke: var(--green); stroke-width: 2; fill: #fbfff9; }
.bus-node.connect-source .bus-card { stroke: var(--amber); stroke-width: 2.5; fill: #fffaf0; }
.busbar { fill: var(--ink); transition-property: fill; transition-duration: 180ms; }
.bus-node.warning .busbar { fill: var(--amber); }
.bus-node.violation .busbar { fill: var(--red); }
.bus-title { fill: var(--ink); font: 700 11px Inter, sans-serif; text-anchor: middle; pointer-events: none; }
.bus-meta { fill: var(--muted); font: 500 8.5px "Inter", sans-serif; text-anchor: middle; pointer-events: none; font-variant-numeric: tabular-nums; }
.bus-voltage { fill: var(--green); font: 700 10px "Inter", sans-serif; text-anchor: middle; pointer-events: none; font-variant-numeric: tabular-nums; }
.bus-node.warning .bus-voltage { fill: var(--amber); }
.bus-node.violation .bus-voltage { fill: var(--red); }
.terminal-line { stroke: #738079; stroke-width: 1.6; }
.device-circle { fill: #fff; stroke: var(--green); stroke-width: 2; }
.device-symbol { fill: none; stroke: var(--green); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.device-hit { fill: transparent; cursor: pointer; }
.device-hit:hover + .device-circle, .device-group.selected .device-circle { fill: var(--green-pale); stroke-width: 2.6; }
.load-symbol { fill: var(--ink-soft); }
.load-group.selected .load-symbol { fill: var(--green); }
.device-caption { fill: var(--muted); font: 600 8px "Inter", sans-serif; text-anchor: middle; pointer-events: none; }
.device-group.warning .device-circle{fill:var(--amber-pale);stroke:var(--amber);stroke-width:3}
.device-group.warning .device-symbol,.device-group.warning .terminal-line{stroke:var(--amber)}
.device-group.warning .device-caption,.bus-limit-label{fill:#a8670b}
.bus-limit-label{font:600 9px Inter,sans-serif;text-anchor:middle;paint-order:stroke;stroke:var(--canvas);stroke-width:4px}
.bus-node.warning .bus-card{stroke:var(--amber);stroke-width:2}
.bus-node.violation .bus-card{stroke:var(--red);stroke-width:2}
#geographicCanvas{position:absolute;inset:0;z-index:1;isolation:isolate;background:#e8eeea}
.canvas-shell[data-network-view=map] .network-canvas{visibility:hidden;pointer-events:none}
.canvas-toolbar{flex-wrap:wrap;gap:8px}
.network-view-controls{display:flex;gap:3px;padding:4px;pointer-events:auto;border-radius:12px;background:#fff;box-shadow:var(--shadow-border);order:0}
.network-view-controls button{border:0;border-radius:8px;min-height:40px;padding:0 14px;background:transparent;font-size:12px;cursor:pointer}
.network-view-controls button[aria-pressed=true]{background:var(--green-pale);color:var(--green);font-weight:600}
.canvas-shell[data-network-view=map] .mode-pill{order:3}
.canvas-shell[data-network-view=map] .zoom-controls{order:1;margin-left:auto}
.canvas-shell[data-network-view=map] .legend{bottom:28px}
.canvas-shell[data-network-view=map] .legend-flow{display:none}
.ac-map-marker{background:none;border:0}
.ac-map-node{position:absolute;top:0;width:116px;transform:translateY(-50%)}
.ac-map-node.label-east{left:12px}.ac-map-node.label-west{right:12px}
.map-bus-point{position:absolute;left:-6px;top:-6px;width:12px;height:12px;border:2px solid white;border-radius:50%;background:#79867f;box-shadow:0 0 0 1px #56675b}
.map-bus-point.healthy{background:var(--green-2)}.map-bus-point.warning{background:var(--amber)}.map-bus-point.violation{background:var(--red)}
#geographicCanvas .leaflet-tile-pane{filter:saturate(.4)}
.ac-map-node{min-height:44px;padding:5px 7px;background:#fff;color:var(--ink);border:1px solid #cbd6cf;border-left:4px solid #79867f;border-radius:8px;box-shadow:0 2px 8px #18231d24;font:11px/1.3 Inter,sans-serif;text-align:left;cursor:grab}
.ac-map-node strong,.ac-map-node span,.ac-map-node small{display:block}
.ac-map-node strong{font-size:11px;font-weight:600;white-space:nowrap}
.ac-map-node span{font-variant-numeric:tabular-nums;color:#52655a;font-size:10px;margin-top:2px}
.ac-map-node.healthy{border-left-color:var(--green-2)}
.ac-map-node.warning{border-color:var(--amber);background:#fff6e5}
.ac-map-node.violation{border-color:var(--red);background:#fff0ee}
.ac-map-node.selected{outline:3px solid var(--blue);outline-offset:2px}
.map-limit-label{font-size:9px;color:#9b600b;font-weight:600;margin-top:3px}
.violation .map-limit-label{color:var(--red)}
#mapAvailability{position:absolute;z-index:6;left:16px;right:16px;bottom:80px;background:white;padding:8px;border-radius:8px;font-size:12px}
#geographicCanvas .leaflet-control-attribution{font:10px/1.4 Inter,sans-serif}
@media(min-width:1024px){.app-shell{grid-template-rows:64px minmax(0,1fr) 48px}}
.slack-badge { fill: var(--lime); stroke: rgba(24,35,29,.12); }
.slack-text { fill: var(--ink); font: 800 7px "Inter", sans-serif; text-anchor: middle; letter-spacing: .04em; }

.legend { position: absolute; z-index: 5; left: 16px; bottom: 14px; display: flex; align-items: center; gap: 13px; min-height: 34px; padding: 0 11px; border-radius: 12px; background: rgba(255,255,252,.9); box-shadow: var(--shadow-border); color: var(--muted); font-size: 8.5px; backdrop-filter: blur(10px); }
.legend span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.healthy { background: var(--green-2); }
.legend-dot.warning { background: var(--amber); }
.legend-dot.violation { background: var(--red); }
.legend-divider { width: 1px; height: 15px; background: var(--line-strong); }
.legend-arrow { width: 18px; height: 2px; background: var(--green-2); position: relative; }
.legend-arrow::after { content: ""; position: absolute; top: -3px; right: -1px; border-left: 5px solid var(--green-2); border-top: 4px solid transparent; border-bottom: 4px solid transparent; }
.legend-note { color: #93a097; }

.canvas-empty { position: absolute; z-index: 4; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; pointer-events: none; }
.canvas-empty[hidden] { display: none; }
.canvas-empty > * { pointer-events: auto; }
.empty-icon { display: grid; place-items: center; width: 66px; height: 66px; border-radius: 22px; background: rgba(255,255,252,.8); box-shadow: var(--shadow-border); }
.empty-icon span { width: 35px; height: 7px; border-radius: 4px; background: var(--green); box-shadow: -9px 10px 0 -2px var(--green); }
.canvas-empty h2 { margin-top: 17px; font-size: 18px; }
.canvas-empty p { margin: 6px 0 15px; color: var(--muted); font-size: 11px; }
.primary-light-button { padding: 0 16px; border-radius: 12px; background: var(--green-pale); color: var(--green); font-size: 11px; font-weight: 700; box-shadow: var(--shadow-border); }
.primary-light-button:hover { background: #d5ebde; }

.toast { position: absolute; z-index: 12; left: 50%; bottom: 58px; min-width: 220px; max-width: 420px; padding: 11px 14px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: 0 12px 32px rgba(24,35,29,.2); font-size: 10.5px; text-align: center; opacity: 0; transform: translate(-50%, 8px); filter: blur(4px); pointer-events: none; transition-property: opacity, transform, filter; transition-duration: 180ms; transition-timing-function: cubic-bezier(.2,0,0,1); }
.toast.show { opacity: 1; transform: translate(-50%, 0); filter: blur(0); }

.right-tabs { display: grid; grid-template-columns: 1fr 1fr; height: 50px; padding: 6px; border-bottom: 1px solid rgba(24,35,29,.08); background: rgba(249,249,245,.95); }
.right-tab { position: relative; min-height: 38px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 10.5px; font-weight: 700; transition-property: background-color, color, box-shadow, scale; transition-duration: 150ms; }
.right-tab:active { scale: .96; }
.right-tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-border); }
.result-count { display: inline-grid; place-items: center; min-width: 17px; height: 17px; margin-left: 3px; padding: 0 4px; border-radius: 8px; background: var(--red-pale); color: var(--red); font-size: 8px; font-variant-numeric: tabular-nums; }
.right-content { height: calc(100% - 50px); overflow-y: auto; }
.right-content[hidden] { display: none; }

.inspector-empty { padding: 42px 28px; text-align: center; }
.inspector-empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 15px; border-radius: 18px; background: var(--green-pale); color: var(--green); }
.inspector-empty-icon svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.inspector-empty h2 { font-size: 16px; }
.inspector-empty p { margin: 7px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.5; }

.inspector-header { padding: 19px 18px 16px; border-bottom: 1px solid rgba(24,35,29,.08); }
.inspector-kicker { display: flex; align-items: center; gap: 6px; color: var(--green-2); font-size: 8.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.inspector-kicker i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.name-row { display: flex; gap: 8px; margin-top: 8px; }
.name-row input { min-width: 0; flex: 1; height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink); font-family: Inter, sans-serif; font-size: 13px; font-weight: 700; }
.delete-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 11px; background: var(--red-pale); color: var(--red); transition-property: scale, background-color; transition-duration: 150ms; }
.delete-button:active { scale: .96; }
.delete-button:hover { background: #fbd8d4; }
.delete-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.result-ribbon { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 12px; }
.result-chip { padding: 9px 10px; border-radius: 11px; background: var(--green-pale); }
.result-chip span, .result-chip strong { display: block; }
.result-chip span { color: var(--green); font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.result-chip strong { margin-top: 3px; font-size: 13px; font-variant-numeric: tabular-nums; }
.result-chip.warning { background: var(--amber-pale); }
.result-chip.warning span { color: #9d6410; }

.form-section { padding: 17px 18px; border-bottom: 1px solid rgba(24,35,29,.08); }
.form-section-title { margin-bottom: 12px; color: var(--ink-soft); font-size: 9px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 9px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-field { min-width: 0; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { display: block; margin: 0 0 5px 2px; color: var(--muted); font-size: 8.5px; font-weight: 650; }
.form-field input, .form-field select { width: 100%; height: 39px; padding: 0 9px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: #fff; color: var(--ink); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.form-field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 13px) 16px, calc(100% - 9px) 16px; background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; padding-right: 25px; }
.field-help { margin: 5px 2px 0; color: #96a198; font-size: 8px; line-height: 1.35; }
.form-note { padding: 10px 11px; border-radius: 11px; background: #f1f2ed; color: var(--ink-soft); font-size: 9px; line-height: 1.45; }
.form-note strong { color: var(--ink); }

.results-wrap { padding: 18px; }
.results-hero { padding: 16px; border-radius: 18px; background: var(--ink); color: #fff; box-shadow: 0 9px 25px rgba(24,35,29,.16); }
.results-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.results-hero h2 { font-size: 16px; }
.converged-badge { padding: 5px 8px; border-radius: 8px; background: rgba(201,237,122,.14); color: var(--lime); font-size: 8.5px; font-weight: 750; }
.results-hero p { margin: 5px 0 0; color: rgba(255,255,255,.62); font-size: 9px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 12px; }
.metric-card { padding: 11px; border-radius: 12px; background: rgba(255,255,255,.07); }
.metric-card span, .metric-card strong { display: block; }
.metric-card span { color: rgba(255,255,255,.58); font-size: 8px; }
.metric-card strong { margin-top: 4px; color: #fff; font: 700 15px Inter, sans-serif; font-variant-numeric: tabular-nums; }
.result-section { margin-top: 20px; }
.result-section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.result-section h3 { font-size: 11px; }
.result-section-heading span { color: var(--muted); font-size: 8.5px; }
.diagnostic-list { display: grid; gap: 7px; }
.diagnostic { display: grid; grid-template-columns: 8px 1fr; gap: 9px; padding: 11px; border-radius: 12px; background: #f2f3ee; }
.diagnostic i { width: 8px; height: 8px; margin-top: 3px; border-radius: 50%; background: var(--green-2); }
.diagnostic.warning { background: var(--amber-pale); }
.diagnostic.warning i { background: var(--amber); }
.diagnostic.error { background: var(--red-pale); }
.diagnostic.error i { background: var(--red); }
.diagnostic strong, .diagnostic span { display: block; }
.diagnostic strong { font-size: 9.5px; }
.diagnostic span { margin-top: 2px; color: var(--muted); font-size: 8.5px; line-height: 1.4; }
.result-table { width: 100%; border-collapse: collapse; font-size: 8.5px; font-variant-numeric: tabular-nums; }
.result-table th { padding: 0 5px 7px; color: var(--muted); font-weight: 650; text-align: right; }
.result-table th:first-child, .result-table td:first-child { text-align: left; }
.result-table td { padding: 8px 5px; border-top: 1px solid var(--line); text-align: right; }
.status-text.healthy { color: var(--green-2); }
.status-text.warning { color: var(--amber); }
.status-text.violation { color: var(--red); }
.results-placeholder { padding: 45px 22px; color: var(--muted); text-align: center; font-size: 10.5px; line-height: 1.5; }

.statusbar { position: relative; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 15px; border-top: 1px solid rgba(24,35,29,.09); background: #f8f7f2; color: var(--muted); font-size: 8.5px; }
.solver-status, .status-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.solver-status{border:0;background:transparent;text-align:left;min-height:40px;padding:6px 2px;cursor:pointer;font:inherit;border-radius:6px}
.solver-status #statusLabel,.solver-status #statusDetail,.solver-status .status-open{font-size:11px}
.solver-status:hover{background:var(--green-pale)}
.status-open{color:var(--green);margin-left:8px;white-space:nowrap}
.status-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--green-2); box-shadow: 0 0 0 3px rgba(33,134,95,.1); }
.solver-status strong { color: var(--ink-soft); font-size: 8.5px; }
.solver-status.error .status-indicator { background: var(--red); box-shadow: 0 0 0 3px rgba(198,77,69,.1); }
.solver-status.warning .status-indicator { background: var(--amber); box-shadow: 0 0 0 3px rgba(217,145,34,.11); }
.status-actions button, .import-label { display: inline-flex; align-items: center; min-height: 28px; padding: 0 7px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-soft); font-size: 8.5px; font-weight: 650; transition-property: background-color, color, scale; transition-duration: 130ms; }
.status-actions button:hover, .import-label:hover { background: rgba(24,35,29,.055); }
.status-actions button:active, .import-label:active { scale: .96; }
.import-label input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(19,29,23,.3); backdrop-filter: blur(8px); opacity: 1; transition-property: opacity; transition-duration: 160ms; }
.modal-backdrop[hidden] { display: none; }
.modal-backdrop.closing { opacity: 0; }
.modal-card { position: relative; width: min(540px, 92vw); padding: 28px; border-radius: 24px; background: #fff; box-shadow: 0 25px 70px rgba(20,34,25,.2), 0 0 0 1px rgba(255,255,255,.5); animation: modalEnter 260ms cubic-bezier(.2,0,0,1) both; }
@keyframes modalEnter { from { opacity: 0; transform: translateY(12px); filter: blur(4px); } to { opacity: 1; transform: translateY(0); filter: blur(0); } }
.modal-close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border: 0; border-radius: 12px; background: #f1f2ed; color: var(--muted); font-size: 21px; transition-property: background-color, color, scale; transition-duration: 140ms; }
.modal-close:hover { background: #e8ebe4; color: var(--ink); }
.modal-close:active { scale: .96; }
.modal-card h2 { font-size: 23px; letter-spacing: -.035em; }
.modal-intro { max-width: 460px; margin: 10px 0 19px; color: var(--ink-soft); font-size: 11.5px; line-height: 1.55; }
.guide-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.guide-steps > div { padding: 14px; border-radius: 16px; background: #f4f5f0; }
.guide-steps > div > span { display: grid; place-items: center; width: 24px; height: 24px; margin-bottom: 11px; border-radius: 8px; background: var(--green-pale); color: var(--green); font-size: 9px; font-weight: 800; }
.guide-steps strong { display: block; font-size: 10.5px; }
.guide-steps p { margin: 5px 0 0; color: var(--muted); font-size: 8.5px; line-height: 1.45; }
.modal-action { width: 100%; justify-content: center; margin-top: 17px; }
.examples-card { width: min(500px, 92vw); }
.example-list { display: grid; gap: 9px; margin-top: 18px; }
.example-option { display: flex; align-items: center; gap: 13px; width: 100%; min-height: 75px; padding: 10px; border: 0; border-radius: 17px; background: #f5f6f1; text-align: left; box-shadow: 0 0 0 1px transparent; transition-property: scale, background-color, box-shadow; transition-duration: 150ms; }
.example-option:hover { background: #f0f2ec; }
.example-option.active { background: var(--green-pale); box-shadow: 0 0 0 1px rgba(22,107,74,.18); }
.example-option > span:last-child { min-width: 0; }
.example-option strong, .example-option small { display: block; }
.example-option strong { font-size: 11.5px; }
.example-option small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.example-preview { position: relative; display: block; width: 72px; height: 52px; flex: 0 0 auto; overflow: hidden; border-radius: 11px; background: #fff; box-shadow: var(--shadow-border); }
.example-preview i { position: absolute; width: 20px; height: 4px; border-radius: 2px; background: var(--green); }
.example-preview i::after { content: ""; position: absolute; left: 9px; top: 3px; width: 1px; height: 18px; background: #9aa59c; transform-origin: top; }
.example-preview.three i:nth-child(1) { left: 7px; top: 11px; }
.example-preview.three i:nth-child(2) { right: 7px; top: 11px; }
.example-preview.three i:nth-child(3) { left: 26px; bottom: 8px; }
.example-preview.three i:nth-child(1)::after { transform: rotate(-49deg); height: 40px; }
.example-preview.three i:nth-child(2)::after { transform: rotate(49deg); height: 40px; }
.example-preview.three i:nth-child(3)::after { display: none; }
.example-preview.radial i:nth-child(1) { left: 6px; top: 24px; }
.example-preview.radial i:nth-child(2) { left: 27px; top: 24px; }
.example-preview.radial i:nth-child(3) { right: 5px; top: 24px; }
.example-preview.radial i::after { top: 1px; left: 19px; width: 22px; height: 1px; transform: none; }
.example-preview.radial i:last-child::after { display: none; }
.example-preview.blank { display: grid; place-items: center; color: var(--green); font-size: 23px; }
.example-preview.california { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px 6px; padding: 11px; }
.example-preview.california i { position: relative; width: 12px; height: 4px; }
.example-preview.california i::after { left: 5px; top: 4px; height: 9px; }
.example-preview.california i:nth-last-child(-n+3)::after { display: none; }

@media (max-width: 1180px) {
    .workspace { grid-template-columns: 242px minmax(480px, 1fr) 286px; }
    .left-panel .panel-section { padding-left: 14px; padding-right: 14px; }
    .legend-note { display: none !important; }
    .topbar-center { display: none; }
    .topbar { grid-template-columns: 1fr 1fr; }
}

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

/* Interactive AC-OPF field guide */
.docs-overlay {
    position: fixed;
    z-index: 200;
    inset: 0;
    display: grid;
    grid-template-rows: 68px minmax(0, 1fr);
    background: #f5f5ef;
    opacity: 1;
    transition-property: opacity, transform;
    transition-duration: 170ms;
    transition-timing-function: ease-out;
    animation: docsOverlayEnter 260ms cubic-bezier(.2, 0, 0, 1) both;
}

.docs-overlay[hidden] { display: none; }
.docs-overlay.closing { opacity: 0; transform: translateY(8px); }

@keyframes docsOverlayEnter {
    from { opacity: 0; transform: translateY(12px); filter: blur(4px); }
    to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

.docs-topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
    padding: 0 18px;
    background: rgba(255, 255, 252, .96);
    border-bottom: 1px solid rgba(24, 35, 29, .09);
    backdrop-filter: blur(16px);
}

.docs-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.docs-brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--green); color: #fff; box-shadow: 0 6px 15px rgba(22,107,74,.19); }
.docs-brand-mark svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.docs-brand strong, .docs-brand span { display: block; }
.docs-brand strong { font: 700 14px Inter, sans-serif; letter-spacing: -.02em; }
.docs-brand span { margin-top: 2px; color: var(--muted); font-size: 9.5px; }

.docs-progress-summary { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.docs-progress-track { width: 115px; height: 6px; overflow: hidden; border-radius: 3px; background: #e4e7df; }
.docs-progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green-2); transition-property: width; transition-duration: 300ms; transition-timing-function: cubic-bezier(.2,0,0,1); }
.docs-progress-summary > span { color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.docs-close-button {
    justify-self: end;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 13px 0 15px;
    border: 0;
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-border);
    font-size: 10.5px;
    font-weight: 700;
    transition-property: scale, box-shadow, background-color;
    transition-duration: 150ms;
}
.docs-close-button:hover { box-shadow: var(--shadow-border-hover); }
.docs-close-button:active { scale: .96; }
.docs-close-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.docs-layout { display: grid; grid-template-columns: 270px minmax(540px, 1fr) 292px; min-height: 0; }
.docs-sidebar { min-height: 0; overflow-y: auto; padding: 24px 16px 20px; background: rgba(255,255,252,.85); border-right: 1px solid rgba(24,35,29,.08); }
.docs-sidebar-intro { padding: 0 8px 17px; }
.docs-sidebar-intro h2 { max-width: 210px; font-size: 17px; line-height: 1.25; letter-spacing: -.03em; }
.docs-sidebar-intro p { margin: 7px 0 0; color: var(--muted); font-size: 9.5px; line-height: 1.5; }
.docs-chapter-list { display: grid; gap: 4px; }

.docs-chapter-button {
    display: grid;
    grid-template-columns: 29px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 53px;
    padding: 7px 8px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    text-align: left;
    transition-property: scale, background-color, color, box-shadow;
    transition-duration: 150ms;
    transition-timing-function: ease-out;
}
.docs-chapter-button:hover { background: rgba(24,35,29,.045); }
.docs-chapter-button:active { scale: .96; }
.docs-chapter-button.active { background: #fff; box-shadow: var(--shadow-border); }
.docs-chapter-number { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px; background: #ecefe8; color: var(--ink-soft); font-size: 9px; font-weight: 800; font-variant-numeric: tabular-nums; }
.docs-chapter-button.active .docs-chapter-number { background: var(--green); color: #fff; }
.docs-chapter-button.completed .docs-chapter-number { background: var(--green-pale); color: var(--green); }
.docs-chapter-text { min-width: 0; }
.docs-chapter-text strong, .docs-chapter-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-chapter-text strong { font-size: 10px; }
.docs-chapter-text small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.docs-chapter-state { display: grid; place-items: center; color: #b0bab2; }
.docs-chapter-state svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.docs-chapter-button.completed .docs-chapter-state { color: var(--green-2); }

.docs-sidebar-note { display: flex; gap: 9px; margin: 20px 4px 0; padding: 12px; border-radius: 15px; background: var(--green-pale); color: var(--green); }
.docs-sidebar-note svg { width: 19px; height: 19px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.docs-sidebar-note span, .docs-sidebar-note strong { display: block; }
.docs-sidebar-note span { font-size: 8.5px; line-height: 1.45; }
.docs-sidebar-note strong { margin-bottom: 2px; font-size: 9px; }

.docs-reader { min-width: 0; min-height: 0; overflow-y: auto; scroll-behavior: smooth; background: #f7f7f2; }
.docs-reader:focus { outline: none; }
.docs-lesson { width: min(760px, calc(100% - 64px)); min-height: calc(100% - 92px); margin: 0 auto; padding: 50px 0 38px; }
.docs-lesson.lesson-changing > * { animation: lessonChunkEnter 320ms cubic-bezier(.2,0,0,1) both; }
.docs-lesson.lesson-changing > *:nth-child(2) { animation-delay: 70ms; }
.docs-lesson.lesson-changing > *:nth-child(3) { animation-delay: 130ms; }
.docs-lesson.lesson-changing > *:nth-child(4) { animation-delay: 190ms; }

@keyframes lessonChunkEnter {
    from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
    to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

.lesson-heading { margin-bottom: 34px; }
.lesson-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; }
.lesson-index { padding: 5px 8px; border-radius: 8px; background: var(--green-pale); color: var(--green); font-size: 8.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.lesson-duration { color: var(--muted); font-size: 8.5px; }
.lesson-heading h1 { max-width: 660px; font-size: clamp(30px, 3.4vw, 43px); line-height: 1.07; letter-spacing: -.05em; }
.lesson-heading .lesson-lede { max-width: 660px; margin: 15px 0 0; color: var(--ink-soft); font-size: 14px; line-height: 1.65; }

.lesson-section { margin-top: 34px; }
.lesson-section h2 { margin-bottom: 12px; font-size: 20px; line-height: 1.22; letter-spacing: -.035em; }
.lesson-section h3 { margin: 20px 0 8px; font-size: 13px; letter-spacing: -.02em; }
.lesson-section > p, .lesson-section li { color: var(--ink-soft); font-size: 11.5px; line-height: 1.68; }
.lesson-section > p { margin: 0 0 12px; }
.lesson-section ul, .lesson-section ol { margin: 12px 0; padding-left: 20px; }
.lesson-section li { margin: 6px 0; padding-left: 3px; }
.lesson-section strong { color: var(--ink); }

.big-picture-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 22px 0 0; }
.picture-step { position: relative; min-height: 113px; padding: 13px; border-radius: 16px; background: #fff; box-shadow: var(--shadow-border); }
.picture-step:not(:last-child)::after { content: ""; position: absolute; z-index: 2; top: 50%; right: -8px; width: 8px; height: 2px; background: var(--line-strong); }
.picture-step span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 8px; background: var(--green-pale); color: var(--green); font-size: 8.5px; font-weight: 800; }
.picture-step strong { display: block; margin-top: 10px; font-size: 10px; }
.picture-step small { display: block; margin-top: 4px; color: var(--muted); font-size: 8.5px; line-height: 1.4; }

.concept-callout { display: grid; grid-template-columns: 38px 1fr; gap: 12px; margin: 20px 0; padding: 15px; border-radius: 18px; background: var(--green-pale); color: var(--green); }
.concept-callout.warning { background: var(--amber-pale); color: #965f0e; }
.concept-callout-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: rgba(255,255,255,.65); font: 800 14px Inter, sans-serif; }
.concept-callout strong, .concept-callout p { display: block; }
.concept-callout strong { margin-top: 1px; font-size: 10.5px; }
.concept-callout p { margin: 4px 0 0; color: var(--ink-soft); font-size: 9.5px; line-height: 1.5; }

.formula-card { margin: 18px 0; padding: 21px; border-radius: 20px; background: var(--ink); color: #fff; box-shadow: 0 12px 30px rgba(24,35,29,.15); }
.formula-card .formula-label { color: var(--lime); font-size: 8px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.formula { display: block; margin-top: 11px; overflow-x: auto; color: #fff; font: 500 20px Inter, sans-serif; line-height: 1.5; letter-spacing: -.02em; white-space: nowrap; }
.formula-card p { margin: 9px 0 0; color: rgba(255,255,255,.62); font-size: 9px; line-height: 1.55; }
.formula em { color: var(--lime); font-style: normal; }

.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 17px 0; }
.comparison-card { padding: 17px; border-radius: 18px; background: #fff; box-shadow: var(--shadow-border); }
.comparison-card.highlight { background: var(--green-pale); }
.comparison-card .comparison-kicker { color: var(--green-2); font-size: 8px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.comparison-card h3 { margin: 7px 0 6px; font-size: 13px; }
.comparison-card p { margin: 0; color: var(--ink-soft); font-size: 9.5px; line-height: 1.5; }
.comparison-card ul { margin: 8px 0 0; padding-left: 15px; }
.comparison-card li { margin: 3px 0; font-size: 9px; }

.lesson-interactive { margin: 24px 0; padding: 8px; border-radius: 24px; background: #e9ece5; box-shadow: 0 0 0 1px rgba(24,35,29,.04); }
.interactive-inner { padding: 20px; border-radius: 16px; background: #fff; box-shadow: 0 3px 12px rgba(24,35,29,.05); }
.interactive-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.interactive-heading h3 { margin: 0; font-size: 13px; }
.interactive-heading p { margin: 4px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.interactive-badge { flex: 0 0 auto; padding: 5px 8px; border-radius: 8px; background: var(--green-pale); color: var(--green); font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.interactive-control { margin-top: 13px; }
.interactive-control label { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--ink-soft); font-size: 9px; font-weight: 650; }
.interactive-control output { color: var(--green); font-weight: 800; font-variant-numeric: tabular-nums; }
.interactive-control input[type="range"] { width: 100%; height: 18px; margin: 0; accent-color: var(--green-2); cursor: pointer; }
.interactive-values { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 14px; }
.interactive-value { padding: 11px; border-radius: 12px; background: #f2f4ef; }
.interactive-value span, .interactive-value strong { display: block; }
.interactive-value span { color: var(--muted); font-size: 8px; }
.interactive-value strong { margin-top: 3px; font-size: 13px; font-variant-numeric: tabular-nums; }

.power-triangle-layout { display: grid; grid-template-columns: 190px 1fr; align-items: center; gap: 23px; }
.power-triangle-visual { position: relative; height: 165px; border-radius: 16px; background: #f4f5f1; overflow: hidden; }
.power-triangle-visual svg { width: 100%; height: 100%; }
.power-triangle-visual path, .power-triangle-visual line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.power-triangle-visual .triangle-p { stroke: var(--green-2); stroke-width: 3; }
.power-triangle-visual .triangle-q { stroke: var(--amber); stroke-width: 3; }
.power-triangle-visual .triangle-s { stroke: var(--ink); stroke-width: 3; }
.power-triangle-visual text { font: 700 9px "Inter", sans-serif; fill: var(--ink-soft); }

.choice-grid { display: grid; gap: 7px; }
.choice-button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 8px 11px; border: 0; border-radius: 13px; background: #f2f4ef; text-align: left; transition-property: scale, background-color, box-shadow, color; transition-duration: 150ms; }
.choice-button:hover { background: #ecefe8; }
.choice-button:active { scale: .96; }
.choice-button.selected { background: var(--green-pale); box-shadow: 0 0 0 1px rgba(22,107,74,.18); color: var(--green); }
.choice-button.incorrect { background: var(--red-pale); color: var(--red); }
.choice-letter { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; border-radius: 9px; background: #fff; box-shadow: 0 0 0 1px rgba(24,35,29,.07); font-size: 9px; font-weight: 800; }
.choice-button span:last-child { font-size: 9.5px; line-height: 1.35; }
.choice-feedback { min-height: 38px; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #f2f4ef; color: var(--muted); font-size: 9px; line-height: 1.45; }
.choice-feedback.correct { background: var(--green-pale); color: var(--green); }
.choice-feedback.incorrect { background: var(--red-pale); color: #99423c; }

.bus-role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bus-role-button { min-height: 145px; padding: 15px; border: 0; border-radius: 16px; background: #f3f4ef; text-align: left; transition-property: scale, background-color, box-shadow; transition-duration: 160ms; }
.bus-role-button:hover { background: #eef1ea; }
.bus-role-button:active { scale: .96; }
.bus-role-button.active { background: var(--green-pale); box-shadow: 0 0 0 1px rgba(22,107,74,.19); }
.mini-busbar { display: block; width: 45px; height: 6px; margin: 7px 0 18px; border-radius: 3px; background: var(--ink); }
.bus-role-button strong, .bus-role-button small { display: block; }
.bus-role-button strong { font-size: 11px; }
.bus-role-button small { margin-top: 4px; color: var(--muted); font-size: 8.5px; line-height: 1.4; }
.role-explanation { margin-top: 10px; padding: 12px; border-radius: 13px; background: var(--ink); color: #fff; font-size: 9px; line-height: 1.5; }
.role-explanation strong { color: var(--lime); }

.nr-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 14px; }
.nr-step { padding: 11px 7px; border-radius: 12px; background: #f0f2ed; opacity: .42; transition-property: opacity, background-color, transform; transition-duration: 220ms; }
.nr-step.active { opacity: 1; background: var(--green-pale); transform: translateY(-2px); }
.nr-step span, .nr-step strong { display: block; text-align: center; }
.nr-step span { color: var(--muted); font-size: 7.5px; }
.nr-step strong { margin-top: 4px; font-size: 10px; font-variant-numeric: tabular-nums; }
.interactive-action { min-height: 40px; margin-top: 13px; padding: 0 14px; border: 0; border-radius: 11px; background: var(--green); color: #fff; font-size: 9.5px; font-weight: 750; transition-property: scale, background-color, box-shadow; transition-duration: 150ms; }
.interactive-action:hover { background: #115d40; }
.interactive-action:active { scale: .96; }

.constraint-board { display: grid; grid-template-columns: 1fr 180px; gap: 16px; align-items: start; }
.constraint-list { display: grid; gap: 6px; }
.constraint-toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px; border-radius: 12px; background: #f2f4ef; cursor: pointer; }
.constraint-toggle input { width: 17px; height: 17px; accent-color: var(--green-2); }
.constraint-toggle span { font-size: 9px; }
.constraint-score { padding: 16px; border-radius: 16px; background: var(--ink); color: #fff; text-align: center; }
.constraint-score span, .constraint-score strong, .constraint-score small { display: block; }
.constraint-score span { color: rgba(255,255,255,.58); font-size: 8px; }
.constraint-score strong { margin: 7px 0 4px; color: var(--lime); font: 700 24px Inter, sans-serif; font-variant-numeric: tabular-nums; }
.constraint-score small { color: rgba(255,255,255,.58); font-size: 8px; line-height: 1.4; }

.dispatch-bars { display: grid; gap: 9px; margin-top: 14px; }
.dispatch-row { display: grid; grid-template-columns: 90px 1fr 58px; align-items: center; gap: 9px; }
.dispatch-row > span { font-size: 9px; font-weight: 650; }
.dispatch-track { height: 18px; overflow: hidden; border-radius: 9px; background: #edf0ea; }
.dispatch-fill { height: 100%; border-radius: inherit; background: var(--green-2); transition-property: width, background-color; transition-duration: 240ms; }
.dispatch-row:nth-child(2) .dispatch-fill { background: var(--blue); }
.dispatch-row:nth-child(3) .dispatch-fill { background: var(--amber); }
.dispatch-row output { text-align: right; color: var(--ink-soft); font-size: 9px; font-weight: 750; font-variant-numeric: tabular-nums; }

.price-composition { display: flex; height: 42px; overflow: hidden; margin: 14px 0 8px; border-radius: 13px; box-shadow: var(--shadow-border); }
.price-segment { display: grid; place-items: center; min-width: 28px; color: #fff; font-size: 8px; font-weight: 750; transition-property: width; transition-duration: 240ms; }
.price-segment.energy { background: var(--green-2); }
.price-segment.loss { background: var(--blue); }
.price-segment.congestion { background: var(--amber); }
.price-legend { display: flex; gap: 13px; color: var(--muted); font-size: 8px; }
.price-legend i { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 2px; }

.solver-landscape { position: relative; height: 185px; overflow: hidden; border-radius: 16px; background: linear-gradient(155deg, #edf2ec, #f7f1e6); }
.solver-landscape svg { width: 100%; height: 100%; }
.solver-landscape .contour { fill: none; stroke: rgba(24,35,29,.15); stroke-width: 1.3; }
.solver-landscape .path-a, .solver-landscape .path-b { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 4 5; }
.solver-landscape .path-a { stroke: var(--green-2); }
.solver-landscape .path-b { stroke: var(--amber); }
.solver-landscape circle { stroke: #fff; stroke-width: 2; }
.solver-landscape text { font: 700 8px "Inter", sans-serif; fill: var(--ink-soft); }

.checklist { display: grid; gap: 7px; margin-top: 14px; }
.checklist-item { display: grid; grid-template-columns: 27px 1fr; gap: 10px; padding: 11px; border-radius: 13px; background: #fff; box-shadow: var(--shadow-border); }
.checklist-item span { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; background: var(--green-pale); color: var(--green); font-size: 9px; font-weight: 800; }
.checklist-item strong, .checklist-item small { display: block; }
.checklist-item strong { font-size: 9.5px; }
.checklist-item small { margin-top: 3px; color: var(--muted); font-size: 8.5px; line-height: 1.4; }

.docs-lesson-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(760px, calc(100% - 64px)); margin: 0 auto; padding: 0 0 42px; }
.docs-nav-button { display: flex; align-items: center; gap: 11px; min-height: 60px; padding: 9px 14px; border: 0; border-radius: 17px; background: #fff; box-shadow: var(--shadow-border); text-align: left; transition-property: scale, box-shadow, background-color, opacity; transition-duration: 150ms; }
.docs-nav-button:hover:not(:disabled) { box-shadow: var(--shadow-border-hover); }
.docs-nav-button:active:not(:disabled) { scale: .96; }
.docs-nav-button:disabled { opacity: .35; cursor: default; }
.docs-nav-button.next { justify-content: flex-end; text-align: right; background: var(--green); color: #fff; }
.docs-nav-button svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.docs-nav-button span, .docs-nav-button small, .docs-nav-button strong { display: block; }
.docs-nav-button span { min-width: 0; }
.docs-nav-button small { color: var(--muted); font-size: 7.5px; font-weight: 650; }
.docs-nav-button.next small { color: rgba(255,255,255,.6); }
.docs-nav-button strong { margin-top: 2px; overflow: hidden; font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }

.docs-companion { min-height: 0; overflow-y: auto; padding: 22px 16px; background: rgba(255,255,252,.72); border-left: 1px solid rgba(24,35,29,.08); }
.companion-card { margin-bottom: 10px; padding: 16px; border-radius: 18px; background: #fff; box-shadow: var(--shadow-border); }
.companion-card h3 { font-size: 12px; line-height: 1.35; }
.companion-card > p { margin: 7px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.concept-card { background: var(--ink); color: #fff; }
.concept-card .eyebrow { color: var(--lime); }
.concept-card > p { color: rgba(255,255,255,.62); }
.companion-heading { display: flex; align-items: center; justify-content: space-between; min-height: 28px; font-size: 9px; font-weight: 750; }
.companion-heading button { width: 32px; height: 32px; border: 0; border-radius: 9px; background: #f0f2ed; color: var(--muted); transition-property: scale, background-color; transition-duration: 140ms; }
.companion-heading button:active { scale: .96; }
.glossary-card.collapsed #docsGlossary { display: none; }
.glossary-term { padding: 10px 0; border-top: 1px solid var(--line); }
.glossary-term:first-child { border-top: 0; }
.glossary-term strong, .glossary-term span { display: block; }
.glossary-term strong { font-size: 8.5px; }
.glossary-term span { margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.4; }
.lab-card { background: #f0f5e8; }
.lab-card button { width: 100%; min-height: 40px; margin-top: 13px; border: 0; border-radius: 11px; background: var(--green); color: #fff; font-size: 9px; font-weight: 750; transition-property: scale, background-color, box-shadow; transition-duration: 150ms; }
.lab-card button:hover { background: #115d40; }
.lab-card button:active { scale: .96; }

@media (max-width: 1220px) {
    .docs-layout { grid-template-columns: 250px minmax(520px, 1fr); }
    .docs-companion { display: none; }
    .documentation-button { width: 40px; padding: 0; justify-content: center; font-size: 0; }
    .documentation-button svg { width: 18px; height: 18px; }
}

@media (max-width: 1023px) {
    .app-shell { height: 100dvh; grid-template-rows: auto 48px minmax(0, 1fr) auto; }
    .topbar { display: flex; flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; }
    .topbar > .brand { flex: 1 0 100%; }
    .tool-identity { padding-left: 12px; }
    .brand-subtitle { font-size: 10px; }
    .topbar-center { display: none; }
    .topbar-actions { justify-content: flex-start; gap: 6px; flex-wrap: wrap; }
    .topbar-actions .icon-button { width: 40px; height: 40px; }
    .topbar-actions .secondary-button, .solve-button { min-height: 40px; padding: 0 10px; }
    .solve-mobile-label { display: inline; }
    #solveBtnLabel { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .documentation-button { width: 40px; padding: 0 !important; }
    .mobile-panel-nav { display: grid; grid-template-columns: repeat(4, 1fr); padding: 4px 8px; gap: 4px; background: var(--panel); border-bottom: 1px solid var(--line); }
    .mobile-panel-nav button { border: 0; border-radius: 8px; background: transparent; font-size: 12px; min-height: 40px; }
    .mobile-panel-nav button[aria-pressed="true"] { color: var(--green); background: var(--green-pale); font-weight: 700; }
    .workspace { display: block; min-height: 0; position: relative; }
    .workspace > .panel, .workspace > .canvas-shell { width: 100%; height: 100%; }
    .left-panel, .right-panel, .canvas-shell { display: none; }
    body[data-mobile-panel="diagram"] .canvas-shell { display: block; }
    body[data-mobile-panel="components"] .left-panel { display: flex; }
    body[data-mobile-panel="inspector"] .right-panel, body[data-mobile-panel="results"] .right-panel { display: block; }
    .right-panel .right-tabs { display: none; }
    .right-content { height: 100%; overflow: auto; }
    .canvas-toolbar { flex-wrap: wrap; gap: 8px; left: 10px; right: 10px; top: 10px; }
    .mode-pill { padding: 8px; font-size: 10px; }
    .zoom-controls { margin-left: auto; padding: 4px; }
    .legend { bottom: 10px; left: 10px; right: 10px; gap: 9px; flex-wrap: wrap; padding: 10px; }
    .legend-note, .legend-divider { display: none; }
    .statusbar { gap: 5px; padding: 8px 12px; flex-wrap: wrap; font-size: 11px; }
    .solver-status { flex-wrap: wrap; }
    .status-actions { width: 100%; gap: 16px; }
    .status-actions > span { display: none; }
    .status-actions button, .import-label { min-height: 40px; font-size: 12px; }
    .model-row-text strong, .result-table, .field-help { font-size: 12px; }
    .model-row-text small { font-size: 11px; }
    .form-field label { font-size: 12px; }
    .input-with-unit input, .form-field select { font-size: 16px; }
    .docs-overlay { grid-template-rows: auto minmax(0, 1fr); }
    .docs-topbar { display: flex; justify-content: space-between; padding: 12px; gap: 8px; }
    .docs-progress-summary, .docs-brand span { display: none; }
    .docs-layout { display: block; overflow-y: auto; }
    .docs-sidebar { padding: 12px; overflow: visible; }
    .docs-sidebar-intro, .docs-sidebar-note { display: none; }
    .docs-chapter-list { display: flex; overflow-x: auto; gap: 8px; }
    .docs-chapter-list > * { min-width: 190px; flex-shrink: 0; }
    .docs-reader { overflow: visible; }
    .docs-companion { display: block; padding: 16px; }
    .docs-lesson { width: calc(100% - 32px); padding: 24px 0; }
    .lesson-heading h1 { font-size: 28px; }
    .docs-lesson p, .docs-lesson li { font-size: 14px; }
}
