/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand-dark: #2D2926;
  --brand-charcoal: #4A4543;
  --warm-gray: #8A8280;
  --warm-light: #C8C3BF;
  --off-white: #F5F3F1;
  --surface: #FFFFFF;
  --accent: #77736A;
  --accent-hover: #635F57;
  --success: #10B981;
  --amber: #F59E0B;
  --error: #DC2626;
  --chat-user: #77736A;
  --chat-bot: #F5F3F1;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-w: 200px;
  --header-h: 56px;
  --tabbar-h: 60px;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--off-white);
  color: var(--brand-dark);
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }
#app { height: 100%; position: relative; }

/* ── Utility ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Screens (pre-portal, full page) ─────────────────────────────────── */
.screen {
  display: none;
  height: 100%;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.screen.active { display: flex; }

/* Loading */
.brand-loading { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.loading-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--warm-light);
  border-top-color: var(--brand-charcoal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pre-portal cards (landing, error, login) */
.pre-portal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 36px;
  text-align: center;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}
.pre-portal-card h2 { font-size: 20px; margin-bottom: 12px; }
.pre-portal-card p { color: var(--warm-gray); font-size: 15px; line-height: 1.6; margin-bottom: 8px; }
.error-title { color: var(--error); }
.hint { font-size: 13px !important; color: var(--warm-light) !important; margin-top: 16px !important; }

/* Logo images */
.logo-full {
  display: block;
  max-width: 220px;
  height: auto;
  margin: 0 auto 20px;
}
.logo-header {
  display: block;
  height: 28px;
  width: auto;
}
.logo-mark {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
}

/* ── Landing page (background image + lookup form) ───────────────────── */
.landing-screen {
  position: relative;
  overflow: hidden;
}
.landing-bg {
  position: absolute;
  inset: 0;
  background: var(--brand-dark) url('/landing-bg.png') center center / cover no-repeat;
  z-index: 0;
}
.landing-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(45, 41, 38, 0.82) 0%,
    rgba(74, 69, 67, 0.72) 50%,
    rgba(45, 41, 38, 0.80) 100%
  );
  z-index: 1;
}
.landing-card {
  position: relative;
  z-index: 2;
  max-width: 460px;
  backdrop-filter: blur(4px);
  background: rgba(255, 255, 255, 0.95);
}
.landing-tagline {
  color: var(--brand-dark) !important;
  font-weight: 500 !important;
  font-size: 16px !important;
  margin-bottom: 20px !important;
}

/* Lookup form */
.lookup-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}
.lookup-input {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 15px;
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
  text-align: left;
  color: var(--brand-dark);
  background: var(--surface);
}
.lookup-input:focus {
  border-color: var(--brand-charcoal);
  box-shadow: 0 0 0 3px rgba(74, 69, 67, 0.1);
}
.lookup-input::placeholder { color: var(--warm-light); }
.btn-lookup {
  width: 100%;
  padding: 14px 24px !important;
  font-size: 15px !important;
  justify-content: center;
}
.btn-lookup:disabled {
  opacity: 0.6;
  cursor: wait;
}
.lookup-error {
  color: var(--warm-gray) !important;
  font-size: 14px !important;
  margin-top: 12px !important;
  padding: 10px 14px;
  background: var(--off-white);
  border-radius: var(--radius-sm);
}

/* Portal cards (lookup results) */
.portal-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.portal-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--off-white);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--brand-dark);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.portal-card:hover {
  border-color: var(--brand-charcoal);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.portal-card-info { text-align: left; }
.portal-card-company {
  font-size: 15px;
  font-weight: 600;
  color: var(--brand-dark);
  margin-bottom: 2px;
}
.portal-card-title {
  font-size: 13px;
  color: var(--warm-gray);
}
.portal-card-arrow {
  color: var(--warm-gray);
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}
.portal-card:hover .portal-card-arrow {
  color: var(--brand-dark);
  transform: translateX(3px);
}

/* Brand name styling (legacy — kept for any remaining references) */
.brand-name { font-weight: 600; font-size: 18px; color: var(--brand-dark); letter-spacing: -0.02em; }
.brand-ai { color: var(--accent); }

/* ── Login screen ─────────────────────────────────────────────────────── */
.login-card { max-width: 420px; }
.login-client {
  font-size: 16px !important;
  font-weight: 600 !important;
  color: var(--brand-dark) !important;
  margin-bottom: 4px !important;
}

.login-state { margin-top: 8px; }

.login-subtitle {
  font-size: 14px !important;
  color: var(--warm-gray) !important;
  margin-bottom: 20px !important;
}

.btn-login {
  width: 100%;
  padding: 12px 24px !important;
  font-size: 15px !important;
  justify-content: center;
  margin-top: 8px;
}

.btn-text-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  padding: 4px 0;
  margin-bottom: 16px;
  display: inline-block;
}
.btn-text-back:hover { text-decoration: underline; }

