/* MO Sales Hub — single stylesheet. Tokens first, then layout, then components. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e1e4ea;
  --ink: #16181d;
  --ink-2: #4a505c;
  --ink-3: #7a8190;
  --accent: #3b4ce0;
  --accent-ink: #ffffff;
  --accent-soft: #e8ebfd;
  --bar: #5b6ae8;
  --good: #1a7f4b;   --good-soft: #e3f4ea;
  --warn: #9a6200;   --warn-soft: #fdf1dc;
  --bad: #b4232a;    --bad-soft: #fbe5e6;
  --info: #1f5fa8;   --info-soft: #e2edf9;
  --win: #6a2bb8;    --win-soft: #efe5fb;
  --neutral-soft: #eceef2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2b303b;
    --ink: #eceef3;
    --ink-2: #b3b9c6;
    --ink-3: #858c9b;
    --accent: #7c89ff;
    --accent-ink: #0f1115;
    --accent-soft: #252b52;
    --bar: #7c89ff;
    --good: #5fd49a;   --good-soft: #15301f;
    --warn: #f1b54c;   --warn-soft: #33270f;
    --bad: #ff7b80;    --bad-soft: #3a1a1c;
    --info: #74b0ff;   --info-soft: #162a44;
    --win: #c49bff;    --win-soft: #2c1d44;
    --neutral-soft: #262a33;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.hide-sm { }

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; color: var(--ink); }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav a {
  padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .count { margin-left: 6px; background: var(--bad); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.main { max-width: 1320px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-body { padding: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- Buttons & inputs ---------- */
