/* ── Fonts are loaded via <link> in each layout's <head> so they fetch in
      parallel with this stylesheet instead of serially after it. ─────────── */

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* ── Custom properties ────────────────────────────────────────────────────── */
:root {
  --bg:           #09090b;
  --bg2:          #111113;
  --bg3:          #18181b;
  --bg4:          #222226;
  --border:       #2a2a2e;
  --border2:      #3a3a3e;
  --text:         #e4e4e7;
  --muted:        #71717a;
  --dim:          #52525b;
  --ok:           #22c55e;
  --warn:         #f59e0b;
  --crit:         #ef4444;
  --info:         #3b82f6;
  --purple:       #a78bfa;
  --ok-bg:        #052e16;
  --warn-bg:      #1c1400;
  --crit-bg:      #1c0505;
  --info-bg:      #0c1e3c;
  --purple-bg:    #1e1435;
  --font-mono:    'JetBrains Mono', monospace;
  --font-ui:      'Inter', system-ui, sans-serif;
  --radius:       8px;
  --radius-lg:    12px;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
html { font-size: 14px; }
body { background: var(--bg); color: var(--text); font-family: var(--font-ui); line-height: 1.6; min-height: 100vh; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.app-main { padding: 20px 24px 48px; max-width: 1600px; margin: 0 auto; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.header-logo  { display: flex; align-items: center; gap: 10px; }
.header-title { font-family: var(--font-mono); font-size: 13px; font-weight: 500; letter-spacing: .06em; color: var(--purple); }
.header-meta  { display: flex; align-items: center; gap: 16px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.header-meta__value { color: var(--text); }
.collect-time { color: var(--dim); }
.stale-badge  { color: var(--warn); }

.uptime-chip { background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; padding: 2px 10px; font-family: var(--font-mono); font-size: 11px; color: var(--info); }

/* ── Env badge ────────────────────────────────────────────────────────────── */
.env-badge { font-family: var(--font-mono); font-size: 10px; padding: 2px 8px; border-radius: 4px; letter-spacing: .06em; font-weight: 500; }
.env-badge--production { background: var(--crit-bg); color: var(--crit); }
.env-badge--stage      { background: var(--info-bg); color: var(--info); }

/* ── Pulse dot ────────────────────────────────────────────────────────────── */
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; animation: pulse 2s ease-in-out infinite; }
.pulse-dot--warn  { background: var(--warn); animation: none; }
.pulse-dot--stale { background: var(--crit); animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(.75); } }

/* ── Section label ────────────────────────────────────────────────────────── */
.section-label { font-family: var(--font-mono); font-size: 10px; font-weight: 400; color: var(--dim); text-transform: uppercase; letter-spacing: .12em; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.section-label__meta { color: var(--muted); }
.section-label__meta--crit { color: var(--crit); }
.dashboard-section { margin-bottom: 4px; }

/* ── Banners ──────────────────────────────────────────────────────────────── */
.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.banner--error { background: var(--crit-bg); border: 1px solid #3a1212; }
.banner--warn  { background: var(--warn-bg); border: 1px solid #3a2800; }
.banner__title { font-family: var(--font-mono); font-size: 11px; font-weight: 500; margin-bottom: 8px; }
.banner--error .banner__title { color: var(--crit); }
.banner--warn  .banner__title { color: var(--warn); }
.banner__list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.banner__list li { font-size: 12px; font-family: var(--font-mono); display: flex; gap: 8px; }
.banner--error .banner__list li { color: #f09595; }
.banner--warn  .banner__list li { color: #fcd38d; }
.banner__key { flex-shrink: 0; }
.banner--error .banner__key { color: var(--crit); }
.banner--warn  .banner__key { color: var(--warn); }

/* ── Metric cards ─────────────────────────────────────────────────────────── */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 8px; }
.metric-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; position: relative; overflow: hidden; }
.metric-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--border); }
.metric-card--ok::before   { background: var(--ok); }
.metric-card--warn         { border-color: #2e2000; }
.metric-card--warn::before { background: var(--warn); }
.metric-card--crit         { border-color: #2e0a0a; }
.metric-card--crit::before { background: var(--crit); }
.metric-card__label { font-size: 10px; font-family: var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.metric-card__value { font-size: 24px; font-weight: 500; font-family: var(--font-mono); line-height: 1; color: var(--text); }
.metric-card__sub   { font-size: 10px; color: var(--muted); font-family: var(--font-mono); margin-top: 4px; }

/* ── Gauge ────────────────────────────────────────────────────────────────── */
.gauge { margin-top: 8px; height: 2px; background: var(--bg4); border-radius: 1px; overflow: hidden; }
.gauge__fill { height: 100%; border-radius: 1px; background: var(--ok); transition: width .6s ease, background .3s; }

/* ── Text helpers ─────────────────────────────────────────────────────────── */
.text--ok    { color: var(--ok); }
.text--warn  { color: var(--warn); }
.text--crit  { color: var(--crit); }
.text--info  { color: var(--info); }
.text--muted { color: var(--muted); }

/* ── Panels ───────────────────────────────────────────────────────────────── */
.panel-row        { display: grid; gap: 8px; margin-bottom: 8px; }
.panel-row--2col  { grid-template-columns: 1fr 1fr; }
.panel-row--3col  { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 960px) { .panel-row--2col, .panel-row--3col { grid-template-columns: 1fr; } }

.panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 8px; }
.panel:last-child { margin-bottom: 0; }
.panel__header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 10px; font-family: var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.panel__meta   { font-size: 10px; color: var(--muted); font-family: var(--font-mono); }
.panel__error  { padding: 8px 14px; background: #1a0808; border-bottom: 1px solid #2e1010; font-size: 11px; font-family: var(--font-mono); color: #f87171; display: none; }
.panel__error--visible { display: block; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge { font-size: 9px; font-family: var(--font-mono); font-weight: 500; letter-spacing: .04em; padding: 2px 6px; border-radius: 3px; flex-shrink: 0; }
.badge--ok     { background: var(--ok-bg);     color: var(--ok); }
.badge--warn   { background: var(--warn-bg);   color: var(--warn); }
.badge--crit   { background: var(--crit-bg);   color: var(--crit); }
.badge--info   { background: var(--info-bg);   color: var(--info); }
.badge--purple { background: var(--purple-bg); color: var(--purple); }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 12px; }
.data-table th { text-align: left; padding: 7px 12px; color: var(--dim); font-weight: 400; border-bottom: 1px solid var(--border); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.data-table td { padding: 7px 12px; border-bottom: 1px solid var(--bg3); color: var(--text); white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td      { background: var(--bg3); }
.table-empty  { color: var(--muted); font-style: italic; }
.col--bar     { width: 80px; }
.cell--bold   { font-weight: 500; }
.cell--truncate { overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.cell--mono   { font-family: var(--font-mono); }

/* ── KV list ──────────────────────────────────────────────────────────────── */
.kv-list { padding: 0; }
.kv-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 14px; border-bottom: 1px solid var(--bg3); font-size: 11px; }
.kv-row:last-child { border-bottom: none; }
.kv-row__key { color: var(--muted); font-family: var(--font-mono); }
.kv-row__val { font-family: var(--font-mono); color: var(--text); }
.kv-row__val--state-waiting   { color: var(--ok); }
.kv-row__val--state-sending   { color: var(--info); }
.kv-row__val--state-keepalive { color: var(--purple); }
.kv-row__val--state-reading   { color: var(--warn); }
.kv-row__val--state-other     { color: var(--dim); }

/* ── Alert items ──────────────────────────────────────────────────────────── */
.alert-item { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 6px; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 12px; }
.alert-item:last-child { border-bottom: none; }

/* ── Item list ────────────────────────────────────────────────────────────── */
.item-list__row { padding: 7px 14px; border-bottom: 1px solid var(--bg3); font-size: 12px; color: var(--text); line-height: 1.5; }
.item-list__row:last-child { border-bottom: none; }
.item-list__row--mono { font-family: var(--font-mono); font-size: 11px; }
.item-list__empty { padding: 10px 14px; color: var(--muted); font-style: italic; font-size: 12px; }

/* ── Slow query cards ─────────────────────────────────────────────────────── */
.slow-query-list       { padding: 4px 0; }
.slow-query-card       { padding: 10px 14px; border-bottom: 1px solid var(--bg3); }
.slow-query-card:last-child { border-bottom: none; }
.slow-query-card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.slow-query-card__time { font-family: var(--font-mono); font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 3px; letter-spacing: 0.02em; }
.slow-query-card--crit .slow-query-card__time { background: var(--crit-bg); color: var(--crit); }
.slow-query-card--warn .slow-query-card__time { background: var(--warn-bg); color: var(--warn); }
.slow-query-card--info .slow-query-card__time { background: var(--info-bg); color: var(--info); }
.slow-query-card__meta { font-family: var(--font-mono); font-size: 10px; color: var(--muted); line-height: 1.5; flex: 1 1 auto; min-width: 0; }
.slow-query-card__ratio{ color: var(--warn); }
.slow-query-card__runs {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 3px;
  background: var(--bg4); color: var(--text); letter-spacing: 0.02em;
}
.slow-query-card__window {
  font-family: var(--font-mono); font-size: 10px; color: var(--dim);
}
.slow-query-card__sql  { font-family: var(--font-mono); font-size: 11px; color: var(--text); background: var(--bg); border-left: 2px solid var(--border2); border-radius: 0 4px 4px 0; padding: 7px 10px; margin: 0; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.slow-query-card--crit .slow-query-card__sql { border-left-color: var(--crit); }
.slow-query-card--warn .slow-query-card__sql { border-left-color: var(--warn); }
.slow-query-card--info .slow-query-card__sql { border-left-color: var(--info); }

.slow-query-card__action {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em;
  padding: 3px 10px; border-radius: 3px;
  background: var(--purple-bg); color: var(--purple);
  border: 1px solid transparent; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.slow-query-card__action:hover:not(:disabled)  { background: var(--purple); color: var(--bg); }
.slow-query-card__action:disabled              { background: var(--bg4); color: var(--muted); cursor: not-allowed; }
.slow-query-card__result                       { margin-top: 8px; }
.slow-query-card__result:empty                 { display: none; }

/* Pagination */
.slow-query-pager {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-top: 1px solid var(--bg3); background: var(--bg2);
}
.pager-btn {
  font-family: var(--font-mono); font-size: 11px;
  padding: 4px 10px; border-radius: 3px;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); cursor: pointer;
  transition: background 0.15s;
}
.pager-btn:hover:not(:disabled) { background: var(--bg4); border-color: var(--border2); }
.pager-btn:disabled             { opacity: 0.4; cursor: not-allowed; }
.pager-info {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
}

/* ── State bar ────────────────────────────────────────────────────────────── */
.state-bar { display: flex; height: 6px; margin: 10px 14px; border-radius: 3px; overflow: hidden; background: var(--bg4); }
.state-bar__segment--waiting   { background: var(--ok); }
.state-bar__segment--sending   { background: var(--info); }
.state-bar__segment--keepalive { background: var(--purple); }
.state-bar__segment--reading   { background: var(--warn); }
.state-bar__segment--other     { background: var(--dim); }

/* ── Analysis box ─────────────────────────────────────────────────────────── */
.analysis-box { padding: 12px 14px; font-size: 13px; line-height: 1.75; color: var(--text); border-left: 2px solid var(--purple); }
.analysis-box--empty { color: var(--muted); font-style: italic; }

/* ── Traffic ──────────────────────────────────────────────────────────────── */
.flag { display: inline-block; font-size: 9px; font-family: var(--font-mono); padding: 1px 5px; border-radius: 3px; margin: 1px; }
.flag--crit { background: var(--crit-bg); color: var(--crit); }
.flag--warn { background: var(--warn-bg); color: var(--warn); }
.rec { font-size: 9px; font-family: var(--font-mono); padding: 2px 7px; border-radius: 3px; }
.rec--block      { background: var(--crit-bg); color: var(--crit); }
.rec--rate-limit { background: var(--warn-bg); color: var(--warn); }
.rec--monitor    { background: var(--info-bg); color: var(--info); }
.abuse-item              { padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 12px; }
.abuse-item:last-child   { border-bottom: none; }
.abuse-item__header      { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.abuse-item__ips         { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.abuse-item__evidence    { font-size: 12px; line-height: 1.5; }
.fan-item                { padding: 8px 14px; border-bottom: 1px solid var(--border); }
.fan-item:last-child     { border-bottom: none; }
.fan-item__header        { display: flex; justify-content: space-between; margin-bottom: 4px; }
.fan-item__identity      { font-family: var(--font-mono); font-size: 11px; color: var(--info); }
.fan-item__endpoints     { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }

/* ── Perf routes ──────────────────────────────────────────────────────────── */
.route-pill { font-family: var(--font-mono); font-size: 11px; background: var(--bg3); border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px; color: var(--info); display: inline-block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.file-pill  { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.src-badge        { font-size: 9px; font-family: var(--font-mono); padding: 1px 6px; border-radius: 3px; }
.src-badge--api   { background: #051a0f; color: var(--ok); }
.src-badge--web   { background: var(--purple-bg); color: var(--purple); }
.rc-badge                    { font-size: 9px; font-family: var(--font-mono); padding: 1px 6px; border-radius: 3px; }
.rc-badge--slow-query        { background: #051a0f; color: var(--ok); }
.rc-badge--php-processing    { background: var(--purple-bg); color: var(--purple); }
.rc-badge--data-volume       { background: var(--info-bg); color: var(--info); }
.rc-badge--no-pagination     { background: var(--warn-bg); color: var(--warn); }
.rc-badge--client-polling    { background: var(--crit-bg); color: var(--crit); }
.rc-badge--platform-fan-out  { background: #1c0a18; color: #e879f9; }
.rc-badge--unknown           { background: var(--bg4); color: var(--muted); }
.perf-bar       { height: 4px; border-radius: 2px; background: var(--bg4); overflow: hidden; width: 80px; }
.perf-bar__fill { height: 100%; border-radius: 2px; transition: width .6s ease; }
.perf-bar__fill--ok   { background: var(--ok); }
.perf-bar__fill--warn { background: var(--warn); }
.perf-bar__fill--high { background: var(--warn); }
.perf-bar__fill--crit { background: var(--crit); }

/* ── Fix cards ────────────────────────────────────────────────────────────── */
.fixes-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.fixes-count   { font-size: 11px; font-family: var(--font-mono); padding: 3px 10px; border-radius: 20px; border: 1px solid var(--border); }
.fixes-count--critical { background: var(--crit-bg); color: var(--crit); border-color: #3a1010; }
.fixes-count--high     { background: var(--warn-bg); color: var(--warn); border-color: #3a2500; }
.fixes-count--medium   { background: var(--info-bg); color: var(--info); border-color: #0c2a4a; }
.fixes-count--low      { background: var(--bg4); color: var(--muted); }
.fix-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 8px; }
.fix-card--critical { border-left: 3px solid var(--crit); }
.fix-card--high     { border-left: 3px solid var(--warn); }
.fix-card--medium   { border-left: 3px solid var(--info); }
.fix-card--low      { border-left: 3px solid var(--muted); }
.fix-header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 14px; background: var(--bg2); cursor: pointer; user-select: none; }
.fix-header:hover { background: var(--bg3); }
.fix-priority { font-size: 9px; font-family: var(--font-mono); font-weight: 500; letter-spacing: .06em; padding: 2px 6px; border-radius: 3px; flex-shrink: 0; }
.fix-priority--critical { background: var(--crit-bg); color: var(--crit); }
.fix-priority--high     { background: var(--warn-bg); color: var(--warn); }
.fix-priority--medium   { background: var(--info-bg); color: var(--info); }
.fix-priority--low      { background: var(--bg4); color: var(--muted); }
.fix-category { font-size: 9px; font-family: var(--font-mono); padding: 2px 6px; border-radius: 3px; border: 1px solid var(--border); color: var(--muted); flex-shrink: 0; }
.fix-title    { font-size: 12px; font-weight: 500; color: var(--text); flex: 1; min-width: 0; }
.fix-chevron  { color: var(--muted); font-size: 10px; transition: transform .2s; flex-shrink: 0; }
.fix-card--open .fix-chevron { transform: rotate(90deg); }
.fix-body     { display: none; border-top: 1px solid var(--border); }
.fix-card--open .fix-body { display: block; }
.fix-section              { padding: 9px 14px; border-bottom: 1px solid var(--bg3); }
.fix-section:last-child   { border-bottom: none; }
.fix-section-label        { font-size: 9px; font-family: var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.fix-problem              { font-size: 12px; color: var(--text); line-height: 1.6; }
.fix-meta                 { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 14px; border-bottom: 1px solid var(--bg3); }
.fix-file                 { font-family: var(--font-mono); font-size: 10px; color: var(--info); }
.fix-code { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-family: var(--font-mono); font-size: 11px; color: #86efac; white-space: pre-wrap; word-break: break-all; line-height: 1.6; position: relative; }
.fix-copy { position: absolute; top: 7px; right: 8px; font-size: 9px; font-family: var(--font-mono); color: var(--muted); background: var(--bg2); border: 1px solid var(--border); border-radius: 3px; padding: 2px 7px; cursor: pointer; }
.fix-copy:hover { color: var(--text); }
.fix-impact { font-size: 11px; color: var(--ok); font-family: var(--font-mono); line-height: 1.5; }

/* ── Chat ─────────────────────────────────────────────────────────────────── */
.chat-wrap { display: grid; grid-template-columns: 1fr 380px; height: 620px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg2); margin-bottom: 8px; }
@media (max-width: 1100px) { .chat-wrap { grid-template-columns: 1fr; height: auto; } }
.chat-history { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; flex-direction: column; gap: 4px; max-width: 85%; }
.chat-msg--user  { align-self: flex-end; align-items: flex-end; }
.chat-msg--agent { align-self: flex-start; align-items: flex-start; }
.chat-bubble { padding: 10px 13px; border-radius: 10px; font-size: 13px; line-height: 1.65; }
.chat-msg--user  .chat-bubble { background: var(--purple); color: #fff; border-bottom-right-radius: 3px; }
.chat-msg--agent .chat-bubble { background: var(--bg3); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.chat-bubble__hint { display: block; font-size: 11px; color: rgba(255,255,255,.6); margin-top: 4px; }
.chat-msg--agent .chat-bubble__hint { color: var(--muted); }
.chat-meta { font-size: 10px; font-family: var(--font-mono); color: var(--dim); }
.chat-thinking { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; font-size: 12px; color: var(--muted); }
.dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--purple); animation: dot 1.2s ease-in-out infinite; display: inline-block; }
.dots      { display: flex; gap: 3px; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }

/* Streaming event log inside the agent thinking bubble */
.chat-stream { background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; max-width: 520px; }
.chat-stream__header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg2); border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.chat-stream__label { color: var(--purple); }
.chat-stream__log { max-height: 240px; overflow-y: auto; padding: 6px 12px; font-family: var(--font-mono); font-size: 11px; line-height: 1.55; }
.chat-stream__log::-webkit-scrollbar       { width: 6px; }
.chat-stream__log::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.stream-line { padding: 2px 0; word-break: break-word; white-space: pre-wrap; }
.stream-line--tool   { color: var(--info);  }
.stream-line--tool::before   { content: '▶ '; color: var(--muted); }
.stream-line--result { color: var(--dim);   }
.stream-line--text   { color: var(--text);  padding: 4px 0; }
.stream-line--info   { color: var(--muted); font-style: italic; }
@keyframes dot { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
.chat-suggestions { padding: 8px 12px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px; background: var(--bg2); }
.sugg-btn { font-size: 11px; font-family: var(--font-mono); padding: 4px 10px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; color: var(--muted); background: var(--bg3); }
.sugg-btn:hover { border-color: var(--purple); color: var(--purple); }
.chat-input-row { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; background: var(--bg3); flex-shrink: 0; }
.chat-input { flex: 1; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius); padding: 10px 12px; color: var(--text); font-family: var(--font-ui); font-size: 13px; resize: none; height: 44px; outline: none; line-height: 1.4; }
.chat-input:focus { border-color: var(--purple); }
.chat-send { background: var(--purple); border: none; color: #fff; border-radius: var(--radius); padding: 0 16px; font-size: 13px; font-weight: 500; cursor: pointer; flex-shrink: 0; height: 44px; }
.chat-send:hover    { opacity: .85; }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }
.chat-detail        { display: flex; flex-direction: column; overflow: hidden; }
.chat-detail__header { padding: 10px 14px; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; background: var(--bg3); flex-shrink: 0; }
.chat-detail__scroll { flex: 1; overflow-y: auto; padding: 12px; }
.detail-empty        { color: var(--muted); font-size: 12px; font-style: italic; }
.detail-rc-badge     { display: inline-block; font-size: 9px; font-family: var(--font-mono); padding: 2px 8px; border-radius: 3px; margin-bottom: 8px; }
.detail-section-label{ font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 10px 0 6px; }
.detail-summary      { font-size: 12px; line-height: 1.6; color: var(--text); margin-bottom: 10px; }
.ev-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 8px; }
.ev-type { font-size: 9px; font-family: var(--font-mono); padding: 4px 10px; background: var(--bg3); border-bottom: 1px solid var(--border); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; justify-content: space-between; }
.ev-src  { color: var(--purple); }
.ev-content { padding: 8px 10px; font-family: var(--font-mono); font-size: 11px; color: var(--text); line-height: 1.5; white-space: pre-wrap; word-break: break-all; background: var(--bg); }
.ev-sig     { padding: 6px 10px; font-size: 11px; color: var(--warn); border-top: 1px solid var(--border); background: var(--bg3); }
.slow-op { display: flex; justify-content: space-between; align-items: center; padding: 5px 8px; background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; font-size: 11px; margin-bottom: 4px; }
.slow-op__name { font-family: var(--font-mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.slow-op__dur  { font-family: var(--font-mono); flex-shrink: 0; margin-left: 8px; }
.slow-op__dur--ok   { color: var(--ok); }
.slow-op__dur--warn { color: var(--warn); }
.slow-op__dur--crit { color: var(--crit); }

/* Slow-query inline fix suggestion */
.sq-btn { font-family: var(--font-mono); font-size: 10px; padding: 3px 8px; border: 1px solid var(--border2); background: var(--bg3); color: var(--text); border-radius: 3px; cursor: pointer; }
.sq-btn:hover { background: var(--bg4); border-color: var(--info); color: var(--info); }
.sq-pending { font-size: 10px; font-family: var(--font-mono); color: var(--warn); }
.sq-done    { font-size: 10px; font-family: var(--font-mono); color: var(--ok); }
.sq-result td { padding: 10px 12px; background: var(--bg2); border-top: 1px dashed var(--border); }
.sq-answer  { font-size: 11px; color: var(--muted); line-height: 1.5; margin-bottom: 8px; white-space: pre-wrap; }
.sq-error   { font-size: 11px; color: var(--crit); padding: 6px 10px; }

.fix-mini { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.fix-mini--critical { border-left: 2px solid var(--crit); }
.fix-mini--high     { border-left: 2px solid var(--warn); }
.fix-mini--medium   { border-left: 2px solid var(--info); }
.fix-mini__header   { padding: 7px 10px; font-size: 11px; font-weight: 500; background: var(--bg3); display: flex; align-items: center; gap: 6px; }
.fix-mini__pri      { font-size: 9px; font-family: var(--font-mono); padding: 1px 5px; border-radius: 3px; }
.fix-mini__pri--critical { background: var(--crit-bg); color: var(--crit); }
.fix-mini__pri--high     { background: var(--warn-bg); color: var(--warn); }
.fix-mini__pri--medium   { background: var(--info-bg); color: var(--info); }
.fix-mini__body     { padding: 8px 10px; font-size: 11px; color: var(--text); line-height: 1.5; }
.fix-mini__problem  { margin-bottom: 5px; color: var(--muted); }
.fix-mini__file     { font-family: var(--font-mono); font-size: 10px; color: var(--info); margin-bottom: 4px; }
.fix-mini__code     { font-family: var(--font-mono); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; font-size: 10px; color: #86efac; white-space: pre-wrap; word-break: break-all; margin-top: 6px; position: relative; }
.fix-mini__copy     { position: absolute; top: 4px; right: 6px; font-size: 9px; font-family: var(--font-mono); color: var(--muted); background: var(--bg2); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; cursor: pointer; }
.fix-mini__copy:hover { color: var(--text); }
.fix-mini__impact   { font-size: 10px; color: var(--ok); margin-top: 4px; }

/* ── Loading ──────────────────────────────────────────────────────────────── */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60vh; gap: 14px; color: var(--muted); font-family: var(--font-mono); font-size: 13px; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border2); border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Trends ───────────────────────────────────────────────────────────────── */
.trend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); }
@media (max-width: 700px) { .trend-grid { grid-template-columns: 1fr; } }

.trend-item { background: var(--bg2); padding: 10px 14px 8px; }
.trend-item__header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.trend-item__label { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.trend-item__stat  { font-family: var(--font-mono); font-size: 12px; color: var(--text); font-weight: 500; }

.sparkline { display: block; width: 100%; height: 40px; border-radius: 3px; }
.sparkline--route { height: 28px; }

.route-trend-item { padding: 8px 14px; border-bottom: 1px solid var(--border); }
.route-trend-item:last-child { border-bottom: none; }
.route-trend-item__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.route-trend-item__p95 { font-family: var(--font-mono); font-size: 12px; font-weight: 500; flex-shrink: 0; margin-left: 8px; }

.trend-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--border); }
.tsm-item { background: var(--bg2); padding: 10px 14px; }
.tsm-item__label { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.tsm-item__val   { font-family: var(--font-mono); font-size: 14px; color: var(--text); font-weight: 500; }

/* ── Nav bar ──────────────────────────────────────────────────────────────── */
.app-nav { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 36px; background: var(--bg3); border-bottom: 1px solid var(--border); font-size: 12px; position: sticky; top: 52px; z-index: 99; }
.app-nav__user  { display: flex; align-items: center; gap: 8px; }
.app-nav__email { font-family: var(--font-mono); color: var(--muted); }
.app-nav__actions { display: flex; align-items: center; gap: 16px; }
.app-nav__link  { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-decoration: none; }
.app-nav__link:hover { color: var(--purple); }
.app-nav__link--logout { color: var(--dim); }
.app-nav__link--logout:hover { color: var(--crit); }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-body  { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card  { width: 100%; max-width: 400px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; }
.login-logo  { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-logo__dot   { width: 8px; height: 8px; border-radius: 50%; background: var(--purple); animation: pulse 2s ease-in-out infinite; flex-shrink: 0; }
.login-logo__title { font-family: var(--font-mono); font-size: 13px; letter-spacing: .06em; color: var(--purple); }
.login-error  { background: var(--crit-bg); border: 1px solid #3a1212; color: #f09595; font-size: 12px; font-family: var(--font-mono); padding: 10px 12px; border-radius: var(--radius); margin-bottom: 20px; }
.login-form   { display: flex; flex-direction: column; gap: 16px; }
.login-field  { display: flex; flex-direction: column; gap: 6px; }
.login-field__label { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.login-field__input { background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); padding: 10px 12px; color: var(--text); font-size: 14px; outline: none; }
.login-field__input:focus { border-color: var(--purple); }
.login-submit { background: var(--purple); border: none; color: #fff; border-radius: var(--radius); padding: 12px; font-size: 14px; font-weight: 500; cursor: pointer; margin-top: 4px; }
.login-submit:hover { opacity: .85; }
.login-footer { font-size: 11px; color: var(--dim); text-align: center; margin-top: 20px; font-family: var(--font-mono); }

/* ── Flash messages ───────────────────────────────────────────────────────── */
.flash { padding: 10px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 12px; font-family: var(--font-mono); }
.flash--ok    { background: var(--ok-bg);   border: 1px solid #0a3a1a; color: #86efac; }
.flash--error { background: var(--crit-bg); border: 1px solid #3a1212; color: #f09595; }

/* ── Admin layout ─────────────────────────────────────────────────────────── */
.admin-breadcrumb { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-bottom: 16px; display: flex; align-items: center; gap: 6px; }
.admin-breadcrumb a { color: var(--purple); text-decoration: none; }
.admin-breadcrumb a:hover { text-decoration: underline; }
.admin-layout { display: flex; flex-direction: column; gap: 16px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field__label  { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.form-field__input  { background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); padding: 8px 10px; color: var(--text); font-family: var(--font-mono); font-size: 12px; outline: none; min-width: 200px; }
.form-field__input:focus  { border-color: var(--purple); }
.form-field__input--sm    { min-width: 140px; }
.form-field__select       { background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); padding: 8px 10px; color: var(--text); font-family: var(--font-mono); font-size: 12px; outline: none; }
.form-field__select--sm   { padding: 6px 8px; font-size: 11px; }
.form-field--action       { justify-content: flex-end; }

.admin-form__row  { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 14px; }

.inline-form { display: inline; }
.action-row  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.role-select { background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-family: var(--font-mono); font-size: 11px; padding: 3px 6px; cursor: pointer; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn { font-family: var(--font-mono); font-size: 12px; padding: 7px 14px; border-radius: var(--radius); border: none; cursor: pointer; font-weight: 500; text-decoration: none; display: inline-block; }
.btn--primary { background: var(--purple); color: #fff; }
.btn--primary:hover { opacity: .85; }
.btn--danger  { background: var(--crit-bg); color: var(--crit); border: 1px solid #3a1010; }
.btn--danger:hover  { background: #2e0a0a; }
.btn--ok      { background: var(--ok-bg); color: var(--ok); border: 1px solid #0a3a1a; }
.btn--ok:hover      { background: #073a17; }
.btn--ghost   { background: var(--bg3); color: var(--muted); border: 1px solid var(--border); }
.btn--ghost:hover   { border-color: var(--border2); }
.btn--sm { font-size: 11px; padding: 4px 10px; }

/* ── User table extras ────────────────────────────────────────────────────── */
.row--inactive td { opacity: .5; }
.self-badge { font-size: 9px; font-family: var(--font-mono); background: var(--purple-bg); color: var(--purple); padding: 1px 5px; border-radius: 3px; margin-left: 4px; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.status-dot--ok  { background: var(--ok); }
.status-dot--off { background: var(--dim); }

/* ── Audit log ────────────────────────────────────────────────────────────── */
.audit-filters { padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--bg3); }
.audit-filters__row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.audit-action { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 3px; }
.audit-action--ok     { background: var(--ok-bg);     color: var(--ok); }
.audit-action--crit   { background: var(--crit-bg);   color: var(--crit); }
.audit-action--warn   { background: var(--warn-bg);   color: var(--warn); }
.audit-action--info   { background: var(--info-bg);   color: var(--info); }
.audit-action--purple { background: var(--purple-bg); color: var(--purple); }
.audit-action--muted  { background: var(--bg4);       color: var(--muted); }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px; border-top: 1px solid var(--border); }
.pagination__btn  { font-family: var(--font-mono); font-size: 12px; color: var(--purple); text-decoration: none; }
.pagination__btn:hover { text-decoration: underline; }
.pagination__info { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ── Role legend ──────────────────────────────────────────────────────────── */
.admin-role-legend { margin-top: 16px; padding: 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); }
.admin-role-legend__title { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.admin-role-legend__grid  { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: baseline; gap: 10px; font-size: 12px; color: var(--muted); }
.legend-item .badge { flex-shrink: 0; }

/* ── Audit filters ────────────────────────────────────────────────────────── */
.audit-filters__row .form-field__input,
.audit-filters__row .form-field__select { background: var(--bg2); }

/* ── Help page ────────────────────────────────────────────────────────────── */
.app-main--help { max-width: 1100px; }

.help-page { display: grid; grid-template-columns: 200px 1fr; gap: 40px; align-items: start; }
@media (max-width: 800px) { .help-page { grid-template-columns: 1fr; } }

/* TOC */
.help-toc { position: sticky; top: 100px; z-index: 90; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; max-height: calc(100vh - 120px); overflow-y: auto; grid-column: 1; grid-row: 1 / -1; }
.help-toc__title { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 10px; }
.help-toc__list { list-style: none; counter-reset: toc; display: flex; flex-direction: column; gap: 2px; }
.help-toc__list li { counter-increment: toc; }
.help-toc__list a { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-decoration: none; display: block; padding: 3px 0; }
.help-toc__list a:hover { color: var(--purple); }
@media (max-width: 800px) {
  .help-toc     { position: static; grid-column: 1; grid-row: auto; max-height: none; }
  .help-section { grid-column: 1; }
}

/* Sections */
.help-section { margin-bottom: 48px; scroll-margin-top: 100px; grid-column: 2; }
.help-section__title { font-family: var(--font-mono); font-size: 16px; font-weight: 500; color: var(--text); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.help-subsection { margin-top: 20px; }
.help-subsection__title { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 10px; }

/* Text */
.help-text { font-size: 13px; line-height: 1.8; color: var(--text); margin-bottom: 10px; }
.help-text code { font-family: var(--font-mono); font-size: 11px; background: var(--bg3); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; color: var(--info); }
.help-link { color: var(--purple); text-decoration: none; }
.help-link:hover { text-decoration: underline; }

/* Notes */
.help-note { background: var(--info-bg); border: 1px solid #0c2a4a; border-radius: var(--radius); padding: 10px 14px; font-size: 12px; line-height: 1.7; color: var(--text); margin-bottom: 12px; }
.help-note--warn { background: var(--warn-bg); border-color: #3a2500; }
.help-note strong { color: var(--info); font-family: var(--font-mono); font-size: 11px; }
.help-note--warn strong { color: var(--warn); }

/* Tables */
.help-table-wrap { overflow-x: auto; margin-bottom: 12px; }
.help-table { width: 100%; border-collapse: collapse; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.help-table th { text-align: left; padding: 8px 12px; background: var(--bg3); color: var(--muted); font-family: var(--font-mono); font-weight: 400; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); }
.help-table td { padding: 8px 12px; border-bottom: 1px solid var(--bg3); color: var(--text); line-height: 1.6; vertical-align: top; }
.help-table tr:last-child td { border-bottom: none; }
.help-table tr:hover td { background: var(--bg3); }
.help-table td code { font-family: var(--font-mono); font-size: 11px; background: var(--bg4); border-radius: 3px; padding: 1px 5px; color: var(--info); }
.help-table td em { color: var(--muted); font-style: normal; }

/* Lists */
.help-list { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.7; padding-left: 4px; }
.help-list li { padding-left: 16px; position: relative; color: var(--text); }
.help-list li::before { content: '›'; position: absolute; left: 0; color: var(--purple); }
.help-list li strong { color: var(--text); font-weight: 500; }
.help-list--compact { gap: 3px; font-size: 12px; }

/* Capability cards */
.help-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.help-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.help-card__icon { font-size: 20px; margin-bottom: 8px; }
.help-card__title { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.help-card__body { font-size: 12px; line-height: 1.7; color: var(--muted); }

/* Alert level grid */
.help-level-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
@media (max-width: 600px) { .help-level-grid { grid-template-columns: 1fr; } }
.help-level { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.help-level--warn { border-left: 3px solid var(--warn); }
.help-level--crit { border-left: 3px solid var(--crit); }
.help-level__label { margin-bottom: 8px; }
.help-level__desc { font-size: 12px; line-height: 1.7; color: var(--muted); }

/* Role cards */
.help-role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
@media (max-width: 700px) { .help-role-grid { grid-template-columns: 1fr; } }
.help-role-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.help-role-card__header { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.help-role-card__note { font-size: 11px; font-family: var(--font-mono); color: var(--dim); line-height: 1.6; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }

/* Code block in FAQ */
.help-code-block { display: block; font-family: var(--font-mono); font-size: 11px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; color: #86efac; white-space: pre-wrap; word-break: break-all; margin-top: 8px; line-height: 1.6; }

/* FAQ */
.faq-list { display: flex; flex-direction: column; gap: 4px; }
.faq-item { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.faq-item[open] { border-color: var(--border2); }
.faq-item__q { padding: 12px 16px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text); list-style: none; display: flex; align-items: center; justify-content: space-between; user-select: none; }
.faq-item__q::-webkit-details-marker { display: none; }
.faq-item__q::after { content: '+'; font-family: var(--font-mono); color: var(--muted); font-size: 16px; }
.faq-item[open] .faq-item__q::after { content: '−'; }
.faq-item__q:hover { background: var(--bg3); }
.faq-item__a { padding: 0 16px 14px; font-size: 13px; line-height: 1.8; color: var(--muted); border-top: 1px solid var(--border); padding-top: 12px; }
.faq-item__a code { font-family: var(--font-mono); font-size: 11px; background: var(--bg3); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; color: var(--info); }
.faq-item__a a { color: var(--purple); text-decoration: none; }

/* ── Notification status panel ────────────────────────────────────────────── */
.notify-status-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); }
@media (max-width: 700px) { .notify-status-grid { grid-template-columns: 1fr; } }
.notify-channel       { background: var(--bg2); padding: 14px; }
.notify-channel__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.notify-channel__name { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text); }
.notify-channel__hint { font-family: var(--font-mono); font-size: 11px; color: var(--muted); line-height: 1.6; }
.notify-channel__hint code { background: var(--bg4); border-radius: 3px; padding: 1px 5px; color: var(--info); }
.notify-test-row      { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); }

/* ── Log streamer ─────────────────────────────────────────────────────────── */
.logs-main   { display: flex; flex-direction: column; height: calc(100vh - 88px); overflow: hidden; padding: 0; max-width: none; }
.logs-layout { display: grid; grid-template-columns: 260px 1fr; height: 100%; overflow: hidden; }

/* Sidebar */
.logs-sidebar { display: flex; flex-direction: column; background: var(--bg2); border-right: 1px solid var(--border); overflow: hidden; }
.logs-sidebar__header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.logs-sidebar__title  { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.logs-sidebar__footer { padding: 10px 14px; border-top: 1px solid var(--border); flex-shrink: 0; }
.logs-sidebar__search { padding: 8px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.logs-search-input    { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; color: var(--text); font-family: var(--font-mono); font-size: 11px; outline: none; }
.logs-search-input:focus { border-color: var(--purple); }

.logs-file-list { flex: 1; overflow-y: auto; }
.logs-group     { padding: 0; }
.logs-group__label { font-family: var(--font-mono); font-size: 9px; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; padding: 8px 14px 4px; }

.logs-file-btn { width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--bg3); padding: 8px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.logs-file-btn:hover                 { background: var(--bg3); }
.logs-file-btn--active               { background: var(--purple-bg); border-left: 2px solid var(--purple); }
.logs-file-btn--active:hover         { background: var(--purple-bg); }
.logs-file-btn__name  { font-family: var(--font-mono); font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.logs-file-btn--active .logs-file-btn__name { color: var(--purple); }
.logs-file-btn__meta  { font-family: var(--font-mono); font-size: 10px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.logs-file-btn__mtime { font-family: var(--font-mono); font-size: 10px; color: var(--dim); }
.logs-file-btn__warn  { color: var(--warn); }
.logs-tail-label      { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* Viewer */
.logs-viewer  { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

/* Toolbar */
.logs-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 6px 12px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.logs-toolbar__left  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.logs-toolbar__right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.log-btn { font-family: var(--font-mono); font-size: 11px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg3); color: var(--muted); cursor: pointer; }
.log-btn:hover       { border-color: var(--border2); color: var(--text); }
.log-btn--primary    { background: var(--purple-bg); border-color: var(--purple); color: var(--purple); }
.log-btn--active     { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.log-btn:disabled    { opacity: .4; cursor: not-allowed; }

.log-toggle { display: flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); cursor: pointer; }
.log-toggle input { cursor: pointer; accent-color: var(--purple); }

.logs-filter-input { background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; color: var(--text); font-family: var(--font-mono); font-size: 11px; outline: none; width: 200px; }
.logs-filter-input:focus { border-color: var(--purple); }
.log-counter { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* Empty state */
.logs-empty       { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
.logs-empty__icon { font-size: 40px; }
.logs-empty__title{ font-size: 14px; color: var(--text); }
.logs-empty__sub  { font-size: 12px; font-family: var(--font-mono); }
.logs-empty__sub code { background: var(--bg3); border-radius: 3px; padding: 1px 6px; color: var(--info); }

/* Output */
.logs-output { flex: 1; overflow-y: auto; overflow-x: auto; }
.logs-lines  { padding: 4px 0; min-height: 100%; }
.logs-lines--wrap .log-line__content { white-space: pre-wrap; word-break: break-all; }

/* Log lines */
.log-line          { display: flex; align-items: baseline; gap: 0; min-height: 18px; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; border-bottom: 1px solid transparent; }
.log-line:hover    { background: var(--bg2); }
.log-line--error   { background: #1a0505; border-bottom-color: #2e0a0a; }
.log-line--warn    { background: #1a1000; }
.log-line--debug   { opacity: .65; }
.log-line--hidden  { display: none; }
.log-line__num     { flex-shrink: 0; width: 52px; text-align: right; padding-right: 12px; color: var(--dim); font-size: 10px; user-select: none; padding-top: 1px; }
.log-line__content { color: var(--text); white-space: pre; flex: 1; padding-right: 12px; }

/* Syntax highlighting */
.hl-ts        { color: var(--dim); }
.hl-error     { color: var(--crit); font-weight: 500; }
.hl-warn      { color: var(--warn); }
.hl-debug     { color: var(--dim); }
.hl-info      { color: var(--info); }
.hl-email     { color: var(--purple); }
.hl-sql       { color: #60a5fa; font-weight: 500; }
.hl-sql-body  { color: #a5b4fc; }
.hl-muted     { color: var(--dim); }
.hl-ip        { color: var(--info); }
.hl-ok-dim    { color: #4ade80; opacity: .6; }
.hl-slow-crit { color: var(--crit); font-weight: 600; }
.hl-slow-warn { color: var(--warn); font-weight: 500; }
.hl-slow-ok   { color: var(--ok); }

/* Status bar */
.logs-status        { display: flex; align-items: center; gap: 8px; padding: 5px 14px; background: var(--bg2); border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: 11px; color: var(--muted); flex-shrink: 0; }
.logs-status__dot   { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.logs-status__dot--connecting { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.logs-status__dot--streaming  { background: var(--ok);   animation: pulse 2s ease-in-out infinite; }
.logs-status__dot--error      { background: var(--crit); animation: none; }
.logs-status__text  { color: var(--text); }
.logs-status__sep   { color: var(--dim); }
.logs-status__path  { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stream-rate        { font-family: var(--font-mono); font-size: 11px; color: var(--ok); margin-left: 8px; }

@media (max-width: 768px) {
  .logs-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .logs-sidebar { max-height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ── Log streamer ─────────────────────────────────────────────────────────── */
.logs-main { padding: 0; max-width: 100%; height: calc(100vh - 88px); display: flex; flex-direction: column; }

.log-layout { display: grid; grid-template-columns: 280px 1fr; height: 100%; overflow: hidden; }
@media (max-width: 800px) { .log-layout { grid-template-columns: 1fr; } }

/* Sidebar */
.log-sidebar { background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.log-sidebar__section { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.log-sidebar__section--files { flex: 1; overflow-y: auto; padding: 8px 0; }
.log-sidebar__label { font-family: var(--font-mono); font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.log-sidebar__label-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px 4px; }
.log-sidebar__label-row .log-sidebar__label { margin-bottom: 0; }
.log-sidebar__keys { padding: 10px 12px; border-top: 1px solid var(--border); margin-top: auto; }

.log-controls-row { display: flex; gap: 6px; align-items: center; }
.log-controls-row .form-field__input--sm { flex: 1; height: 28px; min-width: 0; }
.log-controls-row .form-field__select--sm { height: 28px; }

/* Type chips */
.log-type-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-family: var(--font-mono); font-size: 10px; padding: 3px 8px; border-radius: 20px; border: 1px solid var(--border); cursor: pointer; color: var(--muted); background: var(--bg3); white-space: nowrap; }
.chip:hover       { border-color: var(--border2); color: var(--text); }
.chip--active     { background: var(--purple-bg); border-color: var(--purple); color: var(--purple); }
.chip--error      { }
.chip--error.chip--active { background: var(--crit-bg); border-color: var(--crit); color: var(--crit); }
.chip--warn.chip--active  { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.chip--slow.chip--active  { background: #1c0f00; border-color: #f97316; color: #f97316; }
.chip--query.chip--active { background: var(--info-bg); border-color: var(--info); color: var(--info); }
.chip--debug.chip--active { background: var(--bg4); border-color: var(--dim); color: var(--dim); }

/* File groups */
.log-group { padding: 4px 0; border-bottom: 1px solid var(--border); }
.log-group:last-child { border-bottom: none; }
.log-group__label { font-family: var(--font-mono); font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; padding: 6px 12px 3px; }

.log-file-btn { width: 100%; background: none; border: none; cursor: pointer; padding: 5px 12px; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.log-file-btn:hover { background: var(--bg3); }
.log-file-btn--active { background: var(--purple-bg) !important; border-left: 2px solid var(--purple); padding-left: 10px; }
.log-file-btn__name { font-family: var(--font-mono); font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.log-file-btn__live { color: var(--ok); font-size: 8px; flex-shrink: 0; }
.log-file-btn__meta { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.log-no-files { font-size: 11px; color: var(--muted); padding: 12px; line-height: 1.6; }
.log-no-files code { background: var(--bg4); border-radius: 3px; padding: 1px 4px; color: var(--info); font-size: 10px; }

/* Keyboard shortcuts */
.key-list { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 11px; }
.key-list dt { display: flex; }
.key-list dd { color: var(--muted); align-self: center; }
kbd { font-family: var(--font-mono); font-size: 10px; background: var(--bg4); border: 1px solid var(--border2); border-radius: 3px; padding: 1px 5px; color: var(--text); }

/* Terminal */
.log-terminal-wrap { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

.log-terminal {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  background: #050507;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  padding: 8px 0;
  min-height: 0;
}
.log-terminal::-webkit-scrollbar { width: 6px; height: 6px; }
.log-terminal::-webkit-scrollbar-track { background: var(--bg); }
.log-terminal::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }

.log-terminal__placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--dim); }
.log-placeholder-icon { font-size: 40px; margin-bottom: 12px; opacity: .3; }
.log-placeholder-hint { font-size: 11px; color: var(--dim); margin-top: 6px; }

/* Log lines */
.log-line { display: flex; align-items: baseline; gap: 8px; padding: 1px 12px; white-space: pre-wrap; word-break: break-all; border-left: 2px solid transparent; }
.log-line:hover { background: rgba(255,255,255,.03); }
.log-line--history { opacity: .7; }
.log-line--rotated { color: var(--purple); border-left-color: var(--purple); padding: 4px 12px; font-style: italic; }

.log-ts   { color: var(--dim); flex-shrink: 0; font-size: 10px; }
.log-text { flex: 1; }

/* Line type colours */
.log-line--error     { color: #fca5a5; border-left-color: var(--crit); background: rgba(239,68,68,.05); }
.log-line--warn      { color: #fcd34d; border-left-color: var(--warn); background: rgba(245,158,11,.05); }
.log-line--slow-crit { color: #fb923c; border-left-color: #f97316; background: rgba(249,115,22,.06); }
.log-line--slow      { color: #fde68a; border-left-color: #f59e0b; }
.log-line--slow-query{ color: #6ee7b7; border-left-color: #10b981; }
.log-line--timing    { color: #a5f3fc; }
.log-line--query     { color: #bfdbfe; }
.log-line--curl      { color: #ddd6fe; }
.log-line--debug     { color: var(--dim); }
.log-line--info      { color: var(--muted); }
.log-line--default   { color: #d4d4d8; }

/* Status bar */
.log-statusbar { display: flex; align-items: center; gap: 12px; padding: 5px 12px; background: var(--bg2); border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: 11px; flex-shrink: 0; }
.sb-item        { color: var(--muted); }
.sb-item--ok    { color: var(--ok); }
.sb-item--warn  { color: var(--warn); }
.sb-item--error { color: var(--crit); }
.sb-item--right { margin-left: auto; }
