/* ShieldMind Console. Spacing scale: 4 8 12 16 24 32 48. See docs/CONSOLE.md. */

:root {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-2: #475569;
  --text-3: #64748B;
  --brand: #4F46E5;
  --brand-hover: #4338CA;
  --brand-soft: #EEF2FF;
  --brand-text: #3730A3;
  --on-brand: #FFFFFF;
  --ok: #15803D;
  --ok-soft: #DCFCE7;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --info: #1D4ED8;
  --info-soft: #DBEAFE;
  --muted-soft: #F1F5F9;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .18);
  --ring: 0 0 0 3px rgba(79, 70, 229, .25);
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0B1120;
  --surface: #111827;
  --surface-2: #1E293B;
  --border: #273449;
  --border-strong: #3B4A63;
  --text: #E2E8F0;
  --text-2: #A5B4C8;
  --text-3: #8B9AB0;
  --brand: #818CF8;
  --brand-hover: #A5B4FC;
  --brand-soft: rgba(129, 140, 248, .14);
  --brand-text: #C7D2FE;
  --on-brand: #0B1120;
  --ok: #4ADE80;
  --ok-soft: rgba(74, 222, 128, .13);
  --warn: #FBBF24;
  --warn-soft: rgba(251, 191, 36, .13);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, .14);
  --info: #60A5FA;
  --info-soft: rgba(96, 165, 250, .14);
  --muted-soft: #1E293B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(129, 140, 248, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, p { margin: 0; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 24px; height: 56px;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; }
.brand-mark svg.icon { width: 18px; height: 18px; stroke-width: 1.8; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--text-3); font-weight: 500; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.nav { display: flex; gap: 4px; height: 100%; }
.nav a {
  position: relative; display: flex; align-items: center; padding: 0 12px; color: var(--text-2);
  font-weight: 500; transition: color .15s ease;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); }
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand);
}
.top-actions { display: flex; align-items: center; gap: 8px; }

