/* =============================================
  AppSite CRM — Design System & Component Styles
  Appsations Inc.
  ============================================= */

/* ---- CSS Custom Properties ---- */
:root {
  --background: hsl(220, 20%, 4%);
  --foreground: hsl(210, 20%, 92%);

  --card: hsl(220, 18%, 7%);
  --card-foreground: hsl(210, 20%, 92%);

  --primary: hsl(192, 85%, 55%);
  --primary-foreground: hsl(220, 26%, 10%);
  --primary-10: hsla(192, 85%, 55%, 0.14);
  --primary-3: hsla(192, 85%, 55%, 0.06);

  --secondary: hsl(42, 92%, 56%);
  --secondary-foreground: hsl(220, 26%, 10%);

  --muted: hsl(220, 16%, 11%);
  --muted-foreground: hsl(218, 12%, 66%);

  --accent: hsl(220, 15%, 13%);
  --accent-foreground: hsl(210, 20%, 92%);

  --destructive: hsl(0, 84%, 60%);
  --success: hsl(155, 66%, 48%);
  --success-10: hsla(142, 71%, 45%, 0.10);
  --warning: hsl(42, 92%, 56%);
  --warning-10: hsla(42, 92%, 56%, 0.12);

  --border: hsl(220, 14%, 18%);
  --border-50: hsla(220, 14%, 20%, 0.55);
  --ring: hsl(192, 85%, 55%);

  --radius: 10px;

  --surface: hsl(220, 18%, 8%);

  --shadow-sm:
    0 0 0 1px hsla(210, 20%, 92%, 0.04),
    0 8px 20px hsla(220, 40%, 2%, 0.35);
  --shadow-md:
    0 0 0 1px hsla(210, 20%, 92%, 0.05),
    0 18px 44px hsla(220, 40%, 2%, 0.55);

  --sidebar-bg: hsla(220, 18%, 8%, 0.9);
  --sidebar-foreground: hsl(218, 12%, 68%);
  --sidebar-width: 240px;

  --header-height: 56px;

  font-size: 14px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background:
    radial-gradient(1200px 600px at 0% -20%, hsla(192, 85%, 55%, 0.16), transparent 52%),
    radial-gradient(1100px 540px at 100% -10%, hsla(42, 92%, 56%, 0.12), transparent 50%),
    var(--background);
  color: var(--foreground);
  font-family: "Geist Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
input, select, textarea { border: none; outline: none; }
table { border-collapse: collapse; }

.is-hidden {
  display: none !important;
}

/* ---- Layout ---- */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  flex-shrink: 0;
  z-index: 10;
  transition: width 0.18s ease, padding 0.18s ease, opacity 0.14s ease;
}

.app-layout.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  box-shadow: none;
  pointer-events: none;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px 14px;
  margin-bottom: 32px;
  border-bottom: 2px solid var(--primary);
}

.sidebar-logo-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo-image {
  width: auto;
  max-width: 148px;
  height: 32px;
  display: block;
  object-fit: contain;
}

.sidebar-logo-crm {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-10);
  border: 1px solid hsla(192, 85%, 55%, 0.3);
  border-radius: 5px;
  padding: 3px 7px;
  line-height: 1;
  flex-shrink: 0;
  align-self: center;
  margin-bottom: 1px;
}

/* Landing logo + CRM badge */
.landing-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 2rem;
}

.landing-logo {
  width: 160px;
  height: auto;
}

.landing-logo-crm {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-10);
  border: 1px solid hsla(192, 85%, 55%, 0.3);
  border-radius: 7px;
  padding: 5px 11px;
  align-self: center;
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--primary), hsl(167, 83%, 50%));
  border-radius: calc(var(--radius) + 2px);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  font-size: 14px;
}

.sidebar-logo-text {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--sidebar-foreground);
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: var(--accent);
  color: var(--foreground);
}

.sidebar-nav a.active {
  background: linear-gradient(135deg, var(--primary-10), hsla(42, 92%, 56%, 0.08));
  color: var(--primary);
}

.sidebar-nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
}

/* ---- Email sub-nav folders ---- */
.sidebar-email-folders {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 6px 26px;
}

.sidebar-folder-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar-folder-link svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  stroke: currentColor;
}

.sidebar-folder-link:hover {
  background: var(--accent);
  color: var(--foreground);
}

.sidebar-folder-link.active {
  background: var(--primary-10);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-folder-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}

/* ---- Main Wrapper ---- */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ---- Header ---- */
.top-header {
  height: var(--header-height);
  background: hsla(220, 18%, 8%, 0.86);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  flex-shrink: 0;
  z-index: 9;
}

.sidebar-toggle-btn {
  gap: 8px;
  font-weight: 600;
}

.sidebar-toggle-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: hsla(220, 18%, 10%, 0.85);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  padding: 4px 8px 4px 4px;
}

.user-badge-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--foreground);
}

.user-badge-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-badge-label {
  font-size: 10px;
  line-height: 1;
  color: var(--muted-foreground);
}

.user-badge-email {
  font-size: 11px;
  line-height: 1.2;
  color: var(--foreground);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-badge-logout {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.search-wrapper {
  position: relative;
  width: 280px;
}

.search-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted-foreground);
  stroke: currentColor;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: hsla(220, 18%, 11%, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px 8px 36px;
  font-size: 14px;
  color: var(--foreground);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.search-input::placeholder {
  color: var(--muted-foreground);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-10);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 0 0 1px hsla(220, 26%, 10%, 0.1), 0 8px 18px hsla(192, 85%, 55%, 0.22);
  transition: opacity 0.1s, transform 0.1s, box-shadow 0.16s;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary svg { width: 16px; height: 16px; stroke: currentColor; }

.btn-primary:hover {
  box-shadow: 0 0 0 1px hsla(220, 26%, 10%, 0.1), 0 10px 24px hsla(192, 85%, 55%, 0.28);
}

.btn-surface {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: hsla(220, 18%, 11%, 0.9);
  color: var(--foreground);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}

.btn-surface:hover { background: var(--accent); }

.btn-text {
  display: inline-block;
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn-text:hover { text-decoration: underline; }

/* ---- Ledger Area ---- */
.ledger-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

/* ---- Filter Bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.filter-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-bar-left h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.filter-bar-left h1 span {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted-foreground);
}

.selected-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-10);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 999px;
}

.filter-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-select {
  appearance: none;
  background: var(--surface);
  color: var(--foreground);
  padding: 6px 28px 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' 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 8px center;
}

/* ---- Card / Table ---- */
.card {
  background: hsla(220, 18%, 8%, 0.82);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

table { width: 100%; }

thead tr {
  border-bottom: 1px solid var(--border);
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.th-sort {
  appearance: none;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.th-sort:hover {
  color: var(--foreground);
}

.th-sort-indicator {
  width: 10px;
  height: 10px;
  position: relative;
  opacity: 0.45;
}

.th-sort-indicator::before,
.th-sort-indicator::after {
  content: '';
  position: absolute;
  left: 2px;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
}

.th-sort-indicator::before {
  top: 0;
  border-bottom: 4px solid currentColor;
}

.th-sort-indicator::after {
  bottom: 0;
  border-top: 4px solid currentColor;
}

.th-sort.is-active {
  color: var(--foreground);
}

.th-sort.is-active[data-dir="asc"] .th-sort-indicator {
  opacity: 1;
}

.th-sort.is-active[data-dir="asc"] .th-sort-indicator::after {
  opacity: 0.25;
}

.th-sort.is-active[data-dir="desc"] .th-sort-indicator {
  opacity: 1;
}

.th-sort.is-active[data-dir="desc"] .th-sort-indicator::before {
  opacity: 0.25;
}

th:first-child { width: 40px; }

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-50);
  vertical-align: middle;
  font-size: 13px;
  color: var(--foreground);
}

tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

tbody tr:hover { background: var(--primary-3); }
tbody tr:last-child td { border-bottom: none; }

.task-row-selected {
  background: var(--primary-10);
}

.cell-name {
  font-weight: 500;
  color: var(--foreground);
}

.cell-muted { color: var(--muted-foreground); }

.cell-tabular {
  font-variant-numeric: tabular-nums;
  color: var(--muted-foreground);
}

input[type="checkbox"] {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ---- Owner Cell ---- */
.owner-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.owner-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--foreground);
  flex-shrink: 0;
}

.owner-name {
  font-size: 13px;
  color: var(--muted-foreground);
}

/* ---- Prospector column ---- */
.th-prospector {
  width: 80px;
  text-align: center;
}

.cell-prospector {
  text-align: center;
}

.prospector-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 5px;
  background: transparent;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.prospector-link:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  text-decoration: none;
}

.prospector-link svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  flex-shrink: 0;
}

/* ---- Status Badges ---- */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-customer {
  background: var(--success-10);
  color: var(--success);
}

.badge-lead {
  background: var(--primary-10);
  color: var(--primary);
}

.badge-prospect {
  background: var(--warning-10);
  color: var(--warning);
}

.badge-churned {
  background: var(--muted);
  color: var(--muted-foreground);
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted-foreground);
}

