:root {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --surface-2: #f8fbfd;
  --text: #071827;
  --muted: #657486;
  --line: #dce7ef;
  --line-strong: #bfd0dc;
  --blue: #1ea7e1;
  --blue-2: #246bfe;
  --deep: #071827;
  --near-black: #05080c;
  --green: #17b26a;
  --orange: #f97316;
  --purple: #8b5cf6;
  --red: #ef4444;
  --shadow: 0 12px 32px rgba(7, 24, 39, 0.08);
  --radius: 8px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg: #05080c;
  --surface: #071827;
  --surface-2: #0c2233;
  --text: #eef4ff;
  --muted: #9aa8ba;
  --line: #20384a;
  --line-strong: #355267;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; letter-spacing: 0; overflow-x: hidden; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select, input, textarea { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 6px; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.link-button { border: 0; padding: 0; background: transparent; color: var(--blue); font-weight: 800; }
small, .muted { color: var(--muted); }
code, pre { font-family: "SFMono-Regular", Consolas, monospace; }

#app { --sidebar-width: 282px; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar-hover-zone { display: none; }
.mobile-topbar { display: none; }
.sidebar { position: sticky; z-index: 20; top: 0; width: var(--sidebar-width); height: 100vh; display: flex; flex-direction: column; gap: 26px; padding: 26px 16px; border-right: 1px solid var(--line); background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface-2) 84%, var(--surface))); transition: transform 180ms ease, box-shadow 180ms ease; }
#app.sidebar-mode-auto { grid-template-columns: minmax(0, 1fr); }
#app.sidebar-mode-auto .sidebar-hover-zone { position: fixed; z-index: 31; inset: 0 auto 0 0; display: block; width: 28px; }
#app.sidebar-mode-auto .sidebar { position: fixed; z-index: 32; left: 0; max-width: calc(100vw - 28px); transform: translateX(calc(12px - var(--sidebar-width))); box-shadow: var(--shadow); }
#app.sidebar-mode-auto.sidebar-auto-open .sidebar, #app.sidebar-mode-auto .sidebar:hover, #app.sidebar-mode-auto .sidebar:focus-within, #app.sidebar-mode-auto .sidebar-hover-zone:hover + .sidebar { transform: translateX(0); }
.brand { display: flex; align-items: center; min-width: 0; color: var(--text); }
.brand-lockup { display: inline-flex; align-items: center; gap: 11px; min-width: 0; color: var(--text); }
.brand-mark-image { display: block; width: 42px; height: 47px; min-width: 42px; object-fit: contain; }
.brand-wordmark { display: grid; gap: 2px; min-width: 0; line-height: 1; }
.brand-wordmark-main { display: inline-flex; align-items: baseline; color: var(--text); font-size: 20px; font-weight: 850; letter-spacing: 0; white-space: nowrap; }
.brand-wordmark-main .brand-loop, .brand-byline span { color: var(--blue); }
.brand-byline { color: var(--muted); font-size: 12px; font-weight: 650; }
.sidebar-mode-control { width: 100%; }
.sidebar-mode-control button { flex: 1; font-size: 12px; font-weight: 800; }
.nav { display: grid; gap: 6px; }
.nav a, .mobile-nav a { display: flex; align-items: center; gap: 12px; color: var(--text); border-radius: 7px; padding: 12px 14px; }
.nav a.active, .mobile-nav a.active { background: color-mix(in srgb, var(--blue) 12%, transparent); color: var(--blue); font-weight: 700; }
.icon { display: inline-grid; place-items: center; width: 18px; min-width: 18px; height: 18px; }
.icon svg { width: 18px; height: 18px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon svg circle, .icon svg rect { fill: none; }
.sidebar-footer { margin-top: auto; display: grid; gap: 14px; }
.workspace, .user { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.workspace > span, .user > span { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 7px; color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, transparent); font-weight: 800; }
.workspace div, .user div { display: grid; min-width: 0; }
.workspace strong, .user strong, .workspace small, .user small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace select { width: 100%; min-height: 30px; margin-top: 8px; padding: 4px 8px; font-size: 12px; }
.user button { margin-left: auto; border: 0; background: transparent; }

.app-main { min-width: 0; padding: 36px; overflow-x: clip; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 26px; }
.page-header h1 { margin: 0; font-size: 30px; line-height: 1.15; }
.page-header p { margin: 8px 0 0; color: var(--muted); font-size: 16px; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }
.period-pill { display: inline-flex; align-items: center; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface); font-weight: 700; white-space: nowrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 16px; font-weight: 700; white-space: nowrap; }
.btn.primary { background: var(--blue); color: white; border-color: var(--blue); box-shadow: 0 8px 18px color-mix(in srgb, var(--blue) 24%, transparent); }
.btn.secondary { background: var(--surface); }
.btn.compact { min-height: 30px; padding: 0 10px; font-size: 12px; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); background: color-mix(in srgb, var(--red) 6%, var(--surface)); }
.icon-btn { width: 34px; height: 34px; padding: 0; border: 0; background: transparent; color: var(--muted); }

