:root {
  --night: #0d0f13;
  --deep: #121419;
  --panel: #171a20;
  --panel-2: #1f232a;
  --line: #2e333c;
  --line-soft: #24282f;
  --snow: #eeebe4;
  --mist: #a3a19b;
  --fog: #6f727a;
  --beacon: #d9a441;
  --beacon-soft: rgba(217, 164, 65, 0.13);
  --glacier: #7fa7c9;
  --glacier-soft: rgba(127, 167, 201, 0.12);
  --ember: #d9634f;
  --pine: #69b383;
  --radius: 8px;
  --font-head: "Manrope", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--snow);
  font: 14px/1.55 var(--font-body);
  background-image:
    radial-gradient(1200px 600px at 70% -10%, rgba(127, 167, 201, 0.06), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(217, 164, 65, 0.04), transparent 60%);
}
button, input, select, textarea { font: inherit; color: inherit; }
h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0 0 8px; letter-spacing: 0.01em; }
h3 { font-size: 15px; }
.muted { color: var(--mist); }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); }

.app { display: grid; grid-template-columns: 236px 1fr; height: 100vh; }

/* ---- rail ---- */
.rail {
  background: linear-gradient(180deg, var(--deep), var(--night));
  border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 6px 22px; color: var(--beacon); }
.brand-mark { width: 30px; height: 38px; flex: none; }
.brand-name { font-family: var(--font-head); font-weight: 700; color: var(--snow); font-size: 15px; line-height: 1.15; }
.brand-sub { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--beacon); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; border-radius: 8px; padding: 9px 10px;
  color: var(--mist); cursor: pointer; text-align: left;
}
.nav button:hover { background: var(--panel); color: var(--snow); }
.nav button.active { background: var(--panel-2); color: var(--snow); box-shadow: inset 3px 0 0 var(--beacon); }
.nav .ico { width: 18px; text-align: center; color: var(--fog); }
.nav button.active .ico { color: var(--beacon); }
.badge { margin-left: auto; font-size: 11px; font-family: var(--font-mono); background: var(--line); color: var(--snow);
  padding: 0 7px; border-radius: 99px; min-width: 20px; text-align: center; }
.badge:empty { display: none; }
.badge.hot { background: var(--beacon); color: #1c1407; font-weight: 600; }
.rail-foot { margin-top: auto; }
.founder-chip { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line-soft); border-radius: var(--radius); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-head);
  font-weight: 700; font-size: 13px; color: #10131a; flex: none; }

/* ---- main ---- */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 26px; border-bottom: 1px solid var(--line-soft); }
.top-title { font-family: var(--font-head); font-size: 20px; font-weight: 600; }
.top-chips { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--mist); white-space: nowrap; }
.chip:empty { display: none; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip-btn { cursor: pointer; }
.chip-btn:hover { border-color: var(--fog); color: var(--snow); }
.view { display: none; padding: 22px 26px 40px; overflow: auto; flex: 1; }
.view.active { display: block; }
.card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 14px; padding: 16px 18px; margin-bottom: 14px; }
.section-h { font-size: 13px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--mist); margin: 4px 0 12px; font-family: var(--font-mono); font-weight: 500; }
.empty { margin-bottom: 14px; color: var(--fog); padding: 14px; border: 1px dashed var(--line); border-radius: 12px; text-align: center; font-size: 13px; }

input, select, textarea {
  background: var(--deep); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--glacier); }
textarea { resize: vertical; }
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer;
  white-space: nowrap; color: var(--snow); }
