:root {
  --bg-0: #040608;
  --bg-1: #0a0f14;
  --bg-2: #111822;
  --bg-3: #16202d;
  --line: #273241;
  --line-soft: #19212b;
  --text: #eef3f7;
  --muted: #8b9ab0;
  --good: #28c983;
  --warn: #f1b24b;
  --bad: #ef5b65;
  --accent: #ff6b2d;
  --accent-soft: #ff8d57;
  --cyan: #47d7f4;
  --panel: rgba(12, 18, 26, 0.94);
  --panel-soft: rgba(16, 23, 33, 0.9);
  --glow: rgba(255, 107, 45, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg-0);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  background: transparent;
}

input, select, textarea {
  background: rgba(7, 10, 14, 0.98);
  color: var(--text);
  border: 1px solid #314153;
  border-radius: 10px;
  padding: 9px 11px;
}

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

input::placeholder, textarea::placeholder {
  color: var(--muted);
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 460px at 22% -8%, rgba(255, 107, 45, 0.17), transparent 58%),
    radial-gradient(680px 340px at 88% 0%, rgba(71, 215, 244, 0.12), transparent 45%),
    linear-gradient(180deg, #06090d, #070b11 42%, #040608);
}

.app-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(113, 133, 158, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(113, 133, 158, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, black, transparent 88%);
}

.command-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 72px;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 6, 8, 0.93);
  backdrop-filter: blur(10px);
  z-index: 1200;
}

.command-left, .command-right {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 6px;
}

.rw-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  border: 1px solid #354153;
  background: linear-gradient(180deg, rgba(16, 23, 33, 0.95), rgba(8, 12, 18, 1));
  box-shadow: 0 0 18px rgba(255, 107, 45, 0.08);
}

.rw-badge img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.wordmark {
  height: 24px;
  width: auto;
  object-fit: contain;
}

.pill, .status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(13, 18, 26, 0.96);
}

.pill.status { color: var(--good); }
.pill.env { color: #c8d0dc; }
.pill.approvals { color: var(--warn); }

.cmd-btn,
.mode-btn,
.composer-actions button,
.tab,
.strip-btn {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 24, 34, 0.98), rgba(9, 13, 18, 1));
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.cmd-btn:hover,
.mode-btn:hover,
.composer-actions button:hover,
.tab:hover,
.strip-btn:hover {
  border-color: #52637a;
  transform: translateY(-1px);
}

.cmd-btn {
  padding: 7px 11px;
}

.cmd-btn.mini {
  padding: 4px 8px;
  font-size: 11px;
}

.left-strip {
  position: fixed;
  top: 54px;
  bottom: 40px;
  left: 0;
  width: 58px;
  border-right: 1px solid var(--line);
  background: rgba(5, 8, 11, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
  gap: 8px;
  z-index: 900;
}

.strip-btn {
  width: 38px;
  height: 38px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.strip-btn.active {
  color: var(--accent-soft);
  border-color: rgba(255, 107, 45, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 107, 45, 0.14) inset;
}

.left-rail, .right-rail {
  position: fixed;
  top: 54px;
  bottom: 40px;
  width: 332px;
  padding: 14px;
  background: rgba(6, 10, 14, 0.98);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  overflow: auto;
  transition: transform 0.24s ease;
  z-index: 1000;
}

.left-rail {
  left: 58px;
  transform: translateX(-120%);
}

.right-rail {
  right: 32px;
  transform: translateX(120%);
}

.left-rail.open,
.right-rail.open {
  transform: translateX(0);
}

.right-edge {
  position: fixed;
  top: 54px;
  right: 0;
  bottom: 40px;
  width: 32px;
  border-left: 1px solid var(--line);
  display: grid;
  place-items: start center;
  color: var(--muted);
  padding-top: 12px;
  background: rgba(6, 10, 14, 0.95);
  z-index: 900;
}

.workspace {
  position: relative;
  margin: 68px 44px 54px 74px;
  padding: 8px;
  z-index: 1;
}

.active-banner,
.operator-hero,
.surface-planes,
.readiness-overview,
.composer,
.views,
.ops-feed,
.left-rail section,
.right-rail section,
.operator-form {
  margin-top: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(12, 18, 26, 0.96), rgba(8, 12, 18, 0.98));
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
}

.active-banner {
  padding: 12px 16px;
  border-color: rgba(255, 107, 45, 0.18);
  background: linear-gradient(90deg, rgba(44, 17, 11, 0.7), rgba(13, 18, 26, 0.96));
  font-size: 13px;
}

.operator-hero,
.surface-planes,
.readiness-overview,
.composer,
.views,
.ops-feed,
.left-rail section,
.right-rail section,
.operator-form {
  padding: 14px;
}

.hero-header,
.section-head,
.boundary-callout,
.dual-panel {
  display: grid;
  gap: 12px;
}

.hero-header {
  grid-template-columns: minmax(0, 1fr) 240px;
  align-items: start;
}

.hero-modes {
  align-self: stretch;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-soft);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.operator-hero h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.02;
}