button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); padding: 7px 12px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--bad); }
.btn-lg { padding: 12px 18px; font-size: 16px; font-weight: 600; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-width: 0;
}
textarea { width: 100%; resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
label.field input, label.field select, label.field textarea { font-size: 14px; }
.field-error { color: var(--bad); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 10px;
  font-size: 12px; cursor: pointer; color: var(--ink-2);
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--ink-2);
}
.tone-good { background: var(--good-soft); color: var(--good); }
.tone-warn, .tone-warm { background: var(--warn-soft); color: var(--warn); }
.tone-bad, .tone-hot { background: var(--bad-soft); color: var(--bad); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-win { background: var(--win-soft); color: var(--win); }
.tone-cool { background: var(--good-soft); color: var(--good); }
.score {
  display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 28px;
  border-radius: 8px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 0 6px;
}
.score.p-PRIORITY { background: var(--bad-soft); color: var(--bad); }
.score.p-STRONG { background: var(--warn-soft); color: var(--warn); }
.score.p-NORMAL { background: var(--info-soft); color: var(--info); }
.score.p-LOW, .score.p-none { background: var(--neutral-soft); color: var(--ink-3); }
.score-xl { font-size: 28px; min-width: 64px; height: 52px; border-radius: 12px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--ink-3); font-weight: 600; background: var(--surface); position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
td.name { font-weight: 600; white-space: normal; min-width: 180px; }
td.name .sub { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.overdue { color: var(--bad); font-weight: 600; }
.due-today { color: var(--warn); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.filters input[type=search] { flex: 1 1 220px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }

/* ---------- Queue ---------- */
.queue-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.qstat { padding: 14px 16px; }
.qstat .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.qstat .l { color: var(--ink-3); font-size: 12px; font-weight: 600; }
.qstat.alert .v { color: var(--bad); }
.queue-item {
  display: grid; grid-template-columns: 30px 52px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.queue-item:hover { background: var(--surface-2); }
.queue-item:last-child { border-bottom: 0; }
.queue-item .rank { color: var(--ink-3); font-weight: 600; text-align: right; }
.queue-item .why { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bucket-OVERDUE { background: var(--bad-soft); color: var(--bad); }
.bucket-DUE_TODAY { background: var(--warn-soft); color: var(--warn); }
.bucket-INTERESTED { background: var(--good-soft); color: var(--good); }
.bucket-NEW { background: var(--info-soft); color: var(--info); }
.bucket-RETRY { background: var(--neutral-soft); color: var(--ink-2); }

/* ---------- Call panel ---------- */
.call-panel { border: 2px solid var(--accent); }
.call-btn { width: 100%; font-size: 20px; padding: 14px; }
.outcomes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.outcome { padding: 14px 8px; font-weight: 600; font-size: 14px; border-width: 1px; }
.outcome.tone-neutral { background: var(--surface-2); }
.outcome.selected { outline: 3px solid var(--accent); outline-offset: 1px; }
.outcome:hover { filter: brightness(.97); }
.inline-form { background: var(--surface-2); border-radius: var(--radius); padding: 12px; margin-top: 10px; }
.why-box {
  background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: 8px;
  font-size: 15px; color: var(--ink);
}
.phone-big { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.next-card { max-width: 860px; margin: 0 auto; }

/* ---------- Score breakdown ---------- */
.breakdown { display: flex; flex-direction: column; gap: 10px; }
.bd-row { display: grid; grid-template-columns: minmax(0, 1fr) 52px; gap: 4px 10px; align-items: center; }
.bd-row .lbl { font-weight: 600; font-size: 13px; }
.bd-row .pts { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bd-row .why { grid-column: 1 / -1; color: var(--ink-3); font-size: 12px; }
.meter { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--bar); border-radius: 4px; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline .what { font-weight: 600; }
.timeline .notes { color: var(--ink-2); white-space: pre-wrap; margin-top: 2px; }
.timeline .meta { color: var(--ink-3); font-size: 12px; margin-top: 2px; }

/* ---------- Dashboard ---------- */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.tile { padding: 14px 16px; }
.tile .v { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .l { color: var(--ink-3); font-size: 12px; font-weight: 600; margin-top: 4px; }
.barlist { display: flex; flex-direction: column; gap: 8px; }
.barlist .b { display: grid; grid-template-columns: 130px minmax(0, 1fr) 44px; gap: 10px; align-items: center; }
.barlist .track { height: 14px; background: var(--surface-2); border-radius: 4px; }
.barlist .fill { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.barlist .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.conv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.section-title { margin: 22px 0 10px; }

/* ---------- Review inbox / imports ---------- */
.nav .count.soft { background: var(--accent); color: var(--accent-ink); }
.inbox-item {
  display: grid; grid-template-columns: 20px 52px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.inbox-item:last-child { border-bottom: 0; }
.inbox-item > input[type=checkbox] { margin-top: 8px; }
.inbox-actions { gap: 6px; min-width: 110px; }
.inbox-actions button { width: 100%; }
tr.run-detail { cursor: default; background: var(--surface-2); }
.inbox-filters .filter-label { width: 96px; flex: none; padding-top: 5px; }
@media (max-width: 700px) { .inbox-filters .filter-label { width: 100%; padding-top: 0; } }
/* Google Maps Platform content must be visually distinguished and attributed. */
.google-content { border: 2px solid var(--border); }
.google-content tbody tr { cursor: default; }
.google-attribution { font: 500 12px/1 Roboto, Arial, sans-serif; color: var(--ink-2); letter-spacing: .01em; }
tr.run-detail td { white-space: normal; }
.review-banner { margin-bottom: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }

/* ---------- Misc ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.2);
  max-width: calc(100vw - 32px); font-weight: 500;
}
.toast.error { background: var(--bad); color: #fff; }
.empty { padding: 32px; text-align: center; color: var(--ink-3); }
.alert-box { padding: 12px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); }
.alert-box.bad { background: var(--bad-soft); color: var(--bad); }
.link-list { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1440px) { .hide-md { display: none; } th, td { padding: 8px 8px; } }
@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .conv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .main { padding: 12px 16px; }
  .topbar { padding: 0 12px; gap: 8px; height: auto; min-height: 52px; flex-wrap: wrap; padding-bottom: 6px; padding-top: 6px; }
  .nav { order: 3; width: 100%; }
  .queue-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .queue-item { grid-template-columns: 44px minmax(0, 1fr); }
  .queue-item .rank, .queue-item .qi-right { display: none; }
  .inbox-item { grid-template-columns: 20px minmax(0, 1fr); }
  .inbox-item > .score { display: none; }
  .inbox-actions { grid-column: 1 / -1; flex-direction: row; }
  .outcomes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: none; }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .kv { grid-template-columns: 100px 1fr; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .barlist .b { grid-template-columns: 100px minmax(0, 1fr) 36px; }
}
