/* SAM CRM design system — Linear/Stripe-inspired, self-contained (no CDN).
   Palette: primary #2563EB · AI violet #7C3AED · success #10B981
   warning #F59E0B · danger #EF4444 · sidebar #0F172A · canvas #F8FAFC */
:root {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --ink: #0F172A;
  --muted: #64748B;
  --line: #E2E8F0;
  --primary: #2563EB;
  --ai: #7C3AED;
  --ok: #10B981;
  --warn: #F59E0B;
  --danger: #EF4444;
  --sidebar: #0F172A;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14.5px/1.55 Inter, "IBM Plex Sans", system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1rem; margin: 0 0 .9rem; letter-spacing: -.01em; }
p { margin: .25rem 0 0; }
code { background: #EEF2F7; padding: .1em .35em; border-radius: 5px; font-size: .88em; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ── shell: sidebar + main ─────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar); color: #CBD5E1;
  display: flex; flex-direction: column; padding: 1.1rem .8rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-brand {
  font-size: 1.15rem; font-weight: 800; color: #fff; letter-spacing: -.02em;
  padding: .2rem .55rem 1rem;
}
.side-brand span { color: #93C5FD; font-weight: 600; }
.side-group {
  font-size: .66rem; font-weight: 700; letter-spacing: .09em; color: #475569;
  padding: 1rem .55rem .35rem; display: flex; align-items: center; gap: .4rem;
}
.side-group .soon {
  background: #1E293B; color: #64748B; border-radius: 999px;
  padding: 0 .45rem; font-size: .62rem; letter-spacing: .02em;
}
.side-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .42rem .55rem; border-radius: 8px; color: #CBD5E1;
  font-weight: 500; font-size: .88rem;
}
.side-link:hover { background: #1E293B; color: #fff; text-decoration: none; }
.side-link .ico { width: 1.1rem; text-align: center; opacity: .75; font-size: .85rem; }
.side-active { background: var(--primary); color: #fff; }
.side-active:hover { background: var(--primary); }
.side-link.disabled { color: #475569; cursor: default; }
.side-link.disabled:hover { background: none; color: #475569; }
.side-foot {
  margin-top: auto; padding: .9rem .55rem 0; font-size: .78rem; color: #64748B;
  display: flex; align-items: center; gap: .45rem;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--ok); box-shadow: 0 0 6px var(--ok); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .9rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: .6rem 1.5rem; position: sticky; top: 0; z-index: 10;
}
.top-search { flex: 1; max-width: 440px; }
.top-search input {
  width: 100%; padding: .5rem .85rem; border: 1px solid var(--line);
  border-radius: 9px; background: var(--bg); font: inherit;
}
.top-user { margin-left: auto; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--ai));
  color: #fff; font-weight: 700; font-size: .9rem;
}
.content { padding: 1.5rem; max-width: 1200px; width: 100%; margin: 0 auto; }

@media (max-width: 820px) {
  .sidebar { display: none; }
}

/* ── page chrome ───────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; gap: .9rem; margin-bottom: 1.2rem; }
.page-head .btn, .page-head form { margin-left: auto; }
.page-head h1 .badge { vertical-align: middle; margin-left: .4rem; }
.count-pill {
  background: #E2E8F0; border-radius: 999px; font-size: .78rem;
  padding: .12rem .6rem; vertical-align: middle; color: var(--muted); font-weight: 600;
}

/* ── KPI cards ─────────────────────────────────────────── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .9rem; margin-bottom: 1.2rem;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.1rem; border-top: 3px solid var(--primary);
}
.kpi-warn { border-top-color: var(--warn); }
.kpi-ok   { border-top-color: var(--ok); }
.kpi-ai   { border-top-color: var(--ai); }
.kpi-label { font-size: .78rem; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; margin-top: .15rem; }

/* ── cards / funnel / feed ─────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem; margin-bottom: 1.2rem;
}
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.funnel { display: flex; flex-direction: column; gap: .55rem; }
.funnel-row {
  display: grid; grid-template-columns: 160px 1fr 44px; align-items: center;
  gap: .8rem; color: var(--ink);
}
.funnel-row:hover { text-decoration: none; }
.funnel-row:hover .funnel-label { color: var(--primary); }
.funnel-label { font-size: .82rem; font-weight: 600; text-transform: capitalize; }
.funnel-track { background: #EEF2F7; border-radius: 999px; height: 14px; overflow: hidden; }
.funnel-bar {
  display: block; height: 100%; border-radius: 999px;
  transition: width .6s ease;
}
.funnel-1 { background: #2563EB; } .funnel-2 { background: #4F46E5; }
.funnel-3 { background: #7C3AED; } .funnel-4 { background: #9333EA; }
.funnel-5 { background: #F59E0B; } .funnel-6 { background: #10B981; }
.funnel-7 { background: #059669; }
.funnel-count { font-weight: 700; font-size: .85rem; text-align: right; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: .55rem 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.feed li:first-child { border-top: 0; padding-top: 0; }
.feed-meta { margin-left: auto; font-size: .8rem; }

/* ── forms & buttons ───────────────────────────────────── */
label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%; margin-top: .3rem; padding: .55rem .75rem;
  border: 1px solid var(--line); border-radius: 9px;
  font: inherit; color: var(--ink); background: #fff;
}
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(37, 99, 235, .18); border-color: var(--primary);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1.25rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; align-items: center; gap: .85rem; margin-top: 1rem; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: span 1; } }

