/* DD Portal — Design Tokens & Base Styles */

:root {
  --color-primary:    #1e3a5f;
  --color-accent:     #3b82f6;
  --color-success:    #10b981;
  --color-warning:    #f59e0b;
  --color-danger:     #ef4444;
  --color-bg:         #f8fafc;
  --color-card:       #ffffff;
  --color-border:     #e2e8f0;
  --color-text:       #1e293b;
  --color-text-muted: #64748b;
  --font-heading:     'Inter', sans-serif;
  --font-body:        'DM Sans', sans-serif;
  --radius:           8px;
  --radius-lg:        12px;
  --shadow:           0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg:        0 4px 12px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.3;
}

/* ================================================================
   LOGIN SCREEN
   ================================================================ */

.login-screen {
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--color-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
}

.login-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: block;
  max-width: 160px;
  height: auto;
  margin: 0 auto 2rem;
}

.login-heading {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-subheading {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-input.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: #2563eb;
}

.error-message {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #b91c1c;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

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

/* ================================================================
   APP SHELL (Sessions 5+ will populate this)
   ================================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo img {
  max-width: 140px;
  height: auto;
  display: block;
  filter: brightness(0) invert(1);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-nav ul {
  list-style: none;
}

.sidebar-nav li a,
.sidebar-nav li button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 1.25rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9375rem;
  font-family: var(--font-body);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav li a:hover,
.sidebar-nav li button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-nav li a.active,
.sidebar-nav li button.active {
  background: rgba(59, 130, 246, 0.25);
  color: #fff;
  font-weight: 500;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.875rem;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 0.25rem 0;
  transition: color 0.15s;
}

.sidebar-footer button:hover {
  color: #fff;
}

/* Main content area */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

.topbar {
  height: 60px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-primary);
}

.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* Placeholder / coming soon */
.coming-soon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  text-align: center;
}

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
  max-width: 320px;
}

.toast-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.toast-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

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

/* ================================================================
   DASHBOARD
   ================================================================ */

