:root {
  color-scheme: dark;
  --bg: #070b10;
  --surface: #101721;
  --surface-2: #162231;
  --text: #edf7ff;
  --muted: #91a6b8;
  --line: #25384a;
  --green: #38c172;
  --amber: #f2a93b;
  --red: #ef5b5b;
  --blue: #42c7ff;
  --violet: #8b7cff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(66, 199, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(66, 199, 255, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(66, 199, 255, 0.1), transparent 280px),
    var(--bg);
  background-size: 24px 24px, 24px 24px, auto, auto;
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 4px 0 12px;
}

.status-line {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(66, 199, 255, 0.28);
  border-radius: 999px;
  background: rgba(7, 11, 16, 0.62);
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
}

#statusDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 14px rgba(56, 193, 114, 0.8);
}

#statusDot.warn {
  background: var(--amber);
  box-shadow: 0 0 14px rgba(242, 169, 59, 0.8);
}

.kicker {
  margin: 0 0 2px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.metric {
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(66, 199, 255, 0.08), rgba(16, 23, 33, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
}

.metric.danger strong,
.metric.danger small {
  color: var(--red);
}

.metric.warn strong {
  color: var(--amber);
}

.tabs {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  margin: 8px 0 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0e12;
}

.tab {
  flex: 0 0 auto;
  min-width: 82px;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab.active {
  background: linear-gradient(180deg, rgba(66, 199, 255, 0.18), rgba(22, 34, 49, 0.94));
  color: var(--text);
}

.jarvis-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
  align-items: center;
  min-height: 292px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(66, 199, 255, 0.12), rgba(139, 124, 255, 0.08) 38%, rgba(16, 23, 33, 0.92)),
    var(--surface);
  overflow: hidden;
}

.radar {
  position: relative;
  width: min(280px, 76vw);
  aspect-ratio: 1;
  margin: 14px auto;
  border-radius: 50%;
  background:
    linear-gradient(rgba(66, 199, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(66, 199, 255, 0.08) 1px, transparent 1px),
    #091018;
  background-size: 22px 22px;
  box-shadow: 0 0 42px rgba(66, 199, 255, 0.18), inset 0 0 30px rgba(66, 199, 255, 0.12);
}

.radar-ring,
.radar-sweep,
.radar-core {
  position: absolute;
  border-radius: 50%;
}

.radar-ring {
  inset: 12%;
  border: 1px solid rgba(66, 199, 255, 0.35);
}

.ring-b {
  inset: 28%;
  border-color: rgba(242, 169, 59, 0.34);
}

.ring-c {
  inset: 42%;
  border-color: rgba(56, 193, 114, 0.36);
}

.radar-sweep {
  inset: 0;
  background: conic-gradient(from 0deg, transparent, rgba(66, 199, 255, 0.34), transparent 24%);
  animation: spin 6s linear infinite;
}

.radar-core {
  inset: 35%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(66, 199, 255, 0.5);
  background: rgba(7, 11, 16, 0.86);
  text-align: center;
}

.radar-core strong {
  font-size: 24px;
  line-height: 1;
}

.radar-core span {
  color: var(--muted);
  font-size: 12px;
}

.radar.warn .radar-core strong {
  color: var(--amber);
}

.radar.danger .radar-core strong {
  color: var(--red);
}

.signal-stack {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.signal-stack div {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(66, 199, 255, 0.2);
  border-radius: 8px;
  background: rgba(7, 11, 16, 0.54);
  padding: 12px;
}

.signal-stack span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.signal-stack strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 22px;
}

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

.command-strip button {
  min-height: 44px;
  border: 1px solid rgba(66, 199, 255, 0.25);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(66, 199, 255, 0.12), rgba(16, 23, 33, 0.92));
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 8px;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.section-head.lower {
  margin-top: 18px;
}

input[type="search"] {
  width: min(220px, 48vw);
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
}

select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 10px;
}

.list,
.mono-list {
  display: grid;
  gap: 8px;
}

.item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 23, 33, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.item-title strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.item small,
.item p {
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

.markers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.markers span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 3px 7px;
  font-size: 12px;
}

.mini-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.mini-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.mini-button.danger {
  border-color: rgba(239, 91, 91, 0.45);
  color: #ffb0b0;
}

.pill {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(56, 193, 114, 0.14);
  color: var(--green);
  font-size: 12px;
}

.pill.warn {
  background: rgba(242, 169, 59, 0.14);
  color: var(--amber);
}

.compact .item {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 8px;
}

.mono-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #d7dde8;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-panel {
  margin-top: 16px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.log-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-bottom: 8px;
}