/* Method buttons */
.methods-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.method-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.method-btn:hover { border-color: var(--accent); background: #F5F4F2; }
.method-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.method-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--off-white);
  border-radius: var(--radius-sm);
  font-size: 20px;
  flex-shrink: 0;
}

.method-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.method-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--brand-dark);
}
.method-masked {
  font-size: 13px;
  color: var(--warm-gray);
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  letter-spacing: 0.02em;
}

/* Code entry */
.code-sent-label {
  font-size: 13px !important;
  color: var(--warm-gray) !important;
  margin-bottom: 16px !important;
}

.code-input {
  display: block;
  width: 100%;
  max-width: 220px;
  margin: 0 auto 16px;
  padding: 14px 16px;
  font-size: 28px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.25em;
  border: 2px solid var(--warm-light);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--brand-dark);
  transition: border-color 0.15s;
}
.code-input:focus { border-color: var(--accent); }
.code-input::placeholder { color: var(--warm-light); font-weight: 400; letter-spacing: 0.25em; }

.btn-text-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  padding: 8px 0;
  margin-top: 4px;
  display: inline-block;
}
.btn-text-link:hover { text-decoration: underline; }
.btn-text-link:disabled { color: var(--warm-light); cursor: not-allowed; text-decoration: none; }

/* Login error */
.login-error {
  background: #FEF2F2;
  color: var(--error);
  font-size: 13px !important;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 12px !important;
  margin-bottom: 0 !important;
}

.login-hint {
  font-size: 14px;
  color: var(--warm-gray);
  padding: 16px 0;
}

/* ── Portal shell ────────────────────────────────────────────────────── */
.portal { display: flex; flex-direction: column; height: 100%; }
.portal.hidden { display: none; }

/* Header */
.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
  z-index: 10;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-client { font-size: 14px; color: var(--warm-gray); font-weight: 500; }

/* Body */
.portal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.portal-sidebar {
  width: var(--sidebar-w);
  background: var(--brand-dark);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--warm-light);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--off-white); }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; }

/* Content */
.portal-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Views */
.view { display: none; height: 100%; }
.view.active { display: flex; flex-direction: column; }

/* Bottom tab bar (mobile only) */
.portal-tabbar {
  display: none;
  height: var(--tabbar-h);
  background: var(--surface);
  border-top: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--warm-gray);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
}
.tab-item.active { color: var(--accent); }

/* ── Home view ───────────────────────────────────────────────────────── */
#view-home { padding: 32px; gap: 24px; overflow-y: auto; }

.view-header h1 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.view-subtitle { color: var(--warm-gray); font-size: 14px; }

.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--warm-gray);
  margin-bottom: 12px;
}

.card-task h3 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.card-desc { font-size: 13px; color: var(--warm-gray); margin-bottom: 16px; }

