:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #111821;
  --panel-2: #0d141d;
  --line: #273446;
  --text: #edf6ff;
  --muted: #9fb0c3;
  --accent: #00d4b8;
  --gold: #ffcc66;
  --danger: #ff6b6b;
  --ok: #78f5a2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  border-right: 1px solid var(--line);
  background: #0a1017;
  padding: 18px;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.brand span, .muted { color: var(--muted); }

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-weight: 800;
}

nav { display: grid; gap: 6px; }

.nav-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 10px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover, .nav-item.active {
  border-color: var(--line);
  color: var(--text);
  background: var(--panel);
}

.shell {
  margin-left: 260px;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 34px; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 19px; letter-spacing: 0; }
p { color: var(--muted); line-height: 1.5; }

.status-strip {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-tag {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--accent);
  background: rgba(0, 212, 184, 0.08);
  font-size: 13px;
  white-space: nowrap;
}

.status-tag.muted {
  color: var(--muted);
  background: transparent;
}

.icon-button, button[type="submit"] {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 12px;
  cursor: pointer;
}

button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #04110f;
  font-weight: 800;
}

.kpi-grid, .mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.kpi, .mini-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 14px;
  min-height: 88px;
}

.kpi strong, .mini-card strong {
  display: block;
  color: var(--text);
  font-size: 24px;
  margin-bottom: 4px;
}

.command-hero, .workspace {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.command-hero {
  grid-template-columns: minmax(300px, 0.95fr) minmax(360px, 1.25fr) minmax(280px, 0.9fr);
  align-items: stretch;
}

.workspace {
  grid-template-columns: 1fr 1fr;
}

.workspace.command-row {
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr) minmax(300px, 1fr);
}

.workspace.three {
  grid-template-columns: 1.1fr 1fr 1fr;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.primary-command {
  display: grid;
  align-content: start;
}

.context-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.context-summary p {
  margin: 0;
}

.agent-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.agent-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #080d13;
  color: var(--text);
  padding: 5px 9px;
  cursor: pointer;
  font-size: 12px;
}

.agent-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.command-form { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #080d13;
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
}

textarea { resize: vertical; min-height: 120px; }

.hidden { display: none !important; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.voice-panel {
  overflow: hidden;
}

.jarvis-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 230px;
  border: 1px solid rgba(0, 212, 184, 0.22);
  border-radius: 8px;
  background:
    radial-gradient(circle at center, rgba(0, 212, 184, 0.2), rgba(0, 0, 0, 0) 54%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0));
}

.waveform-canvas {
  position: absolute;
  inset: auto 0 24px;
  width: 100%;
  height: 86px;
  opacity: 0.82;
}

.voice-orb {
  position: relative;
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border: 1px solid rgba(0, 212, 184, 0.78);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 212, 184, 0.34), rgba(10, 16, 23, 0.86) 58%, rgba(255, 204, 102, 0.12));
  box-shadow: 0 0 42px rgba(0, 212, 184, 0.2), inset 0 0 28px rgba(0, 212, 184, 0.18);
  cursor: pointer;
  z-index: 1;
}

.voice-orb::before,
.voice-orb::after {
  content: "";
  position: absolute;
  inset: -18px;
  border: 1px solid rgba(0, 212, 184, 0.24);
  border-radius: 50%;
  animation: voice-ring 3.2s linear infinite;
}

.voice-orb::after {
  inset: -34px;
  border-color: rgba(255, 204, 102, 0.14);
  animation-duration: 4.6s;
}

.voice-orb.listening {
  border-color: var(--gold);
  box-shadow: 0 0 54px rgba(255, 204, 102, 0.24), inset 0 0 28px rgba(0, 212, 184, 0.26);
}

.voice-orb:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.orb-core {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 22px rgba(0, 212, 184, 0.9);
}

.voice-readout {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.voice-meta {
  justify-content: space-between;
  align-items: center;
}

.voice-transcript {
  min-height: 58px;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
}

.dept-tag {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid rgba(255, 204, 102, 0.35);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--gold);
  background: rgba(255, 204, 102, 0.08);
}

.compact {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.recommendation-list, .board-grid, .timeline {
  display: grid;
  gap: 10px;
}

.recommendation {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  padding: 10px;
}

.recommendation button, .board-card button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.recommendation button strong, .board-card button strong {
  display: block;
  margin-bottom: 3px;
}

.recommendation button span, .board-card button span {
  color: var(--accent);
  font-size: 12px;
}

.recommendation p, .board-card p {
  margin: 8px 0 0;
  font-size: 13px;
}

.board-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.board-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  padding: 11px;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  padding: 10px;
}

.timeline-item p {
  margin: 5px 0 8px;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(159, 176, 195, 0.12);
}

.timeline-dot.good { background: var(--ok); box-shadow: 0 0 0 4px rgba(120, 245, 162, 0.12); }
.timeline-dot.warn { background: var(--gold); box-shadow: 0 0 0 4px rgba(255, 204, 102, 0.12); }
.timeline-dot.bad { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.12); }

@keyframes voice-ring {
  from { transform: rotate(0deg) scale(1); opacity: 0.92; }
  50% { transform: rotate(180deg) scale(1.04); opacity: 0.46; }
  to { transform: rotate(360deg) scale(1); opacity: 0.92; }
}

.department-grid, .agent-grid, .action-list {
  display: grid;
  gap: 10px;
}

.department-card, .agent-card, .action-item {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  padding: 12px;
}

.department-card summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}

.department-card summary::-webkit-details-marker { display: none; }

.department-card summary span {
  display: grid;
  gap: 3px;
}

.department-card summary small {
  color: var(--muted);
}

.department-card summary button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 9px;
  cursor: pointer;
}

.agent-drilldown {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.agent-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080d13;
  color: var(--text);
  padding: 8px;
  text-align: left;
  cursor: pointer;
}

.department-card h3, .agent-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.good { color: var(--ok); }
.warn { color: var(--gold); }
.bad { color: var(--danger); }

@media (max-width: 980px) {
  .rail {
    position: static;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .shell { margin-left: 0; padding: 16px; }
  nav { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .command-hero, .workspace, .workspace.command-row, .workspace.three, .form-row { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .jarvis-stage { min-height: 210px; }
  .voice-orb { width: 116px; height: 116px; }
  .board-grid { grid-template-columns: 1fr; }
  .agent-row { grid-template-columns: 1fr; }
}