.log-output {
  max-height: 52vh;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0d10;
  color: #d7dde8;
  padding: 12px;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.metric-chart {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 132px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.metric-chart span {
  flex: 1 1 4px;
  min-width: 3px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--amber), var(--red));
}

.chat-list {
  display: grid;
  gap: 8px;
  max-height: 56vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 11, 16, 0.56);
  padding: 10px;
}

.chat-message {
  width: min(86%, 620px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.chat-message.user {
  justify-self: end;
  border-color: rgba(242, 169, 59, 0.34);
}

.chat-message.assistant {
  justify-self: start;
  border-color: rgba(66, 199, 255, 0.34);
}

.chat-message span {
  display: block;
  margin-bottom: 3px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.command-cards {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.command-card {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 58px;
  border: 1px solid rgba(66, 199, 255, 0.24);
  border-radius: 8px;
  background: rgba(7, 11, 16, 0.56);
  color: var(--text);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.command-card.danger {
  border-color: rgba(239, 91, 91, 0.38);
}

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

.chat-form,
.task-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}

.chat-form input,
.task-form input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
}

.map-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.map-flow div {
  min-height: 86px;
  background: rgba(16, 23, 33, 0.94);
  padding: 12px;
}

.map-flow span,
.project-details span,
.timeline-item span {
  display: block;
  color: var(--blue);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.map-flow strong,
.project-details strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.timeline {
  display: grid;
  gap: 8px;
}

.readiness-summary {
  display: grid;
  grid-template-columns: 0.45fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.readiness-summary article,
.capability-item {
  border-left: 3px solid var(--blue);
}

.readiness-summary article {
  min-height: 78px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 8px;
  background: rgba(16, 23, 33, 0.92);
  padding: 12px;
}

.readiness-summary span,
.capability-item small {
  display: block;
  color: var(--muted);
}

.readiness-summary strong {
  display: block;
  margin-top: 7px;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.capability-item.warn {
  border-left-color: var(--amber);
}

.capability-item.danger {
  border-left-color: var(--red);
}

.capability-item.ok {
  border-left-color: var(--green);
}

.capability-item small {
  margin-top: 8px;
  font-size: 13px;
}

.timeline-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 23, 33, 0.92);
  padding: 12px 12px 12px 18px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: 2px;
  background: var(--blue);
}

.timeline-item.danger::before {
  background: var(--red);
}

.timeline-item strong,
.timeline-item p,
.timeline-item small {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.timeline-item p,
.timeline-item small {
  color: var(--muted);
}

.detail-panel {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.project-details,
.settings-grid {
  display: grid;
  gap: 8px;
}

.project-details div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 23, 33, 0.92);
  padding: 12px;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

.empty {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 24px));
  transform: translateY(16px);
  border: 1px solid rgba(56, 193, 114, 0.38);
  border-radius: 8px;
  background: #102018;
  color: var(--text);
  padding: 10px 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.bad {
  border-color: rgba(239, 91, 91, 0.44);
  background: #241112;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 520px) {
  .app {
    padding: 12px;
  }

  .health-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .jarvis-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .status-line {
    grid-column: 1 / -1;
    order: 3;
    justify-content: center;
  }

  .signal-stack div {
    grid-template-columns: 92px 1fr;
  }

  .log-controls {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }

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

  .command-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-flow {
    grid-template-columns: 1fr;
  }

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

  .metric {
    min-height: 78px;
    padding: 10px;
  }

  .metric strong {
    font-size: 24px;
  }
}