.progress-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.progress-bar {
  flex: 1; height: 6px;
  background: var(--off-white);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-sm { width: 80px; flex: none; }
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.progress-text { font-size: 12px; color: var(--warm-gray); font-weight: 500; min-width: 28px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary.btn-completed {
  background: var(--success);
  cursor: default;
  pointer-events: none;
}

.btn-primary.btn-locked {
  background: var(--warm-light);
  color: var(--warm-gray);
  cursor: not-allowed;
  pointer-events: none;
  font-size: 12px;
}

/* ── Locked card (onboarding gated behind discovery) ─────────────────── */
.card-locked {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

/* ── Locked nav item ─────────────────────────────────────────────────── */
.nav-item.nav-locked {
  opacity: 0.35;
  pointer-events: none;
  cursor: not-allowed;
}
.tab-item.nav-locked {
  opacity: 0.35;
  pointer-events: none;
  cursor: not-allowed;
}

.team-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--off-white); }
.team-row:last-child { border-bottom: none; }
.team-label { font-size: 13px; color: var(--warm-gray); }
.team-value { font-size: 13px; font-weight: 500; }

.status-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
}
.status-active { background: #F0EFED; color: var(--accent); }
.status-complete { background: #ECFDF5; color: var(--success); }

.card-next { grid-column: 1 / -1; }
.next-steps { list-style: none; counter-reset: step; padding: 0; }
.step {
  position: relative;
  padding: 8px 0 8px 32px;
  font-size: 14px;
  color: var(--warm-gray);
  counter-increment: step;
}
.step::before {
  content: counter(step);
  position: absolute;
  left: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--off-white);
  color: var(--warm-gray);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step.active-step { color: var(--brand-dark); font-weight: 500; }
.step.active-step::before { background: var(--accent); color: #fff; }
.step.done-step { color: var(--warm-gray); }
.step.done-step::before { background: var(--success); color: #fff; content: '\2713'; }

/* Placeholder card */
.placeholder-card {
  text-align: center;
  padding: 48px 32px;
}
.placeholder-icon { color: var(--warm-light); margin-bottom: 16px; }
.placeholder-card h3 { font-size: 18px; margin-bottom: 8px; color: var(--warm-gray); }
.placeholder-card p { font-size: 14px; color: var(--warm-light); line-height: 1.5; max-width: 400px; margin: 0 auto; }

/* ── Session views (chat) ────────────────────────────────────────────── */
#view-discovery, #view-onboarding { padding: 0; }

.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: var(--surface);
  flex-shrink: 0;
}
.btn-back {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.btn-back:hover { background: var(--off-white); }
.session-title { font-size: 14px; font-weight: 600; }
.session-progress { display: flex; align-items: center; gap: 8px; }

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.message-user {
  background: var(--chat-user);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.message-bot {
  background: var(--chat-bot);
  color: var(--brand-dark);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.message-bot p {
  margin: 0 0 0.6em 0;
  line-height: 1.5;
}
.message-bot p:last-child {
  margin-bottom: 0;
}
.message-bot strong {
  font-weight: 600;
}
.message-bot em {
  font-style: italic;
}
.message-bot code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Typing indicator */
.typing-indicator {
  padding: 8px 16px;
  display: flex;
  gap: 4px;
  align-self: flex-start;
}
.typing-indicator.hidden { display: none; }
.typing-indicator span {
  width: 8px; height: 8px;
  background: var(--warm-gray);
  border-radius: 50%;
  opacity: 0.4;
  animation: typing 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.4; transform: scale(1); } 30% { opacity: 1; transform: scale(1.2); } }

/* Input */
.input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}
#message-input, .chat-input {
  flex: 1;
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 15px;
  font-family: var(--font);
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s;
  background: var(--surface);
}
#message-input:focus, .chat-input:focus { border-color: var(--accent); }
#message-input::placeholder, .chat-input::placeholder { color: var(--warm-light); }

.btn-send {
  width: 42px; height: 42px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }

/* Complete option buttons (injected by JS) */
.complete-options {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.btn-finish {
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
}
.btn-finish:hover { filter: brightness(0.95); }
.btn-continue {
  background: none;
  color: var(--warm-gray);
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
}
.btn-continue:hover { background: var(--off-white); }

/* ── Buy page ────────────────────────────────────────────────────────── */
#view-buy { padding: 0; overflow-y: auto; }
.buy-page-wrapper {
  padding: 32px;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Identity Banner */
.identity-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.identity-label { color: var(--warm-gray); }
.identity-name  { font-weight: 600; color: var(--brand-dark); }
.identity-title { color: var(--warm-gray); font-size: 13px; }
.identity-email { color: var(--warm-gray); }

/* Agreements Card */
.agreements-card { margin-bottom: 0; }
.agreements-intro { color: var(--warm-gray); font-size: 14px; margin-bottom: 16px; }
.agreement-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.agreement-row:hover { border-color: var(--warm-gray); background: #FAFAFA; }
.agreement-row input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--success);
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
}
.agreement-text { font-size: 14px; color: var(--brand-dark); line-height: 1.5; }
.doc-link { color: var(--accent); text-decoration: underline; cursor: pointer; }
.doc-link:hover { color: var(--accent-hover); }

/* Proceed Button */
.proceed-row { margin-top: 4px; }
.btn-proceed {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  transition: opacity 0.2s, background 0.2s;
}
.btn-proceed:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: var(--warm-gray);
}
.proceed-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--warm-light);
  text-align: center;
  line-height: 1.5;
}
.proceed-code-note {
  margin-top: 6px;
  font-size: 13px;
  color: var(--warm-gray);
  text-align: center;
  line-height: 1.5;
}

/* Price Card */
.price-card {
  text-align: center;
  padding: 24px 20px;
}
.price-loading {
  font-size: 14px;
  color: var(--warm-gray);
}
.price-product-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 4px;
}
.price-product-desc {
  font-size: 14px;
  color: var(--warm-gray);
  margin-bottom: 12px;
}
.price-amount {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.price-error {
  font-size: 14px;
  color: var(--warm-gray);
}

/* Promo Code Callout */
.promo-code-callout {
  background: #FEF9EF;
  border: 1px solid #F5DFA8;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 14px;
  color: #7A6520;
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.5;
  font-weight: 500;
}
.promo-icon {
  margin-right: 4px;
}

/* Identity banner — editable */
.identity-display {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}
.identity-edit-link {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  margin-left: auto;
}
.identity-edit-link:hover { color: var(--accent-hover); }
.identity-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.identity-edit-fields {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.identity-input {
  flex: 1;
  min-width: 140px;
  padding: 8px 12px;
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--brand-dark);
  background: var(--surface);
}
.identity-input:focus {
  outline: none;
  border-color: var(--accent);
}
.identity-edit-actions {
  display: flex;
  gap: 8px;
}
.btn-small {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: none;
}
.btn-small.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-small.btn-primary:hover { background: var(--accent-hover); }
.btn-small.btn-ghost {
  background: transparent;
  color: var(--warm-gray);
  border: 1px solid var(--warm-light);
}
.btn-small.btn-ghost:hover { background: #F5F5F5; }

/* Discovery Intro Form */
.discovery-intro {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.discovery-intro-inner {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}
.discovery-intro-inner h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--brand-dark);
  margin-bottom: 8px;
}
.discovery-intro-text {
  font-size: 14px;
  color: var(--warm-gray);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Company Info Card (Buy page) */
.company-info-card { margin-bottom: 0; }
.company-info-intro { color: var(--warm-gray); font-size: 14px; margin-bottom: 16px; }
.company-fields { display: flex; flex-direction: column; gap: 12px; }
.company-field { display: flex; flex-direction: column; gap: 4px; }
.company-field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-dark);
}
.field-req { color: var(--error); }
.company-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--brand-dark);
  outline: none;
  transition: border-color 0.15s;
}
.company-input:focus { border-color: var(--accent); }
.company-input::placeholder { color: var(--warm-light); }
.company-field-row {
  display: flex;
  gap: 12px;
}
.company-field-row .company-field { flex: 1; }

