:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #e4eaf2;
  --line-strong: #d6dfeb;
  --text: #142033;
  --muted: #6f7d90;
  --blue: #0e5bd8;
  --blue-2: #1d73f0;
  --blue-soft: #edf4ff;
  --green: #16a269;
  --green-soft: #eaf8f1;
  --orange: #e88819;
  --orange-soft: #fff5e8;
  --red: #dc4c4c;
  --red-soft: #fff0f0;
  --purple: #7755d8;
  --shadow: 0 10px 34px rgba(24, 43, 77, 0.09);
  --shadow-soft: 0 4px 18px rgba(24, 43, 77, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 236px;
  --setup: 318px;
  --assistant-h: 108px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(29, 115, 240, 0.22); outline-offset: 2px; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  height: 100vh;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px 16px 14px;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.brand-row { display: flex; align-items: center; gap: 11px; padding: 0 2px 18px; }
.brand-mark { width: 38px; height: 38px; position: relative; display: grid; place-items: center; }
.brand-mark span { position: absolute; width: 29px; height: 5px; border-radius: 999px; background: linear-gradient(90deg, #0b62dd, #48c7ee); transform-origin: center; }
.brand-mark span:nth-child(1) { transform: translateY(-10px) rotate(16deg) scaleX(.8); }
.brand-mark span:nth-child(2) { transform: translateY(-5px) rotate(12deg) scaleX(.95); }
.brand-mark span:nth-child(3) { transform: rotate(7deg); }
.brand-mark span:nth-child(4) { transform: translateY(6px) rotate(2deg) scaleX(.95); }
.brand-mark span:nth-child(5) { transform: translateY(12px) rotate(-4deg) scaleX(.76); }
.brand-name { font-size: 22px; line-height: 1; font-weight: 800; letter-spacing: -0.5px; color: #0c4fae; }
.brand-subtitle { margin-top: 4px; font-size: 8.7px; text-transform: uppercase; color: #8a97aa; letter-spacing: .1em; font-weight: 700; }

.primary-btn, .secondary-btn, .ghost-btn {
  min-height: 40px; border-radius: 9px; border: 1px solid transparent; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 700; transition: .18s ease;
}
.primary-btn { background: linear-gradient(180deg, var(--blue-2), var(--blue)); color: #fff; box-shadow: 0 5px 13px rgba(14, 91, 216, .2); }
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(14, 91, 216, .25); }
.primary-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.secondary-btn { background: #fff; color: #30415a; border-color: var(--line-strong); }
.secondary-btn:hover { border-color: #b7c5d7; background: #f9fbfe; }
.ghost-btn { background: transparent; border-color: var(--line); color: var(--blue); }
.compact { min-height: 34px; padding: 0 11px; font-size: 12px; width: 100%; }
.full { width: 100%; }
.new-project-btn { width: 100%; margin-bottom: 15px; }
.plus { font-size: 18px; line-height: 1; }

.side-nav { display: grid; gap: 3px; }
.side-nav.secondary { gap: 2px; }
.side-link { border: 0; background: transparent; color: #516079; height: 37px; border-radius: 9px; display: flex; align-items: center; gap: 11px; padding: 0 10px; text-align: left; font-size: 13px; transition: .15s ease; }
.side-link:hover { background: #f5f8fc; color: #243650; }
.side-link.active { color: var(--blue); background: var(--blue-soft); font-weight: 750; }
.nav-icon { width: 18px; display: inline-grid; place-items: center; color: #69809d; font-size: 15px; }
.side-link.active .nav-icon { color: var(--blue); }
.side-divider { height: 1px; background: var(--line); margin: 12px 4px; }
.sidebar-spacer { flex: 1 1 auto; min-height: 16px; }
.plan-card { border: 1px solid var(--line); background: linear-gradient(145deg, #f6f9ff, #fff); border-radius: 12px; padding: 11px; }
.plan-card-top { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.plan-card-top div { display: grid; gap: 2px; }
.plan-card strong, .system-state strong { font-size: 12px; }
.plan-card small, .system-state small { color: var(--muted); font-size: 10px; }
.plan-cube { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); }
.system-state { display: flex; gap: 8px; align-items: center; padding: 12px 5px 2px; }
.system-state div { display: grid; gap: 2px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.green { background: var(--green); box-shadow: 0 0 0 4px rgba(22,162,105,.1); }

.workspace { min-width: 0; height: 100vh; display: grid; grid-template-rows: 58px minmax(0, 1fr) var(--assistant-h); }
.topbar { background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(220px, 1fr) auto minmax(290px, 1fr); align-items: center; padding: 0 18px; gap: 18px; z-index: 20; }
.top-left, .top-actions, .profile, .credit-pill { display: flex; align-items: center; }
.top-left { gap: 9px; }
.crumb { font-size: 12px; color: var(--muted); }
.selector-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; height: 34px; display: flex; align-items: center; gap: 16px; padding: 0 11px; color: #25364e; font-size: 12px; font-weight: 650; }
.top-nav { display: flex; height: 100%; align-items: stretch; }
.top-nav button { border: 0; background: transparent; padding: 0 13px; font-size: 12px; color: #516079; position: relative; }
.top-nav button.active { color: var(--blue); font-weight: 750; }
.top-nav button.active::after { content: ""; height: 2px; left: 10px; right: 10px; bottom: 0; background: var(--blue); position: absolute; }
.top-actions { justify-content: flex-end; gap: 8px; }
.credit-pill { border: 1px solid var(--line); border-radius: 9px; padding: 5px 10px; gap: 8px; min-width: 112px; }
.credit-pill > span { color: var(--blue); font-size: 17px; }
.credit-pill div { display: grid; }
.credit-pill small { color: var(--muted); font-size: 8px; }
.credit-pill strong { font-size: 11px; }
.icon-btn { position: relative; border: 0; background: transparent; min-width: 34px; height: 34px; border-radius: 8px; color: #506078; display: inline-grid; place-items: center; }
.icon-btn:hover { background: #f3f6fa; }
.badge { position: absolute; top: 2px; right: 1px; width: 14px; height: 14px; border-radius: 50%; background: var(--red); color: white; font-size: 8px; display: grid; place-items: center; }
.profile { gap: 8px; margin-left: 2px; }
.profile > div { display: grid; text-align: right; }
.profile strong { font-size: 11px; }
.profile small { color: var(--muted); font-size: 9px; }
.avatar { width: 31px; height: 31px; border-radius: 50%; background: #0d4cac; color: white; font-weight: 800; display: grid; place-items: center; font-size: 12px; }

.content { overflow: auto; padding: 18px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.title-line { display: flex; align-items: center; gap: 10px; }
h1 { margin: 0; font-size: 19px; letter-spacing: -.25px; }
.title-row p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.title-actions { display: flex; gap: 8px; }
.state-badge { padding: 4px 9px; border-radius: 999px; font-size: 10px; font-weight: 750; }
.state-badge.ready { background: var(--blue-soft); color: var(--blue); }
.state-badge.running { background: var(--orange-soft); color: #b76c10; }
.state-badge.completed { background: var(--green-soft); color: var(--green); }
.state-badge.failed { background: var(--red-soft); color: var(--red); }

.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) var(--setup); gap: 14px; align-items: start; }
.center-column { min-width: 0; display: grid; gap: 12px; }
.visual-card, .chart-card, .metric-card, .setup-column { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.visual-card { overflow: hidden; }
.visual-tabs { height: 44px; display: flex; align-items: stretch; gap: 1px; padding: 0 10px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.visual-tabs button { border: 0; background: transparent; padding: 0 11px; color: #65748a; font-size: 11px; position: relative; white-space: nowrap; }
.visual-tabs button.active { color: var(--blue); font-weight: 750; }
.visual-tabs button.active::after { content: ""; height: 2px; background: var(--blue); left: 8px; right: 8px; bottom: 0; position: absolute; }
.viewport-toolbar { height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 13px; }
.viewport-toolbar > div:first-child { display: grid; }
.viewport-toolbar strong { font-size: 11px; }
.viewport-toolbar small { color: var(--muted); font-size: 9px; }
.tool-buttons { display: flex; gap: 4px; }
.mini-icon { border: 1px solid transparent; background: transparent; width: 29px; height: 29px; border-radius: 7px; color: #64738a; display: inline-grid; place-items: center; }
.mini-icon:hover, .mini-icon.active { background: var(--blue-soft); color: var(--blue); border-color: #d8e8ff; }
.viewport { position: relative; height: clamp(330px, 42vh, 510px); background: radial-gradient(circle at 50% 25%, #fff 0%, #f7faff 50%, #edf3fa 100%); overflow: hidden; }
.viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#overlayCanvas { pointer-events: none; }
.legend { position: absolute; left: 13px; top: 17px; display: grid; grid-template-columns: auto 14px auto; grid-template-rows: auto 1fr; column-gap: 6px; row-gap: 6px; background: rgba(255,255,255,.84); border: 1px solid rgba(210,222,237,.9); padding: 8px; border-radius: 9px; backdrop-filter: blur(7px); box-shadow: 0 3px 13px rgba(27,45,75,.08); }
.legend > div:first-child { grid-column: 1 / -1; display: grid; }
.legend strong { font-size: 9px; }
.legend small { font-size: 8px; color: var(--muted); }
.legend-gradient { width: 14px; height: 165px; border-radius: 4px; background: linear-gradient(to top, #1028a8 0%, #006fea 20%, #00c7d6 38%, #53d04a 55%, #f3e02e 72%, #f48a20 86%, #d7191c 100%); }
.legend-values { height: 165px; display: flex; flex-direction: column; justify-content: space-between; font-size: 8px; color: #34465f; }
.view-cube { position: absolute; top: 18px; right: 18px; width: 57px; height: 50px; transform: rotate(-8deg); color: #69778b; font-size: 7px; font-weight: 700; }
.view-cube::before { content: ""; position: absolute; inset: 9px 10px 3px; background: rgba(255,255,255,.85); border: 1px solid #cfd8e5; transform: skewY(-18deg); box-shadow: 0 5px 10px rgba(28,45,75,.08); }
.view-cube span, .view-cube b, .view-cube i { position: absolute; z-index: 1; font-style: normal; }
.view-cube span { top: 0; left: 22px; }
.view-cube b { left: 7px; top: 28px; }
.view-cube i { right: 1px; top: 27px; }
.axes { position: absolute; right: 19px; bottom: 17px; width: 50px; height: 50px; font-size: 8px; font-weight: 800; }
.axes::before { content: ""; position: absolute; left: 24px; top: 24px; width: 2px; height: 23px; background: #145dcc; transform: rotate(0deg); transform-origin: top; }
.axes::after { content: ""; position: absolute; left: 24px; top: 24px; width: 28px; height: 2px; background: #e74343; transform: rotate(-5deg); transform-origin: left; }
.axis-z { color: #145dcc; position: absolute; left: 21px; top: 0; }
.axis-y { color: #28a36a; position: absolute; left: 2px; top: 31px; }
.axis-x { color: #e74343; position: absolute; right: -2px; top: 16px; }
.probe-tooltip { position: absolute; min-width: 120px; pointer-events: none; background: rgba(12, 25, 44, .92); color: white; border-radius: 8px; padding: 8px 10px; font-size: 9px; line-height: 1.6; box-shadow: var(--shadow); transform: translate(9px, 9px); }
.viewport-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; color: #53637a; pointer-events: none; }
.viewport-empty strong { margin-top: 9px; font-size: 13px; }
.viewport-empty p { max-width: 390px; font-size: 10px; line-height: 1.5; color: var(--muted); }
.spinner-ring { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #d8e7fb; border-top-color: var(--blue); }
.viewport-empty.running .spinner-ring { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.playback-bar { min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-top: 1px solid var(--line); }
.playback-bar label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.playback-bar select { height: 30px; border: 1px solid var(--line); border-radius: 7px; padding: 0 23px 0 8px; color: #34455e; background: #fff; font-size: 10px; }
.play-btn { width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; color: var(--blue); border-radius: 7px; }
.playback-bar input[type="range"] { flex: 1; accent-color: var(--blue); }
.playback-bar output { min-width: 50px; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; font-size: 9px; color: var(--muted); text-align: center; }

.metric-grid { display: grid; grid-template-columns: repeat(7, minmax(105px, 1fr)); gap: 8px; }
.metric-card { min-height: 78px; padding: 12px; display: flex; align-items: flex-start; gap: 9px; }
.metric-card > div { min-width: 0; display: grid; gap: 3px; }
.metric-card small { color: var(--muted); font-size: 9px; }
.metric-card strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-card em { color: var(--muted); font-size: 8px; font-style: normal; }
.metric-icon { width: 22px; height: 22px; border-radius: 7px; display: inline-grid; place-items: center; flex: 0 0 auto; font-size: 10px; font-weight: 800; }
.metric-icon.green { color: var(--green); background: var(--green-soft); }
.metric-icon.blue { color: var(--blue); background: var(--blue-soft); }
.metric-icon.orange { color: var(--orange); background: var(--orange-soft); }
.metric-icon.red { color: var(--red); background: var(--red-soft); }
.metric-icon.purple { color: var(--purple); background: #f1edff; }
.link-button { border: 0; padding: 0; background: transparent; color: var(--blue); font-size: 10px; font-weight: 700; text-align: left; }

.charts-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.chart-card { padding: 11px; min-width: 0; overflow: hidden; }
.chart-card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.chart-card header > div { display: grid; gap: 2px; }
.chart-card header strong { font-size: 11px; }
.chart-card header small { color: var(--muted); font-size: 8px; }
.chart-card canvas { display: block; width: 100%; height: 210px; }
.chart-chip { font-size: 8px; background: var(--blue-soft); color: var(--blue); border-radius: 999px; padding: 5px 7px; white-space: nowrap; }
.chart-chip.green { background: var(--green-soft); color: var(--green); }
.chart-chip.neutral { background: #f2f5f9; color: #65748a; }

.setup-column { min-width: 0; overflow: hidden; position: sticky; top: 0; }
.setup-header { height: 51px; display: flex; align-items: center; justify-content: space-between; padding: 0 13px; border-bottom: 1px solid var(--line); }
.setup-header > div { display: grid; gap: 2px; }
.setup-header strong { font-size: 12px; }
.setup-header small { color: var(--muted); font-size: 8px; }
.setup-section { padding: 12px; border-bottom: 1px solid var(--line); }
.setup-section:last-child { border-bottom: 0; }
.setup-section > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.setup-section > header strong { font-size: 11px; }
.small-info { width: 16px; height: 16px; border: 1px solid #bfd3ee; color: var(--blue); border-radius: 50%; font-size: 9px; display: grid; place-items: center; }
.setup-section label { display: grid; gap: 5px; color: #738197; font-size: 9px; }
.field-row { display: grid; gap: 8px; margin-bottom: 9px; }
.field-row.two { grid-template-columns: 1fr 1fr; }
.setup-section input, .setup-section select, .drawer input, .drawer select, .drawer textarea { width: 100%; height: 34px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: #25364e; padding: 0 9px; font-size: 10px; }
.drawer textarea { height: auto; min-height: 84px; padding-top: 9px; resize: vertical; }
.switch { display: inline-flex !important; }
.switch input { display: none; }
.switch span { width: 31px; height: 18px; border-radius: 999px; background: #cfd8e5; position: relative; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; background: white; border-radius: 50%; left: 2px; top: 2px; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(13px); }
.quality-wrap { display: grid; grid-template-columns: 88px 1fr; align-items: center; gap: 11px; }
.quality-ring { width: 76px; height: 76px; border-radius: 50%; background: conic-gradient(var(--green) 0 94%, #e5ecf4 94% 100%); display: grid; place-content: center; text-align: center; position: relative; }
.quality-ring::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: white; }
.quality-ring span, .quality-ring small { z-index: 1; }
.quality-ring span { color: var(--green); font-weight: 800; font-size: 15px; }
.quality-ring small { color: var(--muted); font-size: 7px; }
.quality-list { display: grid; gap: 8px; }
.quality-list div, .compute-summary div { display: flex; justify-content: space-between; gap: 9px; }
.quality-list span, .compute-summary span { color: var(--muted); font-size: 8px; }
.quality-list b, .compute-summary b { font-size: 9px; }
.engine-state { font-size: 8px; padding: 4px 7px; border-radius: 999px; font-weight: 750; }
.engine-state.local { color: var(--green); background: var(--green-soft); }
.engine-state.cloud { color: var(--blue); background: var(--blue-soft); }
.engine-options { display: grid; gap: 7px; }
.engine-option { border: 1px solid var(--line); background: white; border-radius: 9px; min-height: 48px; display: flex; align-items: center; gap: 9px; padding: 7px 9px; text-align: left; }
.engine-option.selected { border-color: #99bef4; background: var(--blue-soft); box-shadow: inset 0 0 0 1px rgba(14,91,216,.08); }
.engine-option > span { font-size: 17px; }
.engine-option div { display: grid; gap: 2px; }
.engine-option strong { font-size: 10px; }
.engine-option small { color: var(--muted); font-size: 8px; }
.compute-summary { display: grid; gap: 7px; margin: 11px 2px; padding: 10px; border-radius: 9px; background: var(--panel-soft); }
.cloud-section > button + button { margin-top: 7px; }

.assistant-bar { background: rgba(255,255,255,.98); border-top: 1px solid var(--line); padding: 10px 18px 8px; display: grid; grid-template-columns: 255px minmax(320px, 1fr); grid-template-rows: 49px 27px; gap: 3px 14px; z-index: 20; }
.assistant-brand { display: flex; align-items: center; gap: 9px; grid-row: 1 / span 2; }
.assistant-orb { width: 31px; height: 31px; border-radius: 50%; color: var(--blue); background: radial-gradient(circle, #f8fbff, #dceaff); display: grid; place-items: center; box-shadow: inset 0 0 0 1px #cfe0f8; }
.assistant-brand > div { display: grid; gap: 3px; }
.assistant-brand strong { font-size: 10px; }
.assistant-brand strong em { font-style: normal; font-size: 7px; color: var(--blue); background: var(--blue-soft); padding: 2px 4px; border-radius: 4px; }
.assistant-brand small { color: var(--muted); font-size: 8px; line-height: 1.3; }
.assistant-input-wrap { display: grid; grid-template-columns: minmax(0,1fr) 38px; gap: 7px; align-items: center; }
.assistant-input-wrap input { height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 13px; color: #25364e; background: #fff; }
.send-btn { width: 38px; height: 38px; border: 0; color: white; background: linear-gradient(180deg, var(--blue-2), var(--blue)); border-radius: 9px; box-shadow: 0 5px 12px rgba(14,91,216,.2); }
.prompt-chips { display: flex; align-items: center; gap: 6px; overflow-x: auto; }
.prompt-chips button { height: 24px; border: 1px solid var(--line); border-radius: 999px; background: white; padding: 0 9px; white-space: nowrap; color: #68778d; font-size: 8px; }
.prompt-chips button:hover { color: var(--blue); border-color: #b8d2f6; }

.drawer-backdrop, .modal-backdrop { position: fixed; inset: 0; background: rgba(17, 28, 45, .28); backdrop-filter: blur(2px); z-index: 60; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(430px, 94vw); background: #fff; z-index: 70; box-shadow: -20px 0 50px rgba(16,31,54,.18); transform: translateX(105%); transition: transform .24s ease; display: grid; grid-template-rows: 64px minmax(0,1fr) 67px; }
.drawer.open { transform: translateX(0); }
.drawer > header, .drawer > footer, .modal > header, .modal > footer { display: flex; align-items: center; justify-content: space-between; padding: 0 17px; border-bottom: 1px solid var(--line); }
.drawer > header > div, .modal > header > div { display: grid; gap: 3px; }
.drawer > header strong, .modal > header strong { font-size: 14px; }
.drawer > header small, .modal > header small { color: var(--muted); font-size: 9px; }
.drawer-content { overflow-y: auto; padding: 17px; }
.drawer > footer, .modal > footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; gap: 9px; }
.form-section { border: 1px solid var(--line); border-radius: 11px; padding: 13px; margin-bottom: 12px; }
.form-section h3 { font-size: 11px; margin: 0 0 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-section label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; }
.help-note { color: var(--muted); background: #f7f9fc; border: 1px solid var(--line); border-radius: 9px; padding: 10px; font-size: 9px; line-height: 1.55; }
.code-block { padding: 11px; background: #111d30; color: #dbeaff; border-radius: 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; line-height: 1.55; white-space: pre-wrap; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 9px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); padding: 9px 6px; text-align: left; }
.data-table th { color: var(--muted); font-weight: 650; }

.modal { position: fixed; z-index: 80; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, 92vw); max-height: 82vh; background: #fff; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 25px 70px rgba(13,28,51,.24); display: grid; grid-template-rows: 62px minmax(0,1fr) 65px; overflow: hidden; }
.modal-body { overflow-y: auto; padding: 18px; color: #34455d; font-size: 11px; line-height: 1.6; }
.modal-body h3 { margin: 0 0 8px; color: var(--text); }
.modal-body p { margin: 0 0 10px; }
.modal-body ul { padding-left: 18px; }
.modal-body .result-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin: 12px 0; }
.summary-box { border: 1px solid var(--line); border-radius: 9px; padding: 10px; display: grid; gap: 4px; }
.summary-box small { color: var(--muted); font-size: 8px; }
.summary-box strong { font-size: 14px; }

.toast-stack { position: fixed; z-index: 100; right: 18px; bottom: calc(var(--assistant-h) + 16px); display: grid; gap: 8px; width: min(350px, calc(100vw - 36px)); }
.toast { background: rgba(16, 28, 47, .95); color: #fff; border-radius: 10px; padding: 11px 13px; display: grid; grid-template-columns: 23px 1fr auto; gap: 9px; align-items: start; box-shadow: var(--shadow); animation: toastIn .2s ease; }
.toast.success { background: rgba(18, 111, 74, .96); }
.toast.error { background: rgba(155, 45, 45, .96); }
.toast strong { font-size: 10px; }
.toast p { margin: 2px 0 0; color: rgba(255,255,255,.78); font-size: 8px; line-height: 1.4; }
.toast button { border: 0; background: transparent; color: white; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1450px) {
  :root { --sidebar: 215px; --setup: 292px; }
  .top-nav button { padding: 0 8px; }
  .charts-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .metric-grid { grid-template-columns: repeat(4, minmax(110px, 1fr)); }
}

@media (max-width: 1100px) {
  body { overflow: auto; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: transform .22s; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .workspace { height: auto; min-height: 100vh; grid-template-rows: 58px minmax(0,1fr) auto; }
  .mobile-only { display: inline-grid !important; }
  .topbar { grid-template-columns: 1fr auto; }
  .top-nav { display: none; }
  .main-grid { grid-template-columns: 1fr; }
  .setup-column { position: static; }
  .assistant-bar { position: sticky; bottom: 0; grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .assistant-brand { grid-row: auto; }
}

@media (max-width: 760px) {
  .topbar { padding: 0 9px; }
  .credit-pill, .profile > div, .crumb { display: none; }
  .content { padding: 11px; }
  .title-row { align-items: flex-start; flex-direction: column; }
  .title-actions { width: 100%; }
  .title-actions button { flex: 1; }
  .viewport { height: 330px; }
  .metric-grid, .charts-grid { grid-template-columns: 1fr 1fr; }
  .chart-card canvas { height: 190px; }
  .field-row.two, .form-grid { grid-template-columns: 1fr; }
  .playback-bar { flex-wrap: wrap; }
  .playback-bar input[type="range"] { min-width: 180px; }
}

@media (max-width: 480px) {
  .metric-grid, .charts-grid { grid-template-columns: 1fr; }
  .visual-tabs { padding: 0 4px; }
  .legend { transform: scale(.86); transform-origin: top left; }
  .assistant-bar { padding: 9px; }
  .prompt-chips { display: none; }
}

.setup-column.collapsed .setup-section { display: none; }
.setup-column.collapsed .setup-header { border-bottom: 0; }
