:root {
  color-scheme: dark;
  --bg: #05080d;
  --panel: rgba(12, 18, 27, 0.86);
  --panel-strong: #0c131d;
  --panel-soft: #101925;
  --border: rgba(148, 163, 184, 0.14);
  --border-bright: rgba(76, 201, 240, 0.26);
  --text: #edf4f7;
  --muted: #8594a6;
  --subtle: #536273;
  --cyan: #50d8ff;
  --cyan-soft: rgba(80, 216, 255, 0.12);
  --yellow: #f5d142;
  --red: #ff5c71;
  --green: #4ce5a0;
  --orange: #ffb35c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 0%, rgba(36, 121, 164, 0.11), transparent 31rem),
    radial-gradient(circle at 90% 15%, rgba(245, 209, 66, 0.055), transparent 28rem),
    var(--bg);
  color: var(--text);
}
button, textarea { font: inherit; }
button { color: inherit; }

.ambient { position: fixed; pointer-events: none; filter: blur(80px); opacity: .22; border-radius: 999px; z-index: 0; }
.ambient-one { width: 320px; height: 320px; background: #0e88b9; top: 180px; left: -190px; }
.ambient-two { width: 280px; height: 280px; background: #6a5d14; top: 50px; right: -180px; }

.app-shell { width: min(1540px, calc(100% - 40px)); margin: 0 auto; position: relative; z-index: 1; }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.brand-block, .topbar-right, .agent-identity, .hero-meta, .legend, .architecture-flow { display: flex; align-items: center; }
.brand-block { gap: 12px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border-bright); border-radius: 10px; background: linear-gradient(145deg, rgba(80,216,255,.13), rgba(80,216,255,.02)); box-shadow: inset 0 0 30px rgba(80,216,255,.05); }
.brand-mark svg { width: 24px; fill: var(--cyan); }
.brand-mark .spark { stroke: #d6f7ff; stroke-width: 1.2; fill: none; opacity: .6; }
.brand-line { font-weight: 800; font-size: 15px; letter-spacing: .16em; }
.brand-line span { color: var(--cyan); }
.brand-sub { color: var(--muted); font-size: 11px; letter-spacing: .04em; margin-top: 3px; }
.topbar-right { gap: 8px; }
.tech-pill, .live-pill, .mode-chip { border: 1px solid var(--border); background: rgba(12,18,27,.72); border-radius: 999px; padding: 7px 11px; color: #aeb9c6; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.tech-pill i { display: inline-block; width: 5px; height: 5px; background: var(--cyan); border-radius: 999px; margin: 0 6px 1px 0; }
.live-pill { color: #ffdfe3; border-color: rgba(255,92,113,.28); background: rgba(255,92,113,.08); }
.pulse-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 5px rgba(255,92,113,.08); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(255,92,113,0); } }

main { padding: 26px 0 34px; }
.panel { background: linear-gradient(180deg, rgba(14,21,31,.9), rgba(9,14,22,.9)); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-hero { display: flex; justify-content: space-between; gap: 24px; align-items: center; padding: 26px 28px; background: linear-gradient(105deg, rgba(11,24,35,.96), rgba(13,19,28,.91) 60%, rgba(20,20,15,.84)); position: relative; overflow: hidden; }
.panel-hero::after { content:""; position:absolute; inset:0; background: linear-gradient(90deg, transparent 0 70%, rgba(245,209,66,.035)); pointer-events:none; }
.eyebrow { font-size: 10px; color: #7f93a8; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.hero-copy h1 { margin: 7px 0 8px; font-size: clamp(26px, 3vw, 41px); letter-spacing: -.035em; font-weight: 760; }
.hero-copy p { margin: 0; color: var(--muted); max-width: 760px; font-size: 14px; line-height: 1.6; }
.hero-meta { gap: 10px; margin-top: 16px; color: #66778a; font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.divider { width: 1px; height: 12px; background: var(--border); }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; }
.status-dot.critical { background: var(--red); box-shadow: 0 0 14px rgba(255,92,113,.6); }
.status-dot.healthy { background: var(--green); box-shadow: 0 0 14px rgba(76,229,160,.5); }
.hero-actions { display: flex; gap: 9px; position: relative; z-index: 1; flex-shrink: 0; }
.button { min-height: 41px; border: 1px solid transparent; border-radius: 10px; padding: 0 15px; font-size: 12px; font-weight: 750; cursor: pointer; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--cyan); color: #031017; box-shadow: 0 8px 26px rgba(80,216,255,.16); }
.button-secondary { background: rgba(255,255,255,.025); border-color: var(--border); color: #aab6c3; }
.button-icon { margin-right: 5px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin: 12px 0; }
.kpi { padding: 18px 19px; min-height: 124px; position: relative; overflow: hidden; }
.kpi::after { content:""; position:absolute; left:0; top:17px; bottom:17px; width:2px; background: var(--cyan); opacity:.65; }
.kpi-label { color: #758699; font-size: 11px; font-weight: 650; }
.kpi-value { font-size: clamp(26px, 2.4vw, 36px); font-weight: 760; letter-spacing: -.04em; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.kpi-foot { color: #647487; font-size: 10px; }
.positive { color: #72cba6; }
.critical-text { color: #df8290; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.13fr) minmax(390px, .87fr); gap: 12px; align-items: stretch; }
.left-stack { display: grid; grid-template-rows: auto 1fr; gap: 12px; min-width: 0; }
.network-panel, .incident-panel, .agent-panel { padding: 20px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.panel-heading.compact { align-items: center; margin-bottom: 12px; }
h2 { margin: 4px 0 0; font-size: 16px; letter-spacing: -.015em; }
.legend { gap: 13px; color: #647487; font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.legend-dot.healthy { background: var(--green); }
.legend-dot.critical { background: var(--red); }

.region-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; }
.region-card { border: 1px solid var(--border); border-radius: 13px; padding: 13px; background: rgba(4,9,14,.42); min-width: 0; position: relative; transition: border-color .2s ease, transform .2s ease; }
.region-card:hover { transform: translateY(-2px); border-color: rgba(80,216,255,.25); }
.region-card.critical { border-color: rgba(255,92,113,.26); background: linear-gradient(180deg, rgba(45,15,22,.18), rgba(4,9,14,.42)); }
.region-top { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.region-code { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; overflow:hidden; text-overflow:ellipsis; }
.region-state { width:7px; height:7px; border-radius:50%; background:var(--green); box-shadow:0 0 10px rgba(76,229,160,.4); }
.region-card.critical .region-state { background: var(--red); box-shadow:0 0 10px rgba(255,92,113,.5); }
.region-city { color:#617286; font-size:9px; margin-top:3px; }
.region-stat { margin-top:14px; display:flex; justify-content:space-between; align-items:flex-end; gap:6px; }
.region-stat strong { font-size:16px; font-weight:720; }
.region-stat span { color:#66788a; font-size:9px; text-align:right; }
.region-bar { margin-top:10px; height:3px; border-radius:9px; background:#17212c; overflow:hidden; }
.region-bar i { display:block; height:100%; background:var(--green); border-radius:inherit; }
.region-card.critical .region-bar i { background:var(--red); }

.incident-list { display:grid; gap:8px; }
.incident-row { display:grid; grid-template-columns: 94px minmax(120px,1fr) minmax(120px,1fr) 100px 92px; gap:10px; align-items:center; padding:11px 12px; border:1px solid var(--border); border-radius:11px; background:rgba(3,8,13,.42); font-size:11px; }
.incident-row.empty { display:block; color:#718397; text-align:center; padding:26px; }
.incident-id { color:#99a8b8; font-family:ui-monospace, monospace; }
.severity { display:inline-flex; width:max-content; padding:4px 7px; border-radius:999px; font-size:9px; font-weight:850; letter-spacing:.07em; text-transform:uppercase; }
.severity.critical { color:#ffd9de; background:rgba(255,92,113,.12); border:1px solid rgba(255,92,113,.2); }
.severity.high { color:#ffe4c5; background:rgba(255,179,92,.1); border:1px solid rgba(255,179,92,.18); }
.incident-metric strong { display:block; font-size:12px; }
.incident-metric span { color:#627386; font-size:9px; }
.text-button { border:0; background:transparent; color:#6fbfd7; font-size:10px; cursor:pointer; padding:6px; }
.text-button:hover { color:var(--cyan); }

.agent-panel { min-height: 650px; display:flex; flex-direction:column; background: linear-gradient(180deg, rgba(10,17,25,.97), rgba(5,10,16,.97)); }
.agent-header { display:flex; justify-content:space-between; align-items:center; gap:12px; padding-bottom:15px; border-bottom:1px solid var(--border); }
.agent-identity { gap:10px; }
.agent-avatar { width:35px; height:35px; display:grid; place-items:center; border-radius:10px; background:var(--cyan-soft); color:var(--cyan); border:1px solid rgba(80,216,255,.18); }
.mode-chip { font-size:9px; color:#7ecfe7; border-color:rgba(80,216,255,.18); }
.suggestions { display:flex; gap:6px; flex-wrap:wrap; padding:13px 0; }
.suggestions button { border:1px solid var(--border); background:rgba(255,255,255,.02); color:#718397; border-radius:8px; padding:7px 9px; font-size:9px; cursor:pointer; }
.suggestions button:hover { color:#a9bac9; border-color:rgba(80,216,255,.22); }
.chat-log { flex:1; overflow:auto; min-height:300px; max-height:440px; padding:3px 3px 10px; scrollbar-width:thin; scrollbar-color:#273441 transparent; }
.message { margin: 10px 0; }
.message-label { color:#536779; font-size:9px; font-weight:800; letter-spacing:.12em; margin-bottom:5px; }
.message-body { width:fit-content; max-width:93%; border:1px solid var(--border); border-radius:12px; padding:10px 12px; background:rgba(255,255,255,.018); color:#a9b6c3; font-size:11px; line-height:1.55; }
.user-message { text-align:right; }
.user-message .message-label { color:#617f89; }
.user-message .message-body { margin-left:auto; text-align:left; color:#d6eef5; border-color:rgba(80,216,255,.15); background:rgba(80,216,255,.055); }
.agent-message .message-body h3 { color:#dceaf0; font-size:11px; margin:12px 0 5px; }
.agent-message .message-body h3:first-child { margin-top:0; }
.agent-message .message-body strong { color:#eff9fb; }
.agent-message .message-body ul { margin:5px 0; padding-left:16px; }
.agent-message .message-body li { margin:3px 0; }
.thinking .message-body { color:#637487; }
.dots span { animation: blink 1.3s infinite; opacity:.2; }
.dots span:nth-child(2) { animation-delay:.18s; }
.dots span:nth-child(3) { animation-delay:.36s; }
@keyframes blink { 45% { opacity:1; } }

.trace-panel { margin:8px 0 12px; padding:11px; border:1px solid rgba(80,216,255,.11); border-radius:11px; background:rgba(80,216,255,.025); }
.trace-panel.hidden { display:none; }
.trace-title { color:#7990a1; font-size:9px; font-weight:800; letter-spacing:.1em; text-transform:uppercase; margin-bottom:7px; }
.trace-item { display:grid; grid-template-columns:20px 116px 1fr; gap:7px; align-items:start; padding:5px 0; color:#6f8294; font-size:9px; border-top:1px solid rgba(148,163,184,.06); }
.trace-item:first-child { border-top:0; }
.trace-num { width:17px; height:17px; display:grid; place-items:center; border-radius:50%; background:rgba(76,229,160,.08); color:var(--green); font-size:8px; }
.trace-tool { font-family:ui-monospace, monospace; color:#91a5b4; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.composer { display:flex; gap:8px; align-items:flex-end; border:1px solid var(--border); border-radius:12px; padding:8px; background:#060b11; }
.composer:focus-within { border-color:rgba(80,216,255,.27); box-shadow:0 0 0 3px rgba(80,216,255,.035); }
.composer textarea { flex:1; resize:none; border:0; outline:0; background:transparent; color:#d9e5ea; min-height:42px; max-height:100px; padding:8px; font-size:11px; line-height:1.4; }
.composer textarea::placeholder { color:#445362; }
.send-button { width:38px; height:38px; border:0; border-radius:9px; background:var(--cyan); color:#041117; font-size:18px; cursor:pointer; }
.send-button:disabled { opacity:.35; cursor:wait; }
.composer-foot { display:flex; justify-content:space-between; gap:8px; margin-top:6px; color:#435260; font-size:8px; }

.architecture-strip { margin-top:12px; padding:18px 20px; }
.architecture-flow { gap:8px; margin-top:11px; }
.arch-node { flex:1; min-width:0; border:1px solid var(--border); border-radius:10px; padding:10px 12px; background:rgba(255,255,255,.014); }
.arch-node strong { display:block; font-size:10px; }
.arch-node span { display:block; color:#5f7182; font-size:8px; margin-top:3px; }
.arch-node.accent { border-color:rgba(80,216,255,.18); }
.arch-node.yellow { border-color:rgba(245,209,66,.19); }
.arch-arrow { color:#38505f; font-size:12px; }

footer { display:flex; justify-content:space-between; gap:12px; padding:16px 2px 28px; color:#3f4d5a; font-size:9px; }
.toast { position:fixed; right:22px; bottom:22px; transform:translateY(20px); opacity:0; pointer-events:none; padding:10px 13px; border:1px solid var(--border-bright); border-radius:10px; background:#0c151e; color:#aeeeff; font-size:10px; box-shadow:var(--shadow); transition:.22s ease; z-index:10; }
.toast.show { opacity:1; transform:translateY(0); }

@media (max-width: 1180px) {
  .region-grid { grid-template-columns: repeat(3, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .agent-panel { min-height: 580px; }
  .chat-log { max-height: 360px; }
}
@media (max-width: 820px) {
  .app-shell { width:min(100% - 22px, 1540px); }
  .topbar { height:auto; min-height:75px; padding:12px 0; }
  .tech-pill { display:none; }
  .panel-hero { align-items:flex-start; flex-direction:column; padding:21px; }
  .kpi-grid { grid-template-columns:repeat(2, 1fr); }
  .region-grid { grid-template-columns:repeat(2, 1fr); }
  .incident-row { grid-template-columns:80px 1fr 1fr; }
  .incident-row .hide-mobile { display:none; }
  .architecture-flow { flex-direction:column; align-items:stretch; }
  .arch-arrow { transform:rotate(90deg); text-align:center; }
}
@media (max-width: 520px) {
  .brand-sub { display:none; }
  .topbar-right { gap:4px; }
  .live-pill { font-size:9px; }
  .hero-actions { width:100%; }
  .hero-actions .button { flex:1; }
  .kpi-grid { grid-template-columns:1fr; }
  .region-grid { grid-template-columns:1fr; }
  .network-panel, .incident-panel, .agent-panel { padding:15px; }
  .incident-row { grid-template-columns:1fr 1fr; }
  .incident-row .incident-id { grid-column:1 / -1; }
  .legend { display:none; }
  .composer-foot span:first-child { display:none; }
  footer { flex-direction:column; }
}
