:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-raised: #fbfcfe;
  --surface-soft: #eef6fa;
  --text: #101828;
  --muted: #667085;
  --line: #d9e2ec;
  --line-strong: #c5d2df;
  --brand: #07142f;
  --brand-2: #123b85;
  --accent: #05b8c8;
  --accent-soft: #dcf8fb;
  --ok: #0f9f6e;
  --ok-soft: #dff7ec;
  --warn: #d97706;
  --warn-soft: #fff2d7;
  --danger: #d92d20;
  --danger-soft: #ffe4df;
  --violet: #7c3aed;
  --violet-soft: #efe7ff;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.09);
  --shadow-soft: 0 10px 24px rgba(16, 24, 40, 0.06);
  --radius: 8px;
  --sidebar: 268px;
  --topbar: 82px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f19;
  --surface: #111827;
  --surface-raised: #151d2b;
  --surface-soft: #172235;
  --text: #eef2f7;
  --muted: #a2adbd;
  --line: #263244;
  --line-strong: #344154;
  --brand: #d7f8ff;
  --brand-2: #8dd7ff;
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.13);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.13);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.14);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.14);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.58; }
a { color: inherit; }

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 260ms ease, visibility 260ms ease;
}
.loading-screen.is-hidden { opacity: 0; visibility: hidden; }
.loading-card {
  width: min(300px, calc(100vw - 40px));
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.loading-logo { max-width: 150px; max-height: 82px; object-fit: contain; }
.loading-card p { margin: 0; color: var(--muted); font-size: 14px; }
.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, var(--surface-soft));
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  text-decoration: none;
  border-radius: var(--radius);
}
.brand:hover { background: var(--surface-soft); }
.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #ffffff;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.brand-mark-fallback::before { content: "C"; color: var(--brand-2); font-weight: 800; }
.brand-copy { display: grid; line-height: 1.12; }
.brand-copy strong { font-size: 16px; color: var(--brand); }
.brand-copy span { color: var(--muted); font-size: 13px; }

.main-nav { display: grid; gap: 4px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 650;
  font-size: 14px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}
.nav-link:hover { transform: translateX(2px); background: var(--surface-soft); color: var(--text); }
.nav-link.is-active { color: var(--brand); background: var(--accent-soft); }
.icon, [data-icon] svg { width: 18px; height: 18px; flex: 0 0 auto; stroke-width: 2; }
.sidebar-status {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.mini-progress { display: grid; gap: 8px; margin-top: 8px; color: var(--text); font-size: 13px; font-weight: 700; }
.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}
.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width 300ms ease;
}

.main-shell { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px);
}
.top-greeting { margin: 0 0 4px; color: var(--muted); font-size: 13px; font-weight: 650; }
.topbar h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: 0;
  line-height: 1.15;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mission-chip {
  max-width: 380px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.view { padding: 26px 28px 42px; display: grid; gap: 18px; outline: none; }
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.panel-pad { padding: 18px; }
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.section-heading h2, .section-heading h3 { margin: 3px 0 0; letter-spacing: 0; }
.section-heading h2 { font-size: 21px; }
.section-heading h3 { font-size: 17px; }
.section-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.muted { color: var(--muted); }

.btn, .icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 720;
  font-size: 14px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}
.btn { padding: 0 13px; }
.icon-button { width: 38px; padding: 0; }
.btn:hover, .icon-button:hover { transform: translateY(-1px); border-color: var(--line-strong); background: var(--surface-soft); }
.btn-primary { border-color: transparent; background: var(--brand-2); color: white; }
[data-theme="dark"] .btn-primary { background: #1e9bd7; color: #06101e; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand-2) 90%, var(--accent)); color: white; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, var(--line)); background: var(--danger-soft); }
.btn-small, .table-action { min-height: 32px; padding: 0 10px; font-size: 12px; }

.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-card {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  display: grid;
  align-content: space-between;
  gap: 12px;
}
.stat-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat-card strong { display: block; font-size: 30px; line-height: 1; letter-spacing: 0; }
.stat-card small { color: var(--muted); font-size: 12px; }
.stat-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--brand-2);
}
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr); gap: 18px; }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.three-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }

.goal-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand-2) 10%, transparent), transparent 44%), var(--surface);
}
.goal-title { display: grid; gap: 8px; }
.goal-title h2 { margin: 0; font-size: 22px; }
.goal-title p { margin: 0; color: var(--muted); }
.goal-slots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.goal-slot {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
}
.goal-slot.is-filled {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--ok));
  box-shadow: 0 7px 18px color-mix(in srgb, var(--accent) 28%, transparent);
}
.goal-number { min-width: 148px; text-align: right; }
.goal-number strong { display: block; font-size: 34px; letter-spacing: 0; }
.goal-number span { color: var(--muted); font-weight: 700; }

.chart {
  height: 240px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  padding-top: 10px;
}
.chart-bar { display: grid; gap: 8px; align-items: end; justify-items: center; height: 100%; }
.bar-track {
  width: 100%;
  height: 190px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  display: flex;
  align-items: end;
  overflow: hidden;
  border: 1px solid var(--line);
}
.bar-fill {
  width: 100%;
  min-height: 5px;
  background: linear-gradient(180deg, var(--accent), var(--brand-2));
  transition: height 320ms ease;
}
.chart-bar span { color: var(--muted); font-size: 12px; font-weight: 760; }

.list-stack { display: grid; gap: 9px; }
.activity-item, .lead-card, .mission-task, .script-card, .backup-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
}
.activity-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px; }
.activity-item strong, .lead-card strong, .backup-item strong { display: block; font-size: 14px; }
.activity-item span, .lead-card span, .backup-item span { color: var(--muted); font-size: 12px; }
.empty-state {
  min-height: 130px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
}
.empty-state strong { color: var(--text); font-size: 15px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}
.badge-new { background: var(--accent-soft); color: var(--brand-2); border-color: color-mix(in srgb, var(--accent) 38%, var(--line)); }
.badge-good { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 38%, var(--line)); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 38%, var(--line)); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 38%, var(--line)); }
.badge-violet { background: var(--violet-soft); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 38%, var(--line)); }

.toolbar { display: grid; grid-template-columns: minmax(230px, 1fr) repeat(3, minmax(150px, 190px)); gap: 10px; margin-bottom: 14px; }
.input-shell { position: relative; }
.input-shell [data-icon] { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-shell input { padding-left: 40px; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
textarea { min-height: 94px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 930px; background: var(--surface); }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 13px; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
tr:hover td { background: color-mix(in srgb, var(--surface-soft) 64%, transparent); }
td strong { display: block; font-size: 13px; }
td small { color: var(--muted); font-size: 12px; }
.row-actions { display: inline-flex; gap: 6px; }

.mission-board { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 18px; }
.mission-focus {
  padding: 18px;
  display: grid;
  gap: 12px;
  align-content: start;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, transparent), transparent 54%), var(--surface);
}
.mission-focus strong { font-size: 42px; letter-spacing: 0; }
.mission-task { display: flex; align-items: center; gap: 12px; padding: 12px; }
.mission-task input { width: 18px; height: 18px; min-height: 18px; accent-color: var(--accent); }
.mission-task label { display: grid; gap: 3px; cursor: pointer; }
.mission-task span { color: var(--muted); font-size: 12px; }
.mission-task.is-done { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: var(--ok-soft); }

.scripts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.script-card { padding: 14px; display: grid; gap: 12px; }
.script-card header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.script-card h3 { margin: 0; font-size: 16px; }
.script-text {
  white-space: pre-wrap;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
  line-height: 1.55;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 6px; }