.panel, .kpi, dialog { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 18px; min-width: 0; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-header h2 { margin: 0; font-size: 17px; line-height: 1.2; }
.panel-header .segmented button { padding: 0 8px; font-size: 12px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { padding: 20px; overflow: hidden; }
.kpi-title { color: var(--text); margin-bottom: 12px; }
.kpi-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kpi strong { font-size: 28px; }
.kpi p { margin: 12px 0 0; color: var(--muted); }
.spark { width: 120px; height: 44px; color: var(--blue); }
.spark-green { color: var(--green); }
.spark-orange { color: var(--orange); }
.spark-purple { color: var(--purple); }
.positive { color: var(--green); font-weight: 700; }
.negative { color: var(--red); font-weight: 700; }

.dashboard-grid, .cost-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.85fr); gap: 16px; }
.dashboard-grid .wide, .cost-grid .wide { grid-column: span 1; }
.cost-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cost-grid .wide { grid-column: span 2; }
.cost-grid .full { grid-column: 1 / -1; }
.runs-layout, .prompts-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; }
.exports-grid, .automation-grid, .editor-grid { display: grid; grid-template-columns: 330px minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.automation-grid { grid-template-columns: minmax(0, 1fr) minmax(420px, 0.8fr); }
.manual-grid, .run-detail-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr); gap: 16px; }
.right-stack { display: grid; gap: 16px; align-content: start; }
.editor-main-stack { display: grid; gap: 16px; align-content: start; min-width: 0; }

