/* Lead Intelligence — calm professional blue theme */
:root {
  --bg: #f3f6fb;
  --bg-alt: #eaf0f9;
  --panel: #ffffff;
  --ink: #1b2a4a;
  --muted: #6b7a99;
  --faint: #97a3bd;
  --line: #e2e8f4;
  --line-strong: #cfd9ec;

  --blue: #2563c9;
  --blue-dark: #1d4ed8;
  --blue-600: #2b57b8;
  --blue-050: #eef4fe;
  --blue-100: #dbe7fb;

  --sky: #38bdf8;
  --teal: #0ea5a3;
  --amber: #d98a1f;
  --amber-soft: #fbeccd;
  --green: #1f9d6b;
  --green-soft: #d6f1e4;
  --rose: #d6584f;
  --rose-soft: #f8dcd9;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px -24px rgba(31, 54, 105, 0.35);
  --shadow-sm: 0 6px 18px -12px rgba(31, 54, 105, 0.4);
  --font: "Inter", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }

/* ---------- Auth layout ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--bg);
}
.auth-aside {
  position: relative;
  padding: 56px 60px;
  color: #eaf1ff;
  background: radial-gradient(120% 120% at 0% 0%, #2f6fe0 0%, #1e3a8a 55%, #172a63 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.auth-aside::after {
  content: "";
  position: absolute;
  inset: auto -80px -120px auto;
  width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(120, 170, 255, 0.45), transparent 70%);
}
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 600; letter-spacing: .2px; }
.auth-brand .logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(150deg, #7db4ff, #3b82f6);
  display: grid; place-items: center; color: #fff; font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.auth-aside h2 { font-size: 32px; line-height: 1.2; margin: 0 0 14px; font-weight: 600; }
.auth-aside p { color: #c6d7f7; max-width: 420px; margin: 0; }
.auth-points { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 14px; position: relative; z-index: 1; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: #dbe6fb; }
.auth-points .tick {
  flex: none; width: 22px; height: 22px; border-radius: 7px; margin-top: 1px;
  background: rgba(255,255,255,.15); display: grid; place-items: center; color: #bfe0ff; font-size: 13px;
}
.auth-foot { color: #a9c0ec; font-size: 13px; position: relative; z-index: 1; }

.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 26px; margin: 0 0 6px; font-weight: 600; }
.auth-card .sub { color: var(--muted); margin: 0 0 26px; }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-strong);
  background: #fbfcfe;
  color: var(--ink);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s, background .15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 4px var(--blue-050);
}
.field .hint { font-size: 12px; color: var(--faint); }
.field-inline { display: flex; align-items: center; justify-content: space-between; }

.btn {
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 11px 16px; font-weight: 600; background: var(--blue); color: #fff;
  transition: background .15s, box-shadow .15s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--blue-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost { background: #fff; color: var(--blue); border-color: var(--line-strong); box-shadow: none; }
.btn-ghost:hover { background: var(--blue-050); }
.btn-soft { background: var(--blue-050); color: var(--blue-dark); box-shadow: none; }
.btn-soft:hover { background: var(--blue-100); }

.auth-divider { text-align: center; color: var(--faint); font-size: 13px; margin: 20px 0; position: relative; }
.auth-divider::before, .auth-divider::after {
  content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--line);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }
.auth-alt { text-align: center; color: var(--muted); margin-top: 20px; font-size: 14px; }

.alert { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13.5px; margin-bottom: 18px; border: 1px solid; }
.alert-error { background: var(--rose-soft); border-color: #efc3bf; color: #9a342c; }
.alert-info { background: var(--blue-050); border-color: var(--blue-100); color: var(--blue-dark); }
.alert-success { background: var(--green-soft); border-color: #b4e2cd; color: #157a52; }
.alert code { background: rgba(0,0,0,.05); padding: 2px 6px; border-radius: 5px; font-family: var(--mono); word-break: break-all; }

.status-icon { width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; margin: 0 auto 18px; }
.status-icon.ok { background: var(--green-soft); color: var(--green); }
.status-icon.wait { background: var(--blue-050); color: var(--blue); }
.status-icon.warn { background: var(--amber-soft); color: var(--amber); }
.center { text-align: center; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar {
  background: linear-gradient(180deg, #1e3a8a, #182c63);
  color: #cdd9f2; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 20px; color: #fff; font-weight: 600; }
.sidebar .brand .logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff;
  background: linear-gradient(150deg, #7db4ff, #3b82f6);
}
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: #c2d1ee; font-weight: 500; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,.14); color: #fff; }
.nav-link .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar .spacer { flex: 1; }
.sidebar .user {
  border-top: 1px solid rgba(255,255,255,.12); padding-top: 14px; margin-top: 6px;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.sidebar .user .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.16);
  display: grid; place-items: center; font-weight: 600; color: #fff;
}
.sidebar .user small { color: #a9bce4; display: block; }

.content { padding: 26px 34px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 27px; margin: 0; font-weight: 600; letter-spacing: -.3px; }
.page-head p { margin: 5px 0 0; color: var(--muted); }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.eyebrow { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--blue); font-weight: 700; margin-bottom: 6px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.stat b { display: block; font-size: 32px; font-weight: 700; margin-top: 8px; letter-spacing: -1px; }
.stat .chip { position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; }
.stat.b-blue .chip { background: var(--blue-050); color: var(--blue); }
.stat.b-teal .chip { background: #d6f2f0; color: var(--teal); }
.stat.b-green .chip { background: var(--green-soft); color: var(--green); }
.stat.b-amber .chip { background: var(--amber-soft); color: var(--amber); }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 17px; margin: 0; font-weight: 600; }
.panel-body { padding: 18px 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0,2.1fr) minmax(280px,.72fr); gap: 20px; align-items: start; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search {
  flex: 1; min-width: 200px; position: relative;
}
.search input { width: 100%; padding: 10px 12px 10px 36px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fbfcfe; }
.search input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-050); background: #fff; }
.search .mag { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.select { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; background: #fff; color: var(--ink); }

/* ---------- Leads table ---------- */
.table-wrap { overflow-x: auto; }
table.leads { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 720px; }
table.leads thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted);
  font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #f7f9fd; white-space: nowrap;
}
table.leads thead th.sortable { cursor: pointer; user-select: none; }
table.leads thead th.sortable:hover { color: var(--ink, #1a2233); background: var(--blue-050); }
table.leads thead th.sortable::after { content: "↕"; margin-left: 5px; opacity: .3; font-size: 10px; }
table.leads thead th.sorted-asc::after { content: "↑"; opacity: 1; color: var(--blue, #2563c9); }
table.leads thead th.sorted-desc::after { content: "↓"; opacity: 1; color: var(--blue, #2563c9); }
.review-count { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink, #1a2233); }
table.leads tbody td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.leads tbody tr { transition: background .12s; }
table.leads tbody tr:hover { background: var(--blue-050); }
table.leads tbody tr.lead-row { cursor: pointer; }
table.leads tbody tr.lead-row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; background: var(--blue-050); }
.lead-biz { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.lead-avatar {
  width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-weight: 700; color: #fff; font-size: 14px; letter-spacing: .3px;
}
.lead-biz .name { font-weight: 600; color: var(--ink); }
.lead-biz .addr { font-size: 12.5px; color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-contact { font-size: 13px; }
.lead-contact a { display: inline-flex; align-items: center; gap: 5px; }
.lead-contact .muted { color: var(--faint); }
.cat-tag { display: inline-block; background: var(--bg-alt); color: var(--blue-dark); border-radius: 20px; padding: 4px 11px; font-size: 12px; font-weight: 600; }
.stars { color: var(--amber); letter-spacing: 1px; font-size: 13px; white-space: nowrap; }
.stars .val { color: var(--ink); font-weight: 600; margin-left: 4px; }
.stars .empty { color: var(--line-strong); }

.badge { display: inline-block; padding: 4px 11px; border-radius: 20px; font-size: 11.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; background: var(--bg-alt); color: var(--muted); }
.badge.HOT { background: var(--rose-soft); color: #b23b32; }
.badge.GOOD { background: var(--green-soft); color: #157a52; }
.badge.POTENTIAL { background: var(--amber-soft); color: #9a6412; }
.badge.REJECT { background: #eceff5; color: #8a97b0; }
.badge.UNRATED { background: #eceff5; color: var(--faint); }
.badge.completed { background: var(--green-soft); color: #157a52; }
.badge.failed { background: var(--rose-soft); color: #b23b32; }
.badge.running { background: var(--blue-050); color: var(--blue-dark); }

.score { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.score .bar { flex: 1; height: 7px; border-radius: 6px; background: var(--line); overflow: hidden; }
.score .fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--sky), var(--blue)); }
.score .num { font-weight: 700; font-size: 13px; width: 26px; text-align: right; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; color: var(--muted); font-size: 13.5px; border-top: 1px solid var(--line); }
.pager button { border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; padding: 7px 14px; color: var(--ink); font-weight: 500; }
.pager button:hover:not(:disabled) { background: var(--blue-050); border-color: var(--blue-100); }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

.empty-state { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-state .ico { font-size: 30px; opacity: .5; }

/* ---------- Runs list ---------- */
.run-item { display: block; padding: 13px 14px; border: 1px solid var(--line); border-radius: 11px; margin-bottom: 10px; transition: border-color .15s, box-shadow .15s; }
.run-item:hover { border-color: var(--blue-100); box-shadow: var(--shadow-sm); text-decoration: none; }
.run-item .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.run-item .q { font-weight: 600; color: var(--ink); }
.run-item .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.run-item .time { color: var(--faint); font-size: 12px; margin-top: 3px; }

/* ---------- Forms (campaign) ---------- */
.form-grid { display: grid; gap: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 6px 0 2px; }
.notice { margin-top: 14px; color: var(--muted); font-size: 13.5px; }
.toggle-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toggle-card { border: 1px solid var(--line-strong); border-radius: 11px; padding: 13px 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.toggle-card:hover { border-color: var(--blue-100); }
.toggle-card.active { border-color: var(--blue); background: var(--blue-050); }
.toggle-card .t { font-weight: 600; }
.toggle-card .d { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* ---------- Terminal / run logs ---------- */
.terminal-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.terminal-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: #0f172a; color: #cbd5f5; }
.terminal-bar .dots { display: flex; gap: 7px; }
.terminal-bar .dot { width: 12px; height: 12px; border-radius: 50%; }
.terminal-bar .dot.r { background: #ff5f57; }
.terminal-bar .dot.y { background: #febc2e; }
.terminal-bar .dot.g { background: #28c840; }
.terminal-bar .title { font-family: var(--mono); font-size: 13px; color: #94a3c8; margin-left: 6px; }
.terminal-bar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.terminal-bar .tbtn { background: rgba(255,255,255,.08); border: 0; color: #cbd5f5; border-radius: 7px; padding: 5px 10px; font-size: 12px; }
.terminal-bar .tbtn:hover { background: rgba(255,255,255,.16); }
.terminal {
  background: #0b1120; color: #d7e0f5; font-family: var(--mono); font-size: 13px; line-height: 1.7;
  padding: 18px 20px; height: 62vh; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.terminal .ln { display: flex; gap: 14px; }
.terminal .ts { color: #5f7196; flex: none; }
.terminal .msg { flex: 1; }
.terminal .lvl-INFO .msg { color: #cdd8f2; }
.terminal .lvl-STAGE .msg { color: #7dd3fc; }
.terminal .lvl-OK .msg { color: #6ee7a8; }
.terminal .lvl-WARN .msg { color: #fbcf7a; }
.terminal .lvl-ERROR .msg { color: #ff9d94; }
.terminal .lvl-CMD .msg { color: #a5b4fc; }
.terminal .lvl-DONE .msg { color: #6ee7a8; font-weight: 600; }
.terminal .cursor { display: inline-block; width: 8px; height: 15px; background: #6ee7a8; vertical-align: middle; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.term-meta { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.term-meta .m .k { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; }
.term-meta .m .v { font-weight: 600; margin-top: 3px; }

/* ---------- Lead detail modal ---------- */
body.modal-open { overflow: hidden; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 33, 66, 0.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
  animation: modal-fade .18s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: 100%; max-width: 940px;
  background: var(--bg); border-radius: 18px;
  box-shadow: 0 30px 70px -20px rgba(15, 27, 60, 0.55);
  animation: modal-rise .22s cubic-bezier(.16,.84,.44,1);
}
@keyframes modal-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: #fff; color: var(--muted);
  font-size: 14px; display: grid; place-items: center; transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--rose-soft); color: var(--rose); border-color: #efc3bf; }
.modal-actions {
  position: absolute; top: 16px; right: 140px; z-index: 2;
  display: flex; gap: 8px;
}
.modal-action {
  height: 34px; padding: 0 12px; border-radius: 17px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--muted);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background .15s, color .15s, border-color .15s;
}
.modal-action:hover { background: var(--blue-050); color: var(--blue); border-color: var(--blue); }
.modal-action.is-done { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.modal-body { padding: 0; }
.modal-loading { padding: 60px 24px; text-align: center; color: var(--muted); }
.modal-loading.modal-error { color: var(--rose); }

.modal-header {
  display: flex; align-items: center; gap: 16px;
  padding: 26px 30px; border-radius: 18px 18px 0 0;
  background: linear-gradient(135deg, #eaf1fe 0%, #f4f7fc 60%);
  border-bottom: 1px solid var(--line);
}
.modal-avatar {
  width: 58px; height: 58px; border-radius: 14px; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 21px;
  box-shadow: var(--shadow-sm);
}
.modal-head-main { flex: 1; min-width: 0; }
.modal-head-main h2 { margin: 0 0 8px; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.modal-head-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-stars { font-size: 13px; color: var(--amber); letter-spacing: 1px; }
.modal-stars .val { color: var(--ink); font-weight: 600; margin-left: 4px; }
.modal-stars .empty { color: var(--line-strong); }
.modal-reviews { color: var(--muted); font-size: 13px; font-weight: 600; }
.modal-score-badge {
  flex: none; text-align: center; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 16px; box-shadow: var(--shadow-sm); position: relative; right: 25px;
}
.modal-score-badge b { display: block; font-size: 24px; font-weight: 700; color: var(--blue-dark); letter-spacing: -1px; }
.modal-score-badge span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; }

.modal-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  padding: 22px 30px 30px;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.modal-card-wide { grid-column: 1 / -1; }
.modal-card h3 {
  display: flex; align-items: center; gap: 8px; margin: 0 0 12px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700;
}
.modal-card .mc-ico { color: var(--blue); font-size: 14px; }
.modal-card dl { margin: 0; display: grid; gap: 10px; }
.dl-row { display: grid; grid-template-columns: 130px 1fr; gap: 12px; align-items: baseline; }
.dl-row dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.dl-row dd { margin: 0; color: var(--ink); font-size: 13.5px; word-break: break-word; }
.dl-row dd a { word-break: break-all; }
.modal-notes { margin: 0; color: var(--ink); font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.metric-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.metric-top span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.metric-top b { font-size: 16px; font-weight: 700; color: var(--ink); }
.metric-bar { height: 7px; border-radius: 6px; background: var(--line); overflow: hidden; }
.metric-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--sky), var(--blue)); }

/* ---------- Header stage chip ---------- */
.stage-chip {
  display: inline-block; padding: 4px 11px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .3px; background: var(--blue); color: #fff;
}

/* ---------- Sales funnel ---------- */
.funnel { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.funnel-sep { color: var(--faint); font-size: 14px; font-weight: 600; user-select: none; }
.funnel-step {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--muted);
  border-radius: 22px; padding: 7px 14px 7px 8px; font-weight: 600; font-size: 13px;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.funnel-step:hover { border-color: var(--blue); color: var(--blue-dark); background: var(--blue-050); }
.funnel-step .fs-num {
  width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--bg-alt); color: var(--muted); font-size: 12px; font-weight: 700;
}
.funnel-step.done { border-color: var(--blue-100); background: var(--blue-050); color: var(--blue-dark); }
.funnel-step.done .fs-num { background: var(--blue); color: #fff; }
.funnel-step.current { border-color: var(--blue); background: var(--blue); color: #fff; box-shadow: var(--shadow-sm); }
.funnel-step.current .fs-num { background: rgba(255,255,255,.25); color: #fff; }
.funnel-step.current.won { border-color: var(--green); background: var(--green); }
.funnel-step.current.lost { border-color: var(--rose); background: var(--rose); }

/* ---------- Website development status ---------- */
.wds { display: flex; flex-wrap: wrap; gap: 8px; }
.wds-step {
  border: 1px solid var(--line-strong); background: #fff; color: var(--muted);
  border-radius: 20px; padding: 7px 14px; font-weight: 600; font-size: 13px;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.wds-step:hover { border-color: var(--blue); color: var(--ink); }
.wds-step.active { color: #fff; box-shadow: var(--shadow-sm); }
.wds-step.active.wds-none { background: var(--rose); border-color: var(--rose); }
.wds-step.active.wds-poor { background: var(--amber); border-color: var(--amber); }
.wds-step.active.wds-good { background: var(--green); border-color: var(--green); }
.wds-step.active.wds-redesign { background: var(--blue); border-color: var(--blue); }
.wds-step.active.wds-construction { background: var(--blue-600); border-color: var(--blue-600); }
.wds-hint { margin: 10px 0 0; font-size: 12.5px; color: var(--faint); }

/* ---------- Media (photos & videos) ---------- */
.media-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.media-count { font-size: 13px; font-weight: 600; color: var(--muted); }
.media-mode-wrap { display: inline-flex; gap: 6px; align-items: center; }
.media-mode-wrap .select { min-width: 110px; }
.media-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.media-btns .select { min-width: 110px; }
.media-btns .btn { padding: 8px 14px; font-size: 13px; }
.media-toggle { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.media-toggle input { margin-top: 3px; }
.media-toggle span { display: flex; flex-direction: column; gap: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .modal-grid { grid-template-columns: 1fr; }
  .modal-header { flex-wrap: wrap; padding: 20px; }
  .modal-grid { padding: 18px 20px 24px; }
  .dl-row { grid-template-columns: 110px 1fr; }
}
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .2s; width: 240px; }
  .sidebar.open { transform: none; }
  .content { padding: 20px 16px 50px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ---------- Collapsible sidebar ---------- */
.app { transition: grid-template-columns .18s ease; }
.sidebar { position: sticky; overflow: visible; }
.sidebar-toggle {
  position: absolute; top: 26px; right: -13px; z-index: 30;
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: #fff; color: var(--blue-dark);
  display: grid; place-items: center; line-height: 1; font-size: 16px; padding: 0;
  box-shadow: var(--shadow-sm); transition: background .15s, color .15s;
}
.sidebar-toggle:hover { background: var(--blue-050); }
.sidebar-toggle .chev { display: block; transition: transform .18s ease; margin-top: -2px; }
.sidebar .brand-name, .sidebar .nav-text, .sidebar .user-text { white-space: nowrap; overflow: hidden; }
.sidebar .user-name { color: #fff; font-weight: 600; }
.sidebar .signout-form { margin-top: 12px; }
.sidebar .nav-link.signout { width: 100%; border: 0; background: rgba(255,255,255,.06); text-align: left; }

html.sidebar-collapsed .app { grid-template-columns: 72px 1fr; }
html.sidebar-collapsed .sidebar { padding: 22px 12px; align-items: center; }
html.sidebar-collapsed .sidebar .brand { padding: 6px 0 20px; justify-content: center; }
html.sidebar-collapsed .sidebar-toggle .chev { transform: rotate(180deg); }
html.sidebar-collapsed .brand-name,
html.sidebar-collapsed .nav-text,
html.sidebar-collapsed .user-text { display: none; }
html.sidebar-collapsed .nav-link { justify-content: center; padding: 11px 0; width: 100%; }
html.sidebar-collapsed .nav-link .ico { width: auto; font-size: 16px; }
html.sidebar-collapsed .sidebar .user { justify-content: center; }

/* ---------- Stat card as a link ---------- */
a.stat { display: block; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--blue-100); box-shadow: var(--shadow); }

/* ---------- Toolbar control buttons ---------- */
.ctl-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  border-radius: var(--radius-sm); padding: 9px 13px; font-weight: 600; font-size: 13.5px;
  transition: background .15s, border-color .15s, color .15s;
}
.ctl-btn:hover { background: var(--blue-050); border-color: var(--blue-100); }
.ctl-btn[aria-expanded="true"] { background: var(--blue-050); border-color: var(--blue); color: var(--blue-dark); }
.ctl-btn.has-value { border-color: var(--blue); color: var(--blue-dark); }
.ctl-btn .ctl-ico { color: var(--blue); font-size: 14px; }
.ctl-count {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--blue); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center;
}

/* ---------- Filter / sort builder ---------- */
.builder { border-bottom: 1px solid var(--line); background: #f8fafd; padding: 16px 20px; }
.builder[hidden] { display: none; }
.builder-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.builder-title { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; }
.builder-hint { font-size: 12.5px; color: var(--faint); }
.builder-clear { margin-left: auto; border: 0; background: none; color: var(--blue); font-size: 13px; font-weight: 600; padding: 4px 6px; border-radius: 6px; }
.builder-clear:hover { background: var(--blue-050); }
.match-toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: #fff; }
.match-opt { border: 0; background: none; padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.match-opt.active { background: var(--blue); color: #fff; }

.rule-list { display: grid; gap: 9px; }
.rule {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 9px 11px;
}
.rule-join { font-size: 12.5px; font-weight: 700; color: var(--muted); min-width: 52px; }
.rule select, .rule input {
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 9px;
  background: #fbfcfe; color: var(--ink); font-size: 13.5px; max-width: 100%;
}
.rule select:focus, .rule input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-050); background: #fff; }
.rule-field { min-width: 170px; }
.rule-op { min-width: 140px; }
.rule-values { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 180px; }
.rule-values input { flex: 1; min-width: 110px; }
.rule-multi { flex: 1; min-width: 180px; padding: 4px; }
.rule-multi option { padding: 3px 6px; border-radius: 5px; }
.rule-and { font-size: 12.5px; color: var(--muted); }
.rule-novalue { font-size: 12.5px; color: var(--faint); font-style: italic; }
.rule-remove {
  margin-left: auto; border: 1px solid transparent; background: none; color: var(--faint);
  width: 26px; height: 26px; border-radius: 7px; font-size: 12px; flex: none;
}
.rule-remove:hover { background: var(--rose-soft); color: var(--rose); }
.rule-empty { color: var(--faint); font-size: 13px; padding: 6px 2px; }
.rule-add {
  margin-top: 10px; border: 1px dashed var(--line-strong); background: #fff; color: var(--blue);
  border-radius: 9px; padding: 8px 14px; font-weight: 600; font-size: 13px;
}
.rule-add:hover { border-color: var(--blue); background: var(--blue-050); }

/* ---------- Active filter chips ---------- */
.chip-bar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.chip-bar[hidden] { display: none; }
.chip-join { font-size: 11.5px; font-weight: 700; color: var(--faint); text-transform: uppercase; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--blue-050); border: 1px solid var(--blue-100); color: var(--blue-dark);
  border-radius: 20px; padding: 4px 6px 4px 12px; font-size: 12.5px; font-weight: 600;
}
.filter-chip button {
  border: 0; background: none; color: var(--blue-dark); opacity: .6;
  width: 18px; height: 18px; border-radius: 50%; font-size: 11px; line-height: 1; padding: 0;
}
.filter-chip button:hover { opacity: 1; background: rgba(37, 99, 201, .15); }
.chip-clear { margin-left: 4px; border: 0; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.chip-clear:hover { color: var(--rose); }

/* Multi-level sort rank badge on the column header. */
table.leads thead th.sortable[data-sort-rank]:not([data-sort-rank=""])::before {
  content: attr(data-sort-rank);
  display: inline-grid; place-items: center;
  width: 14px; height: 14px; margin-right: 5px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 9px; font-weight: 700;
}

.stage-chip.sm { font-size: 10.5px; padding: 3px 9px; background: var(--blue-050); color: var(--blue-dark); }

/* ---------- Runs table ---------- */
.runs-table tbody tr.run-row { cursor: pointer; }
.runs-table tbody tr.run-row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; background: var(--blue-050); }
.run-title { font-weight: 600; color: var(--ink); }
.run-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.run-id { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.run-error { font-size: 11.5px; color: var(--rose); margin-top: 4px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.leads td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
table.leads td.num.bad { color: var(--rose); }

@media (max-width: 860px) {
  html.sidebar-collapsed .app { grid-template-columns: 1fr; }
  .rule { align-items: stretch; }
  .rule-field, .rule-op, .rule-values { min-width: 100%; }
  .rule-remove { margin-left: 0; }
}

/* ---------- Duplicate leads ---------- */
.btn-danger { background: var(--rose); color: #fff; }
.btn-danger:hover { background: #bf4a42; }
.btn-danger:disabled { opacity: .5; }

.dup-group { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.dup-group header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; background: #f7f9fd; border-bottom: 1px solid var(--line);
}
.dup-brand { font-weight: 700; color: var(--ink); }
.dup-domain { font-family: var(--mono); font-size: 12px; color: var(--blue-dark); background: var(--blue-050); border-radius: 6px; padding: 2px 8px; }
.dup-count { font-size: 12.5px; color: var(--muted); }
.dup-badge {
  font-size: 10.5px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  background: var(--green-soft); color: #157a52; border-radius: 6px; padding: 3px 8px;
}
.dup-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.dup-merge, .dup-remove, .dup-split {
  border: 1px solid var(--line-strong); background: #fff;
  border-radius: 8px; padding: 5px 12px; font-size: 12.5px; font-weight: 600;
}
.dup-merge { color: var(--blue); }
.dup-merge:hover { background: var(--blue-050); border-color: var(--blue); }
.dup-remove { color: var(--rose); }
.dup-remove:hover { background: var(--rose-soft); border-color: var(--rose); }
.dup-split { color: var(--muted); }
.dup-split:hover { background: var(--bg-alt); border-color: var(--line-strong); color: var(--ink); }
.dup-merge:disabled, .dup-remove:disabled, .dup-split:disabled { opacity: .5; }

/* The two actions do opposite things to the same rows, so the page says which
   is which before either button is pressed. */
.dup-legend {
  display: grid; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: var(--blue-050); font-size: 12.5px; color: var(--blue-dark); line-height: 1.5;
}
.dup-group.is-merged { border-color: #b4e2cd; }
.dup-group.is-merged header { background: var(--green-soft); }
.dup-lead.branch .dup-role {
  background: var(--blue-050); color: var(--blue-dark); width: auto; padding: 3px 8px;
  letter-spacing: .2px; text-transform: none; font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px;
}

.dup-lead { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.dup-lead:last-child { border-bottom: 0; }
.dup-lead.keep { background: rgba(31, 157, 107, .05); }
.dup-role {
  flex: none; width: 46px; text-align: center; border-radius: 6px;
  font-size: 10px; font-weight: 800; letter-spacing: .6px; padding: 3px 0;
}
.dup-lead.keep .dup-role { background: var(--green-soft); color: #157a52; }
.dup-lead.dup .dup-role { background: var(--amber-soft); color: #9a6412; }
.dup-main { flex: 1; min-width: 0; }
.dup-name { font-weight: 600; }
.dup-meta { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dup-facts { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.dup-pick { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); flex: none; }

/* ---------- Contact enrichment in the lead modal ---------- */
.contact-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.contact-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-alt); border-radius: 20px; padding: 4px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--blue-dark);
}
.contact-chip.person { background: var(--green-soft); color: #157a52; }
.social-links { display: flex; flex-wrap: wrap; gap: 7px; }
.social-link {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong); border-radius: 20px; padding: 4px 12px;
  font-size: 12.5px; font-weight: 600; text-transform: capitalize;
}
.social-link:hover { border-color: var(--blue); background: var(--blue-050); text-decoration: none; }
.dup-banner {
  display: flex; align-items: center; gap: 10px; margin: 0 30px 4px;
  background: var(--amber-soft); border: 1px solid #e8cf9b; color: #7d4f0c;
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px;
}

/* ---------- Branches of one brand ---------- */
.branch-totals {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.branch-totals > div {
  background: var(--bg-alt); border-radius: var(--radius-sm); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.branch-totals b { font-size: 20px; color: var(--ink); }
.branch-totals span { font-size: 11.5px; color: var(--muted); }

.branch-table-wrap { overflow-x: auto; margin-bottom: 14px; }
.branch-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.branch-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--faint); padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.branch-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.branch-table tr:last-child td { border-bottom: 0; }
.branch-table tr.is-parent { background: rgba(31, 157, 107, .06); }
.branch-tag {
  display: inline-block; margin-left: 6px; border-radius: 5px; padding: 1px 6px;
  font-size: 10.5px; font-weight: 700; background: var(--green-soft); color: #157a52;
}
.branch-tag.alt { background: var(--blue-050); color: var(--blue-dark); }
.branch-tag.here { background: var(--amber-soft); color: #9a6412; }

/* ---------- Reviews ---------- */
.review-scope { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.review-body { margin-top: 14px; }
.review-summary {
  display: grid; grid-template-columns: minmax(150px, auto) minmax(200px, 1fr);
  gap: 20px; align-items: center; padding: 14px; background: var(--bg-alt);
  border-radius: var(--radius-sm); margin-bottom: 14px;
}
.review-average { display: flex; flex-direction: column; gap: 3px; }
.review-average b { font-size: 34px; line-height: 1; color: var(--ink); }
.review-average .empty { color: var(--line-strong); }
.review-bars { display: grid; gap: 5px; }
.review-bar { display: grid; grid-template-columns: 28px 1fr 34px; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.review-bar-track { height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; }
.review-bar-fill { height: 100%; background: var(--amber); }
.review-bar-count { text-align: right; }

.review-list { display: grid; gap: 12px; }
.review { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.review-avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.review-who { flex: 1; min-width: 0; }
.review-author { font-weight: 600; font-size: 13.5px; }
.review-meta { font-size: 11.5px; color: var(--muted); }
.review-stars { flex: none; color: var(--amber); letter-spacing: 1px; font-size: 13px; }
.review-stars .empty { color: var(--line-strong); }
.review-text { margin: 0; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.review-text.empty { color: var(--faint); font-style: italic; }
.review-photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.review-photos img { width: 74px; height: 74px; object-fit: cover; border-radius: 7px; }
.review-reply {
  margin-top: 10px; padding: 9px 12px; border-left: 3px solid var(--blue-100);
  background: var(--blue-050); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
}
.review-reply p { margin: 4px 0 0; line-height: 1.5; white-space: pre-wrap; }

@media (max-width: 720px) {
  .review-summary { grid-template-columns: 1fr; }
}

/* ---------- Lead map ---------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(260px, .8fr); gap: 20px; align-items: start; }
.map-canvas { height: 62vh; min-height: 420px; width: 100%; background: var(--bg-alt); }
.map-canvas.map-unavailable { display: grid; place-items: center; }
.map-canvas .leaflet-container { font-family: var(--font); }
.map-legend {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted);
}
.legend-ramp {
  width: 150px; height: 9px; border-radius: 6px;
  background: linear-gradient(90deg, #2563c9, #0ea5a3 40%, #d98a1f 70%, #d6584f);
}
.legend-label { font-weight: 600; }
.legend-note { margin-left: auto; color: var(--faint); }
.map-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.map-side { display: grid; gap: 20px; }

.geo-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px auto; gap: 10px; align-items: center; padding: 7px 0; }
.geo-row + .geo-row { border-top: 1px solid var(--line); }
.geo-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.geo-bar { height: 7px; border-radius: 6px; background: var(--line); overflow: hidden; }
.geo-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--sky), var(--blue)); }
.geo-nums { text-align: right; line-height: 1.25; }
.geo-nums b { font-size: 14px; font-variant-numeric: tabular-nums; }
.geo-nums span { display: block; font-size: 11px; color: var(--faint); }

@media (max-width: 1080px) {
  .map-layout { grid-template-columns: 1fr; }
}

/* ---------- Lead detail page ---------- */
.back-link { font-weight: 700; letter-spacing: normal; text-transform: none; font-size: 12px; }
.back-link:hover { text-decoration: underline; }
.head-actions #generateReport { background:linear-gradient(135deg,var(--blue),#5b56d9); color:#fff; border-color:transparent; box-shadow:0 8px 20px -12px var(--blue); }
.head-actions #generateReport:hover { filter:brightness(1.05); transform:translateY(-1px); }
.head-actions #generateReport:disabled { filter:none; transform:none; opacity:.72; }
.lead-page {
  background: var(--bg); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.lead-page .modal-score-badge { right: 0; }

/* ---------- Review analytics ---------- */
.analytics-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.analytics-head h3 { margin-bottom:4px; }
.analytics-head p { margin:0; }
.analytics-body { display:grid; gap:22px; }
.analytics-kpis { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; }
.analytics-kpis > div { padding:15px; border:1px solid var(--line); border-radius:12px; background:var(--bg-alt); }
.analytics-kpis b { display:block; font-size:23px; color:var(--navy); }
.analytics-kpis span { display:block; margin-top:3px; color:var(--muted); font-size:12px; }
.analytics-columns { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:24px; }
.analytics-body h4 { margin:0 0 10px; font-size:13px; color:var(--navy); }
.analytics-delta { margin:0; padding:10px 12px; border-radius:9px; background:#eef6ff; color:var(--muted); font-size:12.5px; }
.trend-bars { height:118px; display:flex; align-items:end; gap:5px; border-bottom:1px solid var(--line); }
.trend-bars > div { min-width:12px; flex:1; height:100%; display:flex; flex-direction:column; justify-content:end; align-items:center; gap:4px; }
.trend-bars i { width:100%; max-width:30px; min-height:5px; border-radius:5px 5px 0 0; background:linear-gradient(var(--sky),var(--blue)); }
.trend-bars span { font-size:9px; color:var(--faint); }
.sentiment-bar { height:16px; display:flex; overflow:hidden; border-radius:8px; background:var(--line); }
.sentiment-bar i { display:block; height:100%; }.sentiment-bar .pos{background:#1f9d6b}.sentiment-bar .neu{background:#d98a1f}.sentiment-bar .neg{background:#d6584f}
.analytics-legend { display:flex; gap:14px; flex-wrap:wrap; color:var(--muted); font-size:11px; }
.theme-bars { display:grid; gap:7px; }
.theme-bars > div { display:grid; grid-template-columns:minmax(100px,180px) 1fr 30px; align-items:center; gap:10px; font-size:12px; }
.theme-bars i { height:7px; overflow:hidden; border-radius:5px; background:var(--line); }.theme-bars b{display:block;height:100%;background:var(--blue)}.theme-bars em{font-style:normal;text-align:right;color:var(--muted)}
.analytics-theme { padding:10px 0; border-top:1px solid var(--line); }.analytics-theme:first-of-type{border-top:0}
.analytics-theme > div { display:flex; justify-content:space-between; gap:8px; font-size:12px; }.analytics-theme span{color:var(--muted)}
.analytics-theme blockquote { margin:7px 0 0; color:var(--muted); font-size:12px; line-height:1.5; }
.action-list ol { margin:0; padding-left:22px; }.action-list li{padding:5px}.action-list li span{display:block;color:var(--muted);font-size:12px;margin-top:2px}
.competitor-panel { border-top:1px solid var(--line); padding-top:18px; }.competitor-names{display:flex;gap:8px;flex-wrap:wrap;margin:8px 0 14px}.competitor-names span{padding:5px 9px;border-radius:12px;background:var(--bg-alt);font-size:11px;color:var(--muted)}
.comparison-table{display:grid;gap:1px;background:var(--line);border:1px solid var(--line);border-radius:9px;overflow:hidden}.comparison-table>div{display:grid;grid-template-columns:minmax(140px,1fr) 90px 120px 70px;gap:8px;padding:9px 11px;background:#fff;align-items:center;font-size:12px}.comparison-table em{font-style:normal;color:var(--muted)}
.reply-workflow{margin-top:12px;padding:12px;border:1px solid var(--line);border-radius:10px;background:var(--bg-alt)}.reply-state{display:inline-block;margin-bottom:8px;padding:3px 7px;border-radius:9px;background:#dcecff;color:var(--blue);font-size:10px;font-weight:700;text-transform:uppercase}.reply-editor{display:block;width:100%;min-height:92px;padding:10px;border:1px solid var(--line);border-radius:8px;background:#fff;color:var(--text);font:inherit;line-height:1.5;resize:vertical}.reply-workflow .media-btns{margin-top:9px}
@media (max-width:720px){.analytics-kpis{grid-template-columns:repeat(2,1fr)}.analytics-columns{grid-template-columns:1fr}.analytics-head{display:grid}}

/* ---------- Media gallery ---------- */
.gallery-modal { max-width: 1120px; padding-bottom: 24px; }
.gallery-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 22px 30px 16px; border-bottom: 1px solid var(--line);
}
.gallery-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
.gallery-sub { color: var(--muted); font-size: 13px; font-weight: 600; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px; padding: 20px 30px 6px;
}
.gallery-grid .modal-loading { grid-column: 1 / -1; }
.gallery-tile {
  position: relative; display: block; padding: 0; overflow: hidden;
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: 12px;
  aspect-ratio: 1 / 1; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.gallery-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--blue); }
.gallery-tile:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.tile-media { width: 100%; height: 100%; object-fit: cover; display: block; background: #0f1b3c; }
.tile-play {
  position: absolute; inset: 0; margin: auto; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; pointer-events: none;
  background: rgba(15, 27, 60, .62); color: #fff; font-size: 15px; padding-left: 3px;
}
.tile-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 8px 6px;
  font-size: 11px; color: #fff; text-align: left; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  background: linear-gradient(to top, rgba(10, 20, 45, .8), transparent);
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8, 15, 34, .92);
  /* A single full-height row keeps the media boxed into the viewport rather
     than letting a tall photo push the arrows and caption off-screen. */
  display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px;
  grid-template-rows: minmax(0, 1fr); padding: 56px 12px 64px;
  animation: modal-fade .16s ease;
}
.lightbox[hidden] { display: none; }
.lb-stage {
  margin: 0; grid-column: 2; min-width: 0; min-height: 0;
  display: grid; place-items: center;
}
.lb-media {
  /* Viewport units rather than a percentage: the height has to resolve against
     something definite or a portrait photo runs off the bottom of the screen. */
  max-width: 100%; max-height: calc(100vh - 120px); object-fit: contain; display: block;
  border-radius: 10px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8);
}
.lb-nav {
  width: 48px; height: 48px; border-radius: 50%; justify-self: center; align-self: center;
  border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .1);
  color: #fff; font-size: 28px; line-height: 1; display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.lb-nav:hover { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .5); }
.lb-nav[hidden] { display: none; }
.lb-prev { grid-column: 1; }
.lb-next { grid-column: 3; }
.lb-close {
  position: absolute; top: 16px; right: 18px; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .1);
  color: #fff; font-size: 15px; display: grid; place-items: center;
}
.lb-close:hover { background: rgba(255, 255, 255, .22); }
.lb-bar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 20px;
  display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap;
  color: rgba(255, 255, 255, .8); font-size: 12.5px; font-weight: 600;
}
.lb-open { color: #cddffb; }
.lb-open:hover { color: #fff; text-decoration: underline; }

@media (max-width: 720px) {
  .gallery-head, .gallery-grid { padding-left: 18px; padding-right: 18px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .lightbox { grid-template-columns: 48px minmax(0, 1fr) 48px; padding: 52px 6px 60px; }
  .lb-media { max-height: calc(100vh - 112px); }
  .lb-nav { width: 40px; height: 40px; font-size: 24px; }
}