/* Authorized Representative Statement */
.auth-rep-statement {
  font-size: 13px;
  line-height: 1.6;
  color: var(--brand-charcoal);
  padding: 14px 16px;
  background: #FAF9F8;
  border: 1px solid var(--warm-light);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

/* Document Modal Overlay */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
body.modal-open { overflow: hidden; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; }
.doc-version {
  font-size: 12px;
  font-weight: 500;
  color: var(--warm-light);
  margin-left: 8px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--warm-gray);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--off-white); color: var(--brand-dark); }
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  font-size: 14px;
  line-height: 1.7;
  color: var(--brand-dark);
}
.modal-body h3 { font-size: 15px; margin-top: 20px; margin-bottom: 8px; }
.modal-body p  { margin-bottom: 12px; }
.modal-footer {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
  justify-content: flex-end;
}
.btn-ghost {
  background: none;
  border: 1px solid var(--warm-light);
  color: var(--brand-dark);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
}
.btn-ghost:hover { background: var(--off-white); }

/* Purchase Complete Card */
.purchase-complete-card {
  text-align: center;
  padding: 48px 32px;
}
.purchase-complete-icon {
  width: 64px; height: 64px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  margin: 0 auto 24px;
}
.purchase-complete-card h2 { font-size: 22px; margin-bottom: 8px; }
.purchase-complete-card p { color: var(--warm-gray); font-size: 14px; margin-bottom: 24px; line-height: 1.5; }

