:root {
  --bg: #0b1118;
  --bg-alt: #121b24;
  --panel: rgba(12, 23, 32, 0.82);
  --panel-strong: rgba(15, 27, 38, 0.96);
  --line: rgba(132, 156, 178, 0.18);
  --text: #edf3f7;
  --muted: #9eafbf;
  --accent: #e3a84a;
  --accent-soft: rgba(227, 168, 74, 0.16);
  --teal: #53c7b2;
  --danger: #ea6e6e;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 20px;
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  --sans: "IBM Plex Sans", "Aptos", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(83, 199, 178, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(227, 168, 74, 0.18), transparent 26%),
    linear-gradient(180deg, #0c131b 0%, #0a0f15 100%);
  color: var(--text);
  font-family: var(--sans);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, black 45%, transparent 95%);
}

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

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1560px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.topbar,
.status-strip,
.panel,
.modal,
.health-pill,
.goal-card,
.agent-card,
.mini-card,
.fact-card,
.subgoal-card {
  backdrop-filter: blur(14px);
}

.topbar {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(14, 24, 35, 0.92), rgba(11, 18, 25, 0.72));
  box-shadow: var(--shadow);
}

.topbar h1,
.panel h2,
.goal-card h3,
.agent-card h3,
.mini-card h3,
.subgoal-card h4,
.modal h2 {
  margin: 0;
  letter-spacing: -0.03em;
}

.subtitle,
.goal-detail,
.muted-text,
.panel p,
.subgoal-card p {
  color: var(--muted);
}

.topbar-actions,
.inline-actions,
.card-actions,
.goal-badges,
.panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  appearance: none;
  border: 1px solid rgba(227, 168, 74, 0.25);
  background: rgba(227, 168, 74, 0.08);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
  background: rgba(227, 168, 74, 0.16);
}

.button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.button.accent {
  background: linear-gradient(135deg, rgba(227, 168, 74, 0.92), rgba(243, 196, 122, 0.72));
  color: #1f1403;
  border-color: rgba(249, 217, 156, 0.45);
}

.button.ghost {
  background: transparent;
}

.button.small {
  padding: 8px 11px;
  font-size: 0.9rem;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  background:
    linear-gradient(140deg, rgba(227, 168, 74, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(14, 24, 35, 0.94), rgba(11, 18, 25, 0.82));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-help {
  margin: 0;
  color: var(--muted);
}

.login-error {
  min-height: 1.25rem;
  color: #ffb0b0;
  font-family: var(--mono);
  font-size: 0.84rem;
}

.status-strip {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin: 16px 0 22px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.view-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.view-tab {
  appearance: none;
  border: 1px solid rgba(83, 199, 178, 0.18);
  background: rgba(10, 20, 28, 0.72);
  color: var(--muted);
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.view-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(83, 199, 178, 0.32);
  color: var(--text);
}

.view-tab.is-active {
  border-color: rgba(83, 199, 178, 0.38);
  background:
    linear-gradient(135deg, rgba(83, 199, 178, 0.16), rgba(227, 168, 74, 0.12)),
    rgba(10, 20, 28, 0.92);
  color: var(--text);
}

.view-stack {
  display: grid;
}

.view-panel[hidden] {
  display: none;
}

.overview-agent-summary {
  margin-bottom: 20px;
}

.summary-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(140deg, rgba(227, 168, 74, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(14, 24, 35, 0.92), rgba(11, 18, 25, 0.74));
  box-shadow: var(--shadow);
}

.summary-card h2 {
  margin: 0;
}

.summary-detail {
  margin: 6px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.86rem;
}

.health-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.health-pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.health-pill.healthy {
  border-color: rgba(83, 199, 178, 0.28);
}

.health-pill.degraded {
  border-color: rgba(234, 110, 110, 0.28);
}

.timestamp,
.eyebrow,
.meta-row,
.muted-text,
.screen-output,
.screen-preview,
.json-block {
  font-family: var(--mono);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.95fr);
  gap: 20px;
}

.sidebar {
  display: grid;
  gap: 20px;
  align-content: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-strong) 100%);
  box-shadow: var(--shadow);
}