.field span { color: var(--muted); font-size: 12px; font-weight: 760; }
.span-2 { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.market-form, .settings-form { padding: 18px; }

.followup-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.followup-column {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  align-content: start;
  gap: 10px;
}
.lead-card { display: grid; gap: 8px; padding: 12px; }
.lead-card footer { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

.insight-list { display: grid; gap: 8px; }
.insight-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 10px; align-items: center; }
.insight-bar { height: 9px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 6px; }
.insight-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--accent)); }
.classification-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.classification-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--surface-raised); }
.classification-card strong { display: block; font-size: 26px; }
.classification-card span { color: var(--muted); font-size: 12px; font-weight: 760; }
.backup-list { display: grid; gap: 10px; }
.backup-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 9, 18, 0.52);
  animation: fadeIn 160ms ease;
}
.modal {
  width: min(900px, 100%);
  max-height: min(88vh, 840px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: riseIn 180ms ease;
}
.modal-small { width: min(520px, 100%); }
.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.modal-header h2 { margin: 0; font-size: 19px; }
.modal-body { padding: 18px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } }

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 40px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: toastIn 180ms ease;
}
.toast strong { display: block; font-size: 14px; }
.toast span { color: var(--muted); font-size: 13px; }
.toast-success { border-color: color-mix(in srgb, var(--ok) 44%, var(--line)); }
.toast-danger { border-color: color-mix(in srgb, var(--danger) 44%, var(--line)); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1180px) {
  .quick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid, .mission-board, .split-grid { grid-template-columns: 1fr; }
  .followup-grid, .three-grid { grid-template-columns: 1fr; }
}
@media (max-width: 920px) {
  :root { --sidebar: 100%; --topbar: auto; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .main-nav { display: flex; overflow-x: auto; padding-bottom: 2px; }
  .nav-link { white-space: nowrap; }
  .sidebar-status { display: none; }
  .topbar { position: static; align-items: flex-start; flex-direction: column; padding: 18px; }
  .topbar-actions { width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .mission-chip { max-width: none; min-width: max-content; }
  .view { padding: 18px; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scripts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .goal-panel, .form-grid, .toolbar, .classification-grid { grid-template-columns: 1fr; }
  .goal-number { text-align: left; }
  .quick-grid { grid-template-columns: 1fr; }
  .section-heading, .backup-item { align-items: stretch; flex-direction: column; }
  .section-actions, .form-actions { justify-content: stretch; }
  .section-actions .btn, .form-actions .btn { width: 100%; }
}

/* Premium SaaS polish */
:root {
  --gray: #6b7280;
  --gray-soft: #f1f5f9;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --orange: #f97316;
  --orange-soft: #ffedd5;
  --cyan: #0891b2;
  --cyan-soft: #cffafe;
}

[data-theme="dark"] {
  --gray-soft: rgba(148, 163, 184, 0.14);
  --blue-soft: rgba(37, 99, 235, 0.16);
  --purple-soft: rgba(124, 58, 237, 0.18);
  --orange-soft: rgba(249, 115, 22, 0.16);
  --cyan-soft: rgba(8, 145, 178, 0.18);
}

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 45%, var(--line)) transparent;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 34%, var(--line));
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

body {
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 10%, transparent), transparent 34rem),
    radial-gradient(circle at 84% 8%, color-mix(in srgb, var(--violet) 8%, transparent), transparent 28rem),
    var(--bg);
}

.panel,
.stat-card,
.script-card,
.lead-card,
.backup-item,
.followup-column,
.classification-card {
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
}

.panel:hover,
.stat-card:hover,
.script-card:hover,
.lead-card:hover,
.backup-item:hover,
.classification-card:hover {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  box-shadow: var(--shadow);
}

.premium-card:hover,
.stat-card:hover {
  transform: translateY(-2px);
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 22px;
  align-items: center;
  padding: 24px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--brand-2) 12%, transparent), transparent 46%),
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
    var(--surface);
}

