:root {
  --bg: #f7f5ef;
  --ink: #16201d;
  --muted: #64716b;
  --panel: #fffdf8;
  --line: #ded8cb;
  --brand: #0f6b5f;
  --brand-dark: #09483f;
  --accent: #d94f30;
  --amber: #e2a72e;
  --sky: #2f6fa3;
  --shadow: 0 18px 45px rgba(22, 32, 29, 0.09);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 34px clamp(18px, 4vw, 54px) 22px;
  background: #17352f;
  color: #fffdf8;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(36px, 7vw, 68px);
  line-height: 0.92;
  letter-spacing: 0;
}

.subtitle {
  max-width: 650px;
  margin: 12px 0 0;
  color: #d9e2dc;
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-header .eyebrow {
  color: #f2b66f;
}

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

main {
  padding: 24px clamp(14px, 4vw, 54px) 48px;
}

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

.metrics-grid article,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics-grid article {
  min-height: 108px;
  padding: 18px;
}

.metrics-grid span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

.metrics-grid strong {
  font-size: 34px;
  line-height: 1;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 22px 0;
  overflow-x: auto;
  padding-bottom: 3px;
}

.tab,
.ghost,
.primary,
.script-btn,
.action-link {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  text-decoration: none;
  white-space: nowrap;
}

.tab {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.split {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
}

.panel-heading {
  align-items: flex-start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-heading h2 {
  font-size: 22px;
  line-height: 1.12;
  margin: 0;
}

.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 800;
}

.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.primary:hover {
  background: var(--brand-dark);
}

.file-button input {
  display: none;
}

.hidden-field {
  height: 0;
  left: -9999px;
  margin: 0;
  overflow: hidden;
  position: absolute;
  width: 0;
}

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

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

label,
fieldset {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 800;
  gap: 7px;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend {
  margin-bottom: 8px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.readonly-box {
  background: #fdf8ea;
  min-height: 170px;
}

.readonly-box.tall {
  min-height: 270px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  gap: 7px;
  padding: 8px 10px;
}

.chip input {
  min-height: auto;
  width: auto;
}

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

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 14px;
}

.item-top {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.item h3 {
  font-size: 17px;
  margin: 0;
}

.item p {
  color: var(--muted);
  margin: 0;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  background: #eef5f2;
  border-radius: 999px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 8px;
}

.badge.hot {
  background: #fff0d0;
  color: #885300;
}

.badge.warn {
  background: #ffe7df;
  color: #91321b;
}

.small-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.small-actions button,
.small-actions a {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 10px;
  text-decoration: none;
}

.flow-list {
  color: var(--muted);
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 22px;
}

.flow-list strong {
  color: var(--ink);
}

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

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.match-controls {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr auto;
}

.people-filter,
.dispatch-actions,
.sandbox-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 14px;
}

.dispatch-actions,
.sandbox-actions {
  grid-template-columns: auto auto;
  justify-content: start;
  margin-bottom: 0;
  margin-top: 12px;
}

.sandbox-actions {
  grid-template-columns: repeat(4, auto);
}

.sandbox-metrics {
  margin-top: 18px;
}

.note {
  color: var(--muted);
  font-size: 13px;
  margin: 12px 0 0;
}

.growth-plan {
  display: grid;
  gap: 12px;
}

.growth-card {
  border-left: 5px solid var(--brand);
  padding: 6px 0 6px 14px;
}

.growth-card:nth-child(2) {
  border-color: var(--accent);
}

.growth-card:nth-child(3) {
  border-color: var(--sky);
}

.growth-card:nth-child(4) {
  border-color: var(--amber);
}

.growth-card h3 {
  margin: 0 0 5px;
}

.growth-card p {
  color: var(--muted);
  margin: 0;
}

.script-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.script-btn {
  background: #fff;
  border-color: var(--line);
  font-weight: 800;
}

.script-btn.active {
  background: var(--ink);
  color: #fff;
}

.toast {
  background: var(--ink);
  border-radius: 8px;
  bottom: 20px;
  color: #fff;
  left: 50%;
  opacity: 0;
  padding: 12px 16px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.access-gate {
  align-items: center;
  background: #17352f;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 50;
}

.access-gate.unlocked {
  display: none;
}

.access-card {
  max-width: 430px;
  width: 100%;
}

.access-card h2 {
  margin: 0 0 8px;
}

.access-card p {
  color: var(--muted);
}

.signup-page {
  background: #17352f;
}

.signup-shell {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 0.85fr) minmax(320px, 1fr);
  min-height: 100vh;
  padding: clamp(18px, 5vw, 56px);
}

.signup-hero {
  align-self: center;
  color: #fffdf8;
  max-width: 620px;
}

.signup-hero h1 {
  font-size: clamp(38px, 7vw, 76px);
  line-height: 0.94;
  margin: 0 0 18px;
}

.signup-hero p:last-child {
  color: #d9e2dc;
  font-size: 19px;
  line-height: 1.45;
  margin: 0;
}

.signup-form {
  align-self: center;
}

.thanks-shell {
  grid-template-columns: minmax(0, 720px);
  justify-content: center;
}

.thanks-action {
  margin-top: 24px;
}

.consent {
  align-items: flex-start;
  border-radius: 8px;
  line-height: 1.35;
}

.modal {
  align-items: center;
  background: rgba(10, 18, 16, 0.66);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 20;
}

.modal.show {
  display: flex;
}

.modal-card {
  max-width: 620px;
  width: 100%;
}

.modal-card h2 {
  margin: 0 0 8px;
}

.modal-card p {
  color: var(--muted);
}

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

@media (max-width: 900px) {
  .app-header,
  .split,
  .match-controls,
  .people-filter,
  .sandbox-actions,
  .signup-shell {
    grid-template-columns: 1fr;
  }

  .app-header {
    display: grid;
  }

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

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

  .signup-shell {
    min-height: auto;
  }
}

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

  .panel {
    padding: 16px;
  }

  .panel-heading {
    display: grid;
  }
}
