:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f3f4f6;
  --ink: #1a1a2e;
  --ink-2: #374151;
  --muted: #6b7280;
  --soft: #9ca3af;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --brand: #7c3aed;
  --brand-light: #ede9fe;
  --brand-hover: #6d28d9;
  --brand-2: #a78bfa;
  --green: #10b981;
  --green-light: #d1fae5;
  --amber: #f59e0b;
  --amber-light: #fef3c7;
  --red: #ef4444;
  --red-light: #fee2e2;
  --shadow-xs: 0 1px 2px rgb(0 0 0 / .04);
  --shadow: 0 1px 3px rgb(0 0 0 / .06), 0 1px 2px rgb(0 0 0 / .04);
  --shadow-md: 0 4px 12px rgb(0 0 0 / .07);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / .10);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 256px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.is-hidden { display: none !important; }

/* ── Auth ─────────────────────────────────────── */

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f5f3ff 0%, #f9fafb 50%, #faf5ff 100%);
}

.auth-panel {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  text-align: center;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-logo-text { text-align: left; }
.auth-logo-text strong { display: block; font-size: 15px; color: var(--ink); }
.auth-logo-text span { color: var(--muted); font-size: 12px; }

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}

.auth-panel h1 {
  margin: 0 0 28px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.auth-form, .form-grid { display: grid; gap: 16px; }

.auth-form label, .form-grid label, .compact-form label, .task-form label, .project-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  min-height: 42px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(124 58 237 / .12);
}

input::placeholder, textarea::placeholder { color: var(--soft); }

.auth-submit { width: 100%; }
.auth-message { min-height: 20px; color: var(--red); font-weight: 600; text-align: center; font-size: 13px; }
.auth-actions { display: flex; gap: 10px; }

/* ── Buttons ──────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  min-height: 38px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, transform 100ms var(--ease-out), box-shadow 160ms ease;
}

.btn:active { transform: scale(0.97); }
.btn svg, .icon-btn svg, .nav-item svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 3px rgb(124 58 237 / .25);
}
.btn-primary:hover { background: var(--brand-hover); }

.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--line-2); }

.btn-danger {
  background: var(--red-light);
  color: var(--red);
  border-color: rgb(239 68 68 / .2);
}
.btn-danger:hover { background: rgb(239 68 68 / .15); }

.btn-success {
  background: var(--green-light);
  color: #059669;
  border-color: rgb(16 185 129 / .2);
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
}
.text-btn:hover { color: var(--brand-hover); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  transition: background 150ms ease;
}
.icon-btn:hover { background: var(--surface-3); }

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

/* ── Layout ───────────────────────────────────── */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  margin-bottom: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { font-size: 14px; font-weight: 700; }
.brand span { display: block; color: var(--muted); font-size: 11px; }

.nav { display: grid; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: transparent;
  font-weight: 600;
  font-size: 13px;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}
.nav-item:hover { color: var(--ink); background: var(--surface-3); }
.nav-item.active { color: var(--brand); background: var(--brand-light); }

.mobile-menu { display: none; }

.main {
  min-width: 0;
  padding: 24px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.avatar-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  position: relative;
  z-index: 2;
  transition: transform 100ms var(--ease-out);
}
.avatar-btn:active { transform: scale(0.95); }

.user-menu-wrap { position: relative; }

.user-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px;
  z-index: 200;
}
.user-menu.open { display: grid; gap: 10px; }
.user-menu-name { font-weight: 600; font-size: 13px; color: var(--muted); }
.user-menu-edit {
  display: grid !important;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}
.user-menu-edit input { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.user-menu-edit .btn { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.user-menu-logout { width: 100%; }
.user-menu-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; cursor: pointer; font-size: 13px; color: var(--text);
}
.user-menu-toggle input { display: none; }
.toggle-slider {
  width: 36px; height: 20px; background: var(--border); border-radius: 10px;
  position: relative; transition: background 150ms ease-out; flex-shrink: 0;
}
.toggle-slider::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: transform 150ms ease-out;
}
.user-menu-toggle input:checked + .toggle-slider { background: var(--brand); }
.user-menu-toggle input:checked + .toggle-slider::after { transform: translateX(16px); }