.dashboard-hero::after {
  content: "";
  position: absolute;
  inset: auto -20% -48% 48%;
  height: 220px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 16%, transparent));
  transform: rotate(-8deg);
  pointer-events: none;
}

.hero-copy { position: relative; z-index: 1; display: grid; gap: 10px; }
.hero-copy h2 { margin: 0; font-size: clamp(30px, 5vw, 48px); line-height: 1.02; letter-spacing: 0; }
.hero-copy p { margin: 0; color: var(--muted); font-size: 16px; font-weight: 650; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

.progress-ring-card {
  position: relative;
  z-index: 1;
  justify-self: end;
  min-width: 210px;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  box-shadow: var(--shadow-soft);
}

.progress-ring {
  --size: 152px;
  --thickness: 14px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background: conic-gradient(var(--accent) calc(var(--progress) * 1%), var(--line) 0);
  animation: ringPop 520ms ease both;
}

.progress-ring::after {
  content: "";
  position: absolute;
  inset: var(--thickness);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.progress-ring span,
.progress-ring small {
  position: relative;
  z-index: 1;
}

.progress-ring span { font-size: 36px; font-weight: 820; line-height: 1; }
.progress-ring small { color: var(--muted); font-weight: 760; margin-top: 42px; position: absolute; }
.progress-ring-card strong { font-size: 15px; }
@keyframes ringPop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.premium-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-card { background: linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 80%, transparent), var(--surface)); }
.stat-icon { color: var(--accent); }

.timeline {
  display: grid;
  gap: 0;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: var(--line);
}
.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px 0;
}
.timeline-dot {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  border: 4px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--line);
}
.timeline-item strong { display: block; font-size: 14px; }
.timeline-item span, .timeline-item time { color: var(--muted); font-size: 12px; }

.leads-toolbar {
  grid-template-columns: minmax(260px, 1.5fr) repeat(7, minmax(128px, 1fr));
  align-items: end;
}
.search-wide { min-width: 260px; }
.filter-field span { margin-bottom: 0; }
.clickable-table tbody tr { cursor: pointer; }
.clickable-table tbody tr:focus td,
.clickable-table tbody tr:hover td {
  background: color-mix(in srgb, var(--accent-soft) 64%, transparent);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}
.status-new { color: var(--gray); background: var(--gray-soft); border-color: color-mix(in srgb, var(--gray) 22%, var(--line)); }
.status-message { color: var(--blue); background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 24%, var(--line)); }
.status-call { color: var(--purple); background: var(--purple-soft); border-color: color-mix(in srgb, var(--purple) 24%, var(--line)); }
.status-interest { color: var(--orange); background: var(--orange-soft); border-color: color-mix(in srgb, var(--orange) 26%, var(--line)); }
.status-demo { color: var(--cyan); background: var(--cyan-soft); border-color: color-mix(in srgb, var(--cyan) 26%, var(--line)); }
.status-pioneer { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 28%, var(--line)); }
.status-lost { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.timeline-dot.status-new { background: var(--gray); }
.timeline-dot.status-message { background: var(--blue); }
.timeline-dot.status-call { background: var(--purple); }
.timeline-dot.status-interest { background: var(--orange); }
.timeline-dot.status-demo { background: var(--cyan); }
.timeline-dot.status-pioneer { background: var(--ok); }
.timeline-dot.status-lost { background: var(--danger); }
.badge-soft { background: var(--surface-soft); color: var(--muted); }

.premium-mission .mission-focus { min-height: 280px; }
.mission-meter {
  width: 148px;
  height: 148px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--progress) * 1%), var(--line) 0);
  box-shadow: var(--shadow-soft);
  position: relative;
}
.mission-meter::after {
  content: "";
  position: absolute;
  inset: 13px;
  background: var(--surface);
  border-radius: 50%;
}
.mission-meter strong,
.mission-meter span { position: relative; z-index: 1; }
.mission-meter strong { font-size: 34px; line-height: 1; }
.mission-meter span { color: var(--muted); font-size: 12px; font-weight: 760; }
.mission-task { position: relative; overflow: hidden; }
.mission-task::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ok) 12%, transparent), transparent);
  transform: translateX(-120%);
  transition: transform 420ms ease;
}
.mission-task.is-done::after { transform: translateX(120%); }
.mission-task.is-done label strong { text-decoration: line-through; text-decoration-thickness: 2px; }

