:root {
  --accent: #e11d48;
  --accent-600: #be123c;
  --accent-50: #fff1f2;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f7fb;
  --card: #ffffff;
  --ok: #059669;
  --ok-50: #ecfdf5;
  --warn: #d97706;
  --warn-50: #fffbeb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
}

html { font-size: 15px; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.link-accent { color: var(--accent); text-decoration: none; }
.link-accent:hover { color: var(--accent-600); text-decoration: underline; }
.link-muted { color: var(--muted); text-decoration: none; }
.link-muted:hover { color: var(--ink); }

/* ---------- Buttons ---------- */
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-accent:hover, .btn-accent:focus { background: var(--accent-600); border-color: var(--accent-600); color: #fff; }
.btn-ghost { color: #fff; border: 1px solid rgba(255,255,255,.2); }
.btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.btn:focus-visible, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 .2rem rgba(225, 29, 72, .2);
  border-color: var(--accent);
}
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 500; letter-spacing: -.01em; }
.brand strong { font-weight: 800; }
.brand-logo { width: 34px; height: 34px; object-fit: contain; }
.brand-lg { font-size: 1.35rem; }
.brand-lg .brand-logo { width: 48px; height: 48px; }
.auth-logo { display: block; width: 120px; height: auto; margin: 0 auto 1.75rem; }

/* ---------- App header ---------- */
.app-header { background: #0f172a; position: sticky; top: 0; z-index: 1030; }
.app-header .navbar { padding: .7rem 0; }
.main-nav .nav-link { white-space: nowrap; color: rgba(255,255,255,.7); font-weight: 500; border-radius: 10px; padding: .45rem .8rem !important; display: flex; align-items: center; gap: .4rem; }
.main-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.main-nav .nav-link.active { color: #fff; background: rgba(255,255,255,.1); }

.app-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 1.25rem 0; margin-top: 2rem; background: #fff; }
.app-footer a { color: var(--ink-2); }

/* ---------- Nav badges ---------- */
.badge-new { background: var(--accent); font-weight: 600; }
.badge-follow { background: #f59e0b; color: #1f1300; font-weight: 600; }
.js-fetch { white-space: nowrap; }
.js-fetch.loading i { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-light-line { background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; border-radius: 10px; }
.btn-light-line:hover, .btn-light-line.active { border-color: var(--ink-2); color: var(--ink); background: #fff; }
.text-accent { color: var(--accent); }

/* ---------- Page actions / search ---------- */
.page-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.search-box { position: relative; }
.search-box i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { padding-left: 2.3rem; min-width: 300px; border-radius: 10px; }

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat-card {
  display: flex; align-items: center; gap: .9rem;
  background: var(--card); border-radius: var(--radius); padding: 1rem 1.1rem;
  box-shadow: var(--shadow); text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s;
}
a.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0; }
.stat-icon.pending { background: var(--accent-50); color: var(--accent); }
.stat-icon.today { background: var(--warn-50); color: var(--warn); }
.stat-icon.hot { background: #fff7ed; color: #ea580c; }
.stat-icon.total { background: #eef2ff; color: #4f46e5; }
.stat-icon.read { background: var(--ok-50); color: var(--ok); }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { display: block; color: var(--muted); font-size: .8rem; }

/* ---------- Panels ---------- */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-title { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.panel-title i { color: var(--accent); }
.side-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.side-title { text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; color: var(--muted); font-weight: 700; margin-bottom: .9rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .9rem; }
.section-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.section-title i { color: #ea580c; }

/* ---------- Tabs & filters ---------- */
.tab-bar { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1rem; scrollbar-width: none; }
.tab-link { display: flex; align-items: center; gap: .4rem; padding: .6rem .9rem; color: var(--muted); font-weight: 600; font-size: .9rem; text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tab-link:hover { color: var(--ink); }
.tab-link.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count { background: #eef2f7; color: var(--ink-2); font-size: .72rem; padding: .05rem .5rem; border-radius: 999px; }
.tab-link.active .tab-count { background: var(--accent-50); color: var(--accent); }
.filter-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; align-items: center; }
.chip-row, .filter-right { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--accent); color: #fff; font-weight: 600; font-size: .78rem; padding: .3rem .75rem; border-radius: 999px; text-decoration: none; border: 1px solid var(--accent); }
.chip-outline { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.chip-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Lead cards ---------- */
.lead-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.lead-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lead-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .55rem; border-left: 4px solid transparent;
  transition: transform .2s, box-shadow .2s, opacity .35s;
}
.lead-card:hover { box-shadow: var(--shadow-lg); }
.lead-card.status-new { border-left-color: var(--accent); }
.lead-card.status-reviewed { opacity: .92; }
.lead-card.status-dismissed, .lead-card.status-lost { opacity: .65; }
.lead-card.removing { opacity: 0; transform: scale(.96); }
.lead-card-top { display: flex; align-items: center; gap: .6rem; }
.lead-card-tags { display: flex; flex-wrap: wrap; gap: .3rem; min-width: 0; }
.lead-age { margin-left: auto; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.src-chip { font-size: .72rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; color: var(--src); background: color-mix(in srgb, var(--src) 12%, #fff); white-space: nowrap; }
.cat-chip { font-size: .72rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; color: var(--ink-2); background: #f1f5f9; white-space: nowrap; }
.tr-chip { font-size: .68rem; font-weight: 800; padding: .15rem .45rem; border-radius: 6px; color: #fff; background: #e30a17; letter-spacing: .03em; }
.lead-title { font-size: 1rem; font-weight: 700; line-height: 1.35; margin: 0; }
.lead-title a { text-decoration: none; }
.lead-title a:hover { color: var(--accent); }
.lead-summary { color: var(--ink-2); font-size: .85rem; line-height: 1.5; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.lead-meta { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .78rem; color: var(--muted); }
.meta-budget { color: var(--ok); font-weight: 700; }
.meta-contact { color: #0d9488; font-weight: 600; }
.meta-due { color: var(--accent); font-weight: 700; }
.lead-actions { margin-top: auto; display: flex; align-items: center; gap: .4rem; padding-top: .35rem; border-top: 1px dashed var(--line); }

.score { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-size: .9rem; color: #fff; }
.score-lg { width: 56px; height: 56px; font-size: 1.2rem; }
.score-hot { background: linear-gradient(135deg, #f97316, #e11d48); box-shadow: 0 4px 12px rgba(225, 29, 72, .3); }
.score-warm { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.score-cold { background: #cbd5e1; color: #334155; }

.btn-review { border: 1px solid var(--line); color: var(--ink-2); background: #fff; border-radius: 999px; font-weight: 600; font-size: .78rem; display: inline-flex; align-items: center; gap: .3rem; }
.btn-review:hover { border-color: var(--ok); color: var(--ok); }
.btn-review.active { background: var(--ok-50); border-color: var(--ok); color: var(--ok); }
.btn-review.active:hover { background: #fff; border-color: var(--muted); color: var(--muted); }
.btn-icon { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: #fff; }
.btn-icon:hover { color: var(--ink); border-color: var(--ink-2); }
.btn-interest:hover { color: #4f46e5; border-color: #4f46e5; background: #eef2ff; }
.btn-dismiss:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-50); }
button:disabled { opacity: .6; }

.status-pill { font-size: .72rem; font-weight: 700; padding: .12rem .55rem; border-radius: 999px; background: #f1f5f9; color: var(--ink-2); white-space: nowrap; }
.status-pill.status-new { background: var(--accent-50); color: var(--accent); }
.status-pill.status-reviewed { background: var(--ok-50); color: var(--ok); }
.status-pill.status-interested { background: #eef2ff; color: #4f46e5; }
.status-pill.status-contacted { background: #e0f2fe; color: #0369a1; }
.status-pill.status-proposed { background: var(--warn-50); color: var(--warn); }
.status-pill.status-won { background: #dcfce7; color: #15803d; }
.status-pill.status-lost, .status-pill.status-dismissed { background: #f1f5f9; color: var(--muted); }

/* ---------- Detail ---------- */
.detail-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; }
.detail-side { position: sticky; top: 84px; }
.detail-title { font-size: 1.55rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; }
.detail-facts { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; color: var(--muted); font-size: .85rem; margin: .5rem 0 1.25rem; }
.detail-desc { white-space: pre-line; line-height: 1.65; color: var(--ink-2); font-size: .95rem; overflow-wrap: anywhere; }
.kw-row { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: 1rem; }
.kw { font-size: .72rem; background: #f8fafc; border: 1px solid var(--line); color: var(--ink-2); padding: .1rem .5rem; border-radius: 6px; }
.reply-draft { font-size: .88rem; line-height: 1.55; background: #f8fafc; border-radius: 10px; }
.contact-box { background: #f0fdfa; color: #0f766e; border-radius: 10px; padding: .6rem .8rem; font-weight: 600; font-size: .88rem; overflow-wrap: anywhere; }

.stepper { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.stepper button { width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: .5rem .75rem; font-size: .88rem; font-weight: 600; color: var(--ink-2); display: flex; gap: .5rem; align-items: center; }
.stepper button:hover { border-color: var(--accent); color: var(--accent); }
.stepper li.done button { background: var(--ok-50); border-color: #a7f3d0; color: var(--ok); }
.stepper li.current button { background: var(--ink); border-color: var(--ink); color: #fff; opacity: 1; }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1rem 1rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline li.is-status::before { background: #cbd5e1; }
.timeline-meta { font-size: .75rem; color: var(--muted); }
.timeline-text { white-space: pre-line; font-size: .9rem; }
.timeline li.is-status .timeline-text { color: var(--muted); font-size: .84rem; }

/* ---------- Create ---------- */
.source-pick { display: flex; flex-wrap: wrap; gap: .5rem; }
.source-option { margin: 0; }
.source-option input { position: absolute; opacity: 0; }
.source-option span { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--ink-2); background: #fff; }
.source-option span i { color: var(--src); }
.source-option input:checked + span { border-color: var(--src); background: color-mix(in srgb, var(--src) 10%, #fff); color: var(--ink); }
.source-option input:focus-visible + span { box-shadow: 0 0 0 .2rem rgba(225, 29, 72, .2); }
.quick-links { list-style: none; padding: 0; margin: 0; display: grid; gap: .9rem; }
.quick-links a { font-weight: 700; text-decoration: none; }
.quick-links a:hover { color: var(--accent); }
.quick-links p { font-size: .8rem; color: var(--muted); margin: .2rem 0 0; }

/* ---------- Sources ---------- */
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.source-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; display: flex; flex-direction: column; border-top: 3px solid var(--src); }
.source-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; color: var(--src); background: color-mix(in srgb, var(--src) 12%, #fff); }
.source-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .9rem; }
.source-stats div { background: #f8fafc; border-radius: 10px; padding: .5rem; text-align: center; }
.source-stats strong { display: block; font-size: 1.15rem; }
.source-stats span { font-size: .72rem; color: var(--muted); }
.source-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.log-table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #f8fafc; padding: .7rem 1rem; }
.log-table td { padding: .6rem 1rem; font-size: .88rem; }
.log-table .num { font-variant-numeric: tabular-nums; }
.error-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Dashboard ---------- */
.dash-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.bar-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.bar-list li { display: grid; grid-template-columns: 130px 1fr 34px; gap: .6rem; align-items: center; font-size: .82rem; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.bar { height: 8px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.follow-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.follow-list a { display: block; font-weight: 600; font-size: .88rem; text-decoration: none; line-height: 1.3; }
.follow-list a:hover { color: var(--accent); }

/* ---------- Toast ---------- */
#appToast { background: #0f172a; color: #fff; border-radius: 12px; }

/* ---------- Page head ---------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.25rem; }
.page-title { font-family: "Playfair Display", Georgia, serif; font-weight: 800; font-size: 1.9rem; margin: 0; letter-spacing: -.01em; }
.page-title i { color: var(--accent); font-size: 1.4rem; vertical-align: .15em; }
.page-sub { color: var(--muted); margin: .25rem 0 0; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--muted); background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-state > i { font-size: 3rem; color: #cbd5e1; display: block; margin-bottom: .5rem; }

/* ---------- Auth ---------- */
body.auth { background: #fff; }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; display: flex; align-items: center; padding: 3rem;
  background:
    radial-gradient(1200px 600px at -10% -10%, rgba(251,113,133,.45), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(129,140,248,.35), transparent 60%),
    #0f172a;
}
.auth-hero-inner { max-width: 460px; margin: 0 auto; }
.auth-hero h1 { font-family: "Playfair Display", Georgia, serif; font-weight: 800; font-size: 2.8rem; line-height: 1.1; margin: 2.5rem 0 1rem; }
.auth-hero p { color: rgba(255,255,255,.75); font-size: 1.05rem; line-height: 1.6; }
.auth-features { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .8rem; }
.auth-features li { display: flex; gap: .7rem; align-items: center; color: rgba(255,255,255,.85); }
.auth-features i { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: rgba(255,255,255,.1); color: #fda4af; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-title { font-weight: 700; font-size: 1.6rem; margin-bottom: .35rem; letter-spacing: -.01em; }
.auth-sub { color: var(--muted); margin-bottom: 1.75rem; }
.auth-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem; background: var(--accent-50); color: var(--accent); margin-bottom: 1.25rem; }
.auth-icon.success { background: var(--ok-50); color: var(--ok); }
.auth .form-label { font-weight: 600; font-size: .88rem; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .form-control { padding: .7rem .9rem .7rem 2.5rem; border-radius: 10px; }
.btn-eye { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); padding: .25rem .5rem; }
.auth .btn { border-radius: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
  .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-layout { grid-template-columns: 1fr; }
}
@media (max-width: 991.98px) {
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .lead-grid-2 { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { padding: 2rem 1.5rem; }
  .auth-hero h1 { font-size: 2rem; margin-top: 1.5rem; }
  .auth-features { display: none; }
}
@media (max-width: 575.98px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead-grid { grid-template-columns: 1fr; }
  .search-box, .search-box input { min-width: 0; width: 100%; }
  .page-actions { width: 100%; }
  .bar-list li { grid-template-columns: 110px 1fr 30px; }
}