.dashboard {
  max-width: 1100px;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.dashboard-greeting {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.2rem;
}

.dashboard-date {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.btn-ai {
  background: var(--color-primary);
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-ai:hover:not(:disabled) {
  background: #16304f;
}

.btn-ai svg {
  color: #f59e0b;
}

/* AI summary output */
.ai-summary {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
  color: var(--color-text);
  line-height: 1.7;
}

.ai-summary ul {
  padding-left: 1.25rem;
  margin: 0;
}

.ai-summary li + li {
  margin-top: 0.25rem;
}

/* Stat cards grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  text-align: left;
  transition: box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  font-family: var(--font-body);
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.stat-card:active {
  transform: translateY(0);
}

.stat-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon--accent  { background: #eff6ff; color: var(--color-accent); }
.stat-icon--success { background: #ecfdf5; color: var(--color-success); }
.stat-icon--primary { background: #e8f0fb; color: var(--color-primary); }
.stat-icon--danger  { background: #fef2f2; color: var(--color-danger); }
.stat-icon--warning { background: #fffbeb; color: var(--color-warning); }

.stat-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-card__value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.stat-card__label {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Accent border on left edge for overdue/danger cards */
.stat-card--danger {
  border-left: 3px solid var(--color-danger);
}

/* Pulsing alert state when overdue count > 0 */
.stat-card--alert .stat-card__value {
  color: var(--color-danger);
}

/* ================================================================
   LEADS SECTION
   ================================================================ */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.leads-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-wrap svg {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 0.55rem 0.875rem 0.55rem 2.2rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-card);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.sort-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0.55rem 2.25rem 0.55rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  background-color: var(--color-card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.sort-select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* Filter pills */
.filter-pills {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  margin-bottom: 1.25rem;
  scrollbar-width: none;
}

.filter-pills::-webkit-scrollbar { display: none; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-card);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.pill-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.pill-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.pill-count {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 1.25rem;
  text-align: center;
}

.pill-btn.active .pill-count {
  background: rgba(255, 255, 255, 0.25);
}

/* Leads grid */
.leads-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

/* Lead card */
.lead-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.125rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  text-align: left;
  width: 100%;
  font-family: var(--font-body);
}

.lead-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.25);
}

.lead-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.lead-name {
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.lead-website {
  font-size: 0.75rem;
  color: var(--color-accent);
  text-decoration: none;
  word-break: break-all;
}

.lead-website:hover { text-decoration: underline; }

.lead-description {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin: 0.3rem 0 0;
  line-height: 1.4;
}

/* Stage badge */
.stage-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.stage-new            { background: #dbeafe; color: #1e40af; }
.stage-contacted      { background: #fef3c7; color: #92400e; }
.stage-proposal_sent  { background: #e0e7ff; color: #3730a3; }
.stage-negotiating    { background: #fce7f3; color: #9d174d; }
.stage-won            { background: #d1fae5; color: #065f46; }
.stage-lost           { background: #fee2e2; color: #991b1b; }
.stage-dormant        { background: #f1f5f9; color: #475569; }

/* Lead meta rows */
.lead-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.meta-row a {
  color: var(--color-accent);
  text-decoration: none;
}

.meta-row a:hover { text-decoration: underline; }

/* Lead footer */
.lead-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: auto;
}

.lead-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Priority dot */
.priority-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.priority-dot .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.priority-high   .dot { background: var(--color-danger); }
.priority-high        { color: #991b1b; }
.priority-medium .dot { background: var(--color-warning); }
.priority-medium      { color: #92400e; }
.priority-low    .dot { background: var(--color-success); }
.priority-low         { color: #065f46; }

/* Star rating */
.stars {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  line-height: 1;
}

.star-icon { font-size: 11px; }

/* Follow-up badge */
.followup-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  background: #f1f5f9;
  color: var(--color-text-muted);
}

.followup-badge.overdue {
  background: #fee2e2;
  color: #991b1b;
}

/* Value badge */
.value-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-success);
}

/* Card action buttons */
.card-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.card-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.card-action-btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.card-action-btn.danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: var(--color-danger);
}

/* Skeleton cards */
.skeleton-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.skel {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.empty-state p {
  font-size: 0.875rem;
}

/* ================================================================
   MODAL
   ================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 1rem;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.2s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--color-text);
  background: var(--color-bg);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* Form sections inside modal */
.form-section {
  margin-bottom: 1.5rem;
}

.form-section:last-child { margin-bottom: 0; }

.form-section-title {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.span2 { grid-column: 1 / -1; }

.form-select {
  width: 100%;
  padding: 0.625rem 2.25rem 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--color-text);
  background: var(--color-bg);
  outline: none;
  resize: vertical;
  min-height: 90px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-error {
  font-size: 0.75rem;
  color: var(--color-danger);
  min-height: 1em;
}

/* Interactive star rating */
.star-rating-input {
  display: flex;
  gap: 4px;
}

.star-input {
  font-size: 22px;
  color: #e2e8f0;
  cursor: pointer;
  transition: color 0.1s, transform 0.1s;
  line-height: 1;
  background: none;
  border: none;
  padding: 0;
}

.star-input:hover,
.star-input.filled { color: #f59e0b; }

.star-input:hover { transform: scale(1.15); }

/* ================================================================
   LEAD DETAIL DRAWER
   ================================================================ */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 300;
  animation: fade-in 0.15s ease;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 760px;
  max-width: 95vw;
  background: var(--color-card);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 301;
  display: flex;
  flex-direction: column;
  animation: slide-in-right 0.2s ease;
}

@keyframes slide-in-right {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.drawer-title-block { display: flex; flex-direction: column; gap: 0.35rem; }

.drawer-title {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-primary);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 300px;
}

.drawer-info {
  padding: 1.5rem;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
}

.drawer-activity {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.drawer-activity h4 {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section:last-child { margin-bottom: 0; }

.detail-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: 0.625rem;
}

.detail-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f8fafc;
  font-size: 0.875rem;
}

.detail-key {
  color: var(--color-text-muted);
  min-width: 100px;
  flex-shrink: 0;
  font-size: 0.8125rem;
}

.detail-val {
  color: var(--color-text);
  font-weight: 500;
  word-break: break-word;
}

.detail-val a {
  color: var(--color-accent);
  text-decoration: none;
}

.detail-val a:hover { text-decoration: underline; }

.detail-notes {
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* Activity log */
.activity-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.activity-item {
  padding: 0.625rem 0.75rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  border-left: 3px solid var(--color-border);
}

.activity-action {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}

.activity-note {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: 0.25rem;
}

.activity-time {
  font-size: 0.7rem;
  color: #94a3b8;
}

.activity-empty {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: 1.5rem 0;
}

.add-note-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.add-note-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-bg);
  outline: none;
  resize: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.add-note-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.drawer-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ================================================================
   CLIENT CARDS
   ================================================================ */

.clients-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.client-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  transition: box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  text-align: left;
  width: 100%;
  font-family: var(--font-body);
}

.client-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.25);
}

.client-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.client-name {
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.client-trading-name {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.client-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.client-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: auto;
  flex-wrap: wrap;
}

.client-badges {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success  { background: #d1fae5; color: #065f46; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-neutral  { background: #f1f5f9; color: #475569; }
.badge-accent   { background: #dbeafe; color: #1e40af; }
.badge-inactive { background: #f1f5f9; color: #94a3b8; }

.monthly-value {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-success);
}

/* Onboarding progress bar */
.onboarding-bar {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.onboarding-bar-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
}

.onboarding-track {
  height: 4px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}

.onboarding-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.onboarding-fill.complete { background: var(--color-success); }

@media (max-width: 1100px) {
  .clients-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .clients-grid { grid-template-columns: 1fr; }
}

/* ================================================================
   CONFIRM DIALOG
   ================================================================ */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
}

.dialog-box {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.dialog-box h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.dialog-box p {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn-ghost:hover { background: var(--color-bg); }

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

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

.form-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.login-switch {
  margin-top: 1.25rem;
  text-align: center;
}

.login-switch-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.login-switch-btn:hover {
  color: var(--color-text);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-secondary {
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg);
  border-color: #94a3b8;
}

/* ================================================================
   LINK DISPLAY (magic link / reset link copy box)
   ================================================================ */

.link-display {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-top: 0.75rem;
}

.link-display input[type="text"] {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  min-width: 0;
}

.link-display input[type="text"]:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.link-copied-msg {
  font-size: 0.8125rem;
  color: var(--color-success);
  margin-top: 0.375rem;
  display: none;
}

/* ================================================================
   CLIENT PORTAL (client-facing shell placeholder)
   ================================================================ */

.portal-shell {
  min-height: 100vh;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
}

.portal-topbar {
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.portal-topbar img {
  height: 28px;
}

.portal-content {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* ================================================================
   PROPOSAL PAGE (public-facing, no auth)
   ================================================================ */

.proposal-topbar {
  background: var(--color-primary);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
}

.proposal-topbar img {
  height: 30px;
  /* If logo is dark, invert it for the dark topbar */
  filter: brightness(0) invert(1);
}

.proposal-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.proposal-loading {
  padding: 3rem 0;
}

.proposal-error {
  text-align: center;
  padding: 4rem 1rem;
}

.proposal-hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.proposal-from {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.proposal-business {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
}

.proposal-tagline {
  font-size: 1.0625rem;
  color: var(--color-text-muted);
  max-width: 480px;
  margin: 0 auto;
}

.proposal-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.proposal-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.proposal-card-title {
  font-family: var(--font-heading);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.proposal-pages-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.proposal-page-item {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.proposal-inclusions {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--color-text);
  white-space: pre-line;
}

.proposal-pricing-card {
  border-color: var(--color-accent);
  background: #eff6ff;
}

.proposal-price {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}

.proposal-price span {
  font-size: 1.125rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.proposal-price-note {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.proposal-start {
  font-size: 0.875rem;
  color: var(--color-text);
  margin-top: 0.5rem;
}

.proposal-cta-section {
  text-align: center;
}

.proposal-cta-btn {
  background: var(--color-success);
  color: #fff;
  font-size: 1.125rem;
  padding: 0.875rem 2.5rem;
  border-radius: 999px;
  width: auto;
  display: inline-flex;
  margin-bottom: 0.75rem;
}

.proposal-cta-btn:hover:not(:disabled) {
  background: #059669;
}

.proposal-cta-note {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  max-width: 400px;
  margin: 0 auto;
}

.proposal-accepted-msg {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  color: #166534;
  font-size: 0.9375rem;
  line-height: 1.6;
  display: inline-block;
  max-width: 480px;
  text-align: left;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1100px) {
  .leads-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .hamburger {
    display: flex;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .stat-grid,
  .leads-grid {
    grid-template-columns: 1fr;
  }

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

  .btn-ai {
    width: 100%;
    justify-content: center;
  }

  .leads-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-wrap { min-width: unset; }
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

/* Hamburger button — hidden on desktop */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.25rem;
  margin-right: 0.75rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

.hamburger:hover {
  color: var(--color-text);
  background: var(--color-bg);
}

@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }
}

/* ================================================================
   ONBOARDING FLOW (Session 16)
   ================================================================ */

.onb-loading {
  padding: 2rem 0;
}

.onb-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Progress indicator */
.onb-progress {
  margin-bottom: 2.5rem;
}

.onb-dots {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  position: relative;
}

.onb-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.onb-dot span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--color-border);
  color: var(--color-text-muted);
  transition: background 0.2s, color 0.2s;
}

.onb-dot small {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-align: center;
  white-space: nowrap;
}

.onb-dot.active span {
  background: var(--color-accent);
  color: #fff;
}

.onb-dot.done span {
  background: var(--color-success);
  color: #fff;
}

.onb-dot.done small,
.onb-dot.active small {
  color: var(--color-text);
  font-weight: 500;
}

.onb-track {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.onb-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* Step content */
.onb-step {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

.onb-heading {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 0.75rem;
}

.onb-sub {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 1.25rem;
}

.onb-section-heading {
  font-size:     1rem;
  font-weight:   600;
  color:         var(--color-text);
  margin-bottom: 0.25rem;
}
.onb-section-note {
  font-size:     0.85rem;
  color:         var(--color-text-muted);
  margin-bottom: 1rem;
  line-height:   1.5;
}

.onb-checklist {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.onb-checklist li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: var(--color-text);
}

.onb-checklist li::before {
  content: '✓';
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e6f4f0;
  color: var(--color-success);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.onb-cta {
  font-size: 1rem;
  padding: 0.75rem 2rem;
}

.onb-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  gap: 1rem;
}

.onb-actions .btn {
  min-width: 140px;
}

.onb-actions .btn:only-child {
  margin-left: auto;
}

.onb-no-assets {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 1rem 0;
  margin: 0;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1rem;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--color-accent);
  background: #eff6ff;
}

.upload-zone-icon {
  font-size: 2rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  line-height: 1;
}

.upload-zone-text {
  font-size: 0.95rem;
  color: var(--color-text);
  margin: 0 0 0.25rem;
}

.upload-zone-link {
  color: var(--color-accent);
  cursor: pointer;
  text-decoration: underline;
}

.upload-zone-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0;
}

.upload-file-hidden {
  display: none;
}

.upload-category-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

/* Uploaded file list */
.upload-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  min-height: 1rem;
}

.upload-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
}

.upload-list-item.uploading {
  opacity: 0.6;
}

.upload-item-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.upload-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.upload-item-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-item-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: capitalize;
}

.upload-item-del {
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.upload-item-del:hover {
  opacity: 1;
  color: var(--color-danger);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

.form-required {
  color: var(--color-danger);
  margin-left: 2px;
}

@media (max-width: 600px) {
  .onb-dot small { display: none; }
  .onb-step { padding: 1.25rem; }
  .onb-heading { font-size: 1.3rem; }
  .form-row { flex-direction: column; }
}

/* ================================================================
   ONBOARDING STEPS 4–6 + PORTAL HOME (Session 17)
   ================================================================ */

/* Step 4 — Contract signing */
.onb-contract-wrap {
  margin: 1.5rem 0;
  min-height: 120px;
}

.onb-loading-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

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

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

.onb-iframe-wrap,
.onb-gc-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 1.25rem 0 0.75rem;
}

.onb-signing-iframe {
  display: block;
  width: 100%;
  height: 560px;
  border: none;
  background: var(--color-bg);
}

.onb-gc-iframe {
  display: block;
  width: 100%;
  height: 620px;
  border: none;
  background: #fff;
}

.onb-iframe-fallback {
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  margin: 0;
  text-align: center;
}

.onb-iframe-fallback a {
  color: var(--color-accent);
}

/* Email-based contract signing flow */
.onb-email-waiting {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  text-align: center;
}

.onb-email-icon {
  margin-bottom: 1rem;
}

.onb-email-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-heading);
  margin: 0 0 0.5rem;
}

.onb-email-desc {
  font-size: 0.95rem;
  color: var(--color-text);
  margin: 0 0 1.25rem;
}

.onb-email-steps {
  list-style: decimal;
  display: inline-block;
  text-align: left;
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.9;
}

.onb-email-spam {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0 0 1.5rem;
}

.onb-poll-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.onb-signed-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem;
  text-align: center;
}

.onb-signed-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #d1fae5;
  color: var(--color-success);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.onb-signed-msg {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-success);
  margin: 0;
}

/* Portal home */
.portal-home {
  padding: 0.5rem 0 2rem;
}

.portal-home-heading {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 0.5rem;
}

.portal-home-sub {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin: 0 0 2rem;
}

.portal-home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.portal-home-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.portal-home-card.coming-soon {
  opacity: 0.6;
}

.portal-home-card-icon {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.portal-home-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.portal-home-card-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

@media (max-width: 600px) {
  .onb-email-waiting { padding: 1.5rem 1.25rem; }
  .onb-gc-iframe      { height: 500px; }
  .portal-home-cards  { grid-template-columns: 1fr; }
}

/* ================================================================
   FORM ACTIONS (modal footer row)
   ================================================================ */

.form-actions {
  display:         flex;
  align-items:     center;
  justify-content: flex-end;
  gap:             0.75rem;
  padding-top:     1.25rem;
  margin-top:      0.75rem;
  border-top:      1px solid var(--color-border);
}

/* ================================================================
   DATA TABLE
   ================================================================ */

.table-wrap {
  overflow-x:    auto;
  border:        1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background:    var(--color-card);
}

.data-table {
  width:           100%;
  border-collapse: collapse;
  font-size:       0.875rem;
}

.data-table thead th {
  padding:          0.75rem 1rem;
  text-align:       left;
  font-size:        0.75rem;
  font-weight:      600;
  text-transform:   uppercase;
  letter-spacing:   0.05em;
  color:            var(--color-text-muted);
  border-bottom:    1px solid var(--color-border);
  white-space:      nowrap;
  background:       var(--color-bg);
}

.data-table thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.data-table thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

.data-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition:    background 0.1s;
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover      { background: var(--color-bg); }
.data-table tbody tr.row-void   { opacity: 0.5; }

.data-table tbody td {
  padding:    0.75rem 1rem;
  color:      var(--color-text);
  white-space: nowrap;
}

.table-actions {
  text-align: right;
  white-space: nowrap;
}

.table-actions .btn { margin-left: 0.25rem; }

/* ================================================================
   CLIENT BILLING
   ================================================================ */

.billing-notice {
  display:       flex;
  align-items:   center;
  gap:           0.6rem;
  padding:       0.875rem 1rem;
  border-radius: var(--radius);
  font-size:     0.875rem;
  font-weight:   500;
  margin-bottom: 1.25rem;
}
.notice-success { background: rgba(16,185,129,0.1); color: #065f46; border: 1px solid rgba(16,185,129,0.25); }
.notice-warning { background: rgba(245,158,11,0.1); color: #92400e; border: 1px solid rgba(245,158,11,0.25); }
.notice-danger  { background: rgba(239,68,68,0.1);  color: #991b1b; border: 1px solid rgba(239,68,68,0.25); }

.invoice-number {
  font-family:    monospace;
  font-size:      0.8rem;
  color:          var(--color-text-muted);
}

.overdue-notice-row {
  font-size:      0.8rem;
  color:          var(--color-danger);
  padding-top:    0 !important;
  padding-bottom: 0.75rem !important;
  border-top:     none !important;
}

/* ================================================================
   CHANGE REQUEST DETAIL
   ================================================================ */

.detail-label {
  margin:      0;
  font-size:   0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color:       var(--color-text-muted);
}

.detail-value {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}

/* ================================================================
   REVENUE STATS + CHART
   ================================================================ */

.rev-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.rev-stat-card {
  padding: 1rem 1.125rem;
}

.rev-stat-value {
  font-size: 1.375rem;
  font-weight: 700;
  font-family: var(--font-heading);
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.rev-stat--success { color: var(--color-success); }
.rev-stat--accent  { color: var(--color-accent); }
.rev-stat--primary { color: var(--color-primary); }
.rev-stat--warning { color: var(--color-warning); }
.rev-stat--danger  { color: var(--color-danger); }

.rev-stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}

.rev-stat-hint {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

@media (max-width: 1100px) {
  .rev-stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .rev-stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ================================================================
   REVENUE / INVOICES
   ================================================================ */

.invoice-stats {
  display:               grid;
  grid-template-columns: repeat(3, 1fr);
  gap:                   1rem;
  margin-top:            1.25rem;
  margin-bottom:         1.25rem;
}

.invoice-stat {
  background:    var(--color-card);
  border:        1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding:       1rem 1.25rem;
}

.invoice-stat-label {
  font-size:     0.75rem;
  font-weight:   600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color:         var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.invoice-stat-value {
  font-size:   1.5rem;
  font-weight: 700;
  font-family: var(--font-heading);
}

.invoice-stat-value.success { color: var(--color-success); }
.invoice-stat-value.accent  { color: var(--color-accent); }
.invoice-stat-value.danger  { color: var(--color-danger); }

.invoice-number { font-weight: 600; font-family: var(--font-heading); }
.invoice-amount { font-weight: 600; }
.invoice-due    { color: var(--color-text-muted); }

@media (max-width: 640px) {
  .invoice-stats { grid-template-columns: 1fr; }
  .data-table tbody td,
  .data-table thead th { padding: 0.6rem 0.75rem; }
}

/* ================================================================
   BREADCRUMB (client portal navigation)
   ================================================================ */

.breadcrumb {
  display:       flex;
  align-items:   center;
  gap:           0.25rem;
  margin-bottom: 1.25rem;
  flex-wrap:     wrap;
}

.breadcrumb-link {
  display:       inline-flex;
  align-items:   center;
  background:    var(--color-card);
  border:        1px solid var(--color-border);
  border-radius: var(--radius);
  padding:       0.35rem 0.7rem;
  font-size:     0.8rem;
  font-weight:   500;
  color:         var(--color-accent);
  cursor:        pointer;
  font-family:   var(--font-body);
  line-height:   1;
  min-height:    36px;
  transition:    border-color 0.15s, background 0.15s;
}

.breadcrumb-link:hover {
  background:   var(--color-bg);
  border-color: var(--color-accent);
}

.breadcrumb-sep {
  font-size:   0.75rem;
  color:       var(--color-text-muted);
  line-height: 1;
  padding:     0 0.1rem;
}

.breadcrumb-current {
  display:       inline-flex;
  align-items:   center;
  padding:       0.35rem 0.7rem;
  font-size:     0.8rem;
  font-weight:   500;
  color:         var(--color-text-muted);
  background:    var(--color-bg);
  border:        1px solid var(--color-border);
  border-radius: var(--radius);
  min-height:    36px;
  line-height:   1;
}

/* ================================================================
   CLIENT PORTAL — Projects
   ================================================================ */

.portal-section-header {
  display:     flex;
  align-items: center;
  gap:         1rem;
  margin-bottom: 1.25rem;
}

.portal-section-title {
  font-size:   1.25rem;
  font-weight: 700;
  color:       var(--color-text);
}

.client-project-card {
  background:    var(--color-card);
  border:        1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding:       1.25rem;
  cursor:        pointer;
  transition:    box-shadow 0.15s, transform 0.15s;
  margin-bottom: 0.75rem;
}

.client-project-card:hover {
  box-shadow: var(--shadow-lg);
  transform:  translateY(-1px);
}

.client-project-card-header {
  display:         flex;
  align-items:     flex-start;
  justify-content: space-between;
  gap:             0.5rem;
  margin-bottom:   0.25rem;
}

.client-project-card-name {
  font-size:   1rem;
  font-weight: 600;
  color:       var(--color-text);
}

.client-project-card-cta {
  font-size:   0.8rem;
  color:       var(--color-accent);
  margin-top:  0.5rem;
}

/* Project detail (client view) */

.client-project-detail-header {
  margin-bottom: 1rem;
}

.client-project-detail-title {
  font-size:     1.4rem;
  font-weight:   700;
  margin-bottom: 0.4rem;
}

.client-project-detail-meta {
  display:     flex;
  align-items: center;
  gap:         0.75rem;
  flex-wrap:   wrap;
}

.client-project-progress-wrap {
  margin-bottom: 1.25rem;
}

.client-project-progress-label {
  display:         flex;
  justify-content: space-between;
  font-size:       0.8rem;
  color:           var(--color-text-muted);
  margin-bottom:   0.4rem;
}

/* Read-only kanban task list */

.client-kanban {
  display:        flex;
  flex-direction: column;
  gap:            1.25rem;
  margin-bottom:  1.5rem;
}

.client-kanban-group-title {
  font-size:      0.75rem;
  font-weight:    600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color:          var(--color-text-muted);
  margin-bottom:  0.4rem;
}

.client-task-row {
  display:       flex;
  align-items:   center;
  gap:           0.6rem;
  padding:       0.5rem 0.75rem;
  background:    var(--color-card);
  border:        1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.35rem;
}

.client-task-row.completed { opacity: 0.6; }

.client-task-tick {
  font-size:  0.9rem;
  color:      var(--color-success);
  flex-shrink: 0;
  width:      1rem;
  text-align: center;
}

.client-task-row.completed .client-task-tick { color: var(--color-text-muted); }

.client-task-name {
  flex:        1;
  font-size:   0.875rem;
  color:       var(--color-text);
}

.client-task-row.completed .client-task-name {
  text-decoration: line-through;
  color:           var(--color-text-muted);
}

.client-task-due {
  font-size:   0.75rem;
  color:       var(--color-text-muted);
  white-space: nowrap;
}

.client-project-notes {
  background:    var(--color-bg);
  border:        1px solid var(--color-border);
  border-radius: var(--radius);
  padding:       1rem;
}

.client-project-notes-label {
  font-size:     0.8rem;
  font-weight:   600;
  color:         var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.client-project-notes p {
  font-size: 0.875rem;
  color:     var(--color-text);
}

/* ================================================================
   PROJECTS — card grid
   ================================================================ */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.project-card {
  background:    var(--color-card);
  border:        1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding:       1.25rem;
  cursor:        pointer;
  transition:    box-shadow 0.15s, transform 0.15s;
  display:       flex;
  flex-direction: column;
  gap:           0.5rem;
}

.project-card:hover {
  box-shadow: var(--shadow-lg);
  transform:  translateY(-1px);
}

.project-card-header {
  display:         flex;
  align-items:     flex-start;
  justify-content: space-between;
  gap:             0.5rem;
}

.project-card-name {
  font-weight: 600;
  font-size:   1rem;
  color:       var(--color-text);
  line-height: 1.3;
}

.project-card-client {
  font-size: 0.85rem;
  color:     var(--color-text-muted);
}

.project-card-progress {
  display:     flex;
  align-items: center;
  gap:         0.5rem;
  margin-top:  0.25rem;
}

.progress-bar {
  flex:          1;
  height:        6px;
  background:    var(--color-border);
  border-radius: 3px;
  overflow:      hidden;
}

.progress-bar-fill {
  height:        100%;
  background:    var(--color-accent);
  border-radius: 3px;
  transition:    width 0.3s;
}

.progress-label {
  font-size:   0.75rem;
  color:       var(--color-text-muted);
  white-space: nowrap;
}

.project-card-no-tasks,
.project-card-due {
  font-size: 0.8rem;
  color:     var(--color-text-muted);
}

/* ================================================================
   PROJECT DETAIL
   ================================================================ */

.project-detail-header {
  display:         flex;
  align-items:     flex-start;
  justify-content: space-between;
  gap:             1rem;
  margin-bottom:   1rem;
  flex-wrap:       wrap;
}

.project-detail-title {
  font-size:     1.5rem;
  font-weight:   700;
  margin-bottom: 0.4rem;
}

.project-detail-meta {
  display:     flex;
  align-items: center;
  gap:         0.75rem;
  flex-wrap:   wrap;
}

.project-detail-client,
.project-detail-due {
  font-size: 0.875rem;
  color:     var(--color-text-muted);
}

.project-detail-actions {
  display:     flex;
  gap:         0.5rem;
  align-items: flex-start;
  flex-shrink: 0;
}

.project-detail-links {
  display:       flex;
  gap:           0.75rem;
  margin-bottom: 1rem;
  flex-wrap:     wrap;
}

.project-link {
  display:         inline-flex;
  align-items:     center;
  gap:             0.3rem;
  padding:         0.45rem 0.875rem;
  background:      var(--color-card);
  border:          1px solid var(--color-border);
  border-radius:   var(--radius);
  font-size:       0.875rem;
  font-weight:     500;
  color:           var(--color-text);
  text-decoration: none;
  transition:      border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.project-link:hover {
  border-color:    var(--color-accent);
  color:           var(--color-accent);
  text-decoration: none;
  box-shadow:      var(--shadow);
}

/* ================================================================
   KANBAN BOARD
   ================================================================ */

.kanban-board {
  display:        flex;
  gap:            1rem;
  overflow-x:     auto;
  padding-bottom: 1rem;
  align-items:    flex-start;
  min-height:     400px;
}

.kanban-col {
  flex:           0 0 260px;
  background:     var(--color-bg);
  border:         1px solid var(--color-border);
  border-radius:  var(--radius-lg);
  padding:        0.75rem;
  display:        flex;
  flex-direction: column;
  gap:            0.5rem;
}

.kanban-col-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         0 0.25rem 0.25rem;
}

.kanban-col-title {
  font-size:      0.8rem;
  font-weight:    600;
  color:          var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kanban-col-count {
  font-size:     0.75rem;
  background:    var(--color-border);
  color:         var(--color-text-muted);
  border-radius: 10px;
  padding:       1px 7px;
  font-weight:   600;
}

.kanban-tasks {
  display:        flex;
  flex-direction: column;
  gap:            0.5rem;
  min-height:     40px;
  padding:        2px;
  border-radius:  var(--radius);
  transition:     background 0.15s;
}

.kanban-tasks.drag-over {
  background: rgba(59, 130, 246, 0.08);
  outline:    2px dashed var(--color-accent);
}

.kanban-task {
  background:     var(--color-card);
  border:         1px solid var(--color-border);
  border-radius:  var(--radius);
  padding:        0.6rem 0.75rem;
  cursor:         grab;
  box-shadow:     var(--shadow);
  user-select:    none;
  transition:     box-shadow 0.15s, opacity 0.15s;
}

.kanban-task:hover  { box-shadow: var(--shadow-lg); }
.kanban-task.dragging { opacity: 0.4; cursor: grabbing; }

.kanban-task.completed                  { opacity: 0.6; }
.kanban-task.completed .kanban-task-title {
  text-decoration: line-through;
  color:           var(--color-text-muted);
}

.kanban-task-title {
  font-size:     0.875rem;
  font-weight:   500;
  color:         var(--color-text);
  margin-bottom: 0.2rem;
}

.kanban-task-due {
  font-size:     0.75rem;
  color:         var(--color-text-muted);
  margin-bottom: 0.2rem;
}

.kanban-task-actions {
  display:    flex;
  gap:        0.25rem;
  margin-top: 0.25rem;
}

.kanban-task-btn {
  background:    var(--color-bg);
  border:        1px solid var(--color-border);
  border-radius: var(--radius);
  cursor:        pointer;
  padding:       0.2rem 0.45rem;
  font-size:     0.8rem;
  color:         var(--color-text-muted);
  transition:    background 0.1s, color 0.1s, border-color 0.1s;
  line-height:   1.4;
}

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

.kanban-add-task {
  background:    none;
  border:        1px dashed var(--color-border);
  border-radius: var(--radius);
  color:         var(--color-text-muted);
  font-size:     0.8rem;
  padding:       0.4rem 0.75rem;
  cursor:        pointer;
  text-align:    left;
  width:         100%;
  transition:    background 0.1s, color 0.1s, border-color 0.1s;
}

.kanban-add-task:hover {
  background:   var(--color-bg);
  color:        var(--color-accent);
  border-color: var(--color-accent);
}

@media (max-width: 768px) {
  .kanban-board           { flex-direction: column; }
  .kanban-col             { flex: none; width: 100%; }
  .projects-grid          { grid-template-columns: 1fr; }
  .project-detail-header  { flex-direction: column; }
  .project-detail-actions { width: 100%; }

}

/* ================================================================
   COMMUNICATIONS — Log / activity feed
   ================================================================ */

.comms-log-item {
  background:       var(--color-card);
  border:           1px solid var(--color-border);
  border-radius:    var(--radius-md);
  padding:          0.9rem 1rem;
  margin-bottom:    0.6rem;
}
.comms-log-item--new {
  border-left:      3px solid var(--color-accent);
}
.comms-log-item--compact {
  padding:          0.55rem 0.75rem;
  margin-bottom:    0.35rem;
}

.comms-log-header {
  display:          flex;
  justify-content:  space-between;
  align-items:      flex-start;
  gap:              0.75rem;
  margin-bottom:    0.6rem;
}
.comms-log-item--compact .comms-log-header {
  margin-bottom:    0;
}

.comms-log-dot {
  display:          inline-block;
  width:            7px;
  height:           7px;
  background:       var(--color-accent);
  border-radius:    50%;
  flex-shrink:      0;
  margin-top:       0.3rem;
}

.comms-log-subject {
  font-size:        0.9rem;
  font-weight:      600;
  color:            var(--color-text);
  overflow:         hidden;
  text-overflow:    ellipsis;
  white-space:      nowrap;
}

.comms-log-badge {
  display:          inline-block;
  padding:          0.15rem 0.5rem;
  background:       rgba(59,130,246,0.1);
  color:            var(--color-accent);
  border-radius:    999px;
  font-size:        0.7rem;
  font-weight:      600;
  white-space:      nowrap;
}

.comms-log-date {
  font-size:        0.72rem;
  color:            var(--color-text-muted);
  white-space:      nowrap;
}

.comms-log-body {
  font-size:        0.875rem;
  color:            var(--color-text);
  line-height:      1.6;
  white-space:      pre-wrap;
  word-break:       break-word;
}

/* ================================================================
   DOCUMENTS — Client Portal
   ================================================================ */

.docs-contract-row {
  display:      flex;
  align-items:  center;
  gap:          1rem;
  flex-wrap:    wrap;
  margin-top:   0.5rem;
}

.docs-asset-list {
  display:        flex;
  flex-direction: column;
  gap:            0;
}

.docs-asset-row {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             1rem;
  padding:         0.75rem 0;
  border-bottom:   1px solid var(--color-border);
}

.docs-asset-row:last-child {
  border-bottom: none;
}

.docs-asset-info {
  display:        flex;
  flex-direction: column;
  gap:            0.2rem;
  min-width:      0;
}

.docs-asset-name {
  font-weight:   500;
  font-size:     0.9rem;
  color:         var(--color-text);
  overflow:      hidden;
  text-overflow: ellipsis;
  white-space:   nowrap;
}

.docs-asset-meta {
  font-size:  0.78rem;
  color:      var(--color-text-muted);
}

@media (max-width: 480px) {
  .docs-asset-row {
    flex-direction: column;
    align-items:    flex-start;
    gap:            0.5rem;
  }
}

/* ================================================================
   POST-LAUNCH — Text wrap utility + Document item styles
   ================================================================ */

/* Force text wrapping in otherwise nowrap table cells (e.g. CR descriptions) */
.col-wrap {
  white-space:    normal !important;
  overflow-wrap:  break-word;
  word-break:     break-word;
}

/* Documents section — section header with icon */
.doc-section-header {
  display:         flex;
  align-items:     center;
  gap:             0.75rem;
  margin-bottom:   1rem;
  padding-bottom:  0.875rem;
  border-bottom:   1px solid var(--color-border);
}

.doc-section-icon {
  width:           36px;
  height:          36px;
  background:      var(--color-bg);
  border:          1px solid var(--color-border);
  border-radius:   8px;
  display:         flex;
  align-items:     center;
  justify-content: center;
  flex-shrink:     0;
  color:           var(--color-primary);
}

.doc-section-title {
  font-size:   0.9rem;
  font-weight: 600;
  color:       var(--color-text);
  font-family: var(--font-heading);
}

/* Document item row */
.doc-item {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             1rem;
  padding:         0.875rem 0;
}

.doc-item + .doc-item {
  border-top: 1px solid var(--color-border);
}

.doc-item-info {
  flex:      1;
  min-width: 0;
}

.doc-item-name {
  font-size:     0.9rem;
  font-weight:   500;
  color:         var(--color-text);
  overflow:      hidden;
  text-overflow: ellipsis;
  white-space:   nowrap;
}

.doc-item-meta {
  font-size:  0.78rem;
  color:      var(--color-text-muted);
  margin-top: 0.2rem;
}

.doc-item-actions {
  display:     flex;
  align-items: center;
  gap:         0.75rem;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .doc-item {
    flex-direction: column;
    align-items:    flex-start;
  }
  .doc-item-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ================================================================
   SESSION 30 — Mobile Polish
   ================================================================ */

/* Reusable 2-column grid that collapses to 1 on mobile */
.modal-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 480px) {
  .modal-2col {
    grid-template-columns: 1fr;
  }
}

/* Drawer: collapse info/activity side-by-side layout on mobile */
@media (max-width: 768px) {
  .drawer-body {
    grid-template-columns: 1fr;
  }
  .drawer-info {
    border-right:  none;
    border-bottom: 1px solid var(--color-border);
  }
  .drawer-activity {
    padding: 1.25rem 1.5rem;
  }
}

/* Modals: ensure they fit on small screens */
@media (max-width: 480px) {
  .modal-overlay {
    padding: 0.5rem;
  }
  .modal {
    max-height: 94vh;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius) var(--radius);
  }
  .modal-header {
    padding: 1rem 1.25rem;
  }
  .modal-body {
    padding: 1rem 1.25rem;
  }
  .modal-footer {
    padding: 0.75rem 1.25rem;
    flex-wrap: wrap;
  }
  .modal-footer .btn {
    flex: 1;
    justify-content: center;
  }
}

/* iframes: more usable height on small screens */
@media (max-width: 480px) {
  .onb-signing-iframe { height: 420px; }
  .onb-gc-iframe      { height: 450px; }
}

/* Section header: stack on very small screens */
@media (max-width: 480px) {
  .section-header {
    flex-direction: column;
    align-items:    flex-start;
    gap:            0.5rem;
  }
  .section-header .section-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Portal section title: ensure it doesn't overflow */
@media (max-width: 480px) {
  .portal-section-title {
    font-size: 1.1rem;
  }
}

/* ================================================================
   Pagination
   ================================================================ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.page-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  font-weight: 600;
}

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

/* ================================================================
   Quick Actions (dashboard)
   ================================================================ */

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

/* ================================================================
   Needs Attention (dashboard)
   ================================================================ */

.needs-attention {
  margin-top: 2rem;
}

.needs-attention__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.75rem;
}

.attention-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.attention-loading {
  color: var(--color-text-light);
  font-size: 0.875rem;
}

.attention-clear {
  color: var(--color-success);
  font-size: 0.875rem;
  font-weight: 500;
}

.attention-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.attention-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.attention-item--danger  { border-left: 3px solid var(--color-danger); }
.attention-item--warning { border-left: 3px solid var(--color-warning); }
.attention-item--accent  { border-left: 3px solid var(--color-accent); }

.attention-item--danger:hover  { border-color: var(--color-danger); }
.attention-item--warning:hover { border-color: var(--color-warning); }
.attention-item--accent:hover  { border-color: var(--color-accent); }

.attention-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.attention-badge--danger  { background: #fef2f2; color: var(--color-danger); }
.attention-badge--warning { background: #fffbeb; color: var(--color-warning); }
.attention-badge--accent  { background: #eff6ff; color: var(--color-accent); }

.attention-label {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

.attention-meta {
  font-size: 0.8rem;
  color: var(--color-text-light);
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .attention-item {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .attention-meta {
    width: 100%;
  }
}

/* ================================================================
   REPORTS SECTION
   ================================================================ */

.report-subnav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
  scrollbar-width: none;
}
.report-subnav::-webkit-scrollbar { display: none; }

.report-subnav-btn {
  flex-shrink: 0;
  padding: 0.4375rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-card);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}
.report-subnav-btn:hover           { border-color: var(--color-accent); color: var(--color-accent); }
.report-subnav-btn.active          { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.report-subnav-btn.ai-btn          { border-color: #8b5cf6; color: #8b5cf6; }
.report-subnav-btn.ai-btn:hover    { background: #8b5cf6; border-color: #8b5cf6; color: #fff; }
.report-subnav-btn.ai-btn.active   { background: #7c3aed; border-color: #7c3aed; color: #fff; }

.report-period-bar {
  display: flex;
  gap: 0.375rem;
  margin-bottom: 1.25rem;
}
.report-period-btn {
  padding: 0.3125rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.report-period-btn:hover  { border-color: var(--color-accent); color: var(--color-accent); }
.report-period-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

.report-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}
.report-stat {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
}
.report-stat-value {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}
.report-stat-value.success { color: var(--color-success); }
.report-stat-value.danger  { color: var(--color-danger); }
.report-stat-value.warning { color: var(--color-warning); }
.report-stat-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-top: 0.25rem;
}

.report-section {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}
.report-section-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-primary);
  background: var(--color-bg);
}
.report-section-body { padding: 1rem; }

.report-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 640px) {
  .report-two-col { grid-template-columns: 1fr; }
}

.report-body { min-height: 200px; }

.ai-forecast-intro {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1px solid #c4b5fd;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.ai-forecast-card {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1px solid #c4b5fd;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.25rem;
}
.ai-forecast-summary {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: #4c1d95;
  margin-bottom: 1.25rem;
}
.ai-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.ai-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.5;
}
.ai-list li::before {
  content: '•';
  color: #8b5cf6;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

/* ================================================================
   SETTINGS SECTION
   ================================================================ */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 768px) {
  .settings-grid { grid-template-columns: 1fr; }
}

.settings-card {
  padding: 1.5rem;
}

.settings-section-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.375rem;
}

.settings-desc {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.settings-info-box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--color-text);
  margin-top: 1rem;
}

.input-prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-prefix {
  position: absolute;
  left: 0.875rem;
  color: var(--color-text-muted);
  font-weight: 500;
  pointer-events: none;
  font-size: 0.9375rem;
}
.input-prefixed {
  padding-left: 1.875rem;
}

/* ================================================================
   MOBILE OPTIMISATION — GLOBAL FIXES
   ================================================================ */

/* Drawer: full-width + wrapping footer on phones */
@media (max-width: 480px) {
  .detail-drawer {
    width: 100vw;
    max-width: 100vw;
  }
  .drawer-footer {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .drawer-footer .btn {
    flex: 1;
    min-width: 110px;
    justify-content: center;
  }
}

/* Invoice / form modal: collapse 2-col form grid on phones */
@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* Responsive table → stacked card layout at ≤ 640px */
@media (max-width: 640px) {
  .data-table.cards-on-mobile thead { display: none; }

  .data-table.cards-on-mobile tbody tr {
    display: block;
    margin-bottom: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-card);
  }

  .data-table.cards-on-mobile tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.875rem;
    border-bottom: 1px solid var(--color-border);
    white-space: normal;
    font-size: 0.8125rem;
  }

  .data-table.cards-on-mobile tbody td:last-child { border-bottom: none; }

  .data-table.cards-on-mobile tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
    margin-right: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  /* Actions column and colspan rows have no label */
  .data-table.cards-on-mobile tbody td[data-label=""]::before { display: none; }
  .data-table.cards-on-mobile tbody td[colspan] { display: block; }

  .data-table.cards-on-mobile tbody td.table-actions {
    justify-content: flex-end;
    gap: 0.5rem;
  }

  /* table-wrap: no horizontal scroll needed when cards are active */
  .table-wrap:has(.cards-on-mobile) { overflow-x: visible; }
}

/* Hide secondary admin table columns on small screens */
@media (max-width: 640px) {
  .col-mobile-hide { display: none; }
}

/* ================================================================
   LEAD GRADING
   ================================================================ */

/* Grade badge — on lead cards and in drawer header */
.grade-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.45rem;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.grade-badge.grade-hot      { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.grade-badge.grade-warm     { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }
.grade-badge.grade-cool     { background: #fffbeb; color: #d97706; border: 1px solid #fcd34d; }
.grade-badge.grade-cold     { background: #eff6ff; color: #2563eb; border: 1px solid #93c5fd; }
.grade-badge.grade-ungraded { background: var(--color-bg); color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* Grading panel in lead drawer */
.grade-panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 0.25rem;
}
.grade-overall {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.grade-overall-left {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
}
.grade-score-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.grade-score-num {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
  min-width: 2.5rem;
  text-align: right;
}
.grade-criteria { padding: 0.25rem 0; }
.grade-row {
  display: grid;
  grid-template-columns: 1fr auto 145px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
}
.grade-row:hover { background: #f8fafc; }
.grade-row-label {
  font-size: 0.78rem;
  color: var(--color-text);
  font-weight: 500;
}
.grade-weight {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.grade-select {
  font-size: 0.76rem;
  padding: 0.28rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: white;
  color: var(--color-text);
  cursor: pointer;
  width: 100%;
}
.grade-select:focus { outline: none; border-color: var(--color-accent); }
.grade-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.9rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}
.grade-reason {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-style: italic;
  padding: 0 0.9rem 0.3rem;
  line-height: 1.4;
}
@media (max-width: 480px) {
  .grade-row { grid-template-columns: 1fr 130px; }
  .grade-weight { display: none; }
}


/* ================================================================
   SCOUT ENRICHMENT — Phase 7.5
   ================================================================ */

/* Scout score mini badge on lead card (top-right) */
.scout-score-mini {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  line-height: 1.2;
  white-space: nowrap;
}
.scout-score-mini.score-green { background: #d1fae5; color: #065f46; }
.scout-score-mini.score-amber { background: #fef3c7; color: #92400e; }
.scout-score-mini.score-red   { background: #fee2e2; color: #991b1b; }

/* Outreach indicators on lead card */
.outreach-indicator {
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
}
.outreach-indicator.draft  { color: var(--color-warning); }
.outreach-indicator.sent   { color: var(--color-success); }

/* Scout Research — drawer section */
.scout-score-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.scout-score-number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  font-family: var(--font-heading);
}
.scout-score-number.score-green { color: #065f46; }
.scout-score-number.score-amber { color: #92400e; }
.scout-score-number.score-red   { color: #991b1b; }

/* Score breakdown bars */
.score-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.score-factor {
  display: grid;
  grid-template-columns: 140px 1fr 32px;
  align-items: center;
  gap: 0.5rem;
}
.factor-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.factor-bar {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}
.factor-bar-fill {
  height: 100%;
  border-radius: 2px;
}
.factor-bar-fill.bar-green { background: var(--color-success); }
.factor-bar-fill.bar-amber { background: var(--color-warning); }
.factor-bar-fill.bar-red   { background: var(--color-danger); }
.factor-val {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  text-align: right;
}

/* Research notes */
.research-notes-text {
  font-size: 0.8125rem;
  color: var(--color-text);
  line-height: 1.55;
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Outreach draft section */
.outreach-draft-fields {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.outreach-field-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.5rem;
}
.outreach-subject-input {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-card);
  font-family: var(--font-body);
  box-sizing: border-box;
}
.outreach-subject-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.1);
}
.outreach-body-textarea {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.8125rem;
  color: var(--color-text);
  background: var(--color-card);
  font-family: var(--font-body);
  line-height: 1.55;
  resize: vertical;
  box-sizing: border-box;
}
.outreach-body-textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.1);
}
.outreach-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.5rem;
}
.sent-indicator {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-success);
}
.save-draft-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.save-draft-status {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Do Not Contact */
.dnc-card-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  vertical-align: middle;
}
.pill-btn[data-stage="dnc"] {
  border-color: var(--color-danger);
  color: var(--color-danger);
}
.pill-btn[data-stage="dnc"].active {
  background: var(--color-danger);
  color: #fff;
}