/* ── Views ────────────────────────────────────── */

.view { display: none; }
.view.active { display: block; contain: layout style; }

/* ── Dashboard ────────────────────────────────── */

.dash-summary {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: #fff;
}

.dash-summary-greeting { font-size: 16px; font-weight: 700; }
.dash-summary .cell-sub { color: rgb(255 255 255 / .75); }

.dash-summary-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-left: auto;
}

.dash-summary-stat { text-align: center; }
.dash-summary-stat strong { display: block; font-size: 20px; line-height: 1; }
.dash-summary-stat span { font-size: 10px; color: rgb(255 255 255 / .7); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: border-color 200ms ease, transform 200ms var(--ease-out);
}
.metric-card:hover { border-color: var(--line-2); transform: translateY(-1px); }

.metric-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -.5px;
  color: var(--ink);
}

.metric-card p {
  margin: 6px 0 0;
  color: var(--soft);
  font-size: 12px;
}

.dash-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.weekly-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: 8px 0;
}

.week-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.week-bar {
  width: 100%;
  max-width: 36px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 6px 6px 0 0;
  overflow: hidden;
  background: var(--surface-3);
}

.week-bar-fill {
  width: 100%;
  border-radius: 6px 6px 0 0;
  background: var(--brand);
  transition: height .3s var(--ease-out);
  min-height: 2px;
}

.week-bar-label { font-size: 10px; color: var(--soft); font-weight: 600; }
.week-bar-value { font-size: 11px; font-weight: 700; color: var(--ink-2); }

.funnel-chart { display: grid; gap: 10px; }
.funnel-step {
  display: grid;
  grid-template-columns: 80px 1fr 40px;
  align-items: center;
  gap: 10px;
}
.funnel-step span { font-size: 12px; font-weight: 600; color: var(--muted); }
.funnel-bar { height: 28px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.funnel-bar-fill { height: 100%; border-radius: 6px; transition: width .3s var(--ease-out); }
.funnel-bar-fill.f-leads { background: var(--brand); }
.funnel-bar-fill.f-contact { background: #a78bfa; }
.funnel-bar-fill.f-offer { background: var(--amber); }
.funnel-bar-fill.f-client { background: var(--green); }
.funnel-step strong { font-size: 14px; text-align: right; color: var(--ink); }

/* ── Panels ───────────────────────────────────── */

.split-grid, .pipeline-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr);
  gap: 12px;
  margin-bottom: 16px;
}

.lead-link { cursor: pointer; color: var(--brand); transition: color 120ms ease; }
.lead-link:hover { color: var(--brand-hover); text-decoration: underline; }

.lead-detail-log-form {
  display: grid; gap: 8px; margin-top: 8px;
  padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.lead-detail-log-form select,
.lead-detail-log-form textarea,
.lead-detail-log-form input { font-size: 13px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  min-width: 0;
}

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

.panel-head h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink); }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

/* ── Toolbar ──────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar select { width: auto; min-width: 140px; flex-shrink: 0; }

.search-box {
  flex: 1 1 220px;
  min-width: 160px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0 12px;
}
.search-box svg { width: 16px; height: 16px; color: var(--soft); }
.search-box input { border: 0; box-shadow: none; padding-left: 0; }
.search-box input:focus { box-shadow: none; }

/* ── Tables ───────────────────────────────────── */

.table-shell {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table { width: 100%; min-width: 800px; border-collapse: collapse; }

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  background: var(--surface-2);
}