.hero-copy {
  margin: 10px 0 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.hero-stats,
.summary-grid,
.summary-columns,
.plane-grid {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.hero-stats {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.summary-columns,
.dual-panel {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.plane-grid {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.hero-stat,
.summary-card,
.summary-panel,
.plane-card {
  border: 1px solid #243241;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(18, 25, 36, 0.96), rgba(10, 14, 20, 1));
  padding: 14px;
}

.hero-stat span,
.summary-card span,
.plane-card .plane-kicker {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.hero-stat strong,
.summary-card strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
  line-height: 1;
}

.hero-stat small,
.summary-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.plane-card h3,
.summary-panel h3,
.left-rail h3,
.right-rail h3,
.ops-feed h3,
.operator-form h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.plane-card p,
.summary-panel p,
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.plane-card .plane-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.plane-card .plane-action {
  border: 1px solid #314153;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  color: var(--text);
  background: rgba(9, 13, 18, 0.92);
  cursor: pointer;
}

.boundary-callout {
  grid-template-columns: minmax(0, 1fr) 280px;
  margin-top: 12px;
}

.boundary-note {
  border: 1px dashed rgba(255, 107, 45, 0.35);
  border-radius: 14px;
  padding: 12px;
  background: rgba(24, 12, 7, 0.35);
  color: #f7c4ad;
  font-size: 12px;
  line-height: 1.6;
}

.mode-stack {
  display: grid;
  gap: 8px;
}

.mode-btn {
  padding: 10px 12px;
  text-align: left;
}

.mode-btn.active {
  border-color: rgba(255, 107, 45, 0.5);
  color: var(--accent-soft);
  background: linear-gradient(180deg, rgba(42, 19, 12, 0.86), rgba(16, 13, 12, 0.98));
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
}

.composer h2,
.section-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 780px;
  line-height: 1.6;
}

.composer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

label.inline {
  flex-direction: row;
  align-items: center;
  padding-top: 24px;
}

label.wide {
  grid-column: span 2;
}

.composer-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.composer-actions .run {
  background: linear-gradient(160deg, #d85a2a, #802613);
  border-color: #ff8e62;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0 10px;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 11px;
  color: var(--muted);
}

.tab.active {
  color: var(--accent-soft);
  border-color: rgba(255, 107, 45, 0.45);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.task-table-wrap {
  overflow: auto;
  max-height: 340px;
}

.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.task-table th,
.task-table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid #1c2632;
}

.task-table td.state-completed,
.task-table td.state-pass,
.task-table td.state-ok {
  color: var(--good);
  font-weight: 600;
}

.task-table td.state-blocked_scope,
.task-table td.state-blocked_policy,
.task-table td.state-warn,
.task-table td.state-partial {
  color: var(--warn);
  font-weight: 600;
}

.task-table td.state-failed_runtime,
.task-table td.state-failed,
.task-table td.state-error {
  color: var(--bad);
  font-weight: 600;
}

.task-table td.state-cancelled {
  color: var(--muted);
  font-weight: 600;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: rgba(23, 32, 44, 0.9);
}

.ops-feed #opsFeed,
#auditStream,
#healthMatrix,
#approvalsQueue,
.panel-list {
  display: grid;
  gap: 6px;
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 11px;
}

.feed-row,
.terminal-preview {
  background: rgba(10, 14, 20, 0.96);
  border: 1px solid #263240;
  border-radius: 10px;
  padding: 8px 9px;
}

.terminal-preview {
  margin-top: 12px;
  white-space: pre-wrap;
  line-height: 1.5;
  color: #d7e0ec;
  min-height: 72px;
}

.terminal .feed-row {
  white-space: pre-wrap;
  line-height: 1.45;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips span {
  font-size: 11px;
  color: #d9e2ee;
  border: 1px solid #384658;
  background: rgba(13, 18, 26, 0.98);
  border-radius: 999px;
  padding: 5px 9px;
}

.posture {
  display: grid;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.approval-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.status-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 74px;
  border-top: 1px solid var(--line);
  background: rgba(5, 8, 11, 0.96);
  overflow-x: auto;
  z-index: 1200;
}

#apiKeyDialog,
#actorDialog,
#taskDetailDialog {
  border: 1px solid #364457;
  border-radius: 14px;
  background: rgba(7, 10, 14, 0.99);
  color: var(--text);
}

.key-form,
.detail-form {
  width: min(640px, 90vw);
  display: grid;
  gap: 10px;
}

.key-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.hidden {
  display: none !important;
}

@media (max-width: 1400px) {
  .hero-header,
  .boundary-callout,
  .dual-panel {
    grid-template-columns: 1fr;
  }

  .hero-stats,
  .summary-grid,
  .plane-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 980px) {
  .left-rail,
  .right-rail,
  .right-edge {
    display: none;
  }

  .workspace {
    margin-right: 12px;
  }

  .hero-stats,
  .summary-grid,
  .summary-columns,
  .plane-grid,
  .composer-grid {
    grid-template-columns: 1fr;
  }
}
