:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1b1f24; --muted: #69707a; --border: #dde1e6;
  --accent: #2f5bd3; --accent-text: #ffffff; --user: #eef3ff; --a: #f1f8ef; --b: #fbf3ea;
  --mod: #f3eefb; --error: #b42318; --error-bg: #fdecea;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --surface: #1a1e24; --text: #e6e9ee; --muted: #9aa3ae; --border: #2c323a;
    --accent: #6d8ff0; --accent-text: #0b0d10; --user: #1d2638; --a: #1b2a1d; --b: #2d2418;
    --mod: #26203a; --error: #f97066; --error-bg: #3a1d1b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.error { color: var(--error); min-height: 1.5em; }
.status { color: var(--muted); min-height: 1.5em; margin: 6px 0 0; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { margin-right: auto; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: transparent; color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }

main { padding: 16px; }
.split { display: grid; grid-template-columns: 240px 1fr; gap: 16px; height: calc(100vh - 90px); }
.sidebar { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.conv-list button.conv { width: 100%; text-align: left; background: transparent; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-list button.conv.active { background: var(--user); }
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.panel.wide { max-width: 1100px; margin: 0 auto; }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px; min-height: 120px; }
.msg { border-radius: 10px; padding: 10px 12px; border: 1px solid var(--border); }
.msg-head { display: flex; gap: 10px; justify-content: space-between; font-size: .85em; margin-bottom: 4px; flex-wrap: wrap; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.role-user { background: var(--user); }
.speaker-a { background: var(--a); }
.speaker-b { background: var(--b); }
.speaker-moderator { background: var(--mod); }
.role-error { background: var(--error-bg); color: var(--error); }
.composer { display: grid; grid-template-columns: 200px 1fr auto; gap: 8px; margin-top: 10px; align-items: end; }
.debate-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row.space { justify-content: space-between; align-items: center; }
.row label { display: flex; flex-direction: column; gap: 4px; font-size: .9em; }
.row label.grow { flex: 1; min-width: 200px; }
.card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.table-wrap { overflow-x: auto; }
table.tasks { width: 100%; border-collapse: collapse; }
table.tasks th, table.tasks td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
td.actions { display: flex; gap: 6px; }
.status-failed { color: var(--error); }
.task-detail { margin-top: 12px; }
.task-detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; }
.task-detail dd { margin: 0; overflow-wrap: anywhere; }
.events .lvl-error { color: var(--error); }
.voice-log { color: var(--muted); }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.login-card h1 { font-size: 1.2rem; margin-top: 0; }
.login-card form { display: flex; flex-direction: column; gap: 8px; }
.login-card button { margin-top: 8px; }

@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; height: auto; }
  .sidebar { max-height: 200px; }
  .messages { max-height: 60vh; }
  .composer { grid-template-columns: 1fr; }
}

/* ---- v0.2: bütçe, yönlendirme, maliyet paneli ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hint { color: var(--muted); font-size: .85em; margin: 6px 0 0; }
button.small { padding: 4px 10px; font-size: .85em; }
.composer { grid-template-columns: 240px 1fr auto; }
.composer-opts { display: flex; flex-direction: column; gap: 6px; }
label.check { display: flex; gap: 6px; align-items: center; font-size: .9em; }
label.check input { width: auto; }
.msg-note { color: var(--muted); font-size: .85em; text-align: center; margin: 0; }

.viz-root {
  --series-1: #2a78d6; --track: #cde2fb; --grid: #e1e0d9; --axisline: #c3c2b7; --ink-muted: #898781;
  --st-good: #0ca30c; --st-warning: #fab219; --st-serious: #ec835a; --st-critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  .viz-root { --series-1: #3987e5; --track: #0d366b; --grid: #2c2c2a; --axisline: #383835; }
}
.banner { display: flex; gap: 10px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.banner .status-icon, .status-chip .status-icon { display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em; border-radius: 999px; font-weight: 700; font-size: .8em; color: #0b0b0b; }
.level-warning .status-icon { background: #fab219; }
.level-serious .status-icon { background: #ec835a; }
.level-critical .status-icon { background: #d03b3b; color: #fff; }
.level-ok .status-icon { background: #0ca30c; color: #fff; }
.banner.level-critical { border-left: 4px solid #d03b3b; }
.banner.level-serious { border-left: 4px solid #ec835a; }
.banner.level-warning { border-left: 4px solid #fab219; }
.status-chip { display: inline-flex; align-items: center; gap: 2px; font-size: .85em; }
.danger-text { color: var(--error); }
.warn-text { color: var(--text); font-weight: 600; }
.warn-text::before { content: "! "; color: #fab219; }

.costs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 12px; }
.viz-root, .viz-root .card { min-width: 0; max-width: 100%; box-sizing: border-box; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data td, table.data th { white-space: nowrap; }
.log-view summary { cursor: pointer; font-weight: 600; }
.loading #costs-body { opacity: .55; }
.card h3 { margin: 0 0 10px; font-size: 1rem; }
.hero .label { color: var(--muted); font-size: .9em; }
.hero-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 4px 0 10px; }
.hero-value { font-size: 52px; font-weight: 600; line-height: 1.05; }
.hero-of { color: var(--muted); }
.hero-meta { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 10px; font-size: .9em; }
.alerts { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: .85em; }
.meter { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--series-1); }
.meter-fill.level-warning { background: var(--st-warning); }
.meter-fill.level-serious { background: var(--st-serious); }
.meter-fill.level-critical { background: var(--st-critical); }
.meter-list { display: flex; flex-direction: column; gap: 10px; }
.meter-row { display: grid; grid-template-columns: minmax(110px, 160px) 1fr auto auto; gap: 10px; align-items: center; font-size: .9em; }
.meter-figure { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-track { height: 12px; }
.rank-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.chart-wrap { position: relative; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis { stroke: var(--axisline); stroke-width: 1; }
svg.chart .ref { stroke: var(--ink-muted); stroke-width: 1; }
svg.chart .tick { fill: var(--ink-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.chart .bar { fill: var(--series-1); }
svg.chart .hit { fill: transparent; }
svg.chart .bar-g:hover .bar, svg.chart .bar-g:focus .bar { opacity: .75; }
svg.chart .bar-g:focus { outline: none; }
svg.chart .bar-g:focus .hit { stroke: var(--axisline); }
.tooltip { position: absolute; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-size: .85em; pointer-events: none; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.table-view { margin-top: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: .85em; }
table.data th, table.data td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
table.data td { font-variant-numeric: tabular-nums; }
.voice-meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; }
.voice-meta dd { margin: 0; font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .composer { grid-template-columns: 1fr; }
  .meter-row { grid-template-columns: 1fr auto auto; grid-template-areas: "name chip fig" "bar bar bar"; row-gap: 4px; }
  .meter-row .meter-name { grid-area: name; }
  .meter-row .status-chip { grid-area: chip; }
  .meter-row .meter-figure { grid-area: fig; }
  .meter-row .meter, .meter-row .rank-track { grid-area: bar; }
  .row.space { flex-wrap: wrap; gap: 8px; }
  .hero-value { font-size: 44px; }
}