:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #b45309;
  --primary-dark: #92400e;
  --danger: #b91c1c;
  --success: #047857;
  --warning: #a16207;
  color-scheme: light dark;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.nav-divider {
  width: 1px;
  align-self: stretch;
  margin: 0.35rem 0;
  background: var(--border);
}
.inline-form { display: inline; margin: 0; }
.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary-dark);
  cursor: pointer;
  font: inherit;
}
.link-button:hover { text-decoration: underline; }

.container {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

.main-content { padding: 2rem 0 4rem; }

h1 { font-size: 1.6rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin: 1rem 0;
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.row-tight { gap: 0.5rem; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.stack > * + * { margin-top: 1rem; }

label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.inline-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  margin-bottom: 0;
}
input[type="checkbox"], input[type="radio"] { width: auto; }
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent);
  outline-offset: 1px;
}
.field { margin-bottom: 1rem; }
.field-note { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.hidden { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-small { padding: 0.3rem 0.55rem; font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tbody tr:hover { background: #f8fafc; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #f1f5f9;
  text-transform: capitalize;
}
.badge-active { background: #ecfdf5; border-color: #a7f3d0; color: var(--success); }
.badge-needs_reauth, .badge-error, .badge-pending { background: #fffbeb; border-color: #fde68a; color: var(--warning); }
.badge-disabled, .badge-revoked { background: #fef2f2; border-color: #fecaca; color: var(--danger); }

.alert {
  border-radius: 0.6rem;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  border: 1px solid var(--border);
}
.alert-error { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #78350f; }

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}

.token-box {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 0.6rem;
  padding: 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
}

.kv { display: grid; grid-template-columns: minmax(9rem, auto) 1fr; gap: 0.35rem 1rem; }
.kv dt { color: var(--muted); font-size: 0.85rem; }
.kv dd { margin: 0; word-break: break-word; }

.note {
  border-left: 3px solid var(--primary);
  background: #fffbeb;
  padding: 0.65rem 0.8rem;
  border-radius: 0.25rem;
  font-size: 0.9rem;
}

.filter-bar { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: end; }
.filter-bar .field { margin-bottom: 0; min-width: 180px; }

.template-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 0.5rem;
}
.template-list .card { margin: 0; width: 100%; }
.template-list .card .spread { align-items: flex-start; }
.template-list .card .spread > div { min-width: 0; }

.section-heading { margin-top: 2rem; }

.landing-hero { max-width: 46rem; padding: 3rem 0 1rem; }
.landing-hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.15;
  margin-bottom: 1rem;
}
.landing-hero .lead {
  font-size: 1.1rem;
  max-width: 42rem;
  margin: 0 0 1.5rem;
}
.landing-section { margin-top: 2.5rem; }
.landing-section h2 { margin-top: 0; }
.landing-section h3 { margin: 0; font-size: 1.05rem; }
.landing-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}
.landing-list li + li { margin-top: 0.35rem; }
.price { font-size: 1.6rem; font-weight: 700; white-space: nowrap; }
.price span {
  margin-left: 0.15rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.method-card { padding: 0; }
.method-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.method-card > summary::-webkit-details-marker { display: none; }
.method-card > summary:hover { background: #f8fafc; border-radius: 0.75rem; }
.method-card > summary:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent);
  outline-offset: -2px;
  border-radius: 0.75rem;
}
.method-summary-text { display: flex; flex-direction: column; gap: 0.15rem; }
.method-card-body { padding: 0 1.25rem 1.25rem; }
.chevron::before { content: "▸"; color: var(--muted); display: inline-block; }
.method-card[open] .chevron::before { content: "▾"; }


/* Hosted connect page: standalone, embeddable, no console navigation. */
.connect-body { background: #f8fafc; min-height: 100vh; }
.connect-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.connect-card { width: 100%; max-width: 30rem; margin: 0; }
.connect-heading h1 { margin: 0.35rem 0 0.25rem; }
.connect-heading { margin-bottom: 1rem; }
.connect-expiry { margin-top: 1.25rem; margin-bottom: 0; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --border: #263244;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --primary: #b45309;
    --primary-dark: #f59e0b;
    --danger: #f87171;
    --success: #34d399;
    --warning: #fbbf24;
    color-scheme: dark;
  }

  .btn:hover { background: #1f2937; }
  .method-card > summary:hover { background: #172033; }
  tbody tr:hover { background: #172033; }
  .badge { background: #1f2937; }
  .badge-active {
    background: #052e23;
    border-color: #065f46;
    color: #6ee7b7;
  }
  .badge-needs_reauth, .badge-error, .badge-pending {
    background: #3b2f0b;
    border-color: #a16207;
    color: #fde68a;
  }
  .badge-disabled, .badge-revoked {
    background: #3f1d1d;
    border-color: #991b1b;
    color: #fca5a5;
  }
  .alert-error {
    background: #3f1d1d;
    border-color: #7f1d1d;
    color: #fecaca;
  }
  .alert-success {
    background: #052e23;
    border-color: #065f46;
    color: #a7f3d0;
  }
  .alert-warning, .note { background: #2b2415; }
  .alert-warning {
    border-color: #a16207;
    color: #fde68a;
  }
  .token-box { background: #020617; color: #e2e8f0; }
  .connect-body { background: var(--bg); }
}