.btn {
  display: inline-block; padding: .5rem 1rem; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-weight: 600; color: var(--ink); cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}
.btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-block { width: 100%; }

/* ── chips & search row ────────────────────────────────── */
.status-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.chip {
  padding: .28rem .8rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.chip:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.chip-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.searchbar { display: flex; gap: .6rem; margin-bottom: 1rem; }
.searchbar input { margin-top: 0; max-width: 420px; }

/* ── tables ────────────────────────────────────────────── */
.table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.table-flat { border-radius: var(--radius-sm); box-shadow: none; margin-top: .4rem; }
.table th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: .6rem .9rem; border-bottom: 1px solid var(--line);
  background: #F8FAFC;
}
.table td { padding: .62rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #F1F5FF; }
.row-link { font-weight: 600; color: var(--ink); }
.row-link:hover { color: var(--primary); }
.row-actions a { font-size: .85rem; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem !important; }
.review-head { margin-bottom: .4rem; }

/* ── status badges ─────────────────────────────────────── */
.badge {
  display: inline-block; padding: .16rem .62rem; border-radius: 999px;
  font-size: .73rem; font-weight: 700; white-space: nowrap;
  background: #EEF2F7; color: var(--muted);
}
.badge-pending_approval      { background: #FEF3C7; color: #92400E; }
.badge-approved              { background: #D1FAE5; color: #065F46; }
.badge-rejected              { background: #FEE2E2; color: #991B1B; }
.badge-contacted             { background: #DBEAFE; color: #1E40AF; }
.badge-engaged               { background: #EDE9FE; color: #5B21B6; }
.badge-site_ready_for_review { background: #FFEDD5; color: #9A3412; }
.badge-website_delivered     { background: #CCFBF1; color: #115E59; }
.badge-handed_to_sales       { background: #DCFCE7; color: #166534; }
.badge-escalated             { background: #FFE4E6; color: #9F1239; }

/* ── detail page ───────────────────────────────────────── */
.detail-list { display: grid; grid-template-columns: 160px 1fr; margin: 0; row-gap: .5rem; }
.detail-list dt { color: var(--muted); font-size: .84rem; }
.detail-list dd { margin: 0; }
.status-form { display: flex; gap: .6rem; }
.status-form select { margin-top: 0; }
.note-form textarea { resize: vertical; }
.note-form button { margin-top: .6rem; }
.notes { list-style: none; margin: 1rem 0 0; padding: 0; }
.notes li { border-top: 1px solid var(--line); padding: .75rem 0; }
.notes p { margin: 0 0 .25rem; white-space: pre-wrap; }

/* ── pagination & alerts ───────────────────────────────── */
.pagination { display: flex; gap: .35rem; margin-top: 1rem; }
.page {
  padding: .3rem .72rem; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); font-weight: 600;
}
.page-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.alert {
  background: #FEF2F2; color: var(--danger); border: 1px solid #FECACA;
  border-radius: 9px; padding: .6rem .95rem; margin-bottom: 1rem;
}

/* ── login ─────────────────────────────────────────────── */
.login-body {
  display: grid; place-items: center; min-height: 100vh; margin: 0;
  background: radial-gradient(1000px 600px at 20% 0%, #1E293B 0%, var(--sidebar) 55%);
  font: 14.5px/1.55 Inter, "IBM Plex Sans", system-ui, "Segoe UI", Roboto, sans-serif;
}
.login-card {
  width: min(370px, 92vw); background: var(--surface);
  border-radius: 18px; padding: 2.1rem; box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}
.login-brand { font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; }
.login-brand span { color: var(--primary); }
.login-sub { color: var(--muted); margin: .2rem 0 1.4rem; }
.login-card label { margin-bottom: .95rem; }
.login-card button { margin-top: .4rem; }