.toolbar, .filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.search { position: relative; min-width: min(100%, 420px); display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 7px; min-height: 42px; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; min-width: 120px; }
.filter-pills, .segmented { display: inline-flex; gap: 4px; min-width: 0; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.filter-pills button, .segmented button { min-width: 0; min-height: 32px; padding: 0 12px; border: 0; background: transparent; overflow: hidden; text-overflow: ellipsis; }
.filter-pills .selected, .segmented .selected { background: color-mix(in srgb, var(--blue) 12%, transparent); color: var(--blue); }
.segmented.full { display: flex; width: 100%; }
.segmented.full button { flex: 1; }
label { display: grid; gap: 7px; min-width: 0; color: var(--text); font-weight: 650; }
label small { font-weight: 400; }
input, select, textarea { min-height: 38px; padding: 8px 10px; }
textarea { min-height: 72px; resize: vertical; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 700; background: var(--surface-2); }
td small { display: block; margin-top: 4px; }
tr[data-route] { cursor: pointer; }
tr[data-route]:hover, .selected-row { background: color-mix(in srgb, var(--blue) 7%, transparent); }
.name-cell { display: flex; gap: 12px; align-items: center; min-width: 280px; }
.thumb { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 7px; background: linear-gradient(135deg, #1f2937, #94a3b8); color: white; font-weight: 800; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 250px; }
.runs-filters .search { flex: 1 1 320px; }
.runs-table th:last-child, .runs-table td:last-child { width: 170px; }
.run-action-menu { position: relative; min-width: 142px; }
.run-action-menu summary { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: var(--surface); font-size: 12px; font-weight: 800; cursor: pointer; list-style: none; }
.run-action-menu summary::-webkit-details-marker { display: none; }
.run-action-panel { position: absolute; z-index: 12; right: 0; top: calc(100% + 6px); display: grid; gap: 8px; width: 220px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.run-action-panel .btn { width: 100%; justify-content: flex-start; }
.run-export-profile { padding: 0; border: 0; background: transparent; font-size: 12px; }
.run-export-profile select { width: 100%; min-height: 32px; }
.run-failure-row { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--text); text-align: left; }
.run-failure-row span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); font-weight: 900; }
.column-list { display: grid; gap: 10px; }

.badge, .tag { display: inline-flex; align-items: center; gap: 7px; min-height: 24px; padding: 0 9px; border-radius: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-active, .status-success, .status-completed, .status-queue { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); }
.status-draft, .status-skip, .status-warning { color: var(--orange); background: color-mix(in srgb, var(--orange) 12%, transparent); border: 1px solid color-mix(in srgb, var(--orange) 35%, transparent); }
.status-failed { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); }
.status-running { color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, transparent); border: 1px solid color-mix(in srgb, var(--blue) 35%, transparent); }
.status-queued, .status-paused, .status-archived, .status-cancel-running { color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, transparent); border: 1px solid var(--line); }
.tag { color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, transparent); margin-left: 8px; }
.ring { --score: 0deg; width: 42px; height: 42px; border-radius: 50%; background: conic-gradient(var(--blue) var(--score), var(--line) 0); display: grid; place-items: center; }
.ring span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface); font-size: 11px; font-weight: 800; }
.ring.empty { background: var(--line); }
.ring-cell { display: flex; align-items: center; gap: 10px; }
.progress { width: 88px; height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 6px; }
.progress-bar { display: block; height: 100%; background: var(--green); }
.progress-bar.status-failed { background: var(--red); }
.progress-bar.status-running { background: var(--blue); }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
.choice-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px 16px; min-height: 76px; padding: 16px; text-align: left; }
.choice small { grid-column: 2; }
.choice.selected, .step-item.selected, .profile-item.selected { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 7%, transparent); }
.step-list, .profile-list { display: grid; gap: 10px; }
.step-item, .profile-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; padding: 10px; text-align: left; }
.step-select { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 12px; align-items: center; width: 100%; padding: 0; border: 0; background: transparent; text-align: left; }
.step-select div { min-width: 0; }
.step-select strong, .step-select small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-actions { display: flex; gap: 4px; }
.step-index { display: grid; place-items: center; width: 28px; height: 36px; color: var(--muted); }
.ok { color: var(--green); }
.form-stack { display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.prompt-binding, .mapping-row, .inline-field, .check, .radio { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.prompt-binding > div { display: grid; gap: 4px; min-width: 0; }
.prompt-binding strong, .prompt-binding small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-binding select { min-width: min(320px, 100%); }
.prompt-preview { padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.prompt-preview summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; font-weight: 800; }
.prompt-preview summary small { font-weight: 500; }
.prompt-meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.prompt-meta-grid div { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.prompt-meta-grid dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.prompt-meta-grid dd { margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.prompt-template-grid { display: grid; gap: 12px; }
.prompt-template-grid pre { max-height: 260px; margin: 8px 0 0; }
.mapping-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: end; }
.mapping-row input { width: 100%; }
.mapping-row label { min-width: 0; }
.mapping-arrow { display: grid; place-items: center; min-height: 38px; color: var(--muted); font-weight: 900; }
.mapping-list { display: grid; gap: 10px; }
.version-card, .selected-run { padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); margin-bottom: 10px; }
.cost-big { font-size: 28px; font-weight: 850; }

.design-grid, .asset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(112px, 100%), 1fr)); gap: 10px; max-width: 100%; overflow: hidden; }
.design-card, .asset-grid figure { min-width: 0; margin: 0; }
.design-card { cursor: zoom-in; overflow: hidden; }
.design-card:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.design-card img, .asset-grid img { display: block; width: 100%; max-width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); }
.design-card figcaption, .asset-grid figcaption { min-width: 0; margin-top: 7px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; }
.alert-list { display: grid; gap: 10px; }
.alert, .insight { padding: 14px; border-radius: 7px; border: 1px solid var(--line); }
.alert.critical { background: color-mix(in srgb, var(--red) 8%, transparent); }
.alert.warning, .insight.warning { background: color-mix(in srgb, var(--orange) 10%, transparent); }
.insight.success { background: color-mix(in srgb, var(--green) 10%, transparent); }
.insight.info { background: color-mix(in srgb, var(--blue) 10%, transparent); }
.insight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.bar-chart { height: 230px; display: flex; align-items: end; gap: 18px; padding: 42px 14px 34px; border-bottom: 1px solid var(--line); }
.bar-chart span { flex: 1; min-width: 22px; border-radius: 5px 5px 0 0; background: var(--blue); position: relative; }
.bar-chart strong { position: absolute; left: 50%; top: -24px; transform: translateX(-50%); color: var(--text); font-size: 12px; white-space: nowrap; }
.bar-chart small { position: absolute; left: 50%; bottom: -26px; transform: translateX(-50%); white-space: nowrap; }
.donut-row { display: flex; gap: 20px; align-items: center; }
.donut { width: 140px; min-width: 140px; height: 140px; border-radius: 50%; display: grid; place-items: center; }
.donut span { display: grid; place-items: center; width: 82px; height: 82px; border-radius: 50%; background: var(--surface); font-weight: 900; }
.legend { display: grid; gap: 8px; }
.legend span { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 50%; }