tr:last-child td { border-bottom: 0; }
.clickable-row { cursor: pointer; transition: background 100ms ease; }
.clickable-row:hover td { background: var(--brand-light); }
.clickable-row.lead-tone-orange td { background: var(--amber-light); }
.clickable-row.lead-tone-green td { background: var(--green-light); }
.clickable-row.lead-tone-red td { background: var(--red-light); }
.clickable-row.lead-tone-orange:hover td { background: rgb(245 158 11 / .15); }
.clickable-row.lead-tone-green:hover td { background: rgb(16 185 129 / .15); }
.clickable-row.lead-tone-red:hover td { background: rgb(239 68 68 / .12); }

.cell-title { font-weight: 700; color: var(--ink); }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ── Badges ───────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-new, .badge-queued { background: var(--brand-light); color: var(--brand); }
.badge-contacted { background: #e0e7ff; color: #4338ca; }
.badge-offer_sent { background: var(--amber-light); color: #b45309; }
.badge-client { background: var(--green-light); color: #047857; }
.badge-lost { background: var(--surface-3); color: var(--muted); }
.badge-hot { background: var(--red-light); color: var(--red); }
.badge-warm { background: var(--amber-light); color: #b45309; }
.badge-cold { background: var(--surface-3); color: var(--muted); }

/* ── Lists ────────────────────────────────────── */

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

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

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
  transition: border-color 150ms ease;
}

.list-item.lead-tone-orange { background: rgb(245 158 11 / .06); border-color: rgb(245 158 11 / .2); }
.list-item.lead-tone-green { background: rgb(16 185 129 / .06); border-color: rgb(16 185 129 / .2); }
.list-item.lead-tone-red { background: rgb(239 68 68 / .06); border-color: rgb(239 68 68 / .15); }
.list-item.is-archived { opacity: .6; }

.section-subtitle {
  margin: 18px 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--muted);
  font-weight: 700;
}

button.list-item { width: 100%; text-align: left; color: inherit; cursor: pointer; }
button.list-item:hover, .project-card:hover { border-color: var(--brand); }

.list-item strong { display: block; font-weight: 700; }
.list-item p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

/* ── Bars ─────────────────────────────────────── */

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 10px; }
.bar-row strong { font-size: 13px; color: var(--ink-2); }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--brand); }

/* ── Forms ────────────────────────────────────── */

.compact-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 130px auto;
  gap: 8px;
  margin-bottom: 14px;
}

.task-form, .project-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.task-form textarea, .project-form textarea { grid-column: 1 / -1; }
.task-form button, .project-form button { grid-column: 1 / -1; }

.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }

.followup-rules {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.followup-rules strong { width: 100%; color: var(--ink); font-size: 13px; margin-bottom: 2px; }
.followup-rules span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Calendar ─────────────────────────────────── */

.calendar-header { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.calendar-header h3 { margin: 0; min-width: 160px; text-align: center; font-size: 18px; }
.calendar-header #cal-add-btn { margin-left: auto; }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  margin-bottom: 2px;
}
.calendar-weekdays span {
  text-align: center;
  padding: 8px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  contain: layout style;
}

.cal-day {
  min-height: 90px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: background 80ms ease-out, border-color 80ms ease-out;
  contain: content;
}
.cal-day:hover { background: var(--surface-2); border-color: var(--line-2); }
.cal-day.cal-other { opacity: .35; }
.cal-day.cal-today { border-color: var(--brand); background: var(--brand-light); }
.cal-day.cal-today:hover { background: rgb(124 58 237 / .1); }

.cal-day-num { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; color: var(--ink); }
.cal-today .cal-day-num { color: var(--brand); }

.cal-event {
  display: block;
  width: 100%;
  padding: 2px 6px;
  margin-bottom: 2px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 0;
  text-align: left;
  cursor: default;
}

.cal-ev-followup { background: var(--brand-light); color: var(--brand); }
.cal-ev-task { background: var(--green-light); color: #047857; cursor: pointer; }
.cal-ev-task:hover { background: rgb(16 185 129 / .18); }
.cal-ev-custom { cursor: default; }
.cal-color-brand { background: var(--brand-light); color: var(--brand); }
.cal-color-green { background: var(--green-light); color: #047857; }
.cal-color-amber { background: var(--amber-light); color: #b45309; }
.cal-color-red { background: var(--red-light); color: var(--red); }

.cal-ev-followup-item { border-left: 3px solid var(--brand); }
.cal-ev-task-item { border-left: 3px solid var(--green); }

/* ── Kanban ───────────────────────────────────── */

.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 100px;
}

.kanban-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.kanban-dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-open { background: var(--amber); }
.dot-doing { background: var(--brand); }
.dot-done { background: var(--green); }

.kanban-list { display: grid; gap: 6px; }

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: var(--shadow-xs);
  transition: border-color 100ms ease-out, box-shadow 100ms ease-out;
  contain: content;
}
.kanban-card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.kanban-card strong { display: block; font-size: 13px; margin-bottom: 2px; }

.kanban-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
}
.kanban-card-meta span { font-size: 11px; color: var(--muted); }

.kanban-card-actions { display: flex; gap: 3px; }
.kanban-card-actions button {
  width: 26px; height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background 100ms ease, color 100ms ease;
}
.kanban-card-actions button:hover { background: var(--brand-light); color: var(--brand); }
.kanban-card-actions button.btn-del:hover { background: var(--red-light); color: var(--red); }
.kanban-card-actions svg { width: 14px; height: 14px; }

/* ── CSV Import ───────────────────────────────── */

.csv-drop-zone {
  border: 2px dashed var(--line-2);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.csv-drop-zone:hover, .csv-drop-zone.dragover { border-color: var(--brand); background: var(--brand-light); }
.csv-drop-zone svg { margin: 0 auto 8px; display: block; opacity: .4; }
.csv-drop-zone p { margin: 4px 0; }

.csv-import-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow-xs);
  animation: csvSlideIn 200ms var(--ease-out);
}

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

.gen-actions { display: flex; align-items: center; gap: 12px; }

/* ── Project / Team / Misc grids ──────────────── */

.plan-board, .project-grid, .team-grid {
  display: grid;
  gap: 12px;
}
.project-grid, .team-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.project-card, .team-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.project-card { cursor: pointer; }
.project-card:hover { border-color: var(--brand); box-shadow: var(--shadow); }

.mini-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.mini-metric {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px;
}
.mini-metric span { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.mini-metric strong { display: block; margin-top: 4px; font-size: 22px; color: var(--ink); }

.project-card h4, .team-card h4 { margin: 0 0 6px; font-size: 15px; }

.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.check-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 9px;
  color: var(--ink) !important;
}
.check-row input { width: 16px; min-height: 16px; height: 16px; padding: 0; }

.panel-head.tight { margin-bottom: 0; }

.mt-16 { margin-top: 16px; }

.note-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-2);
}
.note-preview strong { display: block; margin-bottom: 3px; }
.note-preview p, .note-preview span { margin: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

select option { background: var(--surface); color: var(--ink); }

.empty-state {
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  padding: 18px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

/* ── Modal ────────────────────────────────────── */

.modal {
  border: 0;
  padding: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(640px, calc(100vw - 32px));
  max-height: min(88vh, 820px);
  overflow: hidden;
}

.modal::backdrop { background: rgb(0 0 0 / .3); }

.modal-inner {
  padding: 24px;
  background: var(--surface);
  max-height: min(88vh, 820px);
  overflow-y: auto;
  overflow-x: hidden;
}

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

.modal-head h3 { margin: 0; font-size: 20px; font-weight: 700; }

.detail-body { display: grid; gap: 12px; }
.lead-detail-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }

.lead-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.lead-action-row .btn { flex: 1 1 180px; min-width: 0; white-space: normal; }

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  min-width: 0;
}
.detail-row span, .detail-section p { color: var(--muted); overflow-wrap: anywhere; }
.detail-section { display: grid; gap: 6px; min-width: 0; }
.detail-section p { margin: 0; white-space: pre-wrap; }

