:root {
  --bg: #07090a;
  --panel: rgba(10, 13, 15, 0.92);
  --panel-2: #0d1012;
  --line: #394046;
  --line-bright: #788088;
  --text: #eef2ee;
  --muted: #899198;
  --dim: #555e65;
  --green: #57db8a;
  --red: #ff526b;
  --amber: #ffc247;
  --orange: #ff9347;
  --violet: #7c5cff;
  --cyan: #59d9db;
  --mono: "SFMono-Regular", "Cascadia Mono", "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { background: var(--bg); color: var(--text); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 15%, rgba(124, 92, 255, 0.06), transparent 30%),
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 32px 32px, 32px 32px, auto;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .015em;
}

button, input { font: inherit; }
button { cursor: pointer; }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: .18;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 3px, rgba(255,255,255,.018) 4px);
}

.panel-corners { position: relative; border: 1px solid var(--line); }
.panel-corners::before,
.panel-corners::after {
  content: "";
  position: absolute;
  z-index: 2;
  width: 8px;
  height: 8px;
  pointer-events: none;
}
.panel-corners::before { top: -1px; left: -1px; border-top: 1px solid var(--text); border-left: 1px solid var(--text); }
.panel-corners::after { right: -1px; bottom: -1px; border-right: 1px solid var(--text); border-bottom: 1px solid var(--text); }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(520px, 100%);
  padding: 44px;
  background: rgba(7, 9, 10, .96);
  box-shadow: 0 0 80px rgba(0,0,0,.8), 0 0 55px rgba(87,219,138,.035);
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid var(--text);
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 28px;
  clip-path: polygon(15% 0, 85% 0, 100% 15%, 100% 85%, 85% 100%, 15% 100%, 0 85%, 0 15%);
}
.brand-mark.small { width: 42px; height: 42px; margin: 0; font-size: 19px; }

.eyebrow, .kicker {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
}
.kicker { color: var(--green); }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(22px, 4vw, 34px); letter-spacing: -.04em; }
h1 span { color: var(--muted); font-weight: 400; }
h2 { margin: 0; font-size: 13px; letter-spacing: .12em; }

.login-copy { color: var(--muted); line-height: 1.7; margin-bottom: 32px; }
.login-card label { display: block; color: var(--muted); font-size: 10px; letter-spacing: .16em; margin-bottom: 8px; }
.passcode-row { display: grid; grid-template-columns: 1fr auto; }
.passcode-row input {
  min-width: 0;
  border: 1px solid var(--line-bright);
  border-right: 0;
  border-radius: 0;
  padding: 15px 16px;
  color: var(--text);
  background: #050607;
  outline: none;
}
.passcode-row input:focus { border-color: var(--green); box-shadow: inset 3px 0 var(--green); }
.passcode-row button {
  border: 1px solid var(--green);
  padding: 0 22px;
  color: #061109;
  background: var(--green);
  font-weight: 900;
}
.passcode-row button:hover { filter: brightness(1.12); }
.form-error { min-height: 18px; margin: 10px 0 0; color: var(--red); font-size: 11px; }
.login-foot { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 18px; color: var(--muted); font-size: 10px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(87,219,138,.6); }

.app-shell { width: min(1780px, calc(100% - 32px)); margin: 16px auto 48px; }
.topbar { min-height: 76px; display: grid; grid-template-columns: minmax(280px, .9fr) 2fr auto; align-items: center; padding: 12px 16px; background: var(--panel); }
.identity { display: flex; align-items: center; gap: 14px; }
.identity h1 { margin: 0; font-size: 18px; }
.identity .eyebrow { margin-bottom: 3px; }

.headline-metrics { display: grid; grid-template-columns: repeat(5, minmax(92px, 1fr)); border-left: 1px solid var(--line); }
.headline-metrics > div { min-height: 50px; padding: 8px 18px; border-right: 1px solid var(--line); }
.headline-metrics small, .desk-state small { display: block; color: var(--muted); font-size: 9px; letter-spacing: .14em; margin-bottom: 6px; }
.headline-metrics strong { font-size: 18px; white-space: nowrap; }
.headline-metrics > div:nth-child(2) strong { color: var(--green); }

.desk-state { display: flex; align-items: center; gap: 10px; padding-left: 16px; }
.desk-state strong { color: var(--green); font-size: 11px; }
.ghost-button { border: 1px solid var(--line); color: var(--muted); background: transparent; padding: 7px 9px; margin-left: 8px; }
.ghost-button:hover { color: var(--text); border-color: var(--text); }

