/* Command Centre styles. Dark by default, light via prefers-color-scheme or data-theme. */
:root {
  --bg: #0f1216; --bg-2: #141920; --panel: #181e26; --panel-2: #1f2630; --border: #2a323d; --border-2: #343d4a;
  --text: #e8ebef; --text-2: #aab3bf; --muted: #7b8591; --accent: #3987e5; --accent-2: #5aa0f2; --accent-bg: rgba(57,135,229,.14);
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --bad: #e66767; --violet: #9085e9; --aqua: #199e70; --orange: #d95926;
  --shadow: 0 10px 30px rgba(0,0,0,.35); --radius: 12px; --radius-s: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace; --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --side-w: 228px; --top-h: 58px;
  color-scheme: dark;
}
:root[data-theme="light"], :root:not([data-theme="dark"]) { }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) {
  --bg: #f4f5f7; --bg-2: #eceef2; --panel: #ffffff; --panel-2: #f6f7f9; --border: #dde1e7; --border-2: #cfd5dd;
  --text: #171b21; --text-2: #4b5563; --muted: #7b8591; --accent: #2a78d6; --accent-2: #1c5cab; --accent-bg: rgba(42,120,214,.10);
  --bad: #d03b3b; --shadow: 0 10px 30px rgba(20,30,50,.12); color-scheme: light; } }
:root[data-theme="light"] {
  --bg: #f4f5f7; --bg-2: #eceef2; --panel: #ffffff; --panel-2: #f6f7f9; --border: #dde1e7; --border-2: #cfd5dd;
  --text: #171b21; --text-2: #4b5563; --muted: #7b8591; --accent: #2a78d6; --accent-2: #1c5cab; --accent-bg: rgba(42,120,214,.10);
  --bad: #d03b3b; --shadow: 0 10px 30px rgba(20,30,50,.12); color-scheme: light; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; } h3 { font-size: 14px; } h4 { font-size: 13px; color: var(--text-2); }
code, pre, .num, .mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-bg); }
[hidden] { display: none !important; }