/* Toast Notification */
.toast-notification {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  transition: transform 0.3s ease;
  max-width: 480px;
  text-align: center;
}
.toast-visible { transform: translateX(-50%) translateY(0); }
.toast-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.toast-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.toast-info    { background: #F0EFED; color: #4A4740; border: 1px solid #C8C5C0; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-sidebar { display: none; }
  .portal-tabbar { display: flex; }
  .portal-body { flex-direction: column; }
  #view-home { padding: 20px 16px; }
  .card-grid { grid-template-columns: 1fr; }
  .view-header h1 { font-size: 20px; }
  .message { max-width: 90%; }
  .logo-header { height: 24px; }
  .logo-full { max-width: 180px; }
  .header-client { font-size: 13px; }
  .pre-portal-card { padding: 36px 24px; }
  .login-card { max-width: 100%; margin: 0 16px; }
  .buy-page-wrapper { padding: 20px 16px; }
  .identity-banner { flex-wrap: wrap; }
  .modal-box { max-height: 90vh; }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 16px; flex-direction: column; }
  .modal-footer .btn-primary,
  .modal-footer .btn-ghost { width: 100%; text-align: center; }
}

@media (max-width: 480px) {
  .pre-portal-card { padding: 32px 20px; }
  #view-home { padding: 16px 12px; }
  .card { padding: 20px 16px; }
  .code-input { font-size: 24px; max-width: 200px; }
}

/* ── Safe area for iOS ───────────────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .input-container { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .portal-tabbar { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
}

/* ── Admin Portal ───────────────────────────────────────────────────── */

.admin-email-input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-family: var(--font);
  border: 2px solid var(--warm-light);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--brand-dark);
  transition: border-color 0.15s;
}
.admin-email-input:focus { border-color: var(--accent); }

.admin-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
}

.admin-dashboard { display: flex; flex-direction: column; height: 100%; }
.admin-dashboard.hidden { display: none; }

.admin-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.admin-panel.hidden { display: none; }

.admin-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.admin-panel-header h2 { font-size: 22px; font-weight: 600; }
.admin-count {
  font-size: 13px;
  color: var(--warm-gray);
  background: var(--off-white);
  padding: 2px 10px;
  border-radius: 12px;
}

.admin-loading {
  text-align: center;
  padding: 48px;
  color: var(--warm-gray);
  font-size: 14px;
}
.admin-empty {
  text-align: center;
  padding: 48px;
  color: var(--warm-light);
  font-size: 14px;
}
.admin-empty-inline {
  color: var(--warm-light);
  font-size: 14px;
  padding: 8px 0;
}

.admin-table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--warm-gray);
  background: var(--off-white);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  color: var(--brand-dark);
}
.admin-row { cursor: pointer; transition: background 0.1s; }
.admin-row:hover { background: #FAFAF9; }
.admin-cell-name { min-width: 180px; }
.admin-cell-email { max-width: 220px; word-break: break-all; }
.admin-slug {
  display: block;
  font-size: 12px;
  color: var(--warm-gray);
  font-weight: 400;
}

.admin-step-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.step-new { background: var(--off-white); color: var(--warm-gray); }
.step-discovery { background: #FEF3C7; color: #92400E; }
.step-discovery-done { background: #D1FAE5; color: #065F46; }
.step-purchased { background: #DBEAFE; color: #1E40AF; }
.step-onboarding { background: #FDE68A; color: #78350F; }
.step-complete { background: #A7F3D0; color: #065F46; }
.step-active { background: #FEF3C7; color: #92400E; }
.step-completed { background: #A7F3D0; color: #065F46; }
.step-created { background: var(--off-white); color: var(--warm-gray); }
.step-paid { background: #D1FAE5; color: #065F46; }
.step-pending { background: #FEF3C7; color: #92400E; }
.step-failed { background: #FEE2E2; color: #991B1B; }

/* ── Detail View ──────────────────────────────────────────────────── */
.detail-header { margin-bottom: 24px; }
.detail-header h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.detail-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--warm-gray);
}

.detail-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.detail-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--brand-dark);
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.detail-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--warm-gray);
  background: var(--off-white);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.detail-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  vertical-align: top;
}

.detail-session {
  background: var(--off-white);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.detail-session:last-child { margin-bottom: 0; }
.detail-session-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 14px;
}
.detail-session-header strong { text-transform: capitalize; }

.detail-messages {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 8px;
}
.detail-msg {
  padding: 6px 10px;
  margin-bottom: 4px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}
.detail-msg:last-child { margin-bottom: 0; }
.detail-msg-user { background: #F0EFED; }
.detail-msg-assistant { background: #FAFAF9; }
.detail-msg-role {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--warm-gray);
  margin-right: 8px;
}
.detail-msg-text { word-break: break-word; }

.detail-fact-group { margin-bottom: 16px; }
.detail-fact-group:last-child { margin-bottom: 0; }
.detail-fact-group h4 {
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--accent);
  margin-bottom: 6px;
}
.fact-key {
  font-weight: 500;
  min-width: 140px;
  white-space: nowrap;
  color: var(--brand-charcoal);
}
.fact-source {
  font-size: 11px;
  color: var(--warm-light);
  white-space: nowrap;
}

@media (max-width: 768px) {
  .admin-body { padding: 16px; }
  .admin-table { font-size: 13px; }
  .admin-table th, .admin-table td { padding: 10px 12px; }
  .detail-section { padding: 16px; }
  .detail-meta { font-size: 12px; gap: 8px; }
}

/* Role-based UI: hide action elements for viewers */
.role-viewer .c2-action,
.role-viewer .admin-only {
  display: none !important;
}

/* Break-glass contact management */
.c2-btn-sm {
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--warm-light);
  border-radius: 6px;
  background: var(--surface);
  color: var(--brand-dark);
  cursor: pointer;
  margin-bottom: 10px;
}
.c2-btn-sm:hover { background: var(--off-white); }
.c2-btn-primary { background: var(--brand-dark); color: #fff; border-color: var(--brand-dark); }
.c2-btn-primary:hover { background: var(--brand-charcoal); }
.c2-btn-xs {
  font-family: var(--font);
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--warm-light);
  border-radius: 4px;
  background: var(--surface);
  color: var(--brand-dark);
  cursor: pointer;
}
.c2-btn-xs:hover { background: var(--off-white); }
.c2-btn-danger { color: #DC2626; border-color: rgba(220,38,38,0.3); }
.c2-btn-danger:hover { background: rgba(220,38,38,0.05); }
.c2-inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.c2-input-sm {
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid var(--warm-light);
  border-radius: 4px;
  background: var(--off-white);
}
.c2-input-sm:focus { outline: none; border-color: var(--accent); }

/* ── Information Coverage ─────────────────────────────────────────── */
.coverage-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
}
.coverage-stat {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}
.coverage-answered { background: #D1FAE5; color: #065F46; }
.coverage-partial { background: #FEF3C7; color: #92400E; }
.coverage-open { background: #FEE2E2; color: #991B1B; }
.coverage-pct {
  font-weight: 600;
  color: var(--brand-dark);
  margin-left: auto;
}
.coverage-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.coverage-status-answered { background: #D1FAE5; color: #065F46; }
.coverage-status-partial { background: #FEF3C7; color: #92400E; }
.coverage-status-open { background: #FEE2E2; color: #991B1B; }
.coverage-question {
  font-size: 12px;
  color: var(--warm-gray);
  margin-top: 2px;
  font-weight: 400;
}
.coverage-answer {
  font-size: 12px;
  color: var(--brand-charcoal);
  max-width: 400px;
}