.pagination-buttons {
  display: flex;
  gap: 4px;
}

.pagination-buttons button {
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
  color: var(--foreground);
}

.pagination-buttons button:hover:not(:disabled) {
  background: var(--accent);
}

.pagination-buttons button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 64px 32px;
}

.empty-state p {
  color: var(--muted-foreground);
  font-size: 14px;
}

.empty-state-action {
  margin-top: 12px;
}

/* ---- Overlay ---- */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 40;
}

/* ---- Detail Panel ---- */
#detailPanel {
  display: none;
  position: fixed;
  inset-block: 0;
  right: 0;
  width: 420px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  z-index: 50;
  display: none;
  flex-direction: column;
  animation: slideInRight 0.18s ease-out;
}

#detailPanel.open {
  display: flex;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.detail-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}

.detail-close {
  padding: 4px;
  border-radius: var(--radius);
  color: var(--muted-foreground);
  transition: background 0.15s;
}

.detail-close:hover { background: var(--accent); }
.detail-close svg { width: 16px; height: 16px; stroke: currentColor; display: block; }

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.detail-section {
  margin-bottom: 24px;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  margin-bottom: 10px;
}

.detail-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 4px;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.detail-interest {
  font-size: 12px;
  color: var(--muted-foreground);
}

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--foreground);
  margin-bottom: 8px;
}

.detail-row svg {
  width: 16px;
  height: 16px;
  stroke: var(--muted-foreground);
  flex-shrink: 0;
  margin-top: 1px;
}

.detail-tabular {
  font-variant-numeric: tabular-nums;
}

.detail-row-sub {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.detail-link {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.detail-link:hover {
  color: var(--foreground);
}

.detail-owner-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-owner-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--foreground);
  flex-shrink: 0;
}

.detail-notes {
  width: 100%;
  background: hsla(220, 14%, 96%, 0.5);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
  color: var(--foreground);
  resize: none;
  min-height: 90px;
  line-height: 1.5;
  transition: box-shadow 0.15s;
}

.detail-notes:focus {
  box-shadow: 0 0 0 2px var(--primary-10);
}

.detail-notes::placeholder { color: var(--muted-foreground); }

.task-action-panel {
  margin-top: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 14px;
  display: none;
  gap: 10px;
}

.task-action-panel.open {
  display: grid;
}

.task-action-header h2 {
  font-size: 14px;
  color: var(--foreground);
  margin-bottom: 2px;
}

.task-action-header p {
  color: var(--muted-foreground);
  font-size: 12px;
}

.task-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-action-buttons button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.task-action-result {
  background: hsla(220, 15%, 12%, 0.95);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 10px;
  color: var(--foreground);
  font-size: 12px;
  line-height: 1.4;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: hsla(220, 18%, 12%, 0.96);
  color: var(--foreground);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 100;
  animation: toastIn 0.2s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Loading State ---- */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 32px;
  flex-direction: column;
  gap: 12px;
  color: var(--muted-foreground);
  font-size: 14px;
}

.loading-error {
  color: var(--destructive);
  text-align: center;
}

/* ---- Auth Page ---- */
.auth-layout {
  display: block;
  min-height: 100vh;
  overflow: auto;
}

.auth-main {
  max-width: 520px;
  margin: 64px auto;
  padding: 0 16px;
}

.auth-card {
  padding: 24px;
}

.auth-title {
  font-size: 20px;
  margin-bottom: 8px;
}

.auth-env {
  margin-bottom: 12px;
}

.auth-status {
  margin-bottom: 16px;
}

.auth-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-input {
  padding-left: 12px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.auth-forgot-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.auth-forgot-btn {
  font-size: 12px;
}

.auth-return {
  margin-top: 14px;
}

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

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

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); }

/* =============================================
   AI Prospector — Page Styles
  AppSite CRM | Appsations Inc.
   ============================================= */

/* ---- Nav badge ---- */
.nav-badge-new {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, hsl(262, 83%, 58%), hsl(221, 83%, 53%));
  color: #fff;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* ---- AI header title ---- */
.ai-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}

/* ---- AI page background (AppSite atmosphere) ---- */
body[data-page="ai"] .main-wrapper {
  background:
    radial-gradient(700px 360px at 16% 0%, hsla(192, 85%, 55%, 0.14), transparent 58%),
    radial-gradient(760px 380px at 82% -5%, hsla(42, 92%, 56%, 0.11), transparent 56%),
    linear-gradient(180deg, hsla(220, 20%, 5%, 0.97), hsla(220, 18%, 7%, 0.96));
}

body[data-page="ai"] .top-header {
  background: hsla(220, 18%, 8%, 0.86);
  backdrop-filter: blur(10px);
}

body[data-page="ai"] .ledger-area {
  background: transparent;
}

body[data-page="ai"] .card {
  background: hsla(220, 18%, 8%, 0.86);
  backdrop-filter: blur(8px);
}

/* =============================================
   Email Page
   ============================================= */

/* Override ledger-area to fill height for pane split */
body[data-page="emails"] .ledger-area.email-ledger {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

/* Unread badge in sidebar nav */
.email-unread-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--destructive);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Direction filter tabs */
.email-dir-tabs {
  display: flex;
  gap: 4px;
}