.detail-image {
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.attachment-section { max-width: 100%; }
.attachment-link { color: var(--brand); font-weight: 700; overflow-wrap: anywhere; }

/* ── Dashboard date filter ────────────────────── */

.dash-date-filter {
  display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap;
}
.date-chip {
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 120ms ease-out;
}
.date-chip:hover { border-color: var(--brand); color: var(--brand); }
.date-chip.active {
  background: var(--brand); color: #fff; border-color: var(--brand);
}

/* ── Timeline ────────────────────────────────── */

.timeline {
  position: relative; padding-left: 28px; margin-top: 12px;
}
.timeline::before {
  content: ''; position: absolute; left: 11px; top: 0; bottom: 0;
  width: 2px; background: var(--line); border-radius: 1px;
}
.tl-item {
  display: flex; gap: 12px; margin-bottom: 16px; position: relative;
}
.tl-dot {
  width: 24px; height: 24px; min-width: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: absolute; left: -28px; top: 0;
  border: 2px solid var(--surface);
}
.tl-dot svg, .tl-dot i { width: 12px; height: 12px; color: #fff; }
.tl-blue { background: var(--brand); }
.tl-green { background: var(--green); }
.tl-orange { background: var(--amber); }
.tl-red { background: #ef4444; }
.tl-purple { background: #8b5cf6; }
.tl-gray { background: var(--text-3); }
.tl-content { flex: 1; }
.tl-header {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.tl-header strong { font-size: 13px; }
.tl-date { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.tl-who { font-size: 12px; color: var(--text-2); margin: 2px 0; }
.tl-note {
  font-size: 12px; color: var(--text); background: var(--surface-2);
  padding: 6px 10px; border-radius: 8px; margin-top: 4px;
}
.tl-followup {
  font-size: 11px; color: var(--amber); margin-top: 4px; font-weight: 500;
}

/* ── Analytics ───────────────────────────────── */

.bar-fill-blue { background: var(--brand) !important; }
.bar-fill-green { background: var(--green) !important; }
.avg-time-overall {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; margin-bottom: 12px; background: var(--surface-2);
  border-radius: 10px; font-size: 14px;
}
.avg-time-overall strong { font-size: 20px; color: var(--brand); }

/* ── Weekly Report ───────────────────────────── */

.weekly-report-grid { padding: 4px 0; }
.wr-summary {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.wr-stat {
  flex: 1 1 100px; text-align: center; padding: 14px 12px;
  background: var(--surface-2); border-radius: 12px; min-width: 90px;
}
.wr-stat strong { display: block; font-size: 24px; color: var(--brand); }
.wr-stat span { font-size: 12px; color: var(--text-2); }

/* ── Duplicate alerts ────────────────────────── */

.dup-alert {
  display: inline-block; padding: 4px 10px; background: #fef3c7; color: #92400e;
  border-radius: 6px; font-size: 12px; font-weight: 600; margin-bottom: 6px;
}
.dup-list {
  font-size: 11px; color: var(--text-2); background: var(--surface-2);
  padding: 8px 12px; border-radius: 8px; white-space: pre-wrap;
  max-height: 150px; overflow-y: auto; margin: 4px 0;
}

/* ── Footer ──────────────────────────────────── */

.app-footer {
  margin-top: 40px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-brand { font-size: 13px; color: var(--ink-2); }
.footer-brand strong { color: var(--brand); }
.footer-copy { font-size: 12px; color: var(--soft); }

/* ── Calendar dialog ──────────────────────────── */

.cal-dialog-divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0 12px;
}

.modal-head-actions { display: flex; align-items: center; gap: 6px; }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 12px; }

.cal-day-group { margin-bottom: 14px; }
.cal-day-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 6px;
}
.cal-day-group-title .cal-group-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-day-group-title .dot-events { background: var(--brand); }
.cal-day-group-title .dot-tasks { background: var(--green); }
.cal-day-group-title .dot-followups { background: var(--amber); }

.cal-day-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 6px;
  transition: border-color 150ms ease;
}
.cal-day-item:hover { border-color: var(--brand); }
.cal-day-item strong { display: block; font-size: 13px; }
.cal-day-item p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.cal-day-item .cal-item-time { font-size: 12px; font-weight: 600; color: var(--brand); white-space: nowrap; }
.cal-day-item-actions { display: flex; gap: 4px; }

/* ── Skeleton loaders ────────────────────────── */

.skeleton {
  background: var(--surface-3);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgb(255 255 255 / .4) 50%, transparent 100%);
  animation: skeletonShimmer 1.5s infinite;
}
@keyframes skeletonShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.skeleton-row {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.skeleton-card {
  display: grid;
  gap: 8px;
}
.skeleton-card .skeleton { min-height: inherit; }

/* ── Tooltips ────────────────────────────────── */

[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.96);
  padding: 5px 10px;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease-out, transform 120ms ease-out;
  z-index: 300;
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ── Compact mode ────────────────────────────── */

.compact-mode .metric-card { padding: 10px 12px; }
.compact-mode .metric-card strong { font-size: 22px; margin-top: 3px; }
.compact-mode .metric-card span { font-size: 10px; }
.compact-mode .metric-card p { font-size: 11px; margin-top: 3px; }
.compact-mode .panel { padding: 12px; }
.compact-mode .panel-head { margin-bottom: 10px; }
.compact-mode .panel-head h3 { font-size: 14px; }
.compact-mode .list-item { padding: 8px 10px; gap: 8px; }
.compact-mode .list-item strong { font-size: 13px; }
.compact-mode .list-item p { font-size: 11px; }
.compact-mode .kanban-card { padding: 8px 10px; }
.compact-mode .cal-day { min-height: 72px; padding: 4px; }
.compact-mode .cal-day-num { font-size: 12px; margin-bottom: 2px; }
.compact-mode .cal-event { font-size: 9px; }
.compact-mode .topbar { margin-bottom: 16px; }
.compact-mode .topbar h2 { font-size: 20px; }
.compact-mode .stack-list { gap: 4px; }
.compact-mode .metric-grid { gap: 8px; }
.compact-mode .badge { min-height: 18px; padding: 1px 6px; font-size: 10px; }
.compact-mode .task-form, .compact-mode .project-form { gap: 6px; margin-bottom: 10px; }
.compact-mode .dash-summary { padding: 14px 18px; margin-bottom: 10px; }
.compact-mode .dash-charts { gap: 8px; margin-bottom: 10px; }

/* ── Responsive ───────────────────────────────── */

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid, .pipeline-layout { grid-template-columns: 1fr; }
  .dash-charts { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  html, body { overflow-x: hidden; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    max-height: none;
    overflow-y: auto;
    z-index: 100;
    border-radius: 0 0 12px 12px;
    border-right: 0;
    box-shadow: var(--shadow-lg);
  }
  .nav { display: none; }
  .nav.open { display: grid; }
  .mobile-menu { display: grid; }
  .main { padding: 18px 14px 14px; overflow-x: hidden; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .topbar h2 { font-size: 20px; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; min-width: 0; font-size: 12px; padding: 7px 10px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-card { padding: 12px; }
  .metric-card strong { font-size: 22px; }
  .metric-card span { font-size: 10px; }
  .metric-card p { font-size: 11px; }
  .kanban-board { grid-template-columns: 1fr; }
  .dash-summary { flex-direction: column; align-items: flex-start; padding: 14px 16px; gap: 10px; }
  .dash-summary-greeting { font-size: 14px; }
  .dash-summary .cell-sub { font-size: 11px; }
  .dash-summary-stats { margin-left: 0; gap: 14px; }
  .dash-summary-stat strong { font-size: 16px; }
  .dash-charts { grid-template-columns: 1fr; }
  .wr-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .wr-stat { min-width: 0; padding: 12px 8px; }
  .wr-stat strong { font-size: 21px; }
  .funnel-step { grid-template-columns: 72px 1fr 32px; gap: 8px; }
  .compact-form { grid-template-columns: 1fr; }
  .task-form, .project-form { grid-template-columns: 1fr; }
  .task-form textarea, .project-form textarea { grid-column: auto; }
  .task-form button, .project-form button { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .lead-detail-grid { grid-template-columns: 1fr; }
  .mini-metric-grid { grid-template-columns: 1fr 1fr; }
  .two-cols { grid-template-columns: 1fr; }
  .calendar-header h3 { font-size: 15px; min-width: 130px; }
  .cal-day { min-height: 64px; padding: 4px; }
  .cal-day-num { font-size: 12px; }
  .cal-event { font-size: 9px; padding: 2px 4px; }
  .table-shell { margin: 0; border-radius: var(--radius); overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; width: 100%; min-width: 0; }
  table { border-collapse: separate; border-spacing: 0; }
  thead { display: none; }
  tbody { display: grid; gap: 8px; }
  tr {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 10px 12px;
    box-shadow: var(--shadow-xs);
  }
  td {
    display: grid;
    grid-template-columns: minmax(92px, .42fr) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
    overflow-wrap: anywhere;
  }
  td:last-child { border-bottom: 0; }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
  }
  .clickable-row:hover td,
  .clickable-row.lead-tone-orange td,
  .clickable-row.lead-tone-green td,
  .clickable-row.lead-tone-red td { background: transparent; }
  .modal { width: calc(100vw - 16px); max-height: 92vh; }
  .modal-inner { padding: 16px; max-height: 92vh; }
  .modal-head h3 { font-size: 18px; }
  .lead-action-row .btn { flex: 1 1 100%; }
  .bar-row { grid-template-columns: 80px 1fr 28px; }
  .project-grid, .team-grid { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
  .panel-head h3 { font-size: 15px; }
  .toolbar { flex-direction: column; }
  .search-box { flex: 1 1 auto; width: 100%; }
  .toolbar select { width: 100%; }
  .row-actions { flex-direction: column; }
  .row-actions .btn { width: 100%; }
  .detail-row { flex-direction: column; gap: 2px; }
  .auth-panel { padding: 24px 20px; }
  .auth-panel h1 { font-size: 20px; }
}

@media (max-width: 480px) {
  .main { padding-top: 16px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .metric-card strong { font-size: 18px; }
  .mini-metric-grid { grid-template-columns: 1fr; }
  .calendar-weekdays span { font-size: 10px; padding: 4px 0; }
  .cal-day { min-height: 50px; }
  .cal-event { display: none; }
  .cal-day.cal-today .cal-event, .cal-day:not(.cal-other) .cal-event { display: block; }
  .sidebar { padding: 12px; }
  .brand strong { font-size: 13px; }
  .nav-item { min-height: 36px; padding: 7px 10px; font-size: 12px; }
  .btn { min-height: 36px; padding: 7px 10px; font-size: 12px; }
  .topbar-actions .btn { font-size: 11px; padding: 6px 8px; }
  .dash-summary { padding: 14px 16px; }
  .dash-summary-greeting { font-size: 14px; }
  .panel { padding: 12px; }
  .mini-metric-grid { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 1fr; gap: 5px; }
  .bar-row b { text-align: left; }
  td { grid-template-columns: 1fr; gap: 3px; }
}

.toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}

.toast {
  transform: translateY(10px);
  opacity: 0;
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid rgba(124, 58, 237, .35);
  border-radius: 12px;
  background: rgba(18, 18, 24, .94);
  color: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast strong {
  font-size: 13px;
}

.toast span {
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
}

@media (max-width: 640px) {
  .toast-wrap {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}