.ticker { height: 34px; display: grid; grid-template-columns: auto 1fr; align-items: center; margin-top: 8px; background: var(--panel); overflow: hidden; }
.ticker-label { align-self: stretch; display: grid; place-items: center; padding: 0 16px; background: var(--text); color: var(--bg); font-size: 10px; font-weight: 900; }
.ticker-track { overflow: hidden; white-space: nowrap; color: var(--muted); }
.ticker-track-inner { display: inline-flex; min-width: 100%; animation: ticker 32s linear infinite; }
.ticker-item { padding: 0 24px; border-right: 1px solid var(--line); }
.ticker-item b { color: var(--text); margin-right: 7px; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.command-strip { min-height: 70px; display: grid; grid-template-columns: 1fr auto auto auto auto; align-items: center; gap: 26px; margin-top: 8px; padding: 12px 16px; background: var(--panel); }
.command-strip > div:first-child { display: flex; gap: 18px; align-items: baseline; }
.command-strip > div:first-child strong { font-size: 11px; color: var(--muted); }
.strip-stat { text-align: right; }
.strip-stat strong { display: block; color: var(--green); font-size: 18px; }
.strip-stat span { color: var(--muted); font-size: 9px; }
.readonly-badge { border: 1px solid var(--green); color: var(--green); padding: 7px 11px; font-size: 10px; }

.fleet-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(300px, .9fr); gap: 8px; margin-top: 8px; }
.panel { background: var(--panel); }
.panel-head { min-height: 55px; display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.panel-meta, .chart-legend { display: flex; align-items: center; gap: 18px; }
.live-pill { border: 1px solid rgba(87,219,138,.45); color: var(--green); padding: 4px 7px; font-size: 9px; }
.panel-count { color: var(--text); font-size: 18px; }

.fleet-map { position: relative; height: 570px; overflow: hidden; background: radial-gradient(circle at center, rgba(124,92,255,.06), transparent 38%); }
.fleet-map::before { content: ""; position: absolute; inset: 0; opacity: .28; background-image: radial-gradient(rgba(255,255,255,.22) .65px, transparent .65px); background-size: 17px 17px; }
.fleet-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.fleet-lines line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 5; }
.fleet-lines line.active { stroke: rgba(87,219,138,.48); stroke-dasharray: none; }
.orbit { position: absolute; top: 50%; left: 50%; border: 1px solid rgba(124,92,255,.24); border-radius: 50%; transform: translate(-50%, -50%); }
.orbit-a { width: 240px; height: 240px; }
.orbit-b { width: 330px; height: 330px; border-style: dashed; }

.fleet-node { position: absolute; width: 170px; transform: translate(-50%, -50%); text-align: center; }
.fleet-node .node-shape { position: relative; width: 76px; height: 76px; margin: 0 auto 10px; display: grid; place-items: center; border: 2px solid currentColor; border-radius: 50%; background: var(--bg); color: var(--violet); box-shadow: 0 0 0 8px rgba(124,92,255,.035); }
.fleet-node.central .node-shape { width: 116px; height: 116px; color: var(--text); box-shadow: 0 0 0 12px rgba(255,255,255,.035), 0 0 0 38px rgba(124,92,255,.025); }
.fleet-node .node-glyph { font-size: 20px; font-weight: 900; }
.fleet-node.central .node-glyph { font-size: 28px; }
.fleet-node .node-status { position: absolute; right: 2px; bottom: 5px; width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--bg); background: var(--muted); }
.fleet-node .node-status.online, .fleet-node .node-status.guarded { background: var(--green); }
.fleet-node .node-status.working { background: var(--amber); animation: pulse 1s infinite alternate; }
.fleet-node .node-status.degraded, .fleet-node .node-status.stale { background: var(--red); }
.fleet-node .node-title { display: inline-block; padding: 5px 9px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.fleet-node .node-detail { margin-top: 4px; color: var(--muted); font-size: 9px; }
.fleet-node:nth-child(3n+2) .node-shape { color: var(--green); }
.fleet-node:nth-child(3n+3) .node-shape { color: var(--orange); }
.fleet-node:nth-child(3n+4) .node-shape { color: var(--amber); }
@keyframes pulse { to { box-shadow: 0 0 12px currentColor; } }

.fleet-legend { min-height: 40px; display: flex; justify-content: center; gap: 24px; align-items: center; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.legend-dot { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--muted); }
.legend-dot.online { background: var(--green); }.legend-dot.working { background: var(--amber); }.legend-dot.degraded { background: var(--red); }

.event-panel { min-height: 100%; }
.event-feed { height: 610px; overflow: hidden auto; scrollbar-color: var(--line) transparent; }
.event-row { padding: 11px 12px; display: grid; grid-template-columns: 46px 1fr; gap: 10px; border-bottom: 1px solid rgba(57,64,70,.55); }
.event-row time { color: var(--muted); font-size: 9px; }
.event-row strong { display: block; color: var(--text); font-size: 10px; margin-bottom: 4px; }
.event-row p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.45; word-break: break-word; }
.event-row.success { box-shadow: inset 2px 0 var(--green); }.event-row.error { box-shadow: inset 2px 0 var(--red); }.event-row.agent { box-shadow: inset 2px 0 var(--violet); }