.summary-list { display: grid; grid-template-columns: 1fr auto; gap: 14px; margin: 0 0 14px; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; font-weight: 800; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin: 20px 0 16px; overflow-x: auto; }
.tabs a { padding: 0 0 12px; color: var(--muted); white-space: nowrap; }
.tabs .active { color: var(--blue); border-bottom: 2px solid var(--blue); font-weight: 800; }
.tabs.compact { margin: 0 0 14px; }
.tab-action { margin-left: auto; }

.run-summary { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 16px; }
.run-summary > div { padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.run-summary strong { display: block; margin-top: 6px; font-size: 16px; }
.timeline { display: grid; grid-template-columns: repeat(8, minmax(120px, 1fr)); gap: 8px; margin-bottom: 18px; overflow-x: auto; }
.timeline-step { min-width: 120px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); text-align: left; }
.timeline-step.selected { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 7%, transparent); }
.timeline-step span { color: var(--green); }
.split-panel { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.step-mini { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px; width: 100%; padding: 12px; margin-bottom: 8px; text-align: left; }
.step-mini small { grid-column: 2; }
.step-mini.selected { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 7%, transparent); }
.run-step-list { min-width: 0; }
.run-detail-main { grid-column: 1 / -1; }
.run-detail-tabs button { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 0 0 12px; white-space: nowrap; }
.run-detail-tabs button.active { color: var(--blue); border-bottom: 2px solid var(--blue); font-weight: 800; }
pre { overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); line-height: 1.55; }
.file-list div { display: flex; justify-content: space-between; padding: 11px; border-bottom: 1px solid var(--line); }