.email-header-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.email-page-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--muted-foreground);
}

.email-mailbox-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
}

.email-mailbox-tab {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.email-mailbox-tab:hover {
  background: var(--accent);
  color: var(--foreground);
}

.email-mailbox-tab.active {
  background: var(--primary-10);
  color: var(--primary);
}

.email-compose-btn {
  white-space: nowrap;
}
.email-dir-tab {
  padding: 5px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-foreground);
  background: transparent;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.email-dir-tab:hover {
  background: var(--accent);
  color: var(--foreground);
}
.email-dir-tab.active {
  background: var(--primary-10);
  color: var(--primary);
  border-color: var(--primary);
}

.email-thread-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
  user-select: none;
}

.email-thread-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
}

/* Direction pill / badge */
.email-dir-pill,
.email-dir-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.email-dir-pill.inbound,
.email-dir-badge.inbound {
  background: var(--primary-10);
  color: var(--primary);
}
.email-dir-pill.outbound,
.email-dir-badge.outbound {
  background: var(--warning-10);
  color: var(--warning);
}

/* Two-pane layout */
.email-pane-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
  min-height: 0;
}

/* ---- Email list pane ---- */
.email-list-pane {
  width: 320px;
  min-width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--card);
}

.email-list-tools {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.email-select-all-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--foreground);
  white-space: nowrap;
}

.email-selected-count {
  font-size: 11px;
  color: var(--muted-foreground);
}

.email-bulk-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.email-bulk-actions .btn-surface {
  min-height: 26px;
  padding: 4px 8px;
  font-size: 11px;
}

.email-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border-50);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}
.email-row:hover { background: var(--accent); }
.email-row.is-active { background: var(--primary-10); }
.email-row.is-unread .email-row-subject,
.email-row.is-unread .email-row-from {
  font-weight: 700;
  color: var(--foreground);
}
.email-row.is-unread::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
}

.email-row-select-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 2px;
}

.email-row-select {
  width: 14px;
  height: 14px;
}

.email-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.email-row-from {
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-row-date {
  font-size: 11px;
  color: var(--muted-foreground);
  white-space: nowrap;
  flex-shrink: 0;
}
.email-row-subject {
  font-size: 13px;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-row-preview {
  font-size: 12px;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-row-tags {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.email-row .email-dir-pill {
  align-self: flex-start;
}

.email-mailbox-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--foreground);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* ---- Empty state ---- */
.email-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted-foreground);
}
.email-empty-state svg {
  width: 40px;
  height: 40px;
  opacity: 0.35;
  stroke: currentColor;
}
.email-empty-state p {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
}
.email-empty-state span {
  font-size: 12px;
  max-width: 200px;
}

/* ---- Email detail pane ---- */
.email-detail-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--background);
}

.email-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  color: var(--muted-foreground);
  text-align: center;
}
.email-detail-empty svg {
  width: 48px;
  height: 48px;
  opacity: 0.2;
  stroke: currentColor;
}
.email-detail-empty p {
  font-size: 14px;
}

.email-detail-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.email-detail-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.email-detail-subject-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}
.email-detail-subject-row h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--foreground);
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}

.email-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.email-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 16px;
}

.email-detail-actions .btn-surface {
  padding: 8px 12px;
  font-size: 12px;
}

.email-detail-meta-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
}
.email-meta-label {
  min-width: 44px;
  font-weight: 600;
  color: var(--muted-foreground);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.email-detail-body-wrap {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.email-attachments-wrap {
  padding: 0 24px 16px;
  border-top: 1px solid var(--border-50);
  border-bottom: 1px solid var(--border-50);
  background: linear-gradient(180deg, transparent, rgba(15, 23, 42, 0.02));
}

.email-attachments-title {
  padding: 14px 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.email-attachments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.email-image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.email-image-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}

.email-image-card.is-medium {
  grid-column: span 2;
}

.email-image-card.is-large {
  grid-column: span 2;
}

.email-image-card.is-orphaned {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(180deg, rgba(255, 251, 235, 0.95), rgba(255,255,255,0.98));
}

.email-image-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(226, 232, 240, 0.75), rgba(241, 245, 249, 0.95));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  font-size: 12px;
}

.email-image-card.is-large .email-image-thumb {
  aspect-ratio: 16 / 10;
}

.email-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.email-image-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.email-image-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--foreground);
  word-break: break-word;
}

.email-image-subtext {
  font-size: 11px;
  color: var(--muted-foreground);
}

.email-image-badges,
.email-image-actions,
.email-attachment-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.email-attachment-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.email-attachment-badge.is-orphaned {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.28);
}

.email-attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.email-attachment-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.email-attachment-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  word-break: break-word;
}

.email-attachment-subtext {
  font-size: 11px;
  color: var(--muted-foreground);
}

.email-attachment-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.email-attachment-link:hover {
  text-decoration: underline;
}

.email-attachment-loading {
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.75);
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
}

.attachment-manager-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.attachment-manager-header {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.attachment-manager-header h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.attachment-manager-header p {
  margin: 0;
  font-size: 13px;
  color: var(--muted-foreground);
}

.attachment-manager-list {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  padding: 20px 24px 24px;
}

.attachment-manager-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(248,250,252,0.95));
}

.attachment-manager-item.is-file {
  grid-column: 1 / -1;
}

.attachment-manager-item.is-image {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.attachment-manager-item.is-image.is-medium {
  grid-column: span 2;
}

.attachment-manager-item.is-image.is-large {
  grid-column: span 2;
}

.attachment-manager-item.is-orphaned {
  border-color: rgba(245, 158, 11, 0.45);
}

.attachment-manager-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(226, 232, 240, 0.75), rgba(241, 245, 249, 0.95));
}

.attachment-manager-item.is-image.is-large .attachment-manager-preview {
  aspect-ratio: 16 / 10;
}

.attachment-manager-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-manager-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.attachment-manager-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--foreground);
  word-break: break-word;
}

.attachment-manager-source,
.attachment-manager-subtext {
  font-size: 12px;
  color: var(--muted-foreground);
}

.attachment-manager-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.attachment-manager-actions .btn-surface,
.attachment-manager-actions .btn-primary,
.attachment-manager-actions .email-attachment-link {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.attachment-manager-empty {
  grid-column: 1 / -1;
  padding: 36px 18px;
  text-align: center;
  color: var(--muted-foreground);
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.65);
}

.email-detail-body-html {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}
.email-detail-body-text {
  flex: 1;
  padding: 20px 24px;
  font-family: "Geist Mono", "SF Mono", ui-monospace, monospace;
  font-size: 13px;
  color: var(--foreground);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  background: var(--background);
}

.email-compose-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
}

.email-compose-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.email-compose-dialog {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.3);
}

.email-compose-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.email-compose-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.email-compose-header p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 13px;
}

.email-compose-form {
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.email-compose-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.email-compose-field span {
  font-size: 12px;
  font-weight: 600;
  color: var(--foreground);
}

.email-compose-input,
.email-compose-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--foreground);
  font: inherit;
}

.email-compose-input {
  height: 38px;
  padding: 0 12px;
}