/* Layout */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--bg-2); border-right: 1px solid var(--border); padding: 14px 12px; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-bg) url("favicon.svg") center/100% no-repeat; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { color: var(--muted); font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--text-2); font-weight: 500; position: relative; }
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-bg); color: var(--text); }
.nav a.active .ico { background: var(--accent); }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; }
.ico { width: 18px; height: 18px; display: inline-block; background: var(--muted); mask-size: contain; -webkit-mask-size: contain; mask-repeat: no-repeat; -webkit-mask-repeat: no-repeat; mask-position: center; -webkit-mask-position: center; flex: none; }
.ico-grid { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Crect x='3' y='3' width='7' height='7' rx='1.5'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1.5'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1.5'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1.5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Crect x='3' y='3' width='7' height='7' rx='1.5'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1.5'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1.5'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1.5'/%3E%3C/svg%3E"); }
.ico-search { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E"); }
.ico-news { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 5h13v14H6a2 2 0 0 1-2-2z'/%3E%3Cpath d='M17 9h3v8a2 2 0 0 1-2 2'/%3E%3Cpath d='M7 9h6M7 13h6M7 17h4'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 5h13v14H6a2 2 0 0 1-2-2z'/%3E%3Cpath d='M17 9h3v8a2 2 0 0 1-2 2'/%3E%3Cpath d='M7 9h6M7 13h6M7 17h4'/%3E%3C/svg%3E"); }
.ico-book { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z'/%3E%3Cpath d='M4 19a2 2 0 0 0 2 2h13'/%3E%3Cpath d='M8 7h7'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z'/%3E%3Cpath d='M4 19a2 2 0 0 0 2 2h13'/%3E%3Cpath d='M8 7h7'/%3E%3C/svg%3E"); }
.ico-flow { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='4' width='6' height='6' rx='1.5'/%3E%3Crect x='15' y='4' width='6' height='6' rx='1.5'/%3E%3Crect x='9' y='14' width='6' height='6' rx='1.5'/%3E%3Cpath d='M6 10v2a2 2 0 0 0 2 2h1M18 10v2a2 2 0 0 1-2 2h-1'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='4' width='6' height='6' rx='1.5'/%3E%3Crect x='15' y='4' width='6' height='6' rx='1.5'/%3E%3Crect x='9' y='14' width='6' height='6' rx='1.5'/%3E%3Cpath d='M6 10v2a2 2 0 0 0 2 2h1M18 10v2a2 2 0 0 1-2 2h-1'/%3E%3C/svg%3E"); }
.ico-plug { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M9 3v5M15 3v5M7 8h10v3a5 5 0 0 1-10 0z'/%3E%3Cpath d='M12 16v5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M9 3v5M15 3v5M7 8h10v3a5 5 0 0 1-10 0z'/%3E%3Cpath d='M12 16v5'/%3E%3C/svg%3E"); }
.ico-pulse { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12h4l2-6 4 12 2-6h6'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12h4l2-6 4 12 2-6h6'/%3E%3C/svg%3E"); }
.ico-cog { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1'/%3E%3C/svg%3E"); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px; font-size: 12px; color: var(--text-2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.llm-status, .live-status { display: flex; align-items: center; gap: 8px; }
.llm-status .status-dot.ok, .live-status .status-dot.live { background: var(--good); box-shadow: 0 0 0 3px rgba(12,163,12,.18); }
.llm-status .status-dot.none { background: var(--bad); }
.live-status .status-dot.reconnecting { background: var(--warn); }
.llm-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 16px; padding: 0 22px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.view-title { font-size: 17px; }
.global-search { flex: 1; max-width: 520px; margin-left: auto; }
.global-search input { width: 100%; }
.top-actions { display: flex; gap: 8px; }
.view { padding: 20px 22px 60px; }
.view:focus { outline: none; }

/* Cards & grid */
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card.pad-0 { padding: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; }
.card-head .sub { color: var(--muted); font-size: 12px; font-weight: 400; }
.card-actions { display: flex; gap: 6px; align-items: center; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .k-label { color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .k-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.kpi .k-sub { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.kpi .k-sub .up { color: var(--good); } .kpi .k-sub .down { color: var(--bad); }
.kpi.alert .k-value { color: var(--serious); }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 12px; border-radius: var(--radius-s); border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--border); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: rgba(230,103,103,.12); border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.icon { padding: 4px 8px; font-size: 16px; line-height: 1; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.busy::before { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
input, select, textarea { background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius-s); padding: 7px 10px; color: var(--text); outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
input[type="search"] { -webkit-appearance: none; }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: 12.5px; min-height: 160px; white-space: pre; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field .flabel { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.switch { position: relative; width: 36px; height: 20px; border-radius: 10px; background: var(--border-2); border: none; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--good); } .switch.on::after { left: 18px; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius-s); padding: 2px; }
.seg button { border: none; background: transparent; padding: 4px 10px; border-radius: 6px; color: var(--text-2); cursor: pointer; font-size: 12.5px; }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }

/* Pills, chips, tables, lists */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--panel-2); color: var(--text-2); border: 1px solid var(--border); text-transform: lowercase; }
.pill.st-done, .pill.st-ok, .pill.st-success { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: color-mix(in srgb, var(--good) 10%, transparent); }
.pill.st-running, .pill.st-queued { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-bg); }
.pill.st-failed, .pill.st-error { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.pill.st-cancelled, .pill.st-unconfigured, .pill.st-disabled { color: var(--muted); }
.pill.st-running::before { content: ""; width: 8px; height: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; background: var(--accent-bg); color: var(--accent-2); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); margin: 0 4px 4px 0; cursor: default; }
.chip.tag { background: color-mix(in srgb, var(--violet) 14%, transparent); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 35%, transparent); cursor: pointer; }
.chip.topic { background: color-mix(in srgb, var(--aqua) 14%, transparent); color: var(--aqua); border-color: color-mix(in srgb, var(--aqua) 35%, transparent); }
.chip.type { background: var(--panel-2); color: var(--text-2); border-color: var(--border); }
.sent { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
.sent.positive { background: var(--good); } .sent.negative { background: var(--bad); } .sent.neutral { background: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; } .table tr.clickable:hover td { background: var(--panel-2); }
.table td.num, .table th.num { text-align: right; }
.list { display: flex; flex-direction: column; }
.row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.row.clickable { cursor: pointer; margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; }
.row.clickable:hover { background: var(--panel-2); }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 500; color: var(--text); display: block; }
.row .title a { color: inherit; }
.row .meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.row .side { display: flex; gap: 6px; align-items: center; flex: none; }
.row.unread .title { font-weight: 600; }
.row.read .title { color: var(--text-2); }
.row .thumb { width: 64px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--panel-2); flex: none; }
.empty { padding: 28px 10px; text-align: center; color: var(--muted); }
.empty p { margin: 4px 0; } .empty .sub { font-size: 12px; }
.loading { display: flex; gap: 10px; align-items: center; color: var(--muted); padding: 20px; justify-content: center; }
.spin { width: 16px; height: 16px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline-list { display: flex; flex-wrap: wrap; gap: 6px; }
.callout { padding: 10px 12px; border-radius: var(--radius-s); background: var(--accent-bg); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); font-size: 13px; }
.callout.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.callout.error { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { background: none; border: none; padding: 8px 12px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* Charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; } .chart .axis { stroke: var(--border-2); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 10px; font-family: var(--sans); }
.chart .bar { transition: opacity .12s; } .chart rect[fill="transparent"]:hover + .bar, .chart .bar:hover { opacity: .8; }
.chart-tip { position: fixed; z-index: 100; pointer-events: none; background: var(--panel); border: 1px solid var(--border-2); border-radius: 8px; padding: 6px 9px; font-size: 12px; color: var(--text); box-shadow: var(--shadow); display: none; }
.chart-tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar-row { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; border-radius: 5px; background: var(--bg-2); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 5px; transition: width .4s ease; }
.hbar-value { color: var(--text-2); min-width: 32px; text-align: right; }
.spark { vertical-align: middle; }

/* Markdown */
.md { line-height: 1.6; font-size: 14px; }
.md h1 { font-size: 22px; margin: 18px 0 8px; } .md h2 { font-size: 17px; margin: 18px 0 8px; } .md h3 { font-size: 15px; margin: 14px 0 6px; } .md h4 { margin: 12px 0 4px; }
.md p { margin: 0 0 10px; } .md ul, .md ol { margin: 0 0 10px; padding-left: 22px; } .md li { margin: 2px 0; }
.md blockquote { margin: 0 0 10px; padding: 6px 12px; border-left: 3px solid var(--accent); color: var(--text-2); background: var(--panel-2); border-radius: 0 6px 6px 0; }
.md pre { background: var(--bg-2); border: 1px solid var(--border); padding: 10px 12px; border-radius: 8px; overflow: auto; font-size: 12.5px; }
.md code { background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; } .md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: 0 0 12px; width: 100%; font-size: 13px; } .md th, .md td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.md a.wikilink { color: var(--violet); border-bottom: 1px dotted var(--violet); }
.md img { max-width: 100%; border-radius: 8px; }

/* Drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 92vw); background: var(--panel); border-left: 1px solid var(--border); box-shadow: var(--shadow); transform: translateX(104%); transition: transform .22s ease; z-index: 40; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { padding: 16px 18px 40px; overflow: auto; flex: 1; }
.drawer-foot { padding: 10px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* Modal & toasts */
.modal { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
.modal-card { position: relative; width: min(560px, 94vw); max-height: 90vh; background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.modal-card.wide { width: min(900px, 96vw); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--border-2); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); min-width: 240px; max-width: 420px; animation: rise .2s ease; font-size: 13px; }
.toast.error { border-left-color: var(--bad); } .toast.success { border-left-color: var(--good); } .toast.warn { border-left-color: var(--warn); }
.toast.out { opacity: 0; transition: opacity .3s; }
.toast-x { margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } }

/* Activity ticker */
.activity .row { padding: 7px 0; gap: 10px; align-items: baseline; }
.activity .ts { color: var(--muted); font-size: 11.5px; font-family: var(--mono); flex: none; width: 46px; }
.activity .mod { color: var(--accent-2); font-size: 12px; font-weight: 600; flex: none; width: 86px; overflow: hidden; text-overflow: ellipsis; }
.activity .msg { flex: 1; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.activity .lvl-warn .msg { color: var(--warn); } .activity .lvl-error .msg { color: var(--bad); }

/* Steps timeline */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 16px 1fr; gap: 10px; padding: 6px 0; position: relative; }
.steps li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--border-2); margin-top: 5px; margin-left: 2px; }
.steps li.done::before { background: var(--good); } .steps li.failed::before { background: var(--bad); } .steps li.running::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); } .steps li.skipped::before { background: var(--muted); }
.steps .s-title { font-weight: 500; } .steps .s-detail { color: var(--text-2); font-size: 12.5px; overflow-wrap: anywhere; }
.steps .s-time { color: var(--muted); font-size: 11.5px; margin-left: 8px; }
details.out { margin-top: 4px; } details.out summary { cursor: pointer; color: var(--muted); font-size: 12px; }
details.out pre { background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-size: 11.5px; max-height: 280px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Knowledge */
.kb { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.kb .note-list { max-height: calc(100vh - 170px); overflow: auto; }
.note-item { padding: 9px 10px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--border); }
.note-item:hover, .note-item.active { background: var(--panel-2); }
.note-item .t { font-weight: 500; display: flex; justify-content: space-between; gap: 8px; }
.note-item .t .stale { color: var(--warn); font-size: 11px; }
.note-item .s { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-title { font-size: 20px; font-weight: 600; border: none; background: transparent; padding: 4px 0; width: 100%; }
.editor-title:focus { box-shadow: none; }
.editor-body { min-height: 360px; font-family: var(--mono); font-size: 13px; }
.graph { width: 100%; height: 520px; background: var(--bg-2); border-radius: 10px; border: 1px solid var(--border); }
.graph circle { cursor: pointer; } .graph text { font-size: 10px; fill: var(--text-2); pointer-events: none; }
.graph line { stroke: var(--border-2); stroke-width: 1; }

/* Connectors */
.conn-card .conn-head { display: flex; align-items: center; gap: 10px; }
.conn-card .conn-head h3 { flex: 1; }
.conn-card .setup { font-size: 12.5px; color: var(--text-2); }
.conn-card .setup p { margin: 4px 0; } .conn-card .setup ol { padding-left: 18px; margin: 4px 0; }
.secret-row { display: flex; gap: 8px; align-items: center; }
.secret-row input { flex: 1; }
.set-badge { font-size: 11px; color: var(--good); font-weight: 600; }
.unset-badge { font-size: 11px; color: var(--muted); }

/* Pipelines */
.pipe-steps { display: flex; flex-direction: column; gap: 6px; }
.pipe-step { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-2); }
.pipe-step .n { width: 22px; height: 22px; border-radius: 6px; background: var(--accent-bg); color: var(--accent-2); font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.pipe-step .tool { font-family: var(--mono); font-size: 12.5px; }
.tool-list { max-height: 420px; overflow: auto; }
.tool-item { padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; }
.tool-item:hover { background: var(--panel-2); }
.tool-item .tn { font-family: var(--mono); font-size: 12.5px; color: var(--accent-2); }
.tool-item .td { color: var(--text-2); font-size: 12px; }
.tool-item .tp { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }

/* Weather */
.weather { display: flex; align-items: center; gap: 14px; }
.weather .temp { font-size: 30px; font-weight: 600; }
.weather .days { display: flex; gap: 10px; margin-left: auto; font-size: 12px; color: var(--text-2); }
.weather .days div { text-align: center; }

/* Responsive */
@media (max-width: 1200px) { .cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: none; border-top: 1px solid var(--border); z-index: 30; }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-between; overflow: auto; }
  .nav a { flex-direction: column; gap: 3px; padding: 6px 8px; font-size: 10.5px; }
  .nav-badge { position: absolute; top: 2px; right: 6px; margin: 0; }
  .view { padding: 16px 16px 90px; }
  .topbar { padding: 0 16px; } .view-title { font-size: 15px; }
  .global-search { max-width: none; }
  .cols-2, .cols-3, .cols-4, .cols-6 { grid-template-columns: 1fr 1fr; }
  .span-2, .span-3, .span-4 { grid-column: span 2; }
  .kb { grid-template-columns: 1fr; } .kb .note-list { max-height: 300px; }
  .drawer { width: 100vw; }
}
@media (max-width: 560px) { .cols-2, .cols-3, .cols-4, .cols-6 { grid-template-columns: 1fr; } .span-2, .span-3, .span-4 { grid-column: span 1; } .kpi .k-value { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