.source-target { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; margin-bottom: 16px; }
.arrow { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); }
.code-editor { width: 100%; min-height: 320px; color: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.55; }
.editor-footer { display: flex; justify-content: space-between; color: var(--muted); }
.notice { padding: 14px 16px; border: 1px solid var(--line); border-radius: 7px; margin-bottom: 16px; }
.notice.info { color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, transparent); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
.notice.success { color: var(--green); background: color-mix(in srgb, var(--green) 10%, transparent); }
.notice.warning { color: var(--orange); background: color-mix(in srgb, var(--orange) 10%, transparent); }
.notice.error { color: var(--red); background: color-mix(in srgb, var(--red) 8%, transparent); border-color: color-mix(in srgb, var(--red) 32%, transparent); }
.workflow-editor-feedback { margin-bottom: 16px; }
.automation-editor { max-height: min(760px, calc(100vh - 150px)); overflow: auto; }
.automation-editor .page-actions { position: sticky; bottom: -18px; margin: 0 -18px -18px; padding: 12px 18px 18px; background: var(--surface); border-top: 1px solid var(--line); }
.validation-list { display: grid; gap: 10px; }
.validation-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.validation-item span:last-child { min-width: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 20px; }
.settings-grid .segmented.full { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-grid .segmented.full button { padding: 0 8px; font-size: 12px; }
.settings-tabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.settings-tabs button { min-height: 42px; padding: 0 14px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-weight: 800; white-space: nowrap; }
.settings-tabs button.active { color: var(--blue); border-bottom: 2px solid var(--blue); }
.settings-panel-actions { justify-content: flex-start; margin-bottom: 16px; }
.settings-action-block { display: flex; align-items: end; }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.row input, .row select { min-width: min(260px, 100%); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 14px; }
.info-card { padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.info-card strong { display: block; margin-top: 8px; }
.constraint-list { display: grid; gap: 14px; padding-left: 20px; }
.constraint-list li::marker { color: var(--blue); }
.admin-create-form { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) auto; gap: 12px; align-items: end; margin-bottom: 18px; }
.provider-create-form { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 12px; align-items: end; margin-bottom: 18px; }
.admin-create-form .check { min-height: 38px; justify-content: center; }
.provider-create-form .check { min-height: 38px; justify-content: center; }
.admin-user-list { display: grid; gap: 14px; }
.admin-user-card { display: grid; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.admin-card-header { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.admin-card-header div { display: grid; gap: 4px; min-width: 0; }
.admin-card-header strong, .admin-card-header small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-user-main { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.membership-list, .provider-secret-list { display: grid; gap: 8px; }
.membership-row { display: grid; grid-template-columns: minmax(180px, 1fr) 150px auto auto; gap: 8px; align-items: center; }
.membership-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-secret-row { display: grid; grid-template-columns: minmax(140px, 220px) minmax(220px, 1fr) minmax(110px, auto) auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.provider-secret-name, .secret-status { display: grid; gap: 3px; min-width: 0; }
.provider-secret-name small, .secret-status small { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.provider-secret-name strong, .secret-status span, .provider-secret-updated { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.secret-status span { color: var(--muted); font-size: 0.84rem; }
.provider-secret-updated { color: var(--muted); }
.provider-secret-add { display: grid; grid-template-columns: minmax(140px, 220px) minmax(240px, 1fr) auto; gap: 10px; align-items: end; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 7px; background: color-mix(in srgb, var(--blue) 3%, var(--surface)); }
.provider-secret-add input { width: 100%; }
.provider-secret-value input { min-width: min(100%, 280px); }
.version-timeline { display: grid; gap: 12px; padding-left: 22px; }
.version-timeline li { padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.impact-dialog { width: min(680px, calc(100vw - 32px)); inset: auto 24px 40px auto; padding: 20px; }
.impact-dialog::backdrop { background: rgba(0, 0, 0, 0.25); }
.dialog-close { float: right; border: 0; background: transparent; font-size: 22px; }
.workflow-create-dialog { width: min(560px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 48px)); padding: 20px; color: var(--text); overflow: auto; }
.workflow-create-dialog .page-actions { position: sticky; bottom: -20px; margin: 0 -20px -20px; padding: 12px 20px 20px; background: var(--surface); border-top: 1px solid var(--line); }
.workflow-create-dialog::backdrop { background: rgba(0, 0, 0, 0.38); }
.audit-dialog { width: min(620px, calc(100vw - 32px)); max-height: min(780px, calc(100vh - 48px)); padding: 20px; color: var(--text); overflow: auto; }
.audit-dialog::backdrop { background: rgba(0, 0, 0, 0.38); }
.audit-event-list { display: grid; gap: 12px; margin-top: 18px; }
.audit-event { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.audit-event dl { display: grid; gap: 8px; margin: 0; }
.audit-event dl div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; }
.audit-event dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.audit-event dd { margin: 0; overflow-wrap: anywhere; }
.asset-preview-modal { width: min(980px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.asset-preview-modal::backdrop { background: rgba(0, 0, 0, 0.48); }
.asset-preview-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.asset-preview-media { display: grid; place-items: center; min-height: 360px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.asset-preview-media img { max-width: 100%; max-height: min(70vh, 640px); object-fit: contain; }
.asset-preview-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.asset-preview-header .dialog-close { float: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: var(--muted); }
.asset-preview-details h2 { margin: 6px 0 10px; font-size: 22px; }
.asset-preview-nav { display: flex; align-items: center; gap: 8px; margin: 10px 0 14px; color: var(--muted); font-weight: 700; }
.asset-preview-stepper { display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 20px; line-height: 1; }
.asset-preview-stepper:disabled { cursor: default; opacity: 0.45; }
.asset-preview-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.empty-state, .loading { padding: 36px; text-align: center; color: var(--muted); }

.login-page { grid-column: 1 / -1; width: 100%; min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--deep); background-image: linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px); background-size: 38px 38px; }
.login-panel { width: min(440px, 100%); padding: 30px; border: 1px solid color-mix(in srgb, var(--blue) 28%, #26394a); border-radius: 8px; background: #ffffff; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28); }
[data-theme="dark"] .login-panel { background: var(--surface); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42); }
.login-brand { margin-bottom: 22px; }
.login-lockup .brand-mark-image { width: 64px; height: 71px; min-width: 64px; }
.login-lockup .brand-wordmark-main { font-size: 26px; }
.login-lockup .brand-byline { font-size: 13px; }
.login-panel h1 { margin: 0 0 8px; font-size: 28px; }
.login-panel p { margin: 0 0 22px; color: var(--muted); }
.login-panel form { display: grid; gap: 16px; }
.form-error { margin-bottom: 16px; padding: 12px; border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); border-radius: 7px; color: var(--red); background: color-mix(in srgb, var(--red) 8%, transparent); }

.mobile-nav { display: none; }

@media (max-width: 1180px) {
  #app { --sidebar-width: 220px; }
  .app-main { padding: 26px; }
  .kpi-grid, .cost-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exports-grid, .editor-grid { grid-template-columns: 1fr; }
  .right-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .run-summary { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
  #app { display: block; }
  #app.sidebar-mode-auto .sidebar-hover-zone { display: none; }
  .sidebar { display: none; }
  .mobile-topbar { position: sticky; z-index: 18; top: 0; display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); }
  .mobile-topbar .brand-mark-image { width: 34px; height: 38px; min-width: 34px; }
  .mobile-topbar .brand-wordmark-main { font-size: 18px; }
  .app-main { padding: 18px 14px 82px; }
  .mobile-nav { position: fixed; z-index: 20; left: 12px; right: 12px; bottom: 12px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 8px; border: 1px solid var(--line); border-radius: 22px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
  .mobile-nav a { display: grid; justify-items: center; gap: 3px; padding: 8px 4px; font-size: 11px; }
  .page-header { display: grid; }
  .page-header h1 { font-size: 25px; }
  .page-actions { justify-content: start; }
  .kpi-grid, .dashboard-grid, .runs-layout, .prompts-layout, .cost-grid, .automation-grid, .manual-grid, .run-detail-grid, .source-target { grid-template-columns: 1fr; }
  .right-stack, .settings-grid, .info-grid, .insight-grid { grid-template-columns: 1fr; }
  .admin-create-form, .provider-create-form, .admin-user-main, .membership-row, .provider-secret-row, .provider-secret-add { grid-template-columns: 1fr; }
  .settings-action-block { align-items: start; }
  .choice-grid, .form-grid, .form-grid.three, .prompt-meta-grid, .mapping-row { grid-template-columns: 1fr; }
  .prompt-binding { display: grid; }
  .prompt-binding select { width: 100%; }
  .mapping-arrow { min-height: auto; transform: rotate(90deg); }
  .design-grid, .asset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .run-summary { grid-template-columns: 1fr 1fr; }
  .split-panel { grid-template-columns: 1fr; }
  .donut-row { align-items: flex-start; }
  .asset-preview-layout { grid-template-columns: 1fr; }
  .impact-dialog { inset: auto 12px 82px 12px; }
}