.panel-main {
  min-height: 70vh;
}

.panel-header,
.mini-card-top,
.goal-top,
.subgoal-header {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
}

.goal-list,
.stack {
  display: grid;
  gap: 14px;
}

.agent-summary-table-wrap {
  overflow-x: auto;
}

.agent-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.86rem;
}

.agent-summary-table th,
.agent-summary-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(132, 156, 178, 0.14);
  vertical-align: middle;
}

.agent-summary-table th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.agent-summary-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.agent-summary-name {
  color: var(--text);
  font-weight: 600;
}

.agent-summary-meta,
.agent-summary-idle {
  color: var(--muted);
}

.goal-card,
.agent-card,
.mini-card,
.fact-card,
.subgoal-card {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  padding: 18px;
}

.goal-card {
  background:
    linear-gradient(180deg, rgba(83, 199, 178, 0.06), transparent 28%),
    rgba(255, 255, 255, 0.03);
}

.subgoal-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.meta-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.84rem;
}

.progress-track {
  margin-top: 14px;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.progress-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--accent));
}

.status-badge {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  text-transform: capitalize;
  font-size: 0.84rem;
  border: 1px solid var(--line);
}

.status-active,
.status-working,
.status-done {
  border-color: rgba(83, 199, 178, 0.3);
  color: #8ce9d8;
}

.status-pending,
.status-idle,
.status-paused {
  border-color: rgba(227, 168, 74, 0.3);
  color: #f4cb85;
}

.status-blocked,
.status-stuck,
.status-dead,
.status-cancelled {
  border-color: rgba(234, 110, 110, 0.3);
  color: #ffb0b0;
}

.status-unknown {
  border-color: rgba(132, 156, 178, 0.26);
  color: var(--muted);
}

.screen-preview,
.screen-output,
.json-block {
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 14px;
  border-radius: 14px;
  background: rgba(4, 11, 16, 0.74);
  border: 1px solid rgba(83, 199, 178, 0.12);
  color: #dce8f2;
}

.screen-preview {
  min-height: 140px;
}

.screen-toolbar {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 12px;
  flex-wrap: wrap;
}

.stream-status,
.screen-meta {
  font-family: var(--mono);
  font-size: 0.84rem;
}

.stream-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.stream-status[data-state="live"] {
  border-color: rgba(83, 199, 178, 0.32);
  color: #8ce9d8;
}

.stream-status[data-state="connecting"] {
  border-color: rgba(227, 168, 74, 0.32);
  color: #f4cb85;
}

.stream-status[data-state="error"] {
  border-color: rgba(234, 110, 110, 0.32);
  color: #ffb0b0;
}

.screen-meta {
  color: var(--muted);
}

.facts-list {
  max-height: 460px;
  overflow: auto;
}

.panel-actions {
  align-items: center;
  justify-content: flex-end;
}

.inline-input,
.panel-actions select,
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(132, 156, 178, 0.24);
  background: rgba(6, 13, 19, 0.9);
  color: var(--text);
  padding: 12px 14px;
}

.panel-actions .inline-input {
  min-width: 160px;
}

.modal {
  width: min(860px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(10, 18, 25, 0.98), rgba(13, 23, 33, 0.98));
  color: var(--text);
  padding: 22px;
  box-shadow: var(--shadow);
}

.screen-modal {
  width: min(1100px, calc(100vw - 24px));
}

.modal::backdrop {
  background: rgba(3, 6, 11, 0.72);
}

.modal-header,
.modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.full-width {
  grid-column: 1 / -1;
}

.empty-state,
.empty-inline {
  color: var(--muted);
  padding: 12px 4px;
}

@media (max-width: 1080px) {
  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .topbar,
  .status-strip,
  .modal-header,
  .modal-footer,
  .screen-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 20px 14px 32px;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

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

  .panel,
  .goal-card,
  .agent-card,
  .mini-card,
  .fact-card,
  .subgoal-card {
    padding: 16px;
  }
}
