:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --ink: #1c1d20;
  --muted: #6f6b64;
  --panel: #fffdf8;
  --line: #ded8cc;
  --green: #1d8a5b;
  --red: #b23b3b;
  --amber: #b97917;
  --blue: #2f6fb0;
  --plum: #70508d;
  --shadow: 0 12px 30px rgba(28, 29, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-height: 40px;
  border: 1px solid #c9c0b4;
  border-radius: 8px;
  background: #fffaf1;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
}

button:hover {
  border-color: #958879;
}

button.primary {
  background: #1f6f55;
  border-color: #1f6f55;
  color: #ffffff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: #fff8ec;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.shell {
  width: min(1580px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 34px) 40px;
}

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

.stat {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
}

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

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

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

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(29, 138, 91, 0.12);
}

.org-chart {
  overflow-x: auto;
  padding: 18px;
}

.org-node {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
  max-width: 220px;
  border: 1px solid #cfc5b6;
  border-radius: 8px;
  background: #fffaf1;
  padding: 10px;
  vertical-align: top;
}

.org-node strong {
  font-size: 13px;
}

.org-node span {
  color: var(--muted);
  font-size: 11px;
}

.org-children {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #c7bbaa;
}

.agent-list,
.stack,
.timeline,
.content-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
}

.agent-row,
.item,
.event,
.content-card {
  min-width: 0;
  border: 1px solid #e3dccf;
  border-radius: 8px;
  background: #fffaf3;
  padding: 12px;
}

.agent-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.agent-row strong,
.item strong,
.content-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.agent-row p,
.item p,
.content-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.badge {
  align-self: start;
  border-radius: 999px;
  padding: 5px 8px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.idle,
.badge.completed,
.badge.published,
.badge.published_simulated,
.badge.approved,
.badge.healthy {
  background: var(--green);
}

.badge.working,
.badge.running,
.badge.in_progress,
.badge.copy_ready,
.badge.creative_ready,
.badge.strategy_ready {
  background: var(--blue);
}

.badge.manual_required,
.badge.queued {
  background: var(--amber);
}

.badge.error,
.badge.failed {
  background: var(--red);
}

.event {
  border-left: 4px solid var(--plum);
}

.event small {
  color: var(--muted);
  display: block;
  margin-top: 6px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid #e6ded2;
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #fff6e8;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
}

.metric-card {
  border: 1px solid #e3dccf;
  border-radius: 8px;
  background: #fffaf3;
  padding: 12px;
}

.metric-card strong {
  display: block;
  font-size: 18px;
}

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

.empty {
  color: var(--muted);
  padding: 14px;
}

@media (max-width: 1100px) {
  .grid.two,
  .grid.three,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .org-children {
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .actions {
    width: 100%;
  }
}