.email-compose-file-input {
  height: auto;
  padding: 8px 12px;
}

.email-compose-textarea {
  min-height: 180px;
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

.email-compose-input:focus,
.email-compose-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-10);
}

.email-compose-status {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}

.email-compose-status.is-success {
  background: hsl(143 52% 94%);
  color: hsl(143 74% 22%);
}

.email-compose-status.is-error {
  background: hsl(0 78% 96%);
  color: var(--destructive);
}

.email-row.is-archived {
  opacity: 0.82;
}

.email-row.is-deleted {
  opacity: 0.68;
}

.email-row-state {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.email-compose-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- Spam row state ---- */
.email-row.is-spam {
  opacity: 0.78;
}

.email-row-state.spam,
.email-row-state[data-state="spam"] {
  background: rgba(244, 63, 94, 0.08);
  color: #e11d48;
  border: 1px solid rgba(244, 63, 94, 0.22);
}

/* ---- Block Sender button (warning tone) ---- */
.btn-surface-warn {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #dc2626;
}

.btn-surface-warn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
}

/* ---- Spam Settings button in filter bar ---- */
.email-spam-settings-btn {
  font-size: 12px;
  padding: 8px 12px;
}

/* ---- Spam Settings modal body ---- */
.spam-settings-body {
  padding: 20px 24px 24px;
}

.spam-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  align-items: center;
}

.spam-add-row .email-compose-input {
  flex: 1;
  min-width: 0;
}

.spam-add-type-select {
  flex: 0 0 150px !important;
}

.spam-blocklist-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.spam-blocklist-empty,
.spam-blocklist-loading {
  color: var(--text-muted, #888);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
  margin: 0;
}

.spam-blocklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-surface, #f9f9f9);
  border: 1px solid var(--border-50, #e5e7eb);
  border-radius: 8px;
}

.spam-blocklist-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.spam-blocklist-pattern {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #111);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spam-blocklist-type {
  font-size: 11px;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spam-blocklist-remove {
  font-size: 12px;
  padding: 6px 10px;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .email-compose-grid {
    grid-template-columns: 1fr;
  }

  .attachment-manager-item {
    flex-direction: column;
    align-items: stretch;
  }

  .attachment-manager-list,
  .email-image-gallery {
    grid-template-columns: 1fr;
  }

  .attachment-manager-item.is-image.is-medium,
  .attachment-manager-item.is-image.is-large,
  .email-image-card.is-medium,
  .email-image-card.is-large {
    grid-column: span 1;
  }

  .attachment-manager-actions {
    justify-content: flex-start;
  }
}

/* ---- Page layout (two-column) ---- */
.ai-prospector-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: start;
  padding: 20px 24px;
  overflow-y: auto;
  height: calc(100vh - var(--header-height));
}

/* ---- Control Panel ---- */
.ai-control-panel {
  padding: 20px;
  position: sticky;
  top: 0;
}

.ai-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-panel-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary-10);
  border-radius: 8px;
  flex-shrink: 0;
}

.ai-panel-icon svg { width: 16px; height: 16px; stroke: var(--primary); }

.ai-panel-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.ai-panel-desc {
  font-size: 12px;
  color: var(--muted-foreground);
  line-height: 1.6;
  margin-bottom: 20px;
}

/* ---- Form ---- */
.ai-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ai-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--foreground);
  letter-spacing: 0.01em;
}

.ai-label-required {
  color: var(--destructive);
  margin-left: 2px;
}

.ai-field-hint {
  font-size: 11px;
  color: var(--muted-foreground);
  line-height: 1.5;
}

.ai-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--foreground);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.6;
  resize: vertical;
  min-height: 90px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-10);
}

.ai-input {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--foreground);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-10);
}

/* ---- Checkbox group ---- */
.ai-checkbox-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.ai-checkbox-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--foreground);
  cursor: pointer;
  user-select: none;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.12s, background 0.12s;
}

.ai-checkbox-item:hover { background: var(--secondary); }

.ai-checkbox-item input[type="checkbox"] { display: none; }

.ai-checkbox-mark {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--surface);
  transition: background 0.12s, border-color 0.12s;
  position: relative;
}

.ai-checkbox-item input:checked ~ .ai-checkbox-mark {
  background: var(--primary);
  border-color: var(--primary);
}

.ai-checkbox-item input:checked ~ .ai-checkbox-mark::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* =============================================
   Settings Page
   ============================================= */

.settings-layout {
  display: block;
}

.settings-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-head h2 {
  font-size: 16px;
}

.settings-note {
  font-size: 12px;
  color: var(--muted-foreground);
}

.settings-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-actions-left {
  justify-content: flex-start;
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--foreground);
}

.settings-label-inline {
  margin-bottom: 2px;
}

.settings-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  min-height: 34px;
  padding: 6px 10px;
}

.settings-select {
  appearance: auto;
  -webkit-appearance: menulist;
  -moz-appearance: menulist;
  padding-right: 28px;
  cursor: pointer;
}

.settings-input:focus,
.settings-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-10);
}

.settings-editor {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--foreground);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

.settings-plan {
  min-height: 200px;
}

.settings-status {
  font-size: 12px;
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--success-10);
  color: var(--success);
}

.settings-status.is-error {
  background: hsl(0 78% 96%);
  color: var(--destructive);
}

.settings-denied {
  padding: 24px;
}

.settings-denied h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.settings-wizard {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: hsl(0, 0%, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-quick {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-table-quick {
  min-width: 760px;
}

.settings-advanced {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 10px;
}

.settings-advanced > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-foreground);
  user-select: none;
  list-style: none;
}

.settings-advanced > summary::-webkit-details-marker {
  display: none;
}

.settings-advanced > summary::before {
  content: '\25B8';
  display: inline-block;
  margin-right: 8px;
  color: var(--primary);
  transform: translateY(-1px);
}

.settings-advanced[open] > summary::before {
  content: '\25BE';
}

.settings-advanced[open] {
  padding-bottom: 10px;
}

.settings-advanced > :not(summary) {
  margin-top: 10px;
}

.settings-wizard-head h3 {
  font-size: 14px;
  margin-bottom: 3px;
}

.settings-wizard-head p {
  font-size: 12px;
  color: var(--muted-foreground);
}

.settings-grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-section-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-section-head h4 {
  font-size: 13px;
}

.settings-table-wrap {
  overflow-x: auto;
  padding-bottom: 2px;
}

.settings-table {
  width: 100%;
  border-collapse: collapse;
}

.settings-table th,
.settings-table td {
  padding: 8px;
  font-size: 12px;
  border-bottom: 1px solid var(--border-50);
  vertical-align: middle;
}

.settings-table th {
  color: var(--muted-foreground);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.settings-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
}

.settings-table td input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.settings-table-domains {
  min-width: 1120px;
}

.settings-table-domains th:nth-child(1),
.settings-table-domains td:nth-child(1) {
  min-width: 180px;
}

.settings-table-domains th:nth-child(2),
.settings-table-domains td:nth-child(2) {
  min-width: 110px;
}

.settings-table-domains th:nth-child(3),
.settings-table-domains td:nth-child(3) {
  min-width: 180px;
}

.settings-table-domains th:nth-child(4),
.settings-table-domains td:nth-child(4) {
  min-width: 150px;
}

.settings-table-domains th:nth-child(5),
.settings-table-domains td:nth-child(5) {
  min-width: 95px;
}

.settings-table-domains th:nth-child(6),
.settings-table-domains td:nth-child(6) {
  min-width: 180px;
}

.settings-table-domains th:nth-child(7),
.settings-table-domains td:nth-child(7) {
  min-width: 80px;
}

.settings-table-domains .settings-inline-row {
  grid-template-columns: auto auto;
  justify-content: flex-start;
}

.settings-table-tenants {
  min-width: 1100px;
}

.settings-table-tenants th:nth-child(1),
.settings-table-tenants td:nth-child(1) {
  min-width: 120px;
}

.settings-table-tenants th:nth-child(2),
.settings-table-tenants td:nth-child(2) {
  min-width: 180px;
}

.settings-table-tenants th:nth-child(3),
.settings-table-tenants td:nth-child(3),
.settings-table-tenants th:nth-child(4),
.settings-table-tenants td:nth-child(4) {
  min-width: 220px;
}

.settings-table-tenants th:nth-child(5),
.settings-table-tenants td:nth-child(5) {
  min-width: 220px;
}

.settings-table-domains .settings-input,
.settings-table-domain-mappings .settings-input {
  min-width: 140px;
}

.settings-table-domain-mappings {
  min-width: 760px;
}

.settings-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--foreground);
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-inline-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.settings-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--muted-foreground);
}