.btn:hover { border-color: var(--fog); }
.btn.primary { background: var(--beacon); border-color: var(--beacon); color: #1c1407; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: none; }
.btn.danger { color: var(--ember); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* ---- office floor plan ---- */
.office-layout { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.plan-card { background: #111317; border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden; }
.plan-head { position: relative; height: 112px; background: linear-gradient(180deg, #0b0d11, #141821); border-bottom: 1px solid var(--line-soft); }
.plan-skyline { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 90px; }
.plan-title { position: absolute; inset: 0; padding: 16px 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.plan-title h2 { font-size: 20px; font-weight: 800; margin: 2px 0 0; letter-spacing: -0.01em; }
.eyebrow { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--beacon); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--mist); background: rgba(13, 15, 19, 0.75); padding: 6px 10px; border-radius: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 12px; height: 12px; border: 1px solid #bdb6a8; display: inline-block; }
.lg.lit { background: #2b261c; } .lg.off { background: #13151a; } .lg.shared { background: #1c2027; }
#floorplan { width: 100%; height: auto; display: block; padding: 10px; }
#floorplan text { font-family: var(--font-body); pointer-events: none; }
#floorplan .room { cursor: pointer; }
#floorplan .room:hover .room-wall { stroke: var(--beacon); }
#floorplan .room:hover .room-floor { filter: brightness(1.18); }
.org-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; position: relative; }
.org-row .avatar { font-size: 9px; }
.org-branch { width: 10px; height: 10px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: -8px; margin-right: -2px; }
.rail-skyline { width: 100%; height: 70px; display: block; margin-bottom: 10px; opacity: 0.9; }
.playbook { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.playbook li { position: relative; padding: 0 0 12px 34px; color: var(--mist); font-size: 13px; }
.playbook li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; width: 22px; height: 22px;
  border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--font-mono); font-size: 11px; }
.playbook-cta { margin-top: 4px; }
.playbook li.done::before { background: var(--pine); border-color: var(--pine); color: #0b1d11; content: "\2713"; }
.playbook li.next::before { border-color: var(--beacon); color: var(--beacon); }
.playbook li b { color: var(--snow); display: block; font-weight: 600; }
.detail-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 4px 10px; font-size: 13px; margin: 8px 0; }
.kv dt { color: var(--fog); }
.kv dd { margin: 0; }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--mist);
  font-family: var(--font-mono); }
.pill.active { color: var(--pine); border-color: rgba(108, 194, 138, 0.5); }
.pill.probation { color: var(--beacon); border-color: rgba(217, 164, 65, 0.5); }
.pill.paused { color: var(--fog); }
.pill.planned { border-style: dashed; }
.pill.open { color: var(--glacier); border-color: rgba(127, 167, 201, 0.45); }

/* ---- trail board ---- */
.task-form { display: grid; grid-template-columns: 2fr 2fr 1.2fr auto; gap: 8px; }
.board { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--deep); border: 1px solid var(--line-soft); border-radius: 14px; padding: 12px; min-height: 260px; }
.col-h { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.col-h b { font-family: var(--font-head); font-weight: 600; }
.col-h span { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--fog); }
.col-sub { font-size: 11px; color: var(--fog); margin-bottom: 10px; font-family: var(--font-mono); }
.tcard { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px; margin-bottom: 8px; font-size: 13px; }
.tcard .tid { font-family: var(--font-mono); font-size: 11px; color: var(--fog); }
.tcard .ttl { margin: 2px 0 6px; font-weight: 500; }
.tcard .who { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mist); }
.tcard .who .sw { width: 9px; height: 9px; border-radius: 50%; }
.tcard .tact { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.tcard select { padding: 4px 6px; font-size: 12px; }
.tcard.working { border-color: rgba(217, 164, 65, 0.5); box-shadow: 0 0 0 1px rgba(217, 164, 65, 0.15); }
.tcard .res { margin-top: 6px; font-size: 12px; color: var(--mist); max-height: 72px; overflow: hidden; }

/* ---- radio ---- */
.radio-wrap { display: flex; flex-direction: column; height: calc(100vh - 140px); padding: 0; overflow: hidden; }
.radio-log { flex: 1; overflow-y: auto; padding: 18px 20px; font-family: var(--font-mono); font-size: 13px; }
.msg { display: grid; grid-template-columns: 58px 130px 1fr; gap: 10px; padding: 5px 0; border-bottom: 1px dashed rgba(38, 58, 92, 0.5); }
.msg .t { color: var(--fog); font-size: 11px; padding-top: 2px; }
.msg .s { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .to { color: var(--fog); font-size: 11px; }
.msg.system .b { color: var(--mist); font-style: italic; }
.msg.founder .s { color: var(--beacon); }
.radio-form { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; padding: 12px; border-top: 1px solid var(--line-soft); background: var(--deep); }

/* ---- desk ---- */
.desk-grid, .lodge-grid { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.approval pre, .probation pre { white-space: pre-wrap; background: var(--deep); border: 1px solid var(--line-soft); border-radius: 8px;
  padding: 10px 12px; font: 12.5px/1.5 var(--font-mono); max-height: 280px; overflow: auto; margin: 8px 0; }
.actions-list { font-size: 12px; color: var(--mist); margin: 6px 0; padding-left: 18px; }
.model-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line-soft); font-size: 13px; }
.model-row:last-child { border: 0; }
.ok { color: var(--pine); } .warn { color: var(--beacon); } .bad { color: var(--ember); }

/* ---- wizard ---- */
.steps { display: flex; gap: 6px; margin: 4px 0 18px; flex-wrap: wrap; }
.steps span { font-size: 11px; font-family: var(--font-mono); padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--fog); }
.steps span.on { border-color: var(--beacon); color: var(--beacon); background: var(--beacon-soft); }
.steps span.done { color: var(--pine); border-color: rgba(108, 194, 138, 0.4); }
.wizard label { display: block; font-size: 12px; color: var(--mist); margin: 10px 0 4px; }
.wizard .nav-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.placement { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--glacier-soft); border: 1px solid rgba(127, 167, 201, 0.3); font-size: 13px; }
.tier-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tier { border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; background: var(--deep); }
.tier.sel { border-color: var(--beacon); background: var(--beacon-soft); }
.tier b { font-family: var(--font-head); display: block; }
.tier .m { font-family: var(--font-mono); font-size: 12px; color: var(--glacier); }
.tier .u { font-size: 12px; color: var(--mist); margin: 4px 0; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--line-soft); }
.check input { width: auto; margin-top: 4px; }
.check .d { font-size: 12px; color: var(--mist); }
.check.off { opacity: 0.5; }
.callout { padding: 10px 12px; border-radius: 10px; background: var(--beacon-soft); border: 1px solid rgba(217, 164, 65, 0.3); font-size: 13px; margin: 10px 0; }