.analytics-layout { display: grid; grid-template-columns: 1.55fr 1fr; gap: 8px; margin-top: 8px; }
.chart-wrap { height: 230px; padding: 16px 12px 5px; }
.chart-wrap canvas { width: 100%; height: 100%; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 18px; height: 2px; background: var(--green); }.legend-line.pnl { background: var(--violet); }
.chart-range { min-height: 36px; padding: 8px 14px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }

.run-timeline { min-height: 266px; padding: 14px; }
.run-row { display: grid; grid-template-columns: 120px 1fr 52px; align-items: center; gap: 10px; min-height: 43px; border-bottom: 1px solid rgba(57,64,70,.45); }
.run-name { color: var(--text); font-size: 9px; }
.run-track { position: relative; height: 9px; background: rgba(255,255,255,.04); }
.run-track::after { content: ""; position: absolute; left: 25%; top: -3px; bottom: -3px; border-left: 1px dashed var(--line); box-shadow: 100px 0 0 rgba(57,64,70,.8), 200px 0 0 rgba(57,64,70,.8); }
.run-block { position: absolute; top: 1px; height: 7px; min-width: 5px; background: var(--violet); }
.run-block.failed { background: var(--red); }.run-block.running { background: var(--amber); }
.run-time { color: var(--muted); text-align: right; font-size: 9px; }

.detail-grid { display: grid; grid-template-columns: 1.05fr 1.4fr .8fr; gap: 8px; margin-top: 8px; }
.agent-list { padding: 4px 14px 10px; }
.agent-row { display: grid; grid-template-columns: 1fr 1.3fr 52px; gap: 12px; align-items: center; min-height: 52px; border-bottom: 1px solid rgba(57,64,70,.5); }
.agent-name strong { display: block; font-size: 10px; }.agent-name small { color: var(--muted); font-size: 8px; }
.meter { height: 7px; background: #171b1e; }.meter span { display: block; height: 100%; background: var(--violet); }
.agent-latency { color: var(--muted); font-size: 9px; text-align: right; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 13px; border-bottom: 1px solid rgba(57,64,70,.5); text-align: right; font-size: 10px; white-space: nowrap; }
th { color: var(--muted); font-size: 8px; letter-spacing: .12em; }
th:first-child, td:first-child { text-align: left; }
td.positive { color: var(--green); } td.negative { color: var(--red); }
.side { padding: 3px 5px; border: 1px solid var(--line); font-size: 8px; }.side.long { color: var(--green); }.side.short { color: var(--orange); }

.system-stats { margin: 0; padding: 8px 14px; }
.system-stats div { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid rgba(57,64,70,.5); }
.system-stats dt { color: var(--muted); font-size: 9px; }.system-stats dd { margin: 0; font-weight: 900; font-size: 10px; }
.proposal-box { margin: 10px 14px 14px; border: 1px solid var(--line); padding: 12px; }
.proposal-box > div { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }
.proposal-box strong { color: var(--amber); font-size: 16px; }
.proposal-box p { margin: 12px 0 0; color: var(--text); font-size: 9px; line-height: 1.5; }

footer { display: flex; justify-content: space-between; padding: 18px 4px; color: var(--dim); font-size: 9px; }
[hidden] { display: none !important; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: 1fr auto; }
  .headline-metrics { grid-column: 1 / -1; grid-row: 2; margin-top: 12px; border-top: 1px solid var(--line); }
  .command-strip { grid-template-columns: 1fr repeat(3, auto); }.readonly-badge { display: none; }
  .fleet-layout { grid-template-columns: 1fr; }.event-feed { height: 300px; }
  .analytics-layout, .detail-grid { grid-template-columns: 1fr 1fr; }.system-panel { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .app-shell { width: min(100% - 16px, 1780px); margin-top: 8px; }
  .login-card { padding: 28px 22px; }
  .topbar { grid-template-columns: 1fr; gap: 12px; }.desk-state { position: absolute; right: 10px; top: 15px; }
  .desk-state > div { display: none; }.headline-metrics { overflow-x: auto; grid-template-columns: repeat(5, minmax(115px, 1fr)); }
  .command-strip { grid-template-columns: 1fr 1fr 1fr; gap: 12px; }.command-strip > div:first-child { grid-column: 1 / -1; display: block; }
  .fleet-map { height: 520px; }.fleet-node { width: 122px; }.fleet-node .node-shape { width: 58px; height: 58px; }.fleet-node.central .node-shape { width: 90px; height: 90px; }
  .analytics-layout, .detail-grid { grid-template-columns: 1fr; }.system-panel { grid-column: auto; }
  .panel-head { align-items: flex-start; }.chart-legend { display: none; }
  footer { flex-direction: column; gap: 8px; }
}
