:root {
  --bg: #1b1f27;
  --panel: #232833;
  --panel-2: #2b3140;
  --line: #394052;
  --text: #e9ecef;
  --muted: #9aa3b5;
  --accent: #e8590c;
  --pos: #51cf66;
  --neg: #ff6b6b;
  --warn: #fcc419;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
.hidden { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 8px; padding: 7px 12px; background: var(--accent); color: #fff; font-weight: 600; }
button:hover { filter: brightness(1.1); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
button.danger { background: #c92a2a; }
button.tiny { padding: 1px 7px; font-size: 12px; }
input, textarea, select { width: 100%; background: #171b22; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); border-color: transparent; }
a { color: #74c0fc; }
pre { white-space: pre-wrap; word-break: break-word; background: #171b22; padding: 10px; border-radius: 8px; border: 1px solid var(--line); }
code { background: #171b22; padding: 1px 4px; border-radius: 4px; }
h3 { margin: 18px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.error { color: var(--neg); }
.warn { color: var(--warn); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.empty { color: var(--muted); font-style: italic; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row.between { justify-content: space-between; flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 .span2 { grid-column: span 2; }
.grow { flex: 1; min-width: 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; }
details > summary { cursor: pointer; margin: 6px 0; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }

/* login */
.screen { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #2b3140, var(--bg)); padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card h1 { margin: 0; }
.login-card .logo { font-size: 44px; }
.login-card p { margin: 0; }

/* layout */
#app { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 54px; }
.brand { display: flex; align-items: center; gap: 10px; background: none; padding: 0; color: var(--text); text-align: left; min-width: 0; }
.floor-badge { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); font-weight: 800; flex: none; }
.names { display: flex; flex-direction: column; min-width: 0; }
.names #company-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.names .sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; background: #171b22; border: 1px solid var(--line); white-space: nowrap; cursor: help; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pos); }
.status.running .dot { animation: pulse 1.6s infinite; }
.status.paused .dot, .status.pacing .dot { background: var(--warn); }
.status.no_key .dot, .status.key_invalid .dot, .status.budget .dot { background: var(--neg); }
.status .spend { color: var(--muted); margin-left: 4px; }
.tabs { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: transparent; color: var(--muted); font-weight: 500; white-space: nowrap; position: relative; }
.tabs button.active, .tabs button:hover { background: var(--panel-2); color: var(--text); }
.badge { background: var(--neg); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; margin-left: 2px; }
main { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#office { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud .hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: #fff; background: rgba(20,24,32,.6); padding: 4px 10px; border-radius: 8px; }
.hud .near { position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%); background: rgba(20,24,32,.85); padding: 6px 14px; border-radius: 999px; font-size: 13px; border: 1px solid var(--line); white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.hud .zoom { position: absolute; right: 12px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
.hud .zoom button { width: 38px; height: 38px; padding: 0; background: rgba(20,24,32,.8); border: 1px solid var(--line); font-size: 18px; }

/* side panel */
.panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.3); z-index: 5; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 8px; }
.panel-head h2 { margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head button { background: transparent; font-size: 22px; padding: 0 8px; color: var(--muted); }
#panel-body { padding: 12px 16px 40px; overflow-y: auto; flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; color: var(--muted); border-radius: 0; font-weight: 500; }
.seg button.on { background: var(--panel-2); color: var(--text); }

/* inbox */
.thread summary { font-weight: 600; }
.thread.unread { border-color: var(--accent); }
.thread.closed { opacity: .7; }
.dot-new { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 4px; }
.tag { display: inline-block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 4px; background: var(--line); margin-right: 4px; font-weight: 700; vertical-align: 1px; }
.tag.request, .tag.approval { background: #e8590c; }
.tag.question { background: #1971c2; }
.tag.report { background: #2f9e44; }
.tag.owner { background: #7048e8; }
.posts { margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.post { padding: 8px 10px; border-radius: 8px; background: #1e232d; }
.post.owner { background: color-mix(in srgb, var(--accent) 18%, #1e232d); }
.post .who { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.post .text, .msg .text { white-space: pre-wrap; word-break: break-word; }

/* people */
.person { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.person:hover { border-color: var(--accent); }
.person.fired { opacity: .55; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; position: relative; overflow: hidden; border: 2px solid var(--line); }
.avatar span { position: absolute; width: 16px; height: 16px; border-radius: 50%; left: 9px; top: 4px; }
.avatar.big { width: 52px; height: 52px; }
.avatar.big span { width: 24px; height: 24px; left: 14px; top: 6px; }
.note { margin-top: 4px; padding: 4px 8px; border-left: 2px solid var(--line); color: #cfd5e0; }
.agent-head { display: flex; gap: 12px; align-items: center; }
.agent-head .title { font-weight: 700; }
.live { font-size: 12.5px; margin-top: 4px; }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--pos); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 85%; padding: 7px 10px; border-radius: 12px; background: var(--panel-2); }
.msg.me { align-self: flex-end; background: color-mix(in srgb, var(--accent) 35%, var(--panel-2)); }
.chat-form { display: flex; gap: 8px; margin-top: 8px; align-items: flex-end; }

/* tasks */
.kanban { display: grid; grid-template-columns: 1fr; gap: 10px; }
.kanban h4 { margin: 8px 0 4px; text-transform: uppercase; font-size: 12px; letter-spacing: .05em; }
.task.urgent { border-left: 3px solid var(--neg); }
.task.high { border-left: 3px solid var(--warn); }

/* money */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.kpi b { font-size: 20px; }
.bar { height: 8px; background: #171b22; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; background: var(--accent); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; padding-bottom: 16px; }
.bars div { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.bars span { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars small { position: absolute; bottom: -16px; font-size: 9px; color: var(--muted); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--line); }
.tbl tr.fired { opacity: .55; }
.ledger { border-bottom: 1px solid var(--line); padding: 4px 0; margin: 0; }

/* files & feed */
.file-row { display: flex; justify-content: space-between; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--line); cursor: pointer; word-break: break-all; }
.file-row:hover { background: var(--panel-2); }
pre.file { max-height: 65vh; overflow: auto; font-size: 12px; }
.feed-line { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.feed-line .ico { width: 20px; flex: none; text-align: center; }
.feed-line.journal { background: rgba(255,255,255,.02); }

/* elevator */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding-bottom: 12px; }
.modal-card p { padding: 0 16px; }
#elevator-floors { display: flex; flex-direction: column; gap: 6px; padding: 0 16px; max-height: 60vh; overflow-y: auto; }
.floor-btn { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border: 1px solid var(--line); text-align: left; color: var(--text); font-weight: 500; }
.floor-btn.current { border-color: var(--accent); }
.floor-btn .num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #171b22; font-weight: 800; flex: none; }
.floor-btn small { display: block; color: var(--muted); }

/* toasts */
#toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 20; width: min(520px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; background: #2b3140; border: 1px solid var(--line); border-left: 4px solid #74c0fc; padding: 9px 12px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.35); white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: hidden; cursor: pointer; }
.toast.notify { border-left-color: var(--accent); }
.toast.agent { border-left-color: var(--pos); }
.toast.error { border-left-color: var(--neg); }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .status .spend { display: none; }
  .names #company-name { max-width: 140px; }
  .hud .hint { display: none; }
  .panel { width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  .grid2 .span2 { grid-column: auto; }
}