/* ---- roster ---- */
.agent-card { display: grid; grid-template-columns: auto 1fr; gap: 12px; }
.agent-card .meta { font-size: 12px; color: var(--mist); }
.agent-card .btns { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.edit-box { grid-column: 1 / -1; margin-top: 8px; }

/* ---- logbook ---- */
.entry { border-left: 3px solid var(--line); border-radius: 0; padding: 8px 14px; margin-bottom: 12px; background: var(--panel); }
.entry h4 { margin: 0 0 4px; font-family: var(--font-head); font-weight: 600; }
.entry .by { font-size: 11px; color: var(--fog); font-family: var(--font-mono); }
.entry p { margin: 6px 0 0; white-space: pre-wrap; color: var(--mist); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel-2);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: all 0.2s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--ember); }

@media (max-width: 1100px) {
  .office-layout, .desk-grid, .lodge-grid { grid-template-columns: 1fr; }
  .task-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { flex-direction: row; overflow-x: auto; padding: 10px; gap: 10px; }
  .brand, .rail-foot { display: none; }
  .nav { flex-direction: row; }
  .nav button { white-space: nowrap; }
  .view { padding: 16px; }
  .tier-grid { grid-template-columns: 1fr; }
  .legend { display: none; }
  #floorplan { padding: 4px; }
  .msg { grid-template-columns: 1fr; gap: 0; }
  .radio-form { grid-template-columns: 1fr; }
}

.signout { color: var(--beacon); text-decoration: none; }
.signout:hover { text-decoration: underline; }
.msg.discord .b { color: #b8c0f5; }