.settings-pill.is-success {
  background: var(--success-10);
  border-color: color-mix(in srgb, var(--success) 45%, white);
  color: var(--success);
}

.settings-pill.is-warning {
  background: var(--warning-10);
  border-color: color-mix(in srgb, var(--warning) 45%, white);
  color: hsl(38, 88%, 35%);
}

.settings-pill.is-error {
  background: hsl(0 78% 96%);
  border-color: color-mix(in srgb, var(--destructive) 45%, white);
  color: var(--destructive);
}

.settings-pill.is-info {
  background: var(--primary-10);
  border-color: color-mix(in srgb, var(--primary) 40%, white);
  color: var(--primary);
}

.settings-pill.is-muted {
  background: var(--accent);
  border-color: var(--border);
  color: var(--muted-foreground);
}

.settings-widget-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-widget-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-widget-card.is-active {
  border-color: color-mix(in srgb, var(--primary) 50%, white);
  box-shadow: 0 0 0 2px var(--primary-10);
}

.settings-widget-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.settings-widget-head h5 {
  margin: 0;
  font-size: 13px;
}

.settings-widget-pills {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.settings-widget-css-preview {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  background: var(--accent);
  border: 1px solid var(--border-50);
  border-radius: 8px;
  padding: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted-foreground);
  min-height: 56px;
}

@media (max-width: 980px) {
  .settings-grid-two {
    grid-template-columns: 1fr;
  }

  .settings-widget-gallery {
    grid-template-columns: 1fr;
  }

  .settings-head {
    align-items: flex-start;
  }

  .settings-actions {
    width: 100%;
  }
}

.ai-checkbox-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-3);
}

/* ---- Mine button ---- */
.ai-mine-btn {
  width: 100%;
  height: 40px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  background: linear-gradient(135deg, hsl(262, 83%, 58%), hsl(221, 83%, 53%));
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.ai-mine-btn svg { width: 16px; height: 16px; stroke: #fff; }
.ai-mine-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.ai-mine-btn:active:not(:disabled) { transform: translateY(0); }
.ai-mine-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ---- Results panel ---- */
.ai-results-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.ai-results-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.ai-view-hidden {
  display: none !important;
}

.ai-results-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  width: fit-content;
}

.ai-tab-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.ai-tab-btn:hover {
  background: var(--secondary);
  color: var(--foreground);
}

.ai-tab-btn.is-active {
  background: var(--primary-10);
  border-color: var(--primary-10);
  color: var(--primary);
}

.ai-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.ai-tab-btn.is-active .ai-tab-count {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* ---- Results header ---- */
.ai-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.ai-results-header h2 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-10);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: 20px;
}

.ai-connector-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}

.ai-connector-pill.status-checking {
  background: var(--secondary);
  color: var(--muted-foreground);
}

.ai-connector-pill.status-connected {
  background: var(--success-10);
  color: var(--success);
}

.ai-connector-pill.status-error {
  background: hsl(0, 84%, 96%);
  color: var(--destructive);
}

/* ---- Results grid ---- */
.ai-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
  align-items: start;
}

.ai-draft-section {
  padding: 12px;
}

.ai-draft-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-draft-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-draft-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--foreground);
}

.ai-draft-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  align-items: start;
}

.ai-draft-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  padding: 14px 12px;
  transition: box-shadow 0.12s;
}

.ai-draft-row:hover { box-shadow: var(--shadow-md); }

.ai-draft-check-wrap {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-draft-check {
  display: none;
}

.ai-draft-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-draft-company {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--foreground);
}

.ai-draft-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--muted-foreground);
}

.ai-draft-principal {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 3px;
}

.ai-draft-address {
  font-size: 11px;
  color: var(--foreground);
  line-height: 1.45;
}

.ai-draft-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-draft-links a {
  font-size: 11px;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-draft-empty {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--secondary);
  font-size: 12px;
  color: var(--muted-foreground);
}

/* ---- Contact card ---- */
.ai-contact-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  transition: box-shadow 0.12s;
  position: relative;
}

.ai-contact-card:hover { box-shadow: var(--shadow-md); }

.ai-contact-card.is-imported {
  opacity: 0.65;
}

.ai-imported-banner {
  position: absolute;
  top: 10px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
  border-radius: 5px;
  padding: 2px 8px;
  text-decoration: none;
  white-space: nowrap;
  pointer-events: all;
  transition: background 0.12s;
  z-index: 2;
}

.ai-imported-banner:hover {
  background: color-mix(in srgb, var(--success) 18%, transparent);
  color: var(--success);
  text-decoration: none;
}

.ai-imported-banner svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  flex-shrink: 0;
}

/* ---- Card checkbox ---- */
.ai-card-checkbox-wrap {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.ai-card-checkbox-wrap input[type="checkbox"] { display: none; }

.ai-card-check-mark {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  transition: background 0.12s, border-color 0.12s;
  position: relative;
}

.ai-card-checkbox-wrap input:checked ~ .ai-card-check-mark {
  background: var(--primary);
  border-color: var(--primary);
}

.ai-card-checkbox-wrap input:checked ~ .ai-card-check-mark::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* ---- Card avatar ---- */
.ai-card-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(262, 83%, 65%), hsl(221, 83%, 60%));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

/* ---- Card body ---- */
.ai-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ai-card-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-card-meta {
  font-size: 12px;
  color: var(--muted-foreground);
}

.ai-card-company { font-weight: 500; }
.ai-card-city { margin-left: 2px; }

.ai-card-phone, .ai-card-email {
  font-size: 11.5px;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

.ai-scorecards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.ai-scorecard {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--secondary);
}

