:root {
  --bg: #07110f;
  --bg-soft: #0a1613;
  --panel: rgba(15, 29, 25, 0.94);
  --panel-2: rgba(20, 38, 33, 0.88);
  --line: rgba(220, 244, 235, 0.13);
  --line-strong: rgba(220, 244, 235, 0.23);
  --text: #f4fbf8;
  --muted: #9eb7ad;
  --mint: #8be4c1;
  --mint-soft: rgba(139, 228, 193, 0.11);
  --gold: #f1d28f;
  --gold-soft: rgba(241, 210, 143, 0.1);
  --danger: #ff9f9f;
  --danger-soft: rgba(255, 159, 159, 0.1);
  --warning: #ffd28c;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 0%, rgba(36, 109, 84, 0.26), transparent 34%),
    radial-gradient(circle at 5% 20%, rgba(110, 86, 38, 0.13), transparent 28%),
    linear-gradient(180deg, #07110f 0%, #081512 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button { font: inherit; color: inherit; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }

.shell { width: min(1500px, calc(100% - 36px)); margin: 0 auto; padding: 30px 0 70px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.brand-block h1 { margin: 2px 0 6px; font-size: clamp(2.2rem, 5vw, 4.6rem); line-height: 0.95; letter-spacing: -0.055em; }
.subline { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.65; }
.eyebrow { margin: 0 0 5px; color: var(--mint); font-size: 0.68rem; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; }
.session-state { display: grid; gap: 7px; justify-items: end; color: var(--muted); font-size: 0.75rem; }
.session-state strong { padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--mint); background: var(--mint-soft); }
.session-boundary { max-width: 680px; padding: 28px; margin: 70px auto; border: 1px solid var(--line); border-radius: 22px; text-align: center; background: var(--panel); box-shadow: var(--shadow); }
.session-boundary h2 { margin: 6px 0 10px; }
.session-boundary p:last-child { margin: 0; color: var(--muted); line-height: 1.6; }

.notice { display: flex; gap: 9px; padding: 13px 15px; margin-bottom: 14px; border: 1px solid rgba(241,210,143,0.2); border-radius: 14px; background: rgba(241,210,143,0.065); color: #e8ddc2; font-size: 0.83rem; line-height: 1.5; }
.notice strong { color: var(--gold); white-space: nowrap; }

.hero-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 14px; }
.hero-card, .panel, .department { border: 1px solid var(--line); background: linear-gradient(145deg, var(--panel), rgba(10, 22, 19, 0.92)); box-shadow: var(--shadow); }
.hero-card { min-height: 180px; padding: 22px; border-radius: 20px; }
.hero-card h2, .panel h2, .section-head h2 { margin: 4px 0 8px; letter-spacing: -0.035em; }
.identity-card { display: flex; align-items: center; gap: 16px; }
.identity-card p { margin: 0 0 5px; }
.identity-card small { color: var(--muted); line-height: 1.5; }
.avatar-large, .avatar { display: grid; place-items: center; flex: 0 0 auto; color: #06110e; background: linear-gradient(135deg, var(--mint), #daf9ed); font-weight: 950; }
.avatar-large { width: 66px; height: 66px; border-radius: 21px; font-size: 1.4rem; }
.avatar { width: 44px; height: 44px; border-radius: 14px; }
.status-list { display: grid; gap: 9px; margin: 16px 0 0; }
.status-list div { display: flex; justify-content: space-between; gap: 12px; padding-top: 9px; border-top: 1px solid var(--line); }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; font-weight: 800; }
.status-list dd.ok { color: var(--mint); }
.status-list dd.warm { color: var(--gold); }
.approval-summary p { color: var(--muted); line-height: 1.55; }

button.primary, button.secondary, button.ghost, a.primary { border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: transform 120ms ease, border-color 120ms ease, background 120ms ease; }
button.primary:hover, button.secondary:hover, button.ghost:hover, a.primary:hover { transform: translateY(-1px); border-color: var(--line-strong); }
button.primary, a.primary { padding: 10px 13px; color: #06110e; background: var(--mint); font-weight: 900; }
.login-link { display: inline-block; margin-top: 18px; text-decoration: none; }
button.secondary { padding: 9px 12px; background: rgba(139,228,193,0.08); color: var(--mint); }
button.ghost { padding: 7px 9px; background: rgba(255,255,255,0.025); color: var(--muted); font-size: 0.72rem; }
button:disabled { opacity: 0.48; cursor: not-allowed; transform: none !important; }
.small-button { font-size: 0.75rem; }
.full { width: 100%; margin-top: 16px; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin: 34px 0 13px; }
.section-head h2 { font-size: clamp(1.8rem, 3vw, 2.5rem); }
.section-head > p { max-width: 560px; margin: 0; color: var(--muted); text-align: right; line-height: 1.6; }
.office-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.tower-panel { padding: 18px; border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(145deg, var(--panel), rgba(8, 18, 16, 0.94)); box-shadow: var(--shadow); }
.workspace-switcher { display: flex; flex-wrap: wrap; gap: 8px; }
.workspace-tab { padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: rgba(255,255,255,0.025); cursor: pointer; }
.workspace-tab.active { color: #06110e; border-color: var(--mint); background: var(--mint); font-weight: 900; }
.tower-toolbar { display: flex; align-items: center; gap: 10px; margin: 16px 0; padding-top: 14px; border-top: 1px solid var(--line); }
.tower-toolbar label { color: var(--muted); font-size: 0.76rem; }
.tower-toolbar select { min-width: 250px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: #0b1815; }
.tower-toolbar .system-tag { margin-left: auto; }
.tower-floorplan { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; min-height: 170px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(rgba(139,228,193,0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(139,228,193,0.035) 1px, transparent 1px), rgba(2, 8, 7, 0.45); background-size: 42px 42px; }
.tower-room { min-height: 112px; padding: 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: rgba(11, 26, 22, 0.93); }
.tower-room h3 { margin: 4px 0 14px; font-size: 0.96rem; }
.tower-room small { color: var(--muted); line-height: 1.4; }
.tower-room.room-office { border-color: rgba(241,210,143,0.35); }
.tower-room.room-bridge { border-color: rgba(139,228,193,0.46); }
.department { grid-column: span 4; padding: 18px; border-radius: 20px; position: relative; overflow: hidden; }
.department::before { content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 3px; background: var(--mint); opacity: 0.55; }
.department.zone-leadership { grid-column: span 12; }
.department.zone-product { grid-column: span 4; }
.department.zone-commercial, .department.zone-governance, .department.zone-knowledge { grid-column: span 4; }
.department.read-only { background: linear-gradient(145deg, rgba(13,25,22,0.86), rgba(8,17,15,0.9)); }
.department.read-only::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg, transparent, rgba(255,255,255,0.018)); }
.department-head, .panel-head, .agent-name-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.department-head h3 { margin: 0; font-size: 1.15rem; }
.department-description { margin: 9px 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.55; }
.access-badge, .count-badge, .system-tag { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-size: 0.62rem; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; }
.access-badge { padding: 5px 8px; }
.access-badge.edit { color: var(--mint); background: var(--mint-soft); }
.access-badge.view { color: var(--muted); background: rgba(255,255,255,0.04); }
.count-badge { min-width: 30px; height: 30px; color: var(--mint); background: var(--mint-soft); }
.system-tag { padding: 6px 9px; color: var(--gold); background: var(--gold-soft); }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 10px; margin-top: 15px; }
.agent-card { display: grid; grid-template-columns: 44px 1fr; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 15px; background: rgba(3, 9, 8, 0.38); }
.agent-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.agent-title, .agent-copy small { color: var(--muted); }
.agent-title { font-size: 0.8rem; }
.agent-copy small { font-size: 0.7rem; line-height: 1.35; }
.task-line { color: var(--gold) !important; margin-top: 4px; }
.status-pill { white-space: nowrap; padding: 3px 6px; border-radius: 999px; color: var(--muted); background: rgba(255,255,255,0.05); font-size: 0.56rem; font-weight: 900; text-transform: uppercase; }
.status-pill.working { color: var(--mint); background: var(--mint-soft); }
.status-pill.blocked { color: var(--danger); background: var(--danger-soft); }
.status-pill.ready_for_daniel { color: var(--gold); background: var(--gold-soft); }
.agent-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 7px; padding-top: 3px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 14px; }
.panel { padding: 20px; border-radius: 20px; }
.stack, .progress-stack { display: grid; margin-top: 13px; }
.job-stack { display: grid; gap: 10px; margin-top: 13px; }
.background-jobs-panel { grid-column: 1 / -1; }
.job-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(3, 9, 8, 0.38); }
.job-copy { display: flex; flex-direction: column; gap: 4px; }
.job-copy small { color: var(--muted); }
.job-actions { display: flex; align-items: flex-start; gap: 7px; }
.approval-row, .connector-row, .progress-row { display: grid; align-items: center; gap: 11px; padding: 12px 0; border-top: 1px solid var(--line); }
.approval-row { grid-template-columns: 1fr auto auto; }
.connector-row, .progress-row { grid-template-columns: 1fr auto; }
.approval-row p { margin: 4px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.connector-row > div, .progress-row > div { display: flex; flex-direction: column; gap: 3px; }
.connector-row small, .progress-row small { color: var(--muted); }
.risk { font-size: 0.63rem; font-weight: 950; text-transform: uppercase; }
.risk-low { color: var(--mint); }
.risk-medium { color: var(--warning); }
.risk-high { color: var(--danger); }
.read-only-label { color: var(--muted); font-size: 0.7rem; }
.connector-state, .progress-state { padding: 5px 8px; border-radius: 999px; color: var(--muted); background: rgba(255,255,255,0.045); font-size: 0.62rem; font-weight: 900; text-transform: uppercase; }
.connector-state.prepared, .progress-state { color: var(--mint); background: var(--mint-soft); }
.connector-state.extensible { color: var(--gold); background: var(--gold-soft); }
.chip-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.chip { display: inline-flex; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; color: #cae3d9; background: rgba(139,228,193,0.045); font-size: 0.74rem; }
.panel-note { color: var(--muted); font-size: 0.78rem; line-height: 1.55; }
.activity-panel { margin-top: 14px; }
.timeline { display: grid; margin-top: 12px; }
.timeline-row { display: grid; grid-template-columns: 80px 90px 1fr auto; gap: 11px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 0.8rem; }
.timeline-row time, .timeline-row em { color: var(--muted); font-style: normal; }
.timeline-row em { font-size: 0.62rem; text-transform: uppercase; }

.detail-dialog { width: min(640px, calc(100% - 24px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 22px; color: var(--text); background: #0b1815; box-shadow: 0 40px 110px rgba(0,0,0,0.6); }
.detail-dialog::backdrop { background: rgba(1, 6, 5, 0.76); backdrop-filter: blur(6px); }
.dialog-shell { position: relative; padding: 24px; }
.dialog-close { position: absolute; top: 13px; right: 13px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,0.04); cursor: pointer; }
.dialog-agent-head { display: flex; align-items: center; gap: 14px; padding-right: 36px; }
.dialog-agent-head h2 { margin: 2px 0 4px; font-size: 2rem; }
.dialog-title { color: var(--muted); line-height: 1.5; }
.detail-facts { display: grid; margin: 20px 0 0; }
.detail-facts div { display: grid; grid-template-columns: 135px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.detail-facts dt { color: var(--muted); }
.detail-facts dd { margin: 0; }
.dialog-subhead { margin: 22px 0 4px; }
.dialog-action-box { margin-top: 20px; padding: 14px; border: 1px solid rgba(241,210,143,0.18); border-radius: 14px; background: rgba(241,210,143,0.055); }
.dialog-action-box p { margin: 6px 0 0; color: #d8cdb4; line-height: 1.55; }

@media (max-width: 1100px) {
  .hero-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .department.zone-product, .department.zone-commercial, .department.zone-governance, .department.zone-knowledge { grid-column: span 6; }
}
@media (max-width: 760px) {
  .shell { width: min(100% - 20px, 1500px); padding-top: 18px; }
  .topbar, .section-head { flex-direction: column; align-items: stretch; }
  .session-state { justify-items: start; }
  .section-head > p { text-align: left; }
  .notice { flex-direction: column; }
  .notice strong { white-space: normal; }
  .department.zone-leadership, .department.zone-product, .department.zone-commercial, .department.zone-governance, .department.zone-knowledge { grid-column: span 12; }
  .timeline-row { grid-template-columns: 64px 1fr; }
  .timeline-row span { grid-column: 1 / -1; }
  .approval-row { grid-template-columns: 1fr auto; }
  .tower-toolbar { align-items: stretch; flex-direction: column; }
  .tower-toolbar .system-tag { margin-left: 0; align-self: flex-start; }
  .tower-toolbar select { min-width: 0; width: 100%; }
  .tower-floorplan { grid-template-columns: 1fr; }
  .job-row { grid-template-columns: 1fr; }
  .approval-row button, .approval-row .read-only-label { grid-column: 1 / -1; justify-self: start; }
}

.office-navigation { display: flex; flex-wrap: wrap; gap: .7rem 1.3rem; margin: 1rem 0; }
.office-navigation a { color: inherit; padding: .6rem 0; }
#backup-status, #runtime-status { overflow-wrap: anywhere; }
