/* Tokens follow DESIGN.md at the repo root. */
:root {
  --primary: #00BFA5;
  --primary-hover: #00A38C;
  --on-primary: #062A24;
  --canvas: #F8FAFC;
  --surface: #FFFFFF;
  --surface-subtle: #F8FAFC;
  --text: #0F172A;
  --text-2: #64748B;
  --border: #E2E8F0;
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --info: #4F46E5;
  --prod: #DC2626;
  --prod-soft: #FEF2F2;
  --sandbox-soft: #ECFDF8;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #00DFA2;
    --primary-hover: #00C48F;
    --canvas: #0B0F19;
    --surface: #111827;
    --surface-subtle: #0B0F19;
    --text: #F8FAFC;
    --text-2: #94A3B8;
    --border: #1F2937;
    --prod: #F87171;
    --prod-soft: #2A1215;
    --sandbox-soft: #062A24;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: Quicksand, system-ui, -apple-system, sans-serif;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.57;
  color: var(--text);
  background: var(--canvas);
  min-height: 100vh;
}
h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 12px; }
h2 { font-size: 1rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 16px; }
.muted { color: var(--text-2); }
.small { font-size: .75rem; }
code, .mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: .75rem; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.brand-sub { color: var(--text-2); font-weight: 700; padding-left: 8px; border-left: 1px solid var(--border); }
.who { display: flex; align-items: center; gap: 10px; font-size: .8rem; min-width: 0; }
.who #who-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- layout ---------- */
.login { display: grid; place-items: center; padding: 64px 16px; }
.login-card { width: 100%; max-width: 380px; }
.app { max-width: 920px; margin: 0 auto; padding: 24px 16px 64px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 24px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-between h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.invite-row { display: flex; gap: 12px; align-items: flex-end; }
.invite-row .grow { flex: 1; }
.invite-row .btn { margin-bottom: 14px; }
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .invite-row { flex-direction: column; align-items: stretch; }
  .brand-sub { display: none; }
  .topbar { padding: 10px 16px; }
  .who #who-email { display: none; }
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  font: inherit; font-weight: 700; color: var(--text-2); background: none; border: 0;
  padding: 10px 14px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }

/* ---------- forms ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 20px; }
legend {
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 10px; padding: 0;
}
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > span { font-size: .75rem; font-weight: 700; color: var(--text-2); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 4px; padding: 9px 12px; min-height: 40px; width: 100%;
}
textarea { resize: vertical; font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: .8rem; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent;
}
.code-input { font-size: 1.4rem; letter-spacing: .4em; text-align: center; font-weight: 700; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check input { width: 16px; height: 16px; min-height: 0; accent-color: var(--primary); }
.error { color: var(--error); font-weight: 600; min-height: 0; margin: 0 0 8px; }
.error:empty { display: none; }

/* environment picker */
.env-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.env-option {
  position: relative; display: block; border: 1.5px solid var(--border); border-radius: 6px;
  padding: 12px 14px; cursor: pointer; background: var(--surface);
}
.env-option input { position: absolute; opacity: 0; pointer-events: none; }
.env-option strong { display: block; font-weight: 800; }
.env-option small { color: var(--text-2); }
.env-option:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 1px; }
.env-option.sandbox:has(input:checked) { border-color: var(--primary); background: var(--sandbox-soft); }
.env-option.production:has(input:checked) { border-color: var(--prod); background: var(--prod-soft); }
.env-option.production:has(input:checked) strong { color: var(--prod); }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-size: .85rem; font-weight: 700; border-radius: 4px; height: 36px; padding: 0 14px;
  border: 1px solid transparent; cursor: pointer; display: inline-flex; white-space: nowrap; align-items: center; justify-content: center; gap: 6px;
}
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { background: var(--prod); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-subtle); }
.btn-ghost { background: none; color: var(--text-2); height: 30px; padding: 0 8px; }
.btn-ghost:hover { color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { height: 28px; font-size: .75rem; padding: 0 10px; }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--text-2); text-decoration: underline; cursor: pointer; }
.link:hover { color: var(--text); }
.login form .row-between { margin-top: 14px; }

/* ---------- pills / status ---------- */
.pill {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 9999px; background: var(--surface-subtle); color: var(--text-2);
  border: 1px solid var(--border); white-space: nowrap;
}
.pill.ok { background: var(--success); color: var(--on-primary); border-color: transparent; }
.pill.warn { background: var(--warning); color: #0F172A; border-color: transparent; }
.pill.bad { background: var(--error); color: #1F0909; border-color: transparent; }
.pill.run { background: var(--info); color: #fff; border-color: transparent; }
.pill.env-production { background: var(--prod-soft); color: var(--prod); border-color: var(--prod); }
.pill.env-sandbox { background: var(--sandbox-soft); color: var(--text); border-color: var(--primary); }

.mode-banner {
  background: var(--warning); color: #0F172A; font-weight: 700; font-size: .78rem;
  padding: 8px 12px; border-radius: 4px; margin-bottom: 12px;
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.table th {
  text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2);
  font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-subtle); }
.table td.nowrap { white-space: nowrap; }
.table td.actions-cell { text-align: right; white-space: nowrap; }

/* ---------- dialogs ---------- */
.dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
}
.dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog h2 { margin-bottom: 8px; }
.summary { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: .8rem; }
.summary th { text-align: left; color: var(--text-2); font-weight: 700; padding: 4px 12px 4px 0; vertical-align: top; width: 34%; }
.summary td { padding: 4px 0; word-break: break-word; }
.prod-warning {
  border: 1px solid var(--prod); background: var(--prod-soft); color: var(--prod);
  border-radius: 4px; padding: 10px 12px; font-weight: 700; margin-bottom: 8px;
}

.steps { list-style: none; padding: 0; margin: 12px 0; }
.steps li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.steps li:last-child { border-bottom: 0; }
.steps .icon { width: 16px; flex: none; text-align: center; font-weight: 800; }
.steps .done .icon { color: var(--success); }
.steps .failed .icon { color: var(--error); }
.steps .running .icon { color: var(--info); animation: pulse 1s infinite alternate; }
.steps .detail { color: var(--text-2); font-size: .75rem; display: block; }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }

.result {
  border: 1px solid var(--primary); background: var(--sandbox-soft); border-radius: 6px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.result strong { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 1.05rem; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 6px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px);
}