.ai-scorecard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.ai-scorecard-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-scorecard-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--foreground);
}

.ai-scorecard-bar {
  width: 100%;
  height: 7px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.ai-scorecard-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.ai-scorecard-fill.comp-fill {
  background: linear-gradient(90deg, hsl(142, 71%, 45%), hsl(0, 75%, 55%));
}

.ai-scorecard-fill.retail-fill {
  background: linear-gradient(90deg, hsl(210, 80%, 55%), hsl(280, 75%, 58%));
}

.ai-scorecard-label {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
}

.ai-scorecard-label.comp-prospect { color: hsl(142, 71%, 26%); }
.ai-scorecard-label.comp-mixed { color: hsl(38, 80%, 30%); }
.ai-scorecard-label.comp-competitor { color: hsl(0, 65%, 40%); }
.ai-scorecard-label.comp-unknown { color: var(--muted-foreground); }
.ai-scorecard-label.retail-strong { color: hsl(221, 65%, 38%); }
.ai-scorecard-label.retail-medium { color: hsl(262, 58%, 42%); }
.ai-scorecard-label.retail-low { color: hsl(24, 62%, 38%); }
.ai-scorecard-label.retail-unknown { color: var(--muted-foreground); }

.ai-learning-panel {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.ai-learning-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-learning-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--foreground);
}

.ai-learning-badge {
  font-size: 10px;
  font-weight: 700;
  color: hsl(215, 60%, 34%);
  background: hsl(215, 85%, 92%);
  border-radius: 999px;
  padding: 2px 8px;
}

.ai-learning-badge-ai {
  color: var(--muted-foreground);
  background: var(--secondary);
}

.ai-learning-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-learning-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: var(--muted-foreground);
}

.ai-learning-input-row {
  display: grid;
  grid-template-columns: 1fr 56px;
  gap: 8px;
  align-items: center;
}

.ai-learning-input-row input[type="range"] {
  width: 100%;
}

.ai-learning-input-row input[type="number"] {
  width: 56px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--foreground);
}

.ai-learning-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.ai-learning-save {
  font-size: 11px;
}

.ai-entry-activity-wrap {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--secondary);
}

.ai-entry-activity-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  margin-bottom: 6px;
}

.ai-activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-activity-item {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 8px;
  align-items: start;
}

.ai-activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 4px;
}

.ai-activity-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--foreground);
}

.ai-activity-meta,
.ai-activity-empty {
  font-size: 10.5px;
  color: var(--muted-foreground);
}

.ai-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.ai-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--primary-10);
  color: var(--primary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.ai-tag-src {
  background: var(--secondary);
  color: var(--muted-foreground);
}

.ai-tag-valid {
  background: var(--success-10);
  color: var(--success);
}

.ai-tag-unverified {
  background: hsl(0, 84%, 96%);
  color: var(--destructive);
}

/* ---- Business category badge ---- */
.ai-tag-category {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ---- Competitor score pill ---- */
.ai-comp-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.ai-comp-pill.comp-prospect {
  background: hsl(142, 71%, 93%);
  color: hsl(142, 71%, 26%);
}

.ai-comp-pill.comp-mixed {
  background: hsl(38, 92%, 93%);
  color: hsl(38, 80%, 30%);
}

.ai-comp-pill.comp-competitor {
  background: hsl(0, 84%, 96%);
  color: hsl(0, 65%, 40%);
}

.ai-comp-pill.comp-unknown {
  background: var(--secondary);
  color: var(--muted-foreground);
}

.ai-card-source-link a {
  font-size: 11px;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-card-source-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Embedded web viewer ---- */
.ai-webviewer-panel {
  position: sticky;
  top: 0;
  min-height: calc(100vh - var(--header-height) - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-webviewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.ai-webviewer-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ai-webviewer-title-wrap svg {
  width: 16px;
  height: 16px;
  stroke: var(--primary);
  flex-shrink: 0;
}

.ai-webviewer-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.ai-webviewer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.ai-webviewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ai-webviewer-external.is-hidden {
  display: none;
}

.ai-webviewer-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.ai-webviewer-copyset {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--primary-3), transparent);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-webviewer-copyset-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-webviewer-copyset-title strong {
  font-size: 12px;
  color: var(--foreground);
}

.ai-webviewer-copyset-title span {
  font-size: 11px;
  color: var(--muted-foreground);
}

.ai-copyset-list {
  display: grid;
  gap: 8px;
}

.ai-copyset-item {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 8px;
  align-items: start;
}

.ai-copyset-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-copyset-label {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  font-weight: 700;
  padding-top: 4px;
}

.ai-copyset-value {
  font-size: 12px;
  color: var(--foreground);
  line-height: 1.45;
  white-space: pre-wrap;
}

.ai-copy-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: #fff;
}

.ai-copy-btn:hover {
  border-color: var(--primary);
  background: var(--primary-10);
}

.ai-copy-btn.is-copied {
  color: var(--success);
  border-color: var(--success);
}

.email-attachment-link.is-danger,
.btn-surface.is-danger {
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.28);
  background: rgba(254, 242, 242, 0.9);
}

.email-attachment-link.is-danger:hover,
.btn-surface.is-danger:hover {
  background: rgba(254, 226, 226, 0.96);
  border-color: rgba(239, 68, 68, 0.42);
}

.ai-email-btn {
  color: var(--foreground);
  background: var(--primary-10);
  border-color: rgba(189, 100, 56, 0.24);
}

.ai-email-btn:hover {
  background: rgba(189, 100, 56, 0.16);
}

body.has-modal-open {
  overflow: hidden;
}

.ai-prospect-email-modal {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-prospect-email-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
}

.ai-prospect-email-dialog {
  position: relative;
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 24px;
  background:
    radial-gradient(circle at top left, rgba(189, 100, 56, 0.12), transparent 35%),
    linear-gradient(180deg, #fffaf5 0%, #ffffff 28%);
  box-shadow: 0 36px 100px rgba(15, 23, 42, 0.28);
}

.ai-prospect-email-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 12px;
}

.ai-prospect-email-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 6px;
}

.ai-prospect-email-header h2 {
  margin: 0;
  font-size: 24px;
}

.ai-prospect-email-header p {
  margin: 6px 0 0;
  color: var(--muted-foreground);
  font-size: 13px;
}

.ai-prospect-email-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px 12px;
}

.ai-prospect-email-summary span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(189, 100, 56, 0.1);
  color: var(--foreground);
  font-size: 12px;
  font-weight: 600;
}

.ai-prospect-email-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 24px 24px;
}

.ai-prospect-email-template-bar {
  display: flex;
  align-items: end;
  gap: 12px;
}

.ai-prospect-email-template-field {
  flex: 1;
}

.ai-prospect-email-template-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.ai-template-thumb {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 148px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  text-align: left;
  color: #1f2937;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.ai-template-thumb strong {
  font-size: 16px;
  line-height: 1.25;
}

.ai-template-thumb span {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.74);
  line-height: 1.45;
}