/* Layout */
.main { max-width: 1280px; margin: 0 auto; padding: 32px 24px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; }
.page-head p { color: var(--text-2); margin-top: 4px; max-width: 720px; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.stack > :empty { display: none; }
.stack > .page-head { margin-bottom: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.cols-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; }
.card-head h2 { font-size: 15px; line-height: 1.4; font-weight: 600; }
.card-head .sub { color: var(--text-3); font-size: 12px; }
.card-body { padding: 0 16px 16px; }
.card-body.flush { padding: 0; }
.section-title { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { padding: 16px; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-3); }
.stat-value { font-size: 28px; line-height: 1.1; font-weight: 600; margin-top: 8px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; font-weight: 500; color: var(--text-3); margin-left: 4px; letter-spacing: 0; }
.stat-value.danger { color: var(--danger); }

/* Banner */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius); border: 1px solid transparent; }
.banner svg.icon { margin-top: 2px; }
.banner strong { display: block; font-weight: 600; }
.banner p { color: var(--text-2); }
.banner.info { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.banner.info svg.icon { color: var(--brand); }
.banner.ok { background: var(--ok-soft); }
.banner.ok svg.icon { color: var(--ok); }
.banner.warn { background: var(--warn-soft); }
.banner.warn svg.icon { color: var(--warn); }
.banner.danger { background: var(--danger-soft); }
.banner.danger svg.icon { color: var(--danger); }
.banner .btn { margin-left: auto; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--muted-soft); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-text); }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 500; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.sm.icon-only { width: 30px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { height: auto; min-height: 44px; max-height: 220px; padding: 10px 12px; resize: none; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input.mono { font-family: var(--mono); }
.form-grid { display: grid; gap: 16px; }
.form-error { color: var(--danger); font-size: 13px; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 9px; }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font-weight: 500; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Lists */
.list { display: flex; flex-direction: column; }
.list-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 16px;
  border-top: 1px solid var(--border); cursor: pointer; color: inherit; transition: background .12s ease;
}
.list-row:first-child { border-top: 0; }
.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-row[aria-current="true"] { background: var(--brand-soft); }
.list-row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .meta { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }
.dot.brand { background: var(--brand); }

/* Agents split */
.split { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
.split .list-col { display: flex; flex-direction: column; gap: 16px; }
.chip.brand { background: var(--brand-soft); color: var(--brand-text); }
.split .list-card .card-body { padding-bottom: 12px; }
.agent-list { max-height: calc(100vh - 420px); min-height: 160px; overflow: auto; border-top: 1px solid var(--border); }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-head { display: flex; align-items: flex-start; gap: 16px; padding: 16px; flex-wrap: wrap; }
.detail-head h2 { font-size: 20px; line-height: 1.3; font-weight: 600; }
.detail-head .id { color: var(--text-3); margin-top: 2px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; align-items: center; }
.kv dt { color: var(--text-3); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; display: flex; align-items: center; gap: 8px; }
.kv dd .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill { padding: 12px; border: 1px solid var(--border); border-radius: 8px; }
.skill + .skill { margin-top: 8px; }
.skill .name { font-weight: 500; }
.skill p { color: var(--text-2); margin-top: 2px; }
.skill .row { margin-top: 8px; }
.back-link { display: none; }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 8px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; }
.table-wrap { overflow-x: auto; }

/* Empty, skeleton, spinner */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; color: var(--text-2); }
.empty .empty-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin-bottom: 8px; }
.empty .empty-icon svg.icon { width: 24px; height: 24px; }
.empty h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.empty p { max-width: 420px; }
.empty .btn { margin-top: 8px; }
.skeleton { border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.sk-line { height: 12px; margin: 8px 0; }
.sk-num { height: 30px; width: 60%; margin-top: 8px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; flex: none; }
.typing { display: inline-flex; gap: 4px; align-items: center; height: 16px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

/* Graph */
.graph { width: 100%; height: auto; display: block; }
.graph .edge { stroke: var(--brand); opacity: .55; }
.graph .edge.blocked { stroke: var(--danger); opacity: .8; stroke-dasharray: 6 4; }
.graph .edge:hover { opacity: 1; }
.graph .arrow { fill: var(--brand); }
.graph .arrow-blocked { fill: var(--danger); }
.graph .node circle { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }
.graph .node.service circle { stroke: var(--text-3); stroke-dasharray: 3 3; }
.graph .node.down circle { stroke: var(--warn); }
.graph .node text { fill: var(--text); font: 600 13px var(--font); text-anchor: middle; dominant-baseline: central; }
.graph .node .label { fill: var(--text-2); font-weight: 500; font-size: 12px; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.graph .node { cursor: pointer; }
.graph .node:hover circle { fill: var(--brand-soft); }
.graph .node circle { transition: fill .3s ease, stroke-width .3s ease; }
.graph .node.flash circle { fill: var(--brand-soft); stroke-width: 4; }
.graph .node-new { animation: node-in .6s ease-out; }
.graph .pulse { fill: var(--brand); stroke: var(--surface); stroke-width: 3; filter: drop-shadow(0 0 6px currentColor); color: var(--brand); }
.graph .pulse.ok { fill: var(--ok); color: var(--ok); }
.graph .pulse.danger { fill: var(--danger); color: var(--danger); }
.graph .pulse.warn { fill: var(--warn); color: var(--warn); }
.graph .pulse.info { fill: var(--info); color: var(--info); }

/* Inbox */
.inbox-section { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.inbox-controls { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.inbox-hint { margin-top: 8px; font-size: 13px; }
.inbox-item { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; }
.inbox-item .content-text { background: var(--surface-2); }
.inbox-hist .title { white-space: nowrap; }
.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch { position: relative; width: 40px; height: 24px; border-radius: 999px; border: 0; background: var(--border-strong); cursor: pointer; padding: 0; transition: background .18s ease; flex: none; }
.switch[aria-checked="true"] { background: var(--ok); }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .18s ease; }
.switch[aria-checked="true"] .switch-knob { transform: translateX(16px); }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; line-height: 1; }
.nav-badge.static { margin-left: 0; }
.toast.clickable { cursor: pointer; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

/* Network */
.net-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.stream-card { display: flex; flex-direction: column; max-height: calc(100vh - 210px); min-height: 420px; }
.stream { overflow-y: auto; flex: 1; }
.stream-note:empty { display: none; }
.stream-note { padding: 12px 16px 0; }
.stream-note .banner { padding: 8px 12px; font-size: 13px; }
.stream-item { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; padding: 12px 16px; background: transparent;
  border: 0; border-top: 1px solid var(--border); cursor: pointer; color: inherit; transition: background .12s ease; }
.stream > .stream-item:first-child { border-top: 0; }
.stream-item:hover { background: var(--surface-2); }
.stream-item.inflight { box-shadow: inset 3px 0 0 var(--warn); }
.stream-item.updated { animation: updated 1.4s ease-out; }
@keyframes updated { from { background: var(--ok-soft); } to { background: transparent; } }
.stream-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stream-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; overflow: hidden; }
.stream-title .who { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stream-title .arrow-sep { color: var(--text-3); flex: none; }
.stream-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-3); }
.stream-line { display: flex; gap: 8px; font-size: 13px; color: var(--text-2); min-width: 0; }
.stream-line > span:last-child { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.stream-line .q { color: var(--brand); font-weight: 600; flex: none; }
.stream-line.reply .q { color: var(--ok); }
.content-text { white-space: pre-wrap; word-break: break-word; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13.5px; }
.content-text + .content-text { margin-top: 8px; }
@keyframes node-in { from { opacity: 0; } to { opacity: 1; } }

/* Audit feed */
.feed-row {
  display: grid; grid-template-columns: 76px minmax(0, 1fr) auto 64px; gap: 12px; align-items: center;
  padding: 10px 16px; border-top: 1px solid var(--border); cursor: pointer; width: 100%; text-align: left;
  background: transparent; border-left: 0; border-right: 0; border-bottom: 0; transition: background .12s ease;
}
.feed > .feed-item:first-child .feed-row { border-top: 0; }
.feed-row:hover { background: var(--surface-2); }
.feed-row time { color: var(--text-3); }
.feed-main { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.feed-main .who { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-main .arrow-sep { color: var(--text-3); flex: none; }
.feed-main .method { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-lat { color: var(--text-3); text-align: right; white-space: nowrap; }
.feed.compact .feed-row { grid-template-columns: 64px minmax(0, 1fr) auto 64px; }
.feed.compact .method { display: none; }
.feed-detail { padding: 12px 16px 16px 104px; background: var(--surface-2); border-top: 1px solid var(--border); }
.feed-detail .kv { grid-template-columns: 140px 1fr; margin-bottom: 12px; }
pre.json {
  margin: 0; padding: 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border);
  font: 12px/1.5 var(--mono); overflow: auto; max-height: 360px; white-space: pre-wrap; word-break: break-word;
}
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar .select { width: auto; min-width: 180px; height: 34px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2s infinite; }
.live-dot.off { background: var(--text-3); animation: none; }

/* Chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 222px); min-height: 480px; }
.chat-bar { display: flex; gap: 8px; align-items: flex-end; padding: 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chat-bar .field { min-width: 200px; flex: 1 1 200px; max-width: 280px; }
.chat-bar .swap { margin-bottom: 0; }
.chat-context { font-size: 12px; color: var(--text-3); padding: 8px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.chat-log { flex: 1; overflow-y: auto; padding: 24px 16px; display: flex; flex-direction: column; gap: 16px; }
.msg-out { align-self: flex-end; max-width: 72%; }
.msg-out .bubble { background: var(--brand); color: var(--on-brand); padding: 10px 14px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; word-break: break-word; }
.msg-meta { font-size: 12px; color: var(--text-3); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.msg-out .msg-meta { justify-content: flex-end; }
.msg-in { align-self: flex-start; width: min(100%, 820px); }
.msg-in .panel { background: var(--surface); border: 1px solid var(--border); border-radius: 4px 14px 14px 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.timeline { display: flex; flex-direction: column; gap: 6px; }
.tl-item { display: grid; grid-template-columns: 10px auto 1fr; gap: 8px; align-items: baseline; font-size: 13px; }
.tl-item .dot { transform: translateY(1px); }
.tl-item .state { font-weight: 500; color: var(--text-2); white-space: nowrap; }
.tl-item .text { color: var(--text-2); word-break: break-word; }
.agent-text { white-space: pre-wrap; word-break: break-word; }
.artifact { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.artifact-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface-2); font-size: 12px; color: var(--text-2); font-weight: 500; }
.artifact-body { padding: 12px; }
.artifact-body .agent-text { font-size: 14px; }
.artifact-body.collapsed { max-height: 280px; overflow: hidden; position: relative; }
.artifact-body.collapsed::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 72px; background: linear-gradient(to bottom, transparent, var(--surface)); pointer-events: none; }
.artifact-toggle { display: flex; justify-content: center; padding: 8px; border-top: 1px solid var(--border); }
.file-row { display: flex; align-items: center; gap: 12px; }
.file-row .name { font-weight: 500; }
.error-block { display: flex; gap: 8px; color: var(--danger); background: var(--danger-soft); padding: 10px 12px; border-radius: 8px; word-break: break-word; }
.composer { border-top: 1px solid var(--border); padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.composer .row { align-items: flex-end; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; }
.suggest button { height: 28px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 13px; }
.suggest button:hover { border-color: var(--brand); color: var(--brand); }
.composer .hint { font-size: 12px; color: var(--text-3); }
details.raw summary { cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 500; }
details.raw[open] summary { margin-bottom: 8px; }

/* Scan report */
.report { display: flex; flex-direction: column; gap: 12px; }
.report-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.grade { width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; font-size: 26px; font-weight: 700; }
.grade.g-A, .grade.g-B { background: var(--ok-soft); color: var(--ok); }
.grade.g-C, .grade.g-D { background: var(--warn-soft); color: var(--warn); }
.grade.g-E, .grade.g-F { background: var(--danger-soft); color: var(--danger); }
.finding { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.finding .title { font-weight: 500; }
.finding .where { grid-column: 2; font-size: 12px; color: var(--text-3); word-break: break-all; }

/* Markdown */
.md { display: flex; flex-direction: column; gap: 8px; }
.md h3 { font-size: 16px; font-weight: 600; }
.md h4 { font-size: 15px; font-weight: 600; margin-top: 4px; }
.md h5 { font-size: 14px; font-weight: 600; }
.md ul, .md ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.md code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.md table { border-collapse: collapse; font-size: 13px; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 10px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 16px; animation: fade .16s ease-out; }
.modal.wide { width: min(760px, 100%); }
.modal { width: min(520px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .16s ease-out; max-height: calc(100vh - 32px); overflow: auto; }
.modal-head { display: flex; align-items: center; padding: 16px 16px 0 24px; }
.modal-head h2 { font-size: 16px; font-weight: 600; flex: 1; }
.modal-body { padding: 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { padding: 0 24px 24px; display: flex; justify-content: flex-end; gap: 8px; }
.secret-box { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.secret-box code { flex: 1; font: 13px/1.5 var(--mono); word-break: break-all; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); animation: slide-up .18s ease-out; }
.toast.leaving { animation: fade-out .2s ease-in forwards; }
.toast svg.icon { margin-top: 1px; }
.toast.error svg.icon { color: #FCA5A5; }
.toast.ok svg.icon { color: #86EFAC; }
[data-theme="dark"] .toast.error svg.icon { color: var(--danger); }
[data-theme="dark"] .toast.ok svg.icon { color: #15803D; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: min(420px, 100%); padding: 32px; display: flex; flex-direction: column; gap: 24px; }
.login .brand { justify-content: center; }
.login h1 { font-size: 20px; font-weight: 600; text-align: center; }
.login .lead { text-align: center; color: var(--text-2); margin-top: 4px; }
.login-foot { display: flex; justify-content: center; gap: 8px; }

/* Animation */
.appear { animation: appear .18s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(4px); } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Responsive */
@media (max-width: 1100px) {
  .cols-2, .net-grid { grid-template-columns: 1fr; }
  .stream-card { max-height: 640px; }
}
@media (max-width: 900px) {
  .topbar-inner { grid-template-columns: auto 1fr; grid-template-rows: 56px 44px; height: auto; gap: 0 16px; }
  .nav { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; }
  .nav::-webkit-scrollbar { display: none; }
  .top-actions { justify-content: flex-end; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
  .split.show-detail .list-col { display: none; }
  .form-2 { grid-template-columns: 1fr; }
  .split:not(.show-detail) .detail-card { display: none; }
  .back-link { display: inline-flex; }
  .agent-list { max-height: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .msg-out { max-width: 88%; }
  .feed-row { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .feed-lat { display: none; }
  .feed-detail { padding-left: 16px; }
  .chat { height: calc(100vh - 250px); }
}
@media (max-width: 560px) {
  .main { padding: 24px 16px 32px; }
  .topbar-inner { padding: 0 16px; }
  .brand-text .brand-sub { display: none; }
  .top-actions .mode-badge { display: none; }
  .stat-value { font-size: 24px; }
  .toolbar .seg { width: 100%; }
  .toolbar .seg button { flex: 1 1 auto; padding: 0 6px; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .toolbar .select { width: 100%; }
  .feed-row, .feed.compact .feed-row {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main dec" "time time"; row-gap: 2px;
  }
  .feed-row > .feed-main { grid-area: main; }
  .feed-row > .badge { grid-area: dec; }
  .feed-row > time { grid-area: time; font-size: 11.5px; }
  .feed-main .method { display: none; }
}
