:root {
  --bg: #0e1116; --panel: #151a21; --panel2: #1b222b; --line: #27303b; --text: #e6e9ee; --muted: #8a96a6;
  --accent: #4fb3a9; --accent2: #e0a84f; --danger: #e06c6c; --ok: #6cc28a; --info: #6ea8fe;
  --web: #6ea8fe; --app: #4fb3a9; --data: #e0a84f; --cache: #c58af9; --msg: #f28fb1; --shared: #6b7686; --unknown: #3a4452; --ext: #2d3440;
  --mono: "IBM Plex Mono", ui-monospace, monospace; --sans: "IBM Plex Sans", system-ui, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f6f8; --panel: #ffffff; --panel2: #f0f2f5; --line: #dde2e8; --text: #1c2430; --muted: #5e6b7c;
    --unknown: #c9d0d9; --ext: #e3e7ec; --shared: #9aa4b1;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
a { color: var(--accent); }
.top { display: flex; align-items: center; gap: 18px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.brand svg { fill: var(--accent); stroke: var(--accent); stroke-width: 1.6; }
.brand .tag { font-weight: 400; color: var(--muted); font-size: 12px; }
nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
nav button:hover { color: var(--text); background: var(--panel2); }
nav button.on { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--accent); }
.pill { margin-left: auto; font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.on { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
main { padding: 18px; max-width: 1600px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; min-width: 0; }
.card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.sub, .muted { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
h2.sec { font-size: 15px; margin: 22px 0 10px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.kpi .v { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .s { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.bar { display: grid; grid-template-columns: 130px 1fr 44px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.bar .track { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.gap { border-left: 3px solid var(--accent2); padding: 6px 10px; margin: 8px 0; background: var(--panel2); border-radius: 0 6px 6px 0; font-size: 13px; }
.gap.red { border-color: var(--danger); } .gap.blue { border-color: var(--info); }
.gap b { font-weight: 600; } .gap ul { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.tablewrap { overflow-x: auto; }
.toolbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.toolbar label { display: flex; align-items: center; gap: 6px; }
input, select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit; }
input[type=checkbox] { padding: 0; accent-color: var(--accent); }
input[type=range] { padding: 0; width: 100px; accent-color: var(--accent); }
input.wide { width: 100%; margin-bottom: 10px; }
#map-search { width: 240px; }
button, .btn { background: var(--accent); color: #062a26; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-block; }
button.ghost, .btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: 400; }
button:disabled { opacity: .5; cursor: default; }
button.sm { padding: 4px 10px; font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.mapwrap { display: grid; grid-template-columns: 1fr 380px; gap: 12px; height: calc(100vh - 210px); min-height: 520px; }
@media (max-width: 1000px) { .mapwrap { grid-template-columns: 1fr; height: auto; } #cy { height: 60vh; } }
#cy { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; min-height: 400px; }
.detail { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow-y: auto; font-size: 13px; }
.detail h4 { margin: 0 0 2px; font-size: 15px; } .detail h5 { margin: 14px 0 6px; font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.kv { display: grid; grid-template-columns: 100px 1fr; gap: 3px 10px; font-size: 12.5px; }
.kv span:nth-child(odd) { color: var(--muted); }
.chip { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); margin: 1px 3px 1px 0; white-space: nowrap; }
.chip.src { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.chip.warn { border-color: var(--accent2); color: var(--accent2); }
.chip.bad { border-color: var(--danger); color: var(--danger); }
.chip.okc { border-color: var(--ok); color: var(--ok); }
.link-row { padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.link-row:hover { background: var(--panel2); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.waves { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.wave { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.wave .n { font-size: 11px; color: var(--accent); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.wave h4 { margin: 2px 0 8px; font-size: 13.5px; }
.wave.w0 .n { color: var(--muted); }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.app h4 { margin: 0 0 6px; display: flex; justify-content: space-between; gap: 8px; }
.tier { display: grid; grid-template-columns: 70px 1fr; gap: 6px; font-size: 12.5px; margin: 3px 0; }
.tier > span:first-child { color: var(--muted); }
.pipeline { list-style: none; padding: 0; margin: 14px 0; }
.pipeline li { display: grid; grid-template-columns: 22px 150px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; align-items: start; }
.pipeline .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); margin-top: 3px; }
.pipeline li.done .dot { background: var(--ok); border-color: var(--ok); }
.pipeline li.run .dot { border-color: var(--accent); animation: pulse 1s infinite; }
.pipeline li.err .dot { background: var(--danger); border-color: var(--danger); }
.pipeline .msg { color: var(--muted); }
@keyframes pulse { 50% { opacity: .3; } }
.report { background: var(--panel2); border-radius: 8px; padding: 4px 16px; margin-top: 12px; }
.report h2 { font-size: 15px; } .report h3 { font-size: 13.5px; }
.chat { display: flex; flex-direction: column; min-height: 600px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 0; max-height: 62vh; }
.msg-u { align-self: flex-end; background: var(--panel2); padding: 8px 12px; border-radius: 10px 10px 2px 10px; max-width: 85%; }
.msg-a { background: color-mix(in srgb, var(--accent) 8%, var(--panel)); border: 1px solid var(--line); padding: 4px 12px; border-radius: 10px 10px 10px 2px; max-width: 95%; }
.msg-a .meta { color: var(--muted); font-size: 11.5px; margin: 6px 0; }
#chat-form { display: flex; gap: 8px; margin-top: 10px; } #chat-form input { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chips button { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); font-size: 12px; padding: 4px 10px; font-weight: 400; }
.form label { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; color: var(--muted); }
.subnet { margin-bottom: 12px; } .subnet .c { font-family: var(--mono); font-size: 12.5px; margin-bottom: 4px; }
.hostdot { display: inline-block; font-family: var(--mono); font-size: 11.5px; padding: 2px 6px; margin: 2px; border-radius: 4px; border: 1px solid var(--accent); }
.hostdot.solid { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.hostdot.ext { border-color: var(--line); color: var(--muted); }
.status-done { color: var(--ok); } .status-failed { color: var(--danger); } .status-running { color: var(--accent2); }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--panel2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 420px; z-index: 50; }
.toast.on { opacity: 1; }
.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 60; }
.login.hidden { display: none; }
.login form { display: flex; flex-direction: column; gap: 10px; width: 300px; }
.err { color: var(--danger); font-size: 12.5px; min-height: 1em; margin: 0; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
@media (max-width: 640px) { main { padding: 12px 16px; } .top { padding: 10px 16px; } .bar { grid-template-columns: 100px 1fr 36px; } }

.whoami { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.whoami b { color: var(--text); font-weight: 500; }
.whoami button { padding: 3px 10px; font-size: 12px; }
#login .btn { text-align: center; }
[data-hide-role] { display: none !important; }

/* ---- Leon voice dock (character from Chief/Marshal) ---- */
.voice-dock { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 300px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; z-index: 40;
  box-shadow: 0 14px 40px rgba(0,0,0,.35); display: none; overflow: visible; }
.voice-dock.open { display: block; }
.vd-stage { position: relative; height: 210px; border-radius: 14px 14px 0 0; overflow: visible;
  background: radial-gradient(ellipse at 50% 85%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%); --leon-top: 50%; --leon-h: 92%; }
.vd-body { padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.vd-status { font-size: 12.5px; color: var(--muted); min-height: 1.4em; }
.vd-heard { font-size: 13px; font-style: italic; min-height: 1.3em; margin: 2px 0 8px; overflow-wrap: anywhere; }
.vd-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.vd-speak { font-size: 12px; color: var(--muted); display: flex; gap: 4px; align-items: center; margin-left: auto; }
.vd-open { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 39; border-radius: 99px; padding: 10px 18px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.cast { position: absolute; left: 50%; top: var(--leon-top, 42%); height: var(--leon-h, 40%); aspect-ratio: 720 / 679;
  transform: translate(-50%, -50%); z-index: 3; pointer-events: none; }
.cast canvas { position: relative; z-index: 1; width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 14px color-mix(in srgb, var(--accent) 55%, transparent)); }
.cast.photo canvas { filter: drop-shadow(0 0 14px rgba(0,0,0,.25)); }
.cast-beam { position: absolute; left: 20%; right: 20%; bottom: -6%; height: 40%; z-index: 0; opacity: .6;
  background: linear-gradient(to top, color-mix(in srgb, var(--accent) 40%, transparent), transparent 85%); clip-path: polygon(30% 100%, 70% 100%, 100% 0, 0 0); }
.cast.arriving { animation: castIn .9s cubic-bezier(.2, .9, .3, 1.15); }
@keyframes castIn { 0% { opacity: 0; transform: translate(-50%, -46%) scaleY(.02); } 60% { opacity: 1; transform: translate(-50%, -50%) scaleY(1.03); } 100% { transform: translate(-50%, -50%); } }
@media (prefers-reduced-motion: reduce) { .cast.arriving { animation: none; } }
.cast-name { display: none; }
.cast-bubble { position: absolute; right: 70%; top: -14%; z-index: 4; width: max-content; max-width: 240px; padding: 9px 13px;
  border-radius: 16px 16px 4px 16px; background: var(--text); color: var(--bg); font-size: 13px; line-height: 1.4; box-shadow: 0 8px 28px rgba(0,0,0,.35); }
@media (max-width: 640px) { .voice-dock { width: calc(100% - 32px); } .cast-bubble { max-width: 170px; } }
