/* ===========================================================================
   Agent OS Cockpit — Rod & Staff Media
   Brand: charcoal #0E0E0E · red #D51C20 · white #FFFFFF · grey #9A9A9A
   =========================================================================== */
:root {
  --bg: #0E0E0E;
  --bg-2: #141416;
  --bg-3: #17171a;
  --panel: #121214;
  --line: #26262b;
  --line-2: #34343c;
  --red: #D51C20;
  --red-soft: #ff6b66;
  --red-glow: rgba(213, 28, 32, 0.45);
  --white: #ffffff;
  --grey: #9A9A9A;
  --grey-2: #6f6f76;
  --green: #36d399;
  --yellow: #f4c150;
  --redhealth: #ff5b54;
  --radius: 16px;
  --radius-sm: 11px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --head: 'Bebas Neue', 'Oswald', 'Segoe UI', sans-serif;
  --body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #1a1a1d 0%, var(--bg) 55%, #070707 100%);
  color: var(--white);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 60px;
}
::selection { background: var(--red); color: #fff; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }

/* ----------------------------- TOP BAR ----------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  padding: 14px 26px;
  background: rgba(12, 12, 13, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { display: flex; }
.brand-kicker { color: var(--red); font-size: 11px; letter-spacing: 4px; font-weight: 700; }
.brand-title { font-family: var(--head); font-size: 30px; letter-spacing: 1.5px; line-height: .9; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.client-switch { display: flex; flex-direction: column; gap: 3px; }
.client-switch-label { font-size: 9px; letter-spacing: 2.5px; color: var(--grey); font-weight: 700; }
#clientSelect {
  background: var(--bg-2); color: #fff; border: 1px solid var(--line-2);
  border-radius: 9px; padding: 7px 30px 7px 12px; font-size: 13px; font-weight: 600;
  appearance: none; cursor: pointer; min-width: 170px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%239A9A9A' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center;
  transition: border-color .2s var(--ease);
}
#clientSelect:hover { border-color: var(--red); }

.roadmap { min-width: 150px; }
.roadmap-text { font-size: 12px; color: var(--grey); margin-bottom: 5px; }
.roadmap-text strong { color: #fff; font-size: 14px; }
.roadmap-bar { height: 6px; border-radius: 4px; background: var(--bg-3); overflow: hidden; border: 1px solid var(--line); }
.roadmap-bar span { display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--red), #ff4742);
  box-shadow: 0 0 10px var(--red-glow); transition: width .6s var(--ease); }

.btn {
  border: 1px solid var(--line-2); background: var(--bg-2); color: #fff;
  border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  transition: all .18s var(--ease);
}
.btn:hover { border-color: var(--red); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-ghost { background: transparent; }
.btn-red { background: var(--red); border-color: var(--red); }
.btn-red:hover { background: #ef2a2e; box-shadow: 0 6px 18px var(--red-glow); }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ----------------------------- CONTROLS ---------------------------------- */
.controls {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 26px 4px;
}
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; padding: 4px; gap: 2px; }
.seg-btn {
  border: 0; background: transparent; color: var(--grey); font-size: 12.5px; font-weight: 600;
  padding: 7px 13px; border-radius: 8px; display: inline-flex; align-items: center; gap: 7px;
  transition: all .16s var(--ease); white-space: nowrap;
}
.seg-btn:hover { color: #fff; }
.seg-btn.is-active { background: var(--red); color: #fff; box-shadow: 0 2px 10px var(--red-glow); }
.seg-btn.is-active .dot { background: #fff !important; border-color: #fff !important; }
.controls-hint { margin-left: auto; color: var(--grey-2); font-size: 12px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-live { background: var(--red); }
.dot-planned { background: transparent; border: 1.5px dashed var(--grey); }

/* ----------------------------- STAGE / MAP ------------------------------- */
.stage { display: flex; align-items: flex-start; gap: 22px; padding: 0 26px; }
.map { position: relative; flex: 1 1 auto; min-width: 0; padding: 18px 0 10px; }
.wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.wires path { fill: none; transition: stroke-opacity .22s var(--ease), stroke-width .22s var(--ease); }
.wires .wire { stroke: var(--grey); stroke-width: 1.3; stroke-opacity: .22; }
.wires .wire-write { stroke: var(--red); stroke-opacity: .3; }
.wires .spine { stroke: var(--red); stroke-opacity: .28; stroke-width: 1.6; }
.wires.dim .wire, .wires.dim .wire-write { stroke-opacity: .04; }
.wires .wire.hot { stroke: var(--red); stroke-opacity: .95; stroke-width: 2.2; }
.wires .wire-write.hot { stroke: var(--red); stroke-opacity: 1; stroke-width: 2.6; }
.wires .feed.hot { stroke: var(--red); stroke-opacity: 1; stroke-width: 2.6; stroke-dasharray: 6 4; }

.tier { position: relative; z-index: 2; margin-bottom: 24px; }
.tier-label { font-size: 12px; letter-spacing: 3px; font-weight: 700; color: var(--red); margin: 0 2px 12px; }
.tier-label span { color: var(--grey); letter-spacing: .3px; font-weight: 500; font-size: 12px; }

/* Human node */
.human {
  display: flex; align-items: center; gap: 18px; max-width: 560px; margin: 0 auto;
  background: linear-gradient(180deg, #221316, #160f11);
  border: 1.6px solid var(--red); border-radius: var(--radius);
  padding: 16px 22px; box-shadow: 0 14px 36px rgba(0,0,0,.5), 0 0 0 4px rgba(213,28,32,.05);
}
.human-crown {
  width: 52px; height: 52px; border-radius: 50%; flex: 0 0 auto;
  background: #1f1316; border: 1.5px solid var(--red); display: grid; place-items: center;
}
.human-meta .k { color: var(--red); font-size: 10px; letter-spacing: 3px; font-weight: 700; }
.human-meta .n { font-family: var(--head); font-size: 30px; letter-spacing: 1px; line-height: 1; margin: 3px 0; }
.human-meta .r { color: #cdcdcd; font-size: 12.5px; }
.human-owner { margin-left: auto; align-self: flex-start; color: var(--grey); font-size: 10px; letter-spacing: 2px; }

/* System layers */
.layers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.layer {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 15px; position: relative; overflow: hidden;
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.layer::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--red); opacity: .8; }
.layer.glow { border-color: var(--red); transform: translateY(-2px); }
.layer .ln { font-family: var(--head); font-size: 23px; letter-spacing: 1px; }
.layer .ls { color: #bdbdbd; font-size: 11px; margin: 2px 0 7px; }
.layer .li { color: var(--grey); font-size: 10.5px; line-height: 1.4; }

/* Divisions */
.divisions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.division { display: flex; flex-direction: column; gap: 14px; }
.division-head {
  display: flex; align-items: center; gap: 12px;
  background: #1a0e10; border: 1.3px solid var(--red); border-radius: var(--radius-sm); padding: 10px 14px;
}
.division-key {
  width: 30px; height: 30px; border-radius: 8px; background: var(--red); color: #fff;
  font-family: var(--head); font-size: 19px; display: grid; place-items: center; flex: 0 0 auto;
}
.division-name { font-family: var(--head); font-size: 19px; letter-spacing: .8px; line-height: 1; }
.division-note { color: var(--grey); font-size: 11px; }

/* Agent card */
.card {
  position: relative; background: linear-gradient(180deg, var(--bg-3), #111113);
  border: 1.4px solid var(--line-2); border-radius: var(--radius);
  padding: 16px 16px 14px; cursor: pointer; overflow: hidden;
  transition: transform .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease), opacity .2s var(--ease);
}
.card::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px;
  border-radius: 3px; background: var(--line-2); transition: background .2s var(--ease);
}
.card.live { border-color: var(--red); background: linear-gradient(180deg, #1c1416, #141011); }
.card.live::before { background: var(--red); box-shadow: 0 0 12px var(--red-glow); }
.card.planned { border-style: dashed; border-color: #3a3a42; }
.card:hover { transform: translateY(-3px); border-color: var(--red); box-shadow: 0 16px 36px rgba(0,0,0,.5); }
.card.is-hot { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), 0 16px 36px rgba(0,0,0,.55); }
.card.is-linked { border-color: var(--red-soft); }
.card.paused { opacity: .55; }
.card.paused::after {
  content: "PAUSED"; position: absolute; top: 12px; right: 14px;
  font-size: 9px; letter-spacing: 2px; color: var(--yellow); font-weight: 700;
}

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-name { font-family: var(--head); font-size: 25px; letter-spacing: .5px; line-height: .95; }
.card-statusdot { display: flex; align-items: center; gap: 7px; margin-top: 4px; }
.shealth { width: 9px; height: 9px; border-radius: 50%; background: var(--grey-2); box-shadow: 0 0 0 0 transparent; }
.shealth.green { background: var(--green); box-shadow: 0 0 9px rgba(54,211,153,.6); }
.shealth.yellow { background: var(--yellow); box-shadow: 0 0 9px rgba(244,193,80,.6); }
.shealth.red { background: var(--redhealth); box-shadow: 0 0 9px rgba(255,91,84,.6); }
.shealth-txt { font-size: 10px; color: var(--grey); letter-spacing: .5px; }

.badge { font-size: 10.5px; font-weight: 700; letter-spacing: 1px; padding: 5px 10px; border-radius: 20px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.badge-live { background: var(--red); color: #fff; box-shadow: 0 0 12px var(--red-glow); }
.badge-live i { width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.badge-planned { border: 1.2px dashed var(--grey); color: #cfcfcf; }
.badge-planned i { width: 6px; height: 6px; border-radius: 50%; border: 1.2px solid var(--grey); }

.card-trigger { display: flex; align-items: center; gap: 7px; color: #fff; font-size: 13px; font-weight: 600; margin: 12px 0 8px; }
.card-trigger .tk { color: var(--red); font-size: 9px; letter-spacing: 2px; font-weight: 700; }
.card-job { color: #e6e6e6; font-size: 13px; line-height: 1.45; min-height: 36px; }

.card-kpis { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 11px; }
.kpi { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: 11px; }
.kpi b { color: #fff; } .kpi span { color: var(--grey); }
.card-kpis.empty { color: var(--grey-2); font-size: 11.5px; font-style: italic; }

.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 11px; }
.tag { font-size: 10.5px; color: #b9b9b9; background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 7px; padding: 3px 8px; }

.card-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; color: var(--grey); font-size: 11px; }
.switch { width: 36px; height: 20px; border-radius: 20px; background: #2a2a30; border: 1px solid var(--line-2); position: relative; transition: background .2s var(--ease); flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 1.5px; left: 1.5px; width: 15px; height: 15px; border-radius: 50%; background: #888; transition: transform .2s var(--ease), background .2s var(--ease); }
.switch.on { background: rgba(213,28,32,.35); border-color: var(--red); }
.switch.on::after { transform: translateX(16px); background: var(--red); }
.build-no { position: absolute; right: 14px; bottom: 12px; font-family: var(--head); font-size: 13px; color: var(--grey-2); }

/* Data layer */
.data-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.conn {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 14px; position: relative; overflow: hidden; transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.conn::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--red); opacity: .65; }
.conn.is-linked { border-color: var(--red); transform: translateY(-2px); }
.conn .cn { font-family: var(--head); font-size: 20px; letter-spacing: .5px; }
.conn .cp { color: #bdbdbd; font-size: 10.5px; margin: 3px 0 9px; line-height: 1.4; min-height: 28px; }
.conn .ca { font-size: 10px; font-weight: 700; letter-spacing: .8px; padding: 3px 8px; border-radius: 20px; display: inline-block; }
.conn .ca.rw { color: var(--red-soft); border: 1px solid var(--red); background: rgba(213,28,32,.08); }
.conn .ca.ro { color: var(--grey); border: 1px solid var(--line-2); }

/* ----------------------------- ACTIVITY (docked rail) -------------------- */
.activity {
  flex: 0 0 312px; width: 312px; align-self: stretch;
  position: sticky; top: 80px; margin-top: 50px;
  background: rgba(16,16,18,.96); border: 1px solid var(--line-2); border-radius: 14px; z-index: 5;
  box-shadow: 0 18px 44px rgba(0,0,0,.45); overflow: hidden;
  transition: transform .25s var(--ease);
}
.activity-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; border-bottom: 1px solid var(--line); cursor: pointer; }
.activity-title { font-size: 13px; font-weight: 700; letter-spacing: .5px; display: flex; align-items: center; gap: 9px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 0 var(--red-glow); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(213,28,32,.5); } 70% { box-shadow: 0 0 0 8px rgba(213,28,32,0); } 100% { box-shadow: 0 0 0 0 rgba(213,28,32,0); } }
.activity-collapse { background: transparent; border: 0; color: var(--grey); font-size: 14px; transition: transform .2s var(--ease); }
.activity[data-open="false"] .activity-list { display: none; }
.activity[data-open="false"] .activity-collapse { transform: rotate(180deg); }
.activity-list { list-style: none; margin: 0; padding: 8px; max-height: calc(100vh - 200px); overflow-y: auto; }
.activity-item { display: flex; gap: 10px; padding: 9px 8px; border-radius: 9px; transition: background .15s var(--ease); }
.activity-item:hover { background: rgba(255,255,255,.03); }
.activity-item .ai-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-top: 6px; flex: 0 0 auto; }
.activity-item.planned .ai-dot { background: var(--grey-2); }
.ai-body { min-width: 0; }
.ai-top { display: flex; gap: 8px; align-items: baseline; }
.ai-agent { font-size: 12px; font-weight: 700; color: #fff; }
.ai-time { font-size: 10px; color: var(--grey-2); white-space: nowrap; }
.ai-msg { font-size: 11.5px; color: var(--grey); line-height: 1.35; }
.activity-item.fresh { animation: flashIn .9s var(--ease); }
@keyframes flashIn { 0% { background: rgba(213,28,32,.22); } 100% { background: transparent; } }

/* ----------------------------- DRAWER ------------------------------------ */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); opacity: 0; visibility: hidden; transition: opacity .25s var(--ease); z-index: 49; }
.drawer-backdrop.show { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 440px; max-width: 92vw; z-index: 50;
  background: linear-gradient(180deg, #151013, #0e0d0e); border-left: 1px solid var(--line-2);
  transform: translateX(100%); transition: transform .3s var(--ease); overflow-y: auto;
  box-shadow: -24px 0 60px rgba(0,0,0,.6);
}
.drawer.show { transform: translateX(0); }
.drawer-inner { padding: 24px 24px 40px; }
.dh { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dh-name { font-family: var(--head); font-size: 38px; letter-spacing: 1px; line-height: .95; }
.dh-div { color: var(--grey); font-size: 12px; letter-spacing: .5px; margin-top: 4px; }
.drawer-close { background: var(--bg-2); border: 1px solid var(--line-2); color: #fff; width: 34px; height: 34px; border-radius: 9px; font-size: 16px; flex: 0 0 auto; transition: all .18s var(--ease); }
.drawer-close:hover { border-color: var(--red); }
.d-section { margin-top: 22px; }
.d-section h4 { font-size: 11px; letter-spacing: 2px; color: var(--red); font-weight: 700; margin-bottom: 10px; }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.d-fact { background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; }
.d-fact .fk { font-size: 10px; letter-spacing: 1px; color: var(--grey); text-transform: uppercase; }
.d-fact .fv { font-size: 13.5px; font-weight: 600; margin-top: 3px; }
.resp { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.resp li { display: flex; gap: 10px; font-size: 13px; color: #e2e2e2; line-height: 1.4; }
.resp li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--red); margin-top: 7px; flex: 0 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 12px; color: #fff; background: rgba(213,28,32,.12); border: 1px solid rgba(213,28,32,.45); border-radius: 20px; padding: 5px 12px; }
.chip.alt { background: rgba(255,255,255,.04); border-color: var(--line-2); color: #cfcfcf; }
.d-actions { display: flex; gap: 10px; margin-top: 26px; position: sticky; bottom: 0; }
.d-actions .btn { flex: 1; justify-content: center; display: flex; align-items: center; gap: 8px; }
.d-health { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--grey); margin-top: 6px; }

/* ----------------------------- TOASTS ------------------------------------ */
.toasts { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  background: #191314; border: 1px solid var(--red); color: #fff; padding: 11px 18px; border-radius: 11px;
  font-size: 13px; box-shadow: 0 14px 40px rgba(0,0,0,.5); display: flex; align-items: center; gap: 10px;
  animation: toastIn .3s var(--ease); max-width: 90vw;
}
.toast .ti { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red-glow); }
@keyframes toastIn { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastOut { to { transform: translateY(14px); opacity: 0; } }

/* ----------------------------- FOOTER ------------------------------------ */
.page-foot { padding: 24px 26px 0; color: var(--grey-2); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-foot strong { color: var(--red); }
.foot-sep { color: var(--line-2); }

.card.hidden, .division.hidden { display: none; }

/* ----------------------------- RESPONSIVE -------------------------------- */
@media (max-width: 1280px) {
  .stage { flex-direction: column; }
  .activity { position: static; top: auto; width: 100%; flex: none; margin-top: 10px; }
  .activity-list { max-height: 40vh; }
}
@media (max-width: 1080px) {
  .divisions { grid-template-columns: 1fr !important; }
  .layers, .data-row { grid-template-columns: repeat(2, 1fr); }
  .wires { display: none; }              /* arrows only make sense in the column layout */
}
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .brand-title { font-size: 24px; }
  .stage { padding: 0 14px; }
  .layers, .data-row { grid-template-columns: 1fr; }
  .roadmap { order: 3; }
}

/* boot overlay (file:// without bundle) */
.boot { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 80; padding: 24px; text-align: center; }
.boot-card { max-width: 520px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 16px; padding: 30px 32px; }
.boot-card h2 { font-family: var(--head); font-size: 30px; letter-spacing: 1px; color: var(--red); }
.boot-card p { color: var(--grey); font-size: 14px; }
.boot-card code { background: #000; border: 1px solid var(--line-2); padding: 3px 8px; border-radius: 6px; color: #fff; font-size: 13px; }
