:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f8;
  color: #17202a;
  --ink: #17202a;
  --muted: #68737d;
  --line: #dde3e8;
  --panel: #ffffff;
  --soft: #f0f4f7;
  --teal: #176b63;
  --teal-dark: #0f4e49;
  --coral: #c45a45;
  --gold: #b7832f;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #eef4f3 0, #f6f7f8 320px),
    #f6f7f8;
}

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

button {
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: progress;
  opacity: 0.62;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 56px;
  display: grid;
  gap: 22px;
}

.app-header {
  min-height: 210px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  padding: 28px;
  border: 1px solid rgba(23, 107, 99, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(23, 107, 99, 0.12), transparent 40%),
    linear-gradient(315deg, rgba(196, 90, 69, 0.12), transparent 36%),
    #ffffff;
  box-shadow: var(--shadow);
}

.brand-block {
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.3rem, 6vw, 4.9rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2,
h3 {
  margin-bottom: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1.08rem;
}

.lead {
  max-width: 700px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.header-meta {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.status-pill,
.mini-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.status-pill {
  max-width: 340px;
  padding: 10px 13px;
  color: #45515b;
  font-size: 0.94rem;
}

.mini-stat {
  min-width: 128px;
  padding: 14px;
  display: grid;
  gap: 2px;
  text-align: right;
}

.mini-stat span {
  font-size: 1.9rem;
  line-height: 1;
  font-weight: 900;
  color: var(--teal-dark);
}

.mini-stat small {
  color: var(--muted);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.86fr) minmax(460px, 1.14fr);
  gap: 18px;
  align-items: start;
}

.setup-column {
  display: grid;
  gap: 18px;
}

.surface,
.results-section,
.result-card,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.surface {
  padding: 18px;
}

.task-panel,
.manager-panel,
.team-panel {
  display: grid;
  gap: 14px;
}

.panel-title,
.section-head,
.agent-editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-head,
.agent-editor-head {
  justify-content: space-between;
}

.panel-title p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.panel-title.compact p {
  font-size: 0.9rem;
}

.title-icon {
  flex: 0 0 auto;
  min-width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  padding: 0 10px;
  color: #fff;
  background: var(--teal);
  font-size: 0.82rem;
  font-weight: 900;
}

label {
  font-size: 0.92rem;
  font-weight: 850;
  color: #2b343c;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd8df;
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fbfdfe;
  line-height: 1.55;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(23, 107, 99, 0.18);
  border-color: var(--teal);
  background: #ffffff;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  min-height: 48px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(23, 32, 42, 0.16);
}

.secondary-button {
  min-height: 40px;
  padding: 0 14px;
  color: #fff;
  background: var(--teal);
  white-space: nowrap;
}

.danger-button {
  min-height: 40px;
  padding: 0 14px;
  color: #fff;
  background: var(--coral);
  white-space: nowrap;
}

.model-select {
  min-height: 46px;
  cursor: pointer;
}

.history-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: #fff;
  background: var(--coral);
  font-size: 1.25rem;
  line-height: 1;
}

.agent-editor-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.agent-editor {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(190px, 1fr);
  gap: 10px 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.agent-editor-head {
  grid-column: 1 / -1;
}

.agent-editor strong {
  color: var(--teal-dark);
}

.results-section {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

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

.result-card {
  min-height: 152px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "num title"
    "num body";
  gap: 8px 14px;
  align-content: start;
  padding: 18px;
  box-shadow: none;
}

.result-card span {
  grid-area: num;
  min-width: 46px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  padding: 0 10px;
  color: #fff;
  background: var(--teal);
  font-weight: 900;
  font-size: 0.85rem;
}

.result-card h3,
.result-card h2 {
  grid-area: title;
  margin: 0;
}

.result-card p {
  grid-area: body;
  margin: 0;
  color: #4c5964;
  line-height: 1.62;
  white-space: pre-wrap;
}

.supervisor-card {
  border-color: rgba(196, 90, 69, 0.28);
  background:
    linear-gradient(90deg, rgba(196, 90, 69, 0.08), transparent 42%),
    #fff;
}

.supervisor-card span {
  background: var(--coral);
}

.summary-card {
  background:
    linear-gradient(90deg, rgba(183, 131, 47, 0.11), transparent 42%),
    #fff;
}

.summary-card span {
  background: var(--gold);
}

.history-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
  box-shadow: none;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.history-item strong {
  color: var(--ink);
}

.history-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.history-meta,
.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  margin: 0;
  padding: 12px;
  border: 1px dashed #cbd5dc;
  border-radius: 8px;
}

.result-card.is-loading {
  border-color: rgba(196, 90, 69, 0.6);
  box-shadow: inset 4px 0 0 var(--coral);
}

.result-card.is-done {
  border-color: rgba(23, 107, 99, 0.45);
  box-shadow: inset 4px 0 0 var(--teal);
}

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

  .setup-column {
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 1280px);
    padding-top: 18px;
  }

  .app-header,
  .setup-column,
  .agent-editor,
  .agent-board {
    grid-template-columns: 1fr;
  }

  .app-header {
    padding: 20px;
  }

  .header-meta {
    justify-items: stretch;
  }

  .mini-stat {
    text-align: left;
  }

  h1 {
    font-size: clamp(2.1rem, 13vw, 3.5rem);
  }

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

  .secondary-button {
    width: 100%;
  }
}
