:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-soft: #818cf8;
  --accent: #7c3aed;
  --dark: #0f172a;
  --dark-mid: #1e293b;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --white: #ffffff;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --emerald: #10b981;
  --amber: #f59e0b;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.7;
  color: var(--gray-700);
  background: var(--gray-50);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────── */
.site-header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--gray-200);
  padding: 0.6rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo { display: flex; align-items: center; text-decoration: none; gap: 0.5rem; }
.logo img { height: 44px; width: auto; }
.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  align-items: center;
}
.nav-links a {
  text-decoration: none;
  color: var(--gray-500);
  font-weight: 500;
  font-size: 0.88rem;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--primary); }
.nav-auth {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nav-auth a {
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-auth .signin { color: var(--gray-500); }
.nav-auth .signin:hover { color: var(--primary); }
.nav-auth .signup,
.nav-auth .btn-nav {
  background: var(--primary);
  color: var(--white);
  padding: 0.4rem 1rem;
  border-radius: 8px;
  font-weight: 600;
}
.nav-auth .signup:hover,
.nav-auth .btn-nav:hover {
  background: var(--accent);
  transform: translateY(-1px);
}
.nav-user-email {
  font-size: 0.82rem;
  color: var(--gray-500);
  font-weight: 500;
}

/* ── Main ───────────────────────────────── */
.site-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 1.5rem;
}
.site-main.center-v {
  align-items: center;
}
.site-main.wide {
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  display: block;
  padding: 2.5rem 24px;
}

/* ── Flash messages ─────────────────────── */
.flash-messages { margin-bottom: 1.25rem; max-width: 480px; width: 100%; }
.flash {
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}
.flash.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Auth card (login, register, forgot, reset) ─ */
.auth-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 440px;
  padding: 2.5rem 2rem;
}
.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: 0.25rem;
}
.auth-card .subtitle {
  font-size: 0.88rem;
  color: var(--gray-500);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.info-box {
  font-size: 0.82rem;
  color: #4b5563;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* ── Form elements ──────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.4rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  color: #111827;
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.form-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 1.5rem;
}
.form-row a {
  font-size: 0.82rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.pw-hint {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.3rem;
}
.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 1rem 0;
}
.checkbox-group input[type="checkbox"] { width: auto; margin-top: 0.25rem; }

/* ── Buttons ────────────────────────────── */
.btn-submit {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.btn-submit:hover { background: var(--accent); transform: translateY(-1px); }
.btn-submit:disabled { background: var(--gray-400); cursor: not-allowed; transform: none; }
.btn-secondary {
  display: inline-block;
  padding: 0.55rem 1.25rem;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-small {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 8px;
  background: var(--primary);
  color: var(--white);
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}
.btn-small:hover { background: var(--accent); }
.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover { background: #dc2626; }

/* ── Auth footer ────────────────────────── */
.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-100);
}
.auth-footer span { font-size: 0.88rem; color: var(--gray-500); }
.auth-footer a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* ── Content card (general pages) ───────── */
.content-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 600px;
  padding: 2rem 2rem;
}
.content-card h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: 0.5rem;
}
.content-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}
.content-card p { margin: 0.5rem 0; font-size: 0.92rem; }
.content-card a { color: var(--primary); text-decoration: none; font-weight: 500; }
.content-card a:hover { text-decoration: underline; }