.ai-template-thumb-brow {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ai-template-thumb.tone-sunrise {
  background: linear-gradient(180deg, #fff2df 0%, #ffffff 100%);
}

.ai-template-thumb.tone-ocean {
  background: linear-gradient(180deg, #e6f4ff 0%, #ffffff 100%);
}

.ai-template-thumb.tone-sage {
  background: linear-gradient(180deg, #edf7ef 0%, #ffffff 100%);
}

.ai-template-thumb.is-active {
  border-color: rgba(189, 100, 56, 0.45);
  box-shadow: 0 0 0 3px rgba(189, 100, 56, 0.14);
}

.ai-prospect-email-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ai-prospect-email-body {
  min-height: 280px;
  font-family: inherit;
  line-height: 1.55;
}

.ai-prospect-email-status {
  display: none;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  font-size: 13px;
  font-weight: 600;
}

.ai-prospect-email-status.is-visible {
  display: block;
}

.ai-prospect-email-status.is-error {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

.ai-prospect-email-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.ai-prospect-email-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flows-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.flows-overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.flows-overview-head h1 {
  margin: 0;
  font-size: 24px;
}

.flows-overview-head p {
  margin: 6px 0 0;
  color: var(--muted-foreground);
  max-width: 820px;
}

.flows-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.flows-stat-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--secondary);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flows-stat-card span {
  font-size: 12px;
  color: var(--muted-foreground);
}

.flows-stat-card strong {
  font-size: 24px;
  line-height: 1;
}

.flows-stat-card.is-warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.32);
}

.flows-filters-row {
  display: grid;
  grid-template-columns: 170px 220px 220px minmax(220px, 1fr);
  gap: 10px;
  align-items: end;
}

.flows-search-field {
  min-width: 220px;
}

.flows-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.flows-table-head h2 {
  margin: 0;
}

.flows-empty {
  padding: 12px 0;
  color: var(--muted-foreground);
}

.flows-table-wrap {
  overflow-x: auto;
}

.flows-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.flows-table th,
.flows-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.flows-table th {
  color: var(--muted-foreground);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flows-thread-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.flows-thread-cell strong {
  font-size: 13px;
}

.flows-thread-cell span {
  color: var(--foreground);
  font-size: 12px;
}

.flows-thread-cell small {
  color: var(--muted-foreground);
  font-size: 11px;
}

.flows-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
}

.flows-pill.is-customer {
  background: rgba(16, 185, 129, 0.16);
  color: #047857;
}

.flows-pill.is-prospector {
  background: rgba(59, 130, 246, 0.16);
  color: #1d4ed8;
}

.flows-pill.is-unknown {
  background: rgba(148, 163, 184, 0.16);
  color: #334155;
}

.flows-pill.is-customer_replied {
  background: rgba(16, 185, 129, 0.16);
  color: #047857;
}

.flows-pill.is-waiting_recent {
  background: rgba(251, 191, 36, 0.16);
  color: #92400e;
}

.flows-pill.is-waiting_long {
  background: rgba(239, 68, 68, 0.16);
  color: #b91c1c;
}

.flows-pill.is-inbound_only,
.flows-pill.is-outbound_only,
.flows-pill.is-no_activity {
  background: rgba(148, 163, 184, 0.16);
  color: #334155;
}

.flows-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.ai-webviewer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 36px 24px;
  min-height: 360px;
  color: var(--muted-foreground);
}

.ai-webviewer-empty h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--foreground);
}

.ai-webviewer-empty p {
  max-width: 340px;
  font-size: 12px;
  line-height: 1.6;
}

.ai-webviewer-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, hsla(262, 83%, 58%, 0.12), hsla(221, 83%, 53%, 0.12));
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-webviewer-empty-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--primary);
}

.ai-webviewer-frame {
  width: 100%;
  flex: 1;
  min-height: 720px;
  border: 0;
  background: #fff;
}

.ai-webviewer-note {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted-foreground);
  background: var(--secondary);
}

/* ---- Confidence ring ---- */
.ai-card-confidence {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.ai-confidence-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s;
}

.ai-confidence-ring.high { border-color: var(--success); color: var(--success); }
.ai-confidence-ring.med  { border-color: var(--warning); color: var(--warning); }
.ai-confidence-ring.low  { border-color: var(--muted-foreground); color: var(--muted-foreground); }

.ai-confidence-ring small { font-size: 9px; font-weight: 500; margin-top: 1px; }

.ai-confidence-label {
  font-size: 10px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---- Activity log ---- */
.ai-log-card {
  padding: 12px 14px;
}

.ai-log-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--foreground);
}

.ai-log-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-foreground);
  flex-shrink: 0;
}

.ai-log-dot.is-pulsing {
  background: var(--primary);
  animation: pulse-dot 1s ease-in-out infinite;
}

.ai-log-dot.is-done {
  background: var(--success);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.75); }
}

.ai-log-body {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ai-log-line {
  font-size: 11.5px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--muted-foreground);
  line-height: 1.5;
}

.ai-log-ts {
  color: var(--border);
  margin-right: 6px;
  font-size: 10.5px;
}

.ai-log-success { color: var(--success); }
.ai-log-error   { color: var(--destructive); }
.ai-log-progress { color: var(--primary); }

.ai-log-detail {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  margin-top: 6px;
  background: color-mix(in srgb, var(--secondary) 60%, var(--card));
}

.ai-log-detail summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.79rem;
}

.ai-log-detail summary::-webkit-details-marker {
  display: none;
}

.ai-log-detail pre {
  margin: 8px 0 0;
  max-height: 220px;
  overflow: auto;
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: pre-wrap;
  color: var(--foreground);
}

.ai-secret-help {
  border: 1px solid color-mix(in srgb, var(--destructive) 35%, var(--border));
  background: color-mix(in srgb, var(--destructive) 8%, var(--card));
  margin-top: 10px;
}

.ai-secret-help-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--destructive);
  margin-bottom: 6px;
}

.ai-secret-help-reason {
  font-size: 0.82rem;
  color: var(--foreground);
  margin: 0 0 10px;
}

.ai-secret-help-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.ai-secret-help-links a {
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}

.ai-secret-help-links a:hover {
  text-decoration: underline;
}

.ai-secret-help-cmd {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--secondary) 65%, black 4%);
  border: 1px solid var(--border);
  color: var(--foreground);
  font-size: 0.74rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

/* ---- Idle / Empty state ---- */
.ai-idle-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 40px 48px;
  gap: 12px;
  text-align: center;
}

.ai-idle-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, hsla(262, 83%, 58%, 0.12), hsla(221, 83%, 53%, 0.12));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.ai-idle-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--primary);
}

.ai-idle-state h3 {
  font-size: 16px;
  font-weight: 600;
}

.ai-idle-state p {
  font-size: 13px;
  color: var(--muted-foreground);
  max-width: 380px;
  line-height: 1.6;
}

.ai-idle-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.ai-chip {
  font-size: 12px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--foreground);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.ai-chip:hover {
  border-color: var(--primary);
  background: var(--primary-3);
  color: var(--primary);
}

/* ---- AI Intelligence Section (idle state) ---- */
.ai-intelligence-banner {
  width: 100%;
  max-width: 680px;
  margin: 0 auto 0;
  text-align: left;
  padding-bottom: 8px;
}

