/* Tunggal — design tokens */
:root {
  --blue: #1254ff; --blue-hover: #0a45e0; --blue-soft: #eef3ff; --blue-line: #d5e1ff; --navy: #0b2a6f;
  --ink: #11203b; --text: #2c3a52; --muted: #66738a; --faint: #98a2b3;
  --line: #e4e8ef; --line-soft: #eef1f5; --canvas: #f6f8fb; --surface: #fff; --hover: #f8fafd;
  --green: #0f8460; --green-soft: #e7f6f0; --red: #cc3340; --red-soft: #fdeeef; --amber: #a3620a; --amber-soft: #fdf3e1;
  --radius: 10px; --radius-sm: 7px;
  --shadow-pop: 0 12px 32px -8px rgba(17, 32, 59, .18), 0 2px 6px rgba(17, 32, 59, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 240px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
h1, h2, h3, p, dl, dd, figure { margin: 0; }
h1, h2, h3, strong { color: var(--ink); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 10px 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.link { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 550; }
.link:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 13.5px; font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn.primary { background: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(18, 84, 255, .25), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn.primary:hover:not(:disabled) { background: var(--blue-hover); }
.btn.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: 0 1px 1px rgba(17, 32, 59, .04); }
.btn.secondary:hover:not(:disabled) { background: var(--hover); border-color: #d3d9e3; }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #b42733; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--line-soft); color: var(--ink); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; height: 38px; }
.btn svg { flex-shrink: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Shell */
.app { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px 12px; z-index: 30; }
.sidebar-top { padding: 2px 8px 18px; }
.brand { display: inline-block; }
.brand img { display: block; height: 26px; width: auto; }
.workspace { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; margin-bottom: 14px; background: var(--canvas); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); text-align: left; color: var(--muted); }
.workspace:hover { border-color: var(--line); }
.workspace-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.nav-link { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 520; font-size: 13.5px; position: relative; }
.nav-link:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.nav-link svg { flex-shrink: 0; }
.account { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 6px 2px; border-top: 1px solid var(--line-soft); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--navy); color: #fff; font-size: 11.5px; font-weight: 650; flex-shrink: 0; }
.account-meta { flex: 1; min-width: 0; line-height: 1.3; }
.account-meta strong { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-meta span { font-size: 12px; color: var(--muted); }
.main { margin-left: var(--sidebar); min-width: 0; }
.content { max-width: 1280px; margin: 0 auto; padding: 28px 36px 64px; }
.mobile-bar, .scrim { display: none; }
.page-loading { display: grid; place-items: center; min-height: 50vh; color: var(--faint); }
.boot { min-height: 100vh; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 24px; }

/* Page header */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; min-height: 36px; }
.page-head h1 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
.page-head p { color: var(--muted); margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel + .panel, .grid + .panel, .panel + .grid { margin-top: 16px; }
.grid > .panel + .panel, .playground > .panel + .panel { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; min-height: 52px; }
.panel-head h2 { font-size: 14.5px; font-weight: 620; }
.panel-head .meta { color: var(--muted); font-size: 13px; }
.panel-head + .table-wrap, .panel-head + .list { border-top: 1px solid var(--line-soft); }
.panel-body { padding: 4px 18px 18px; }
.pad { padding: 18px; }
.pad .facts > div:last-child, .pad .facts > div:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.wide-left { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > .panel + .panel { margin-top: 0; }

/* Signature: spend panel (KPIs + chart in one surface) */
.spend { padding: 0; overflow: hidden; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line-soft); }
.kpi { padding: 18px 20px 16px; border-left: 1px solid var(--line-soft); }
.kpi:first-child { border-left: 0; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 640; color: var(--ink); letter-spacing: -.025em; line-height: 1.2; margin-top: 6px; }
.kpi-note { font-size: 12.5px; color: var(--faint); margin-top: 3px; }
.kpi-note.bad { color: var(--red); }
.kpi.lead .kpi-value { color: var(--blue); }
.chart-area { position: relative; padding: 12px 20px 6px; }
.chart { display: block; overflow: visible; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis { stroke: var(--line); }
.chart .series { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart text { fill: var(--faint); font-size: 11.5px; }
.chart .cursor { stroke: #b9c7e6; stroke-dasharray: 3 3; opacity: 0; }
.chart .cursor.on { opacity: 1; }
.chart .marker { fill: var(--surface); stroke: var(--blue); stroke-width: 2.5; opacity: 0; }
.chart .marker.on { opacity: 1; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; border-radius: 7px; padding: 7px 10px; font-size: 12px; line-height: 1.35; box-shadow: var(--shadow-pop); white-space: nowrap; margin-top: 12px; }
.chart-tip span { display: block; color: #a9b6cc; }
.chart-tip strong { color: #fff; font-size: 14px; display: block; }
.chart-tip em { font-style: normal; color: #c8d3e6; }
.chart-empty { height: 220px; display: grid; place-items: center; color: var(--faint); }

/* Lists with bars */
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.rank li:last-child { border-bottom: 0; }
.rank .name { color: var(--ink); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .value { color: var(--ink); font-weight: 600; }
.rank .bar { grid-column: 1 / -1; }
.rank .sub { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.bar { display: block; height: 6px; border-radius: 6px; background: var(--line-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--blue); transition: width .4s ease; }
.bar.warn > span { background: #e0942a; }
.bar.bad > span { background: var(--red); }
.bar.good > span { background: var(--green); }
.bar.thin { height: 4px; }

/* Attention list */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line-soft); }
.list > li:last-child { border-bottom: 0; }
.attention a { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: var(--text); }
.attention a:hover { background: var(--hover); text-decoration: none; }
.attention .count { min-width: 28px; height: 24px; padding: 0 7px; border-radius: 12px; display: grid; place-items: center; font-weight: 650; font-size: 12.5px; }
.attention .count.warn { background: var(--amber-soft); color: var(--amber); }
.attention .count.bad { background: var(--red-soft); color: var(--red); }
.attention .count.info { background: var(--blue-soft); color: var(--blue); }
.attention span.text { flex: 1; }
.attention svg { color: var(--faint); }
.all-clear { display: flex; align-items: center; gap: 10px; padding: 18px; color: var(--muted); }
.all-clear svg { color: var(--green); }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 550; font-size: 12.5px; color: var(--muted); padding: 9px 16px; background: #fbfcfd; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-id] { cursor: pointer; }
.table tbody tr:hover td { background: var(--hover); }
.table .num { text-align: right; }
.table .primary { color: var(--ink); font-weight: 560; }
.table .secondary { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.table .wrap { white-space: normal; min-width: 220px; }
.table .actions { width: 1%; text-align: right; }
.table .actions > * { vertical-align: middle; }
.cell-flex { display: flex; align-items: center; gap: 10px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 13px; }

/* Status, tags, providers */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text); white-space: nowrap; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.status.tone-good::before { background: #16a874; }
.status.tone-bad::before { background: var(--red); }
.status.tone-warn::before { background: #e39a2d; }
.status.tone-info::before { background: var(--blue); }
.tag { display: inline-flex; align-items: center; height: 21px; padding: 0 7px; border-radius: 5px; font-size: 12px; font-weight: 550; background: var(--line-soft); color: var(--muted); white-space: nowrap; }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.demo { background: #f1ecfb; color: #7454b0; height: 19px; font-size: 11.5px; }
.provider { width: 28px; height: 28px; border-radius: 7px; display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 700; flex-shrink: 0; background: var(--line-soft); color: var(--muted); }
.provider.p-openai { background: #e9f6f0; color: #1d7a57; }
.provider.p-anthropic { background: #f8efe6; color: #9a6a3c; }
.provider.p-google { background: #eaf1fe; color: #2f62c9; }
.provider.p-compatible { background: #eef1f5; color: #4d5b72; }
.provider.p-demo { background: #f1ecfb; color: #7454b0; }

.budget-used { display: flex; flex-direction: column; gap: 6px; min-width: 160px; max-width: 240px; }

/* Spend breakdown */
.breakdown { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line-soft); }
.breakdown > div { padding: 14px 18px 16px; border-left: 1px solid var(--line-soft); min-width: 0; }
.breakdown > div:first-child { border-left: 0; }
.breakdown h3 { font-size: 12.5px; font-weight: 560; color: var(--muted); margin-bottom: 8px; }
.breakdown ul { list-style: none; margin: 0; padding: 0; }
.breakdown li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 13px; }
.breakdown li span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.breakdown li b { font-weight: 600; color: var(--ink); }
.panel + .toolbar { margin-top: 18px; }

/* Toolbar, filters, segmented */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 10px; color: var(--faint); pointer-events: none; }
.search input { height: 34px; width: 280px; padding: 0 12px 0 34px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); outline: none; }
.search input:focus, .select:focus { border-color: #8aa9ff; box-shadow: 0 0 0 3px var(--blue-soft); }
.select { height: 34px; padding: 0 30px 0 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2366738a' stroke-width='1.7' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 9px center; appearance: none; outline: none; color: var(--ink); }
.segmented { display: inline-flex; padding: 3px; background: var(--line-soft); border-radius: 9px; gap: 2px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 4px 11px; border-radius: 6px; font-size: 13px; font-weight: 550; color: var(--muted); cursor: pointer; user-select: none; }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(17, 32, 59, .1); }
.segmented input:focus-visible + span { outline: 2px solid var(--blue); }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { border: 0; background: none; padding: 0 0 10px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 550; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--blue); }

/* Menus */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: fixed; z-index: 50; min-width: 160px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; }
.menu-list button { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 6px; font-size: 13.5px; color: var(--ink); }
.menu-list button:hover { background: var(--hover); }
.menu-list button.danger { color: var(--red); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 560; color: var(--ink); }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .input {
  width: 100%; min-height: 36px; padding: 7px 11px; border: 1px solid #dbe0e8; border-radius: var(--radius-sm); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; color: var(--ink);
}
.field select { appearance: none; padding-right: 32px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2366738a' stroke-width='1.7' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: #8aa9ff; box-shadow: 0 0 0 3px var(--blue-soft); }
.field input[readonly] { background: var(--canvas); color: var(--muted); }
.field textarea { resize: vertical; min-height: 92px; line-height: 1.55; }
.field textarea.code, .field input.code { font-family: var(--mono); font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-section { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.form-section > legend { padding: 0; margin-bottom: 12px; font-size: 14px; font-weight: 640; color: var(--ink); }
.form-section > legend + .hint { margin: -8px 0 12px; }
.form-error { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; margin-bottom: 16px; border-radius: var(--radius-sm); background: var(--red-soft); color: #a3222e; font-size: 13.5px; }
.form-error svg { margin-top: 1px; flex-shrink: 0; }
.check-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 220px; overflow: auto; }
.check { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 6px; cursor: pointer; min-width: 0; }
.check:hover { background: var(--hover); }
.check-list.one { grid-template-columns: minmax(0, 1fr); max-height: none; }
.check span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.check small { margin-left: auto; color: var(--faint); font-size: 12px; }
.check input, .switch input { accent-color: var(--blue); }
.switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 34px; height: 20px; border-radius: 10px; background: #d3d9e3; position: relative; flex-shrink: 0; transition: background .15s; margin-top: 1px; }
.switch-track::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--blue); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--blue); outline-offset: 2px; }
.disclosure { border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 4px; }
.disclosure > summary { cursor: pointer; font-weight: 560; color: var(--ink); list-style: none; display: flex; align-items: center; gap: 6px; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary svg { transition: transform .15s; color: var(--muted); }
.disclosure[open] > summary svg { transform: rotate(90deg); }
.disclosure > .disclosure-body { margin-top: 14px; }

/* Option cards (radio) */
.choice-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice-card { position: relative; display: block; padding: 11px 13px 11px 38px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.choice-card:hover { border-color: #cdd5e1; }
.choice-card input { position: absolute; left: 13px; top: 13px; accent-color: var(--blue); }
.choice-card strong { display: block; font-size: 13.5px; font-weight: 600; }
.choice-card span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.choice-card:has(input:checked) { border-color: var(--blue); background: #f8faff; box-shadow: 0 0 0 1px var(--blue); }

/* Builders (ordered picks, rules, checks) */
.picker { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.picker-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line-soft); background: var(--surface); }
.picker-row:last-child { border-bottom: 0; }
.picker-row .rank-no { width: 20px; height: 20px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; flex-shrink: 0; }
.picker-row .grow { flex: 1; min-width: 0; }
.picker-row .grow strong { display: block; font-weight: 560; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-row .grow small { color: var(--muted); font-size: 12px; }
.picker-row .icon-btn { width: 28px; height: 28px; }
.picker-empty { padding: 14px 12px; color: var(--muted); font-size: 13px; }
.picker-add { display: flex; gap: 8px; margin-top: 8px; }
.picker-add select { flex: 1; }
.rule { border: 1px solid var(--line); border-radius: 9px; padding: 12px; display: grid; gap: 10px; background: var(--hover); }
.rule + .rule { margin-top: 8px; }
.rule-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rule-line > span { color: var(--muted); font-size: 13px; }
.rule-line .input { width: auto; flex: 1; min-width: 140px; }
.rule-line select.input { flex: 0 0 auto; width: auto; padding-right: 30px; appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2366738a' stroke-width='1.7' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 8px center; }
.rule .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle { position: relative; }
.chip-toggle input { position: absolute; opacity: 0; }
.chip-toggle span { display: inline-block; padding: 4px 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; cursor: pointer; color: var(--muted); }
.chip-toggle input:checked + span { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue); font-weight: 560; }
.chip-toggle input:focus-visible + span { outline: 2px solid var(--blue); }
.add-row { margin-top: 8px; }

/* Dialogs: modal and drawer */
dialog { padding: 0; border: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); max-height: 100vh; }
dialog::backdrop { background: rgba(14, 24, 44, .38); }
.modal { width: min(560px, calc(100vw - 32px)); max-height: min(88vh, 900px); border-radius: 14px; margin: auto; }
.modal.sm { width: min(420px, calc(100vw - 32px)); }
.modal.lg { width: min(820px, calc(100vw - 32px)); }
.modal[open] { display: flex; flex-direction: column; animation: pop .16s ease-out; }
.drawer { width: min(560px, 100vw); height: 100vh; max-height: 100vh; margin: 0 0 0 auto; border-radius: 0; border-left: 1px solid var(--line); }
.drawer.lg { width: min(760px, 100vw); }
.drawer[open] { display: flex; flex-direction: column; animation: slide .2s ease-out; }
@keyframes pop { from { transform: translateY(6px) scale(.985); } }
@keyframes slide { from { transform: translateX(32px); } }
@keyframes fade { from { opacity: 0; } }
dialog[open]::backdrop { animation: fade .16s ease-out; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-soft); flex-shrink: 0; }
.dialog-head h2 { font-size: 16.5px; font-weight: 650; letter-spacing: -.01em; }
.dialog-head p { margin-top: 4px; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dialog-body { padding: 18px 20px 20px; overflow-y: auto; flex: 1; }
.modal.sm .dialog-head { border-bottom: 0; padding-bottom: 4px; }
.modal.sm .dialog-body { padding-top: 8px; }
.dialog-text { color: var(--text); margin-bottom: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.drawer .dialog-actions.sticky { position: sticky; bottom: -20px; margin: 20px -20px -20px; padding: 14px 20px; background: var(--surface); border-top: 1px solid var(--line-soft); }
.secret { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 8px 8px 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--canvas); }
.secret code { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.choice { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); text-align: left; }
.choice:hover { border-color: #cdd5e1; background: var(--hover); }
.choice strong { flex: 1; font-weight: 580; }
.choice span { color: var(--muted); font-size: 13px; }
.choice.current { border-color: var(--blue-line); background: #f8faff; }
.choice.current svg { color: var(--blue); }

/* Detail blocks */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.facts > div { padding: 9px 0; border-bottom: 1px solid var(--line-soft); min-width: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { color: var(--ink); font-weight: 520; margin-top: 1px; overflow-wrap: anywhere; }
.facts dd .secondary { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; }
.stat-row > div { padding: 12px 14px; border-left: 1px solid var(--line-soft); }
.stat-row > div:first-child { border-left: 0; }
.stat-row span { display: block; font-size: 12.5px; color: var(--muted); }
.stat-row strong { display: block; font-size: 18px; font-weight: 640; margin-top: 2px; letter-spacing: -.01em; }
.block { margin-top: 22px; }
.block > h3 { font-size: 13.5px; font-weight: 640; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.text-out { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; padding: 14px 16px; border-radius: 9px; background: var(--canvas); border: 1px solid var(--line-soft); color: var(--ink); font-size: 14px; }
.text-out .role { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.text-out .role + * { margin-bottom: 10px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 9px; background: var(--canvas); color: var(--muted); font-size: 13px; }
.notice svg { flex-shrink: 0; margin-top: 1px; }
.notice.warn { background: var(--amber-soft); color: #7c4c08; }

/* Signature: attempt timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 28px; }
.timeline li::before { content: ''; position: absolute; left: 8px; top: 20px; bottom: -2px; width: 2px; background: var(--line); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.timeline .node { position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); background: var(--faint); }
.timeline .node.tone-good { background: #16a874; }
.timeline .node.tone-bad { background: var(--red); }
.timeline .node.tone-warn { background: #e39a2d; }
.timeline .node.tone-info { background: var(--blue); }
.timeline .head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.timeline .head strong { font-weight: 600; }
.timeline .head .amount { color: var(--ink); font-weight: 600; }
.timeline .detail { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); font-size: 13px; margin-top: 2px; }
.timeline .error { color: var(--red); font-size: 13px; margin-top: 2px; }
.timeline .btn { margin-top: 8px; }

/* Stepper (recommendation lifecycle) */
.stepper { display: flex; list-style: none; margin: 0 0 20px; padding: 0; counter-reset: step; }
.stepper li { flex: 1; position: relative; font-size: 12.5px; color: var(--faint); padding-top: 22px; }
.stepper li::before { content: ''; position: absolute; top: 5px; left: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); z-index: 1; }
.stepper li::after { content: ''; position: absolute; top: 10px; left: 12px; right: 0; height: 2px; background: var(--line); }
.stepper li:last-child::after { display: none; }
.stepper li.done { color: var(--ink); }
.stepper li.done::before { background: var(--blue); border-color: var(--blue); }
.stepper li.done::after { background: var(--blue); }
.stepper li.current { color: var(--ink); font-weight: 600; }
.stepper li.current::before { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.case-list > li { padding: 12px 0; }
.case-list p { color: var(--text); font-size: 13.5px; margin: 3px 0 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.case-group { margin-bottom: 16px; }
.case-group > strong { display: block; margin-bottom: 2px; font-weight: 600; }
.grow { flex: 1; min-width: 0; }
.dialog-actions .hint { align-self: center; }
.drawer .panel.table-wrap { margin-bottom: 4px; }

/* Collapsible blocks */
.fold { border: 1px solid var(--line); border-radius: 9px; margin-top: 10px; }
.fold > summary { cursor: pointer; list-style: none; padding: 10px 14px; font-weight: 560; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary svg { color: var(--muted); transition: transform .15s; }
.fold[open] > summary svg { transform: rotate(90deg); }
.fold > .fold-body { padding: 0 14px 14px; }

/* Playground */
.playground { display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.playground .panel-body { padding-top: 16px; }
.playground textarea[name=prompt] { min-height: 170px; }
.composer-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.composer-actions .kbd { margin-right: auto; color: var(--faint); font-size: 12.5px; }
.result { min-height: 360px; display: flex; flex-direction: column; }
.result .tabs { padding: 14px 18px 0; margin-bottom: 0; }
.result-body { padding: 18px; flex: 1; }
.result-idle { height: 100%; min-height: 260px; display: grid; place-items: center; text-align: center; color: var(--faint); }
.result-meta { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); }
.result-meta b { color: var(--ink); font-weight: 600; }
.result-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.result-actions .spacer { flex: 1; }
.feedback-btn.on { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-line); }

.field > .segmented { align-self: flex-start; }

/* AI routing qualified models */
.coverage-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 9px; margin-top: 6px; overflow: hidden; }
.coverage-row { padding: 4px 6px; border-bottom: 1px solid var(--line-soft); }
.coverage-row:last-child { border-bottom: 0; }
.coverage-detail { padding: 2px 8px 10px 34px; }
.coverage-detail[hidden] { display: none; }
.coverage-list > .hint { padding: 12px; }

/* Attachments */
.attachments { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.file-list { display: flex; flex-wrap: wrap; gap: 6px; }
.file-list:empty { display: none; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 30px; padding: 0 2px 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--hover); font-size: 13px; color: var(--ink); }
.file-chip > svg { color: var(--muted); flex-shrink: 0; }
.file-chip.pending { padding-right: 10px; color: var(--muted); }
.file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.file-size { color: var(--faint); font-size: 12px; }
.file-chip .icon-btn { width: 24px; height: 24px; }
.attach-btn { cursor: pointer; margin-left: -8px; }
.attach-btn:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
#needs-text { width: 100%; display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--hover); }
#needs-text[hidden] { display: none; }
.needs-text-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Recommendation list */
.recs .rec { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 24px; padding: 16px 18px; cursor: pointer; }
.recs .rec:hover { background: var(--hover); }
.rec h3 { font-size: 14.5px; font-weight: 600; }
.rec p { color: var(--muted); font-size: 13px; max-width: 70ch; }
.rec .rec-meta { display: flex; gap: 14px; align-items: center; margin-top: 6px; font-size: 13px; color: var(--muted); }
.rec .impact { text-align: right; grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.rec .impact strong { display: block; font-size: 18px; font-weight: 650; color: var(--green); letter-spacing: -.01em; }
.rec .impact span { font-size: 12.5px; color: var(--muted); }
.rec .impact.none strong { color: var(--faint); font-size: 14px; font-weight: 550; }

/* Settings layout */
.settings-row { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; padding: 26px 0; border-top: 1px solid var(--line); }
.settings-row:first-of-type { border-top: 0; padding-top: 4px; }
.settings-row > header h2 { font-size: 15px; font-weight: 640; }
.settings-row > header p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.code-block { position: relative; background: var(--ink); color: #c9d6ec; border-radius: 9px; padding: 14px 16px; font: 12.5px/1.7 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.code-block .btn { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .12); color: #dfe7f5; box-shadow: none; }
.code-block .btn:hover { background: rgba(255, 255, 255, .16); }
.inline-copy { display: flex; gap: 8px; }
.inline-copy input { flex: 1; }

/* Empty, toast */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty strong { display: block; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty p { max-width: 42ch; margin: 0 auto; }
.empty .btn { margin-top: 16px; }
.page-error { margin-top: 10vh; }
#toast-stack { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-radius: 9px; background: var(--ink); color: #fff; font-size: 13.5px; box-shadow: var(--shadow-pop); animation: pop .16s ease-out; max-width: min(460px, calc(100vw - 32px)); }
.toast svg { color: #6ee0b4; flex-shrink: 0; }
.toast.error svg { color: #ff9aa2; }
.toast.leaving { opacity: 0; transform: translateY(4px); transition: opacity .3s, transform .3s; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: var(--canvas); }
.auth-wrap { width: min(400px, 100%); }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 1px 2px rgba(17, 32, 59, .04), 0 8px 24px -12px rgba(17, 32, 59, .08); }
.auth-logo { display: block; height: 30px; width: auto; margin: 0 0 22px 2px; }
.auth h1 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 20px; }
.auth .field input { min-height: 40px; }
.auth form .btn.block { margin-top: 4px; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--faint); font-size: 12.5px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-switch { margin-top: 18px; color: var(--muted); font-size: 13.5px; text-align: center; }

/* Responsive */
/* Admin */
.account { gap: 8px; }
.account .icon-btn + .icon-btn { margin-left: -4px; }
.tabs .count { margin-left: 5px; color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.input-action { display: flex; gap: 8px; }
.input-action input { flex: 1; min-width: 0; }
.input-action .btn { height: auto; }
.profile-form { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--line-soft); }
.profile-form .form-section { margin: 0; }
.member-row, .member-add { display: grid; grid-template-columns: minmax(0, 1fr) 132px 84px; gap: 10px; align-items: center; }
.member-row { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.member-row .btn { justify-content: center; }
.member-row.off .member-name { color: var(--muted); }
.member-name { font-weight: 560; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.member-name .secondary { display: block; font-size: 12px; font-weight: 450; color: var(--muted); }
.member-add { margin-top: 12px; }
.member-add .select, .member-row .select { width: 100%; }
.dialog-actions.start { justify-content: flex-start; margin-top: 2px; }

@media (max-width: 1180px) {
  .content { padding: 24px 24px 56px; }
  .grid.wide-left { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
  .grid.two, .grid.wide-left, .playground { grid-template-columns: minmax(0, 1fr); }
  .breakdown { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .breakdown > div:nth-child(3) { border-left: 0; }
  .breakdown > div:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
  .settings-row { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-pop); visibility: hidden; }
  .app.nav-open .sidebar { transform: none; visibility: visible; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(14, 24, 44, .3); z-index: 25; }
  .main { margin-left: 0; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .mobile-bar img { height: 22px; width: auto; }
  .content { padding: 18px 16px 48px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: flex-start; }
  .page-head h1 { font-size: 20px; }
  .kpi { padding: 14px 16px; }
  .kpi-value { font-size: 21px; }
  .search, .search input { width: 100%; }
  .toolbar .select { flex: 1; }
  .form-grid, .form-grid.three, .facts, .choice-cards, .check-list { grid-template-columns: minmax(0, 1fr); }
  .stat-row { grid-template-columns: minmax(0, 1fr); }
  .stat-row > div { border-left: 0; border-top: 1px solid var(--line-soft); }
  .stat-row > div:first-child { border-top: 0; }
  .recs .rec { grid-template-columns: minmax(0, 1fr); }
  .rec .impact { grid-row: auto; grid-column: 1; text-align: left; }
  .table th, .table td { padding: 10px 12px; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

[hidden] { display: none !important; }
