:root {
  --bg-0: #020617;
  --bg-1: #0f172a;
  --surface: rgba(15, 23, 42, 0.78);
  --surface-strong: rgba(30, 41, 59, 0.88);
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --border: rgba(148, 163, 184, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Fira Sans", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, rgba(34, 197, 94, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(56, 189, 248, 0.12) 0%, transparent 45%),
    linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 55%, #111827 100%);
  min-height: 100vh;
}

h1,
h2,
th,
.value,
.eyebrow {
  font-family: "Fira Code", monospace;
}

.app-shell {
  width: min(1460px, 96vw);
  margin: 1.25rem auto 2rem;
  display: grid;
  gap: 1rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
}

h1 {
  margin: 0.2rem 0 0;
  font-size: clamp(1.3rem, 1.8vw, 2rem);
}

h2 {
  margin: 0;
  font-size: 1rem;
}

.eyebrow {
  margin: 0;
  color: #86efac;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.32);
  backdrop-filter: blur(4px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.muted {
  color: var(--text-dim);
  font-size: 0.84rem;
}

.config-panel {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field.actions {
  align-items: end;
}

.field-span-2 {
  grid-column: span 2;
}

label {
  font-size: 0.78rem;
  color: var(--text-dim);
}

input,
select,
textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.65);
  color: var(--text);
  padding: 0.55rem 0.65rem;
  font: inherit;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
textarea:focus-visible {
  outline: 2px solid #34d399;
  outline-offset: 2px;
}

.button {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.56rem 0.75rem;
  font-family: "Fira Code", monospace;
  font-size: 0.8rem;
  color: var(--text);
  background: rgba(15, 23, 42, 0.95);
  cursor: pointer;
}

.button:hover {
  background: var(--surface-strong);
}

.button-primary {
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(22, 101, 52, 0.75);
}

.button-danger {
  border-color: rgba(244, 63, 94, 0.55);
  background: rgba(159, 18, 57, 0.35);
}

.check-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.check-row label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text);
}

.quick-create-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.agent-editor-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.8rem;
  align-items: end;
  margin-bottom: 0.8rem;
}

.code-area {
  min-height: 240px;
  font-family: "Fira Code", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #dbeafe;
}

.kpi-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.stat-card .label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.stat-card .value {
  margin: 0.42rem 0;
  font-size: 1.4rem;
}

.grid-two {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 0.9rem;
}

.explorer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.collection-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.chips-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.status-bars {
  display: grid;
  gap: 0.65rem;
}

.status-bar {
  display: grid;
  grid-template-columns: 90px 1fr 60px;
  align-items: center;
  gap: 0.5rem;
}

.status-bar-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.status-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #14b8a6);
}

.signal-list {
  margin: 0;
  display: grid;
  gap: 0.6rem;
}

.signal-list div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding-bottom: 0.45rem;
}

.signal-list dd {
  margin: 0;
  font-family: "Fira Code", monospace;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

th,
td {
  text-align: left;
  font-size: 0.82rem;
  padding: 0.52rem 0.4rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  vertical-align: top;
}

th {
  color: var(--text-dim);
}

tbody tr:hover {
  background: rgba(30, 41, 59, 0.45);
}

.chip {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.12rem 0.48rem;
  font-size: 0.75rem;
  border: 1px solid;
  font-family: "Fira Code", monospace;
}

.chip-ok {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.55);
  background: rgba(22, 101, 52, 0.28);
}

.chip-warn {
  color: #fcd34d;
  border-color: rgba(252, 211, 77, 0.6);
  background: rgba(146, 64, 14, 0.28);
}

.chip-bad {
  color: #fda4af;
  border-color: rgba(253, 164, 175, 0.55);
  background: rgba(159, 18, 57, 0.25);
}

.actions-inline {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.mini-button {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.8);
  color: var(--text);
  padding: 0.2rem 0.48rem;
  font-size: 0.72rem;
  cursor: pointer;
}

.execution-filters {
  display: grid;
  grid-template-columns: 1fr 1fr 180px auto;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.events-log {
  margin: 0;
  max-height: 180px;
  overflow: auto;
  font-family: "Fira Code", monospace;
  font-size: 0.76rem;
  color: #cbd5e1;
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  padding: 0.65rem;
  white-space: pre-wrap;
}

@media (max-width: 1100px) {
  .config-panel,
  .quick-create-grid,
  .kpi-grid,
  .explorer-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
  .grid-two,
  .agent-editor-grid,
  .execution-filters {
    grid-template-columns: 1fr;
  }
  .field-span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 680px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .config-panel,
  .quick-create-grid,
  .kpi-grid,
  .explorer-grid {
    grid-template-columns: 1fr;
  }
}
