:root {
  --bg: #f5f8fd;
  --surface: #ffffff;
  --ink: #12253f;
  --muted: #607089;
  --line: #dbe4f2;
  --brand: #1e4ed9;
  --brand-dark: #153ca8;
  --accent: #0f9488;
  --warn: #b45309;
  --danger: #b91c1c;
  --success: #166534;
  --shadow: 0 18px 40px rgba(14, 35, 80, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: linear-gradient(180deg, #f9fbff 0%, #f2f6fd 100%);
  color: var(--ink);
  font-family: Manrope, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Loading Overlay ── */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(249, 251, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-overlay[hidden] {
  display: none;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Topbar ── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(249, 251, 255, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.logo {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 16px;
}

.nav-links {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.nav-links a:hover {
  color: var(--ink);
}

.session-meta {
  color: var(--muted);
  font-size: 14px;
}

/* ── Layout ── */

.main-shell {
  padding: 32px 20px 56px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

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

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 10px 0 10px;
}

h2 {
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 10px 0;
}

.sub,
.muted {
  color: var(--muted);
}

.hero-side {
  display: grid;
  gap: 12px;
}

.mini-stat,
.summary-card,
.list-card,
.message {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.mini-stat {
  padding: 14px;
}

.mini-stat strong {
  display: block;
  margin-bottom: 6px;
}

.mini-stat span {
  color: var(--muted);
  font-size: 14px;
}

/* ── Grid ── */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

/* ── Forms ── */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid label {
  display: grid;
  gap: 8px;
}

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

.form-grid span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea,
.btn {
  font: inherit;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(30, 78, 217, 0.1);
}

textarea {
  resize: vertical;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  transition: background 0.15s, border-color 0.15s;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

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

.btn.danger {
  background: #fff;
  border-color: var(--danger);
  color: var(--danger);
}

.btn.danger:hover:not(:disabled) {
  background: #fef2f2;
}

.btn.ghost:hover:not(:disabled) {
  border-color: var(--brand);
}

/* ── Messages ── */

.message {
  padding: 12px 14px;
  margin-top: 14px;
  color: var(--muted);
}

.message[hidden] {
  display: none;
}

.message.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--success);
}

.message.warn {
  border-color: #fde68a;
  background: #fffbeb;
  color: var(--warn);
}

.message.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

/* ── Summary Card ── */

.summary-card {
  padding: 14px;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

/* ── Actions Row ── */

.actions-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ── List Stack ── */

.list-stack {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.list-card {
  padding: 16px;
}

.list-card h3 {
  margin-bottom: 6px;
  font-size: 18px;
}

.list-card.empty {
  color: var(--muted);
}

/* ── Pills ── */

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pill {
  background: #edf3ff;
  color: #1d4188;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
}

.pill-success {
  background: #f0fdf4;
  color: var(--success);
}

.pill-warn {
  background: #fffbeb;
  color: var(--warn);
}

.pill-danger {
  background: #fef2f2;
  color: var(--danger);
}

.pill-info {
  background: #edf3ff;
  color: var(--brand);
}

.pill-muted {
  background: #f1f5f9;
  color: var(--muted);
}

/* ── Stack List ── */

.stack-list {
  margin: 0;
  padding-left: 18px;
}

.stack-list li {
  margin-bottom: 6px;
  line-height: 1.5;
}

/* ── Queue Meta ── */

.queue-meta {
  margin: 10px 0 0;
  color: var(--muted);
}

/* ── Admin ── */

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.admin-actions label {
  display: grid;
  gap: 8px;
}

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

.admin-actions span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
}

.admin-button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Bounty Card (agent board) ── */

.bounty-card {
  border-left: 3px solid var(--brand);
}

/* ── Auth Layout ── */

.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  min-height: calc(100vh - 200px);
}

.auth-hero {
  padding: 20px 0;
}

.auth-hero h1 {
  font-size: clamp(26px, 3.5vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 12px 0 14px;
}

.auth-hero .sub {
  font-size: 15px;
  line-height: 1.6;
  max-width: 440px;
}

.auth-hero-features {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.auth-feature {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.auth-feature-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-feature strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.auth-feature span {
  font-size: 13px;
  color: var(--muted);
}

/* ── Auth Cards ── */

.auth-card-wrap {
  display: flex;
  justify-content: center;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  animation: authFadeIn 0.3s ease-out;
}

.auth-card[hidden] {
  display: none;
}

@keyframes authFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-card h2 {
  font-size: 24px;
  margin-bottom: 4px;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.auth-form label {
  display: grid;
  gap: 6px;
}

.auth-form label span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
}

.auth-switch {
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

.auth-switch a {
  color: var(--brand);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}

.auth-switch a:hover {
  text-decoration-color: var(--brand);
}

.btn.full {
  width: 100%;
}

/* ── Role Picker ── */

.role-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 4px;
}

.role-option {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}

.role-option:hover {
  border-color: var(--brand);
  background: #f8faff;
}

.role-option.selected {
  border-color: var(--brand);
  background: #edf3ff;
}

.role-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.role-option strong {
  display: block;
  font-size: 14px;
  margin-bottom: 1px;
}

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

/* ── Welcome Banner ── */

.welcome-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-radius: 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  margin-bottom: 18px;
  animation: authFadeIn 0.4s ease-out;
}

.welcome-banner[hidden] {
  display: none;
}

.welcome-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.welcome-content strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}

.welcome-content span {
  font-size: 14px;
  color: var(--muted);
}

.welcome-dismiss {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-dismiss:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* ── Signup Success ── */

.success-card {
  max-width: 540px;
  margin: 0 auto;
  text-align: center;
  padding: 40px 32px;
  animation: successFadeIn 0.4s ease-out;
}

@keyframes successFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.success-icon {
  margin-bottom: 20px;
}

.success-title {
  font-size: 36px;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  color: var(--ink);
}

.success-sub {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 32px;
}

.success-steps {
  text-align: left;
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 380px;
}

.success-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.success-step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-step strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.success-step p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* ── Responsive ── */

@media (max-width: 900px) {
  .hero,
  .grid,
  .form-grid,
  .admin-actions {
    grid-template-columns: 1fr;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    gap: 24px;
    min-height: auto;
  }

  .auth-hero {
    text-align: center;
  }

  .auth-hero .sub {
    max-width: none;
  }

  .auth-hero-features {
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
  }

  .auth-card {
    max-width: 480px;
  }
}

@media (max-width: 640px) {
  .nav-links {
    display: none;
  }

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

  .main-shell {
    padding-top: 20px;
  }

  .role-picker {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 24px 20px;
  }
}