.canvas-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.canvas-panel canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
}

.modal { border-radius: 12px; }
.modal-header {
  background: color-mix(in srgb, var(--surface) 92%, var(--surface-soft));
  backdrop-filter: blur(16px);
}
.modal-header h2 { margin-top: 2px; }
.modal-form { gap: 14px; }
.premium-form { background: linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 80%, transparent), var(--surface)); }

.skeleton-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--line), var(--surface-soft), var(--line));
  background-size: 240% 100%;
  animation: skeleton 1300ms ease infinite;
}
@keyframes skeleton { to { background-position: -240% 0; } }

@media (max-width: 1320px) {
  .premium-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .leads-toolbar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .search-wide { grid-column: 1 / -1; }
}

@media (max-width: 920px) {
  .dashboard-hero { grid-template-columns: 1fr; }
  .progress-ring-card { justify-self: stretch; }
  .progress-ring { --size: 132px; }
  .premium-grid, .canvas-grid { grid-template-columns: 1fr; }
  .leads-toolbar { grid-template-columns: 1fr 1fr; }
  .timeline-item { grid-template-columns: 26px minmax(0, 1fr); }
  .timeline-item time { grid-column: 2; }
}

@media (max-width: 640px) {
  .dashboard-hero { padding: 18px; }
  .hero-copy h2 { font-size: 30px; }
  .hero-actions .btn { width: 100%; }
  .leads-toolbar { grid-template-columns: 1fr; }
  .progress-ring-card { min-width: 0; }
  .toast-root { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
  .modal-backdrop { padding: 10px; }
  .modal { max-height: 94vh; }
}

/* Supabase sync */
.sync-chip {
  min-height: 38px;
  max-width: 220px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.sync-chip:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.sync-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 14%, transparent);
}

.sync-online {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 34%, var(--line));
}

.sync-online::before {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent);
}

.sync-local {
  color: var(--muted);
  background: var(--surface);
}

.sync-pending {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 34%, var(--line));
}

.sync-pending::before {
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent);
  animation: syncPulse 1050ms ease infinite;
}

.sync-panel {
  display: grid;
  gap: 12px;
}

.sync-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--line));
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
}

code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.92em;
}

@keyframes syncPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.28); opacity: 0.72; }
}

@media (max-width: 920px) {
  .sync-chip { max-width: none; min-width: max-content; }
}
/* Auth gate */
body:not(.is-authenticated) .app-shell {
  display: none;
}

.auth-root:empty,
body.is-authenticated .auth-root {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background: var(--bg);
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-logo {
  justify-self: center;
  max-width: 172px;
  max-height: 94px;
  object-fit: contain;
  margin-bottom: 4px;
}

.auth-submit {
  width: 100%;
  min-height: 42px;
}

.auth-link {
  justify-self: center;
  border: 0;
  background: transparent;
  color: var(--brand-2);
  font-weight: 760;
  padding: 6px 8px;
}

.auth-link:hover:not(:disabled) {
  color: var(--accent);
}

.auth-alert,
.auth-note {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.auth-alert {
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--line));
  background: var(--danger-soft);
  color: var(--danger);
}

.auth-note {
  border: 1px solid color-mix(in srgb, var(--ok) 34%, var(--line));
  background: var(--ok-soft);
  color: var(--ok);
}

.button-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 32%, transparent);
  border-top-color: currentColor;
  animation: spin 800ms linear infinite;
}

@media (max-width: 640px) {
  .auth-screen { padding: 18px; }
  .auth-card { padding: 22px; }
}