/* ── Hub dashboard ──────────────────────── */
.hub-greeting {
  margin-bottom: 2rem;
}
.hub-greeting h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #111827;
}
.hub-greeting p {
  font-size: 0.92rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.svc-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: box-shadow 0.2s, transform 0.15s;
}
.svc-card:hover { box-shadow: 0 8px 30px rgba(0,0,0,0.08); transform: translateY(-2px); }
.svc-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.svc-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.svc-icon.vault { background: rgba(16,185,129,0.1); color: var(--emerald); }
.svc-icon.quantum { background: rgba(99,102,241,0.1); color: var(--primary); }
.svc-icon.automation { background: rgba(245,158,11,0.1); color: var(--amber); }
.svc-card-title { font-size: 1rem; font-weight: 700; color: #111827; }
.svc-card-desc { font-size: 0.85rem; color: var(--gray-500); line-height: 1.5; flex: 1; }
.svc-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.svc-badge.active { background: #ecfdf5; color: #065f46; }
.svc-badge.coming-soon { background: #fef3c7; color: #92400e; }
.svc-badge.pending { background: #eff6ff; color: #1e40af; }
.svc-card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}
.svc-card-actions a,
.svc-card-actions button {
  padding: 0.45rem 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.svc-btn-primary {
  background: var(--primary);
  color: var(--white);
}
.svc-btn-primary:hover { background: var(--accent); }
.svc-btn-emerald { background: var(--emerald); color: var(--white); }
.svc-btn-emerald:hover { background: #059669; }
.svc-btn-amber { background: var(--amber); color: var(--white); }
.svc-btn-amber:hover { background: #d97706; }
.svc-btn-outline {
  background: transparent;
  color: var(--gray-500);
  border: 1px solid var(--gray-200);
}
.svc-btn-outline:hover { border-color: var(--gray-400); color: var(--gray-700); }
.svc-btn-disabled {
  background: var(--gray-100);
  color: var(--gray-400);
  cursor: not-allowed;
}

/* ── Quick links row ────────────────────── */
.hub-quick {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.hub-quick a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-700);
  text-decoration: none;
  transition: all 0.2s;
}
.hub-quick a:hover { border-color: var(--primary-light); color: var(--primary); }

/* ── Tables ─────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.88rem;
}
.data-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 2px solid var(--gray-200);
}
.data-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}
.data-table code {
  font-size: 0.82rem;
  background: var(--gray-50);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

/* ── Detect / activate section ──────────── */
.detect-section { margin: 1rem 0; }
.detect-hint { font-size: 0.85rem; color: var(--gray-500); margin-top: 0.5rem; }
.detect-status { font-size: 0.85rem; margin-top: 0.5rem; color: #065f46; }
.detect-status.error { color: #991b1b; }
.detected-section {
  margin: 1rem 0;
  padding: 1rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
}
.detected-values p { margin: 0.25rem 0; font-size: 0.9rem; }
.manual-section details { margin-top: 1rem; }
.manual-section summary { cursor: pointer; color: var(--primary); font-size: 0.88rem; font-weight: 500; }

/* ── Token display ──────────────────────── */
.token-display { margin: 1rem 0; }
.token-display code {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  word-break: break-all;
  font-size: 0.88rem;
}

/* ── Legal ──────────────────────────────── */
.legal-doc {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  max-width: 740px;
  width: 100%;
  padding: 2.5rem 2rem;
}
.legal-doc h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-top: 0;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 0.75rem;
  color: #111827;
}
.legal-content h2 { font-size: 1.15rem; margin-top: 1.75rem; font-weight: 700; }
.legal-content h3 { font-size: 1rem; margin-top: 1rem; font-weight: 600; }
.legal-content p { margin: 0.5rem 0; font-size: 0.92rem; }
.legal-content ul, .legal-content ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.legal-content table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.legal-content th, .legal-content td { padding: 0.5rem; text-align: left; border: 1px solid var(--gray-200); font-size: 0.88rem; }
.legal-content th { background: var(--gray-50); font-weight: 600; }
.legal-doc > p { margin-top: 1.5rem; }
.legal-doc a { color: var(--primary); text-decoration: none; font-weight: 500; }

/* ── Admin ──────────────────────────────── */
.admin-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  padding: 2rem;
  max-width: 800px;
  width: 100%;
}
.admin-card h1 { font-size: 1.4rem; font-weight: 800; color: #111827; margin-bottom: 0.5rem; }
.admin-card p { font-size: 0.92rem; color: var(--gray-500); margin-bottom: 1rem; }

/* ── Pending approval ───────────────────── */
.pending-card {
  text-align: center;
  padding: 3rem 2rem;
}
.pending-card .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}
.pending-card h1 { margin-bottom: 0.75rem; }
.pending-card p { color: var(--gray-500); font-size: 0.92rem; max-width: 400px; margin: 0 auto; }

/* ── Footer ─────────────────────────────── */
.site-footer {
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: 1.25rem 0;
  text-align: center;
}
.site-footer p {
  font-size: 0.78rem;
  color: var(--gray-400);
}
.site-footer a {
  color: var(--gray-500);
  text-decoration: none;
  font-weight: 500;
}
.site-footer a:hover { color: var(--primary); }

/* ── Responsive ─────────────────────────── */
@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .nav-links { gap: 1rem; }
  .auth-card, .content-card { padding: 1.75rem 1.25rem; }
  .hub-grid { grid-template-columns: 1fr; }
  .form-row-2 { grid-template-columns: 1fr; }
  .hub-quick { flex-direction: column; }
}