.ai-intelligence-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 14px;
}
.ai-intelligence-eyebrow svg {
  width: 14px;
  height: 14px;
  stroke: var(--primary);
}

.ai-intelligence-headline {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 14px;
}

.ai-intelligence-lead {
  font-size: 14px;
  color: var(--muted-foreground);
  line-height: 1.75;
  max-width: 640px;
  margin: 0 0 28px;
}

.ai-pillars {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.ai-pillar {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-50);
  background: hsla(220, 18%, 8%, 0.6);
  backdrop-filter: blur(8px);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.ai-pillar:hover {
  border-color: var(--primary);
  background: var(--primary-3);
}

.ai-pillar-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary-10);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.ai-pillar-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--primary);
}

.ai-pillar-body {
  flex: 1;
}
.ai-pillar-body strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 4px;
}
.ai-pillar-body p {
  font-size: 12.5px;
  color: var(--muted-foreground);
  line-height: 1.65;
  margin: 0;
  max-width: unset;
}

.ai-intelligence-quote {
  border-left: 2px solid var(--primary);
  padding: 10px 16px;
  margin: 0 0 8px;
  font-size: 13px;
  font-style: italic;
  color: var(--muted-foreground);
  line-height: 1.7;
  background: var(--primary-3);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.ai-intelligence-quote cite {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  font-style: normal;
  font-weight: 600;
  color: var(--primary);
}

.ai-idle-divider {
  width: 48px;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  margin: 24px auto 8px;
}

/* ---- Landing AI Intelligence Section (home page) ---- */
.landing-ai-section {
  max-width: 860px;
  width: 100%;
  margin: 6rem auto 0;
  padding: 3rem 3rem 3.5rem;
  border: 1px solid var(--border-50);
  border-top: 2px solid var(--primary);
  border-radius: calc(var(--radius) * 1.5);
  background: hsla(220, 18%, 6%, 0.85);
  backdrop-filter: blur(16px);
  text-align: left;
}

.landing-ai-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 16px;
  border: 1px solid hsla(192, 85%, 55%, 0.25);
  background: var(--primary-10);
  border-radius: 5px;
  padding: 4px 10px;
}
.landing-ai-eyebrow svg {
  width: 12px;
  height: 12px;
  stroke: var(--primary);
}

.landing-ai-headline {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 1rem;
}

.landing-ai-body {
  font-size: 14.5px;
  color: var(--muted-foreground);
  line-height: 1.8;
  margin: 0 0 2rem;
  max-width: 640px;
}

.landing-ai-pillars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.landing-ai-pillar {
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-50);
  background: var(--primary-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.landing-ai-pillar strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}
.landing-ai-pillar span {
  font-size: 12.5px;
  color: var(--muted-foreground);
  line-height: 1.65;
}

@media (max-width: 600px) {
  .landing-ai-pillars { grid-template-columns: 1fr; }
  .landing-ai-section { padding: 1.75rem 1.5rem 2rem; }
}

/* ---- Toast ---- */
.ai-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  transition: opacity 0.3s;
}

.ai-toast.is-success { background: hsl(142, 71%, 95%); color: hsl(142, 71%, 28%); border: 1px solid hsl(142, 45%, 80%); }
.ai-toast.is-error   { background: hsl(0, 84%, 96%); color: var(--destructive); border: 1px solid hsl(0, 50%, 85%); }
.ai-toast.is-hidden  { display: none; }

/* ---- Search History Panel ---- */
.ai-history-panel {
  padding: 0;
  overflow: hidden;
}

.ai-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.ai-history-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
}

.ai-history-header-left svg {
  width: 14px;
  height: 14px;
  stroke: var(--primary);
  flex-shrink: 0;
}

.ai-history-list {
  display: flex;
  flex-direction: column;
  max-height: 340px;
  overflow-y: auto;
}

.ai-history-empty {
  padding: 24px 16px;
  font-size: 12px;
  color: var(--muted-foreground);
  text-align: center;
}

.ai-history-group-label {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  background: var(--secondary);
  border-bottom: 1px solid var(--border-50);
}

.ai-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-50);
  transition: background 0.12s;
}

.ai-history-row:last-child { border-bottom: none; }
.ai-history-row:hover { background: var(--primary-3); }
.ai-history-row.is-archived { opacity: 0.55; }

.ai-history-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-history-ts {
  font-size: 10.5px;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

.ai-history-cat {
  font-size: 12px;
  font-weight: 500;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-history-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted-foreground);
}

.ai-history-region {
  background: var(--primary-10);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
}

.ai-history-count-badge {
  font-weight: 700;
  color: var(--foreground);
}

.ai-history-status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

.ai-history-status-badge.is-success {
  background: var(--success-10);
  color: var(--success);
}

.ai-history-status-badge.is-failed {
  background: hsl(0, 84%, 96%);
  color: var(--destructive);
}

.ai-history-error {
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--destructive);
  line-height: 1.35;
}

.ai-history-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ai-hist-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--foreground);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.ai-hist-btn:hover { background: var(--accent); }

.ai-hist-restore {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.ai-hist-restore:hover { opacity: 0.88; }

.ai-hist-archive {
  color: var(--muted-foreground);
}

.ai-hist-unarchive {
  color: var(--primary);
}

.ai-hist-delete {
  color: var(--destructive);
  border-color: hsl(0, 50%, 85%);
}

.ai-hist-delete:hover {
  background: hsl(0, 84%, 96%);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .ai-prospector-layout {
    grid-template-columns: 1fr;
  }
  .ai-results-panel {
    grid-template-columns: 1fr;
  }
  .ai-control-panel {
    position: static;
  }
  .ai-webviewer-panel {
    position: static;
    min-height: auto;
  }
  .ai-webviewer-frame {
    min-height: 420px;
  }
  .ai-scorecards,
  .ai-learning-controls {
    grid-template-columns: 1fr;
  }
  .ai-prospect-email-grid,
  .ai-prospect-email-template-bar {
    grid-template-columns: 1fr;
    display: grid;
  }
  .ai-prospect-email-dialog {
    width: min(100vw - 20px, 920px);
    max-height: calc(100vh - 20px);
  }
  .ai-copyset-item {
    grid-template-columns: 84px 1fr;
  }
  .ai-copyset-actions {
    grid-column: 2;
  }
  .ai-prospect-email-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .ai-prospect-email-actions {
    justify-content: flex-end;
  }
  .flows-stats-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
  .flows-filters-row {
    grid-template-columns: 1fr;
  }
}

/* ---- Settings Modals ---- */
.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.settings-modal.is-hidden {
  display: none;
}

.settings-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.settings-modal-content {
  position: relative;
  z-index: 2;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  width: 90%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow-y: auto;
}

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

.settings-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.settings-modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.settings-modal-close:hover {
  color: var(--foreground);
}

.settings-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.settings-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
  margin-top: auto;
}

/* ---- App footer copyright ---- */
.app-footer {
  text-align: center;
  padding: 18px 0 14px;
  font-size: 11.5px;
  color: var(--muted-foreground);
  opacity: 0.6;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
