/* Page styles for the Scoreboard / Canvassing / Capacity pages. Every colour
   is a token from vault.css (light + dark); nothing here is theme-specific. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px; line-height: 1.5; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.error { background: var(--bad-bg); color: var(--bad); padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; }

/* ---------- Loading indicator ---------- */
/* Slim progress bar sliding across the top while a request is in flight. */
.loading-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; background: transparent; z-index: 9999; pointer-events: none; }
.loading-bar::after { content: ""; position: absolute; top: 0; left: 0; height: 100%; width: 30%; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: 0; transition: opacity 0.2s; }
body.loading .loading-bar::after { opacity: 1; animation: loading-slide 1.1s ease-in-out infinite; }
@keyframes loading-slide {
  0%   { left: -30%; }
  100% { left: 100%; }
}

/* While loading, dim the KPI cards + table to communicate "stale" data */
body.loading .kpis .kpi-value,
body.loading .rows-table tbody { opacity: 0.45; transition: opacity 0.15s; }
body.loading .kpis .kpi-value::after,
body.loading #row-count::after { content: ""; }
.kpis .kpi-value, .rows-table tbody { transition: opacity 0.2s; }

/* Subtle "pulse" on the active chip while a request is in flight */
body.loading .chip.active { animation: chip-pulse 1.2s ease-in-out infinite; }
@keyframes chip-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--tint); }
  50%      { box-shadow: 0 0 0 4px transparent; }
}

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--panel); padding: 32px; border-radius: 12px; width: 100%; max-width: 380px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.login-card h1 { margin: 0 0 4px; }
.login-card form { margin-top: 20px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 4px; }
.login-card label span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.login-card input { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 6px; font-size: 14px; }
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.login-card button { background: var(--accent); color: var(--accent-ink); border: 0; padding: 10px 14px; border-radius: 6px; font-weight: 600; cursor: pointer; margin-top: 4px; }
.login-card button:hover { background: var(--accent-2); }

/* ---------- Page ---------- */
.page { max-width: 1400px; margin: 0 auto; padding: 20px 24px 60px; }
.page > h1 { margin: 4px 0 6px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.page-header h1 { margin: 0; }

/* ---------- Filter bar (dates + markets) ---------- */
.filter-bar { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 14px 0 10px; display: flex; flex-direction: column; gap: 8px; }
.fb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fb-row + .fb-row { border-top: 1px solid var(--border); padding-top: 8px; }
.fb-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; min-width: 62px; }
.fb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.date-chips, .region-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar .chip { padding: 5px 12px; }
.chip-clear { border-color: transparent; color: var(--muted); }
.chip-clear:hover { color: var(--text); }
.mk-dropdown summary { min-width: 0; padding: 5px 12px; border-radius: 20px; }
.mk-dropdown.has-selection summary { border-color: var(--accent); color: var(--accent-2); }
.bu-opt-group { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 6px 2px; }
.bu-opt-group:first-child { padding-top: 2px; }
.scope-line { font-size: 12px; margin: 0 0 12px 2px; min-height: 18px; }
.page-sub { margin: 0; }

/* ---------- Date chips ---------- */
.chip { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 7px 14px; border-radius: 20px; cursor: pointer; font-size: 13px; }
.chip:hover { background: var(--panel-2); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.custom-wrap { display: inline-flex; gap: 6px; align-items: center; }
.custom-wrap input[type="date"] { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: 6px; }

/* ---------- KPIs — three labelled groups of three tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi-group { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px; }
.kpi-group-title { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 2px 8px; }
.kpi-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; min-height: 1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) { .kpis { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .kpi-tiles { grid-template-columns: 1fr 1fr; } }

/* ---------- Rows table ---------- */
.table-section { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table-controls { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table-controls input[type="search"] { flex: 1; max-width: 360px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 6px; }
.rows-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rows-table thead th { text-align: left; padding: 10px 12px; background: var(--panel-2); color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; border-bottom: 1px solid var(--border); white-space: nowrap; }
.rows-table thead th.num { text-align: right; }
.rows-table thead th:hover { color: var(--text); }
.rows-table tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.rows-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rows-table tbody tr:hover { background: var(--panel-2); }

.status-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-Completed { background: var(--ok-bg); color: var(--ok); }
.status-Scheduling { background: var(--info-bg); color: var(--info); }
.status-NotRun { background: var(--warn-bg); color: var(--warn); }
.status-Cancelled { background: var(--bad-bg); color: var(--bad); }
.status-Overbook { background: var(--purple-bg); color: var(--purple-ink); }
.status-Unknown { background: var(--grey-bg); color: var(--grey-ink); }
.net-fell-through { color: var(--orange); font-size: 11px; }

/* Tags column — job tagTypeIds resolved to names, shown as small chips */
.rows-table .col-tags { max-width: 200px; }
.tag-chip {
  display: inline-block; padding: 1px 7px; margin: 1px 3px 1px 0;
  border-radius: 9px; font-size: 11px; font-weight: 500;
  background: var(--grey-bg); color: var(--text);
  white-space: nowrap;
}

/* Assigned/Unassigned column — only shown in Upcoming mode */
.col-assigned { display: none; }
body.upcoming-mode .col-assigned { display: table-cell; }
.assign-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.assign-yes { background: var(--ok-bg); color: var(--ok); }
.assign-no  { background: var(--warn-bg); color: var(--warn); }

/* Upcoming (forward-looking) view */
.chip-upcoming { border-color: var(--accent); color: var(--accent-2); }
.chip-upcoming.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.upcoming-note { background: var(--tint); border: 1px solid var(--border); border-left: 3px solid var(--accent); color: var(--text); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }

/* Date — short m/d/yy, never wrap */
.rows-table .col-date { white-space: nowrap; }

/* Slot — 10am / 2pm / 6pm or raw time for off-slot reschedules */
.rows-table .col-slot,
.history-table .col-slot { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }

/* Address — narrower, truncated with ellipsis (full value in title tooltip) */
.rows-table .col-address { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Notes (commentary) — collapsed to 2 lines, click to expand full text */
.rows-table .col-notes { max-width: 260px; }
.notes-cell { cursor: pointer; vertical-align: top; }
.notes-cell .notes-text {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; font-size: 12px; color: var(--muted); line-height: 1.35;
}
.notes-cell:hover .notes-text { color: var(--text); }
.notes-cell.expanded { white-space: normal; }
.notes-cell.expanded .notes-text { -webkit-line-clamp: unset; display: block; color: var(--text); }

/* ---------- Capacity (markets × days grid) ---------- */
.refresh-meta { font-size: 12px; }
.cap-legend { margin-top: 14px; font-size: 12px; }

/* Legend under the header */
.legend { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 4px 0 6px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.legend-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.legend-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-right: 2px; }
.legend .lg { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text); }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.legend .sw-red    { background: var(--red); }
.legend .sw-orange { background: var(--orange); }
.legend .sw-yellow { background: var(--yellow); }
.legend .sw-green  { background: var(--green); }
.legend .sw-grey   { background: var(--grey); }

.cap-grid { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
/* Market | Today (widest) | Tomorrow | Day-after (narrowest) */
.cap-row {
  display: grid;
  grid-template-columns: 120px 2.6fr 1.7fr 1.2fr;
  gap: 10px;
  align-items: stretch;
}
.cap-header { align-items: end; padding: 0 4px 4px; }
.cap-market-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; align-self: end; }
.cap-col-head { display: flex; flex-direction: column; gap: 1px; font-weight: 700; font-size: 13px; padding: 0 4px; }
.cap-col-head .muted { font-size: 11px; font-weight: 400; }
.cap-col-head.col-today { color: var(--text); }
.cap-col-head.col-tom, .cap-col-head.col-after { color: var(--muted); }

/* Section divider between market groups (see app/constants.py MARKET_GROUPS),
   clickable to collapse/expand that section (state persisted in localStorage,
   see capacity.js). Sits right under the column-header row for the first
   group, so no top border there — .cap-header already draws its own bottom
   edge via padding. */
.cap-group-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding: 10px 4px 2px; border-top: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.cap-group-head:hover { color: var(--text); }
.cap-header + .cap-group-head { border-top: none; padding-top: 0; }
.cgh-chevron { display: inline-block; width: 10px; font-size: 10px; }
.cgh-count { margin-left: auto; font-weight: 400; text-transform: none; letter-spacing: normal; font-size: 10px; }

.cap-market { display: flex; align-items: center; font-weight: 700; font-size: 14px; padding-right: 4px; gap: 6px; flex-wrap: wrap; }

/* Each day cell — heat-scale by that day's dial-priority */
.cap-day {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 5px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.cap-day.prio-high { border-left-color: var(--red); background: linear-gradient(90deg, var(--bad-bg), transparent 70%); }
.cap-day.prio-med  { border-left-color: var(--orange); background: linear-gradient(90deg, var(--warn-bg), transparent 70%); }
.cap-day.prio-low  { border-left-color: var(--yellow); }
.cap-day.prio-plan { border-left-color: var(--grey); opacity: 0.9; }
.cap-day.prio-full { border-left-color: var(--green); opacity: 0.8; }
.cap-day.prio-done { border-left-color: var(--border); opacity: 0.5; }

.cd-open { display: flex; align-items: baseline; gap: 7px; }
.cd-open .cd-num { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.cd-open .cd-status { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.cd-open .cd-fill { font-size: 11px; margin-left: auto; }
.prio-high .cd-num, .prio-high .cd-status { color: var(--red); }
.prio-med  .cd-num, .prio-med  .cd-status { color: var(--orange); }
.prio-low  .cd-num, .prio-low  .cd-status { color: var(--yellow); }
.prio-plan .cd-num, .prio-plan .cd-status { color: var(--grey-ink); }
.prio-full .cd-num, .prio-full .cd-status { color: var(--ok); }
.prio-done .cd-num, .prio-done .cd-status { color: var(--muted); }

.cd-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.slot-cell { background: var(--panel-2); border: 1px solid var(--border); border-top: 3px solid var(--border); border-radius: 6px; padding: 5px 6px; text-align: center; }
.slot-cell.slot-room    { border-top-color: var(--red); }
.slot-cell.slot-fullup  { border-top-color: var(--green); }
.slot-cell.slot-closed  { border-top-color: var(--border); opacity: 0.35; }
.slot-cell.slot-na      { border-top-color: var(--border); opacity: 0.22; }
.slot-cell.slot-lastcall { box-shadow: inset 0 0 0 1px var(--yellow); }
.slot-cell.slot-next { box-shadow: inset 0 0 0 2px var(--accent-2); }
.next-tag { display: inline-block; margin-left: 4px; font-size: 8px; font-weight: 800; letter-spacing: 0.06em; color: var(--accent-ink); background: var(--accent); border-radius: 3px; padding: 1px 4px; vertical-align: middle; }
.slot-cell .sc-label { font-weight: 600; font-size: 11px; }
.slot-cell .sc-count { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 1px; }
.slot-cell .sc-bar { display: flex; height: 4px; background: var(--border); border-radius: 3px; margin: 4px 0 3px; overflow: hidden; }
.slot-cell .sc-fill { height: 100%; background: var(--green); flex: none; }
.slot-cell .sc-fill.over { background: var(--red); }
/* Back-up seats: bookings to replace (low outbound call score / Faraday 71+).
   Amber hatch on the bar for the seats that still count as open, and the
   "N in back-up" line under the count. */
.slot-cell .sc-backup-fill { height: 100%; flex: none; background: repeating-linear-gradient(135deg, var(--yellow) 0 2px, transparent 2px 4px); opacity: 0.9; }
.slot-cell .sc-backup { font-size: 10px; font-weight: 600; color: var(--yellow); margin-top: 1px; cursor: help; }
.cap-day.size-tiny .slot-cell .sc-backup { font-size: 9px; }
.slot-cell .sc-slack { font-size: 10px; color: var(--muted); }
.slot-cell.slot-room .sc-slack { color: var(--red); font-weight: 600; }

/* Planning column (day-after): no hot-red slot accents or red slack text. */
.cap-day.prio-plan .slot-cell.slot-room { border-top-color: var(--grey); }
.cap-day.prio-plan .slot-cell.slot-room .sc-slack { color: var(--grey-ink); font-weight: 400; }

/* Size variants per column */
.cap-day.size-compact { padding: 7px 8px; }
.cap-day.size-compact .cd-num { font-size: 18px; }
.cap-day.size-compact .slot-cell .sc-count { font-size: 13px; }
.cap-day.size-tiny { padding: 6px 8px; }
.cap-day.size-tiny .cd-num { font-size: 16px; }
.cap-day.size-tiny .slot-cell { padding: 3px 4px; }
.cap-day.size-tiny .slot-cell .sc-label { font-size: 10px; }
.cap-day.size-tiny .slot-cell .sc-count { font-size: 12px; }

@media (max-width: 820px) {
  .cap-row { grid-template-columns: 1fr; gap: 4px; }
  .cap-header { display: none; }
  .cap-market { font-size: 15px; padding-top: 6px; }
  .cap-day.size-tiny, .cap-day.size-compact { opacity: 1; }
}

/* ---------- Reschedule badge + drill-in modal ---------- */
.rows-table .col-customer { white-space: nowrap; }
.resched-badge {
  display: inline-flex; align-items: center; gap: 2px;
  margin-left: 6px; padding: 1px 7px; border-radius: 10px;
  font-size: 11px; font-weight: 700; line-height: 1.4;
  background: var(--warn-bg); color: var(--warn);
  border: 1px solid var(--warn); cursor: pointer;
  vertical-align: middle;
}
.resched-badge:hover { filter: brightness(1.08); }

.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--overlay);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px; overflow-y: auto;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  width: 100%; max-width: 760px;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-close {
  background: none; border: 0; color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 14px 18px 18px; }
.error-msg { color: var(--bad); font-size: 13px; }

.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table thead th {
  text-align: left; padding: 8px 10px; color: var(--muted);
  font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.history-table thead th.num { text-align: right; }
.history-table tbody td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.history-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.history-table tbody tr:last-child td { border-bottom: 0; }

/* Appointment notes ride a full-width sub-row under their appointment, so the
   dispo commentary is readable at a glance instead of clipped into a column. */
.history-table tbody tr.history-appt-row.has-note td { border-bottom: 0; }
.history-table tbody tr.history-note-row td {
  padding: 0 10px 10px; font-size: 12px; line-height: 1.45;
  color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere;
}
.money-pending { color: var(--muted); opacity: .6; }
.history-note + .history-note { margin-top: 6px; }
.history-note.is-cancel .history-note-label { border-color: var(--red); color: var(--red); }
.history-note-label {
  display: inline-block; margin-right: 8px; padding: 1px 6px;
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); vertical-align: 1px;
}

/* ---------- Rehash queue ---------- */
.chip-rehash { border-color: var(--yellow); color: var(--yellow); }
.chip-rehash.active { background: var(--yellow); border-color: var(--yellow); color: #1a1d23; }

/* A queue row whose customer is already rebooked — dimmed, no action needed. */
.rows-table tbody tr.row-rehashed { opacity: 0.45; }
.rows-table tbody tr.row-rehashed:hover { opacity: 0.7; background: var(--panel-2); }
.future-pill {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: 10px; font-size: 11px; font-weight: 600;
  background: var(--ok-bg); color: var(--ok); white-space: nowrap;
}

/* Day-group header row (rehash queue only) — a full-width divider between days. */
.rows-table tbody tr.day-group-header td {
  padding: 8px 10px; background: var(--panel-2); border-top: 1px solid var(--border);
  font-weight: 700; color: var(--text);
}
.rows-table tbody tr.day-group-header:first-child td { border-top: none; }
.day-group-count { font-weight: 500; color: var(--muted); }
/* Column-header sort doesn't apply in rehash mode — the day grouping IS the sort. */
body.rehash-mode #rows-table thead th[data-sort] { cursor: default; }

/* ---------- Capacity History ---------- */
.month-nav { display: flex; align-items: center; gap: 10px; }
.month-nav .chip { padding: 4px 12px; font-size: 16px; line-height: 1; }
.month-nav .chip:disabled { opacity: 0.4; cursor: default; }
.month-label { font-weight: 700; font-size: 15px; min-width: 130px; text-align: center; }

.mtd-banner { margin: 6px 0 18px; }
.mtd-card {
  display: inline-flex; flex-direction: column; gap: 2px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 22px; box-shadow: var(--shadow);
}
.mtd-card .mtd-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.mtd-card .mtd-value { font-size: 34px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mtd-card .mtd-sub { font-size: 12px; }

.ch-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.ch-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ch-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-2); color: var(--muted);
  font-weight: 700; text-align: center; padding: 9px 8px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.ch-table thead th.ch-date-h { text-align: left; }
.ch-table thead th.ch-total-h { color: var(--text); border-left: 1px solid var(--border); }
.ch-table thead th.ch-demo-h { color: var(--text); border-left: 2px solid var(--border); }

.ch-table tbody td, .ch-table tfoot td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: center; }
.ch-table tbody tr:hover { background: var(--row-hover); }
.ch-table tbody tr.ch-today { outline: 1px solid var(--accent); outline-offset: -1px; }

.ch-date { text-align: left !important; font-weight: 700; white-space: nowrap; }
.ch-date .ch-dow { font-weight: 400; font-size: 11px; margin-left: 6px; }

.ch-cell { font-variant-numeric: tabular-nums; }
.ch-cell .ch-pct { display: block; font-weight: 700; font-size: 14px; }
.ch-cell .ch-bk { display: block; font-size: 10px; }
.ch-cell.ch-na { background: transparent; }
.ch-cell-total { border-left: 1px solid var(--border); font-weight: 800; }
.ch-cell.ch-demo { border-left: 2px solid var(--border); font-weight: 700; }

.ch-table tfoot td { border-bottom: 0; }
.ch-table tfoot .ch-mtd-row { background: var(--panel-2); }
.ch-table tfoot .ch-mtd-row .ch-date { text-transform: uppercase; font-size: 12px; letter-spacing: 0.03em; }
.ch-table tfoot .ch-mtd-row td { border-top: 2px solid var(--border); }

.ch-empty { padding: 24px; text-align: center; }
.ch-legend { margin-top: 14px; }

/* ---------- Scoreboard: Visualize toggle + monthly trend chart ---------- */
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

.view-toggle { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 3px; gap: 2px; }
.vt-btn { background: none; border: 0; color: var(--muted); padding: 6px 14px; border-radius: 18px; cursor: pointer; font-size: 13px; }
.vt-btn:hover { color: var(--text); }
.vt-btn.active { background: var(--accent); color: var(--accent-ink); }

/* In chart view, hide the table-side containers without touching their own
   `hidden` state (so Upcoming/Rehash modes restore correctly on switch back). */
body.chart-view #filter-bar .fb-row:first-child,
body.chart-view #scope-line,
body.chart-view #kpis,
body.chart-view .table-section,
body.chart-view #upcoming-note { display: none !important; }

.trends-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.trends-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin-bottom: 14px; }
.tc-field { display: flex; flex-direction: column; gap: 4px; }
.tc-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.trends-controls input[type="month"] { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: 6px; }
.trends-controls #trends-apply { align-self: flex-end; }

.bu-dropdown { position: relative; }
.bu-dropdown summary { list-style: none; cursor: pointer; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: 6px; min-width: 150px; }
.bu-dropdown summary::-webkit-details-marker { display: none; }
.bu-dropdown summary::after { content: " ▾"; color: var(--muted); }
.bu-options { position: absolute; z-index: 20; margin-top: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px; min-width: 200px; max-height: 280px; overflow: auto; box-shadow: var(--shadow); }
.bu-opt { display: flex; align-items: center; gap: 8px; padding: 5px 6px; font-size: 13px; cursor: pointer; border-radius: 5px; }
.bu-opt:hover { background: var(--panel-2); }

.trends-chart-wrap { position: relative; height: 420px; }
.trends-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.trends-note { font-size: 12px; margin: 12px 0 0; }

/* ---------- Pace panel ---------- */
.pace-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pace-row .tc-label { white-space: nowrap; min-width: 50px; }
.pace-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Scoreboard: Markets view (recent window vs trailing-30-day) ---------- */
.mk-controls { align-items: center; }
.mk-vs { font-size: 12px; margin-left: 6px; }
.mk-note { font-size: 12px; margin: 0 0 10px; }
.mk-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.mk-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mk-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-2); color: var(--muted);
  font-weight: 700; text-align: center; padding: 8px 8px 6px;
  border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 12px;
}
.mk-table thead th.mk-market-h { text-align: left; }
.mk-table thead th.is-sorted { color: var(--text); }
.mk-h-sub { display: block; font-weight: 400; font-size: 10px; color: var(--muted); }

.mk-table tbody td, .mk-table tfoot td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: center; vertical-align: middle; }
.mk-table tbody tr:hover { background: var(--row-hover); }
.mk-market { text-align: left !important; font-weight: 700; white-space: nowrap; }
.mk-market-sub { display: block; font-weight: 400; font-size: 10px; color: var(--muted); }

/* Each cell: recent value (big) / delta chip / 30-day baseline (small) */
.mk-cell { font-variant-numeric: tabular-nums; min-width: 96px; border-left: 3px solid transparent; }
.mk-cell .mk-val { display: block; font-weight: 800; font-size: 15px; line-height: 1.15; }
.mk-cell .mk-delta { display: inline-block; margin: 2px 0 1px; padding: 0 6px; border-radius: 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.01em; }
.mk-cell .mk-base { display: block; font-size: 10px; color: var(--muted); }

/* Good/bad deviation bands: green = producing better than its 30-day norm, red = worse,
   grey = within the normal band. Shade depth = distance from the norm. The direction is
   per metric (markets.js badHigh): more sets/runs/demos/gross = good, more cancels/no-runs = bad. */
.mk-cell.dev-flat   { border-left-color: var(--grey); }
.mk-cell.dev-flat   .mk-delta { background: var(--grey-bg); color: var(--grey-ink); }
.mk-cell.dev-good-1 { border-left-color: var(--green); background: color-mix(in srgb, var(--ok-bg) 40%, transparent); }
.mk-cell.dev-good-1 .mk-delta { background: var(--ok-bg); color: var(--ok); }
.mk-cell.dev-good-2 { border-left-color: var(--green); background: var(--ok-bg); }
.mk-cell.dev-good-2 .mk-delta { background: var(--green); color: #fff; }
.mk-cell.dev-bad-1  { border-left-color: var(--red); background: color-mix(in srgb, var(--bad-bg) 40%, transparent); }
.mk-cell.dev-bad-1  .mk-delta { background: var(--bad-bg); color: var(--bad); }
.mk-cell.dev-bad-2  { border-left-color: var(--red); background: var(--bad-bg); }
.mk-cell.dev-bad-2  .mk-delta { background: var(--red); color: #fff; }
.mk-cell.dev-na     .mk-delta { background: transparent; color: var(--muted); }

/* Small-sample rate: hatched so a 1-of-2 "50%" isn't read as a trend */
.mk-cell.mk-thin { background-image: repeating-linear-gradient(135deg, var(--hatch) 0 4px, transparent 4px 9px); }
.mk-cell.mk-thin .mk-val { color: var(--muted); }

.mk-table tfoot tr.mk-total td { background: var(--panel-2); border-top: 2px solid var(--border); border-bottom: 0; font-weight: 700; }
.mk-table tfoot tr.mk-total .mk-market { text-transform: uppercase; font-size: 12px; letter-spacing: 0.03em; }

.mk-legend { line-height: 1.6; }
.mk-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin: 0 3px 0 6px; }
.mk-sw-good { background: var(--green); }
.mk-sw-bad  { background: var(--red); }
.mk-sw-flat { background: var(--grey); }

/* Settings sub-navigation (Thresholds / Users / Lead sources / Dropdowns / Intake sheet). */
.subnav { display: flex; flex-wrap: wrap; gap: 2px 18px; margin: -8px 0 18px; border-bottom: 1px solid var(--line, rgba(128,128,128,.25)); }
.subnav .l { padding: 6px 0 8px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-weight: 600; }
.subnav .l:hover { color: var(--ink, inherit); }
.subnav .l.on { color: var(--ink, inherit); border-bottom-color: var(--accent); }
ul.plain { margin: 0; padding-left: 18px; columns: 2; }
ul.plain li { break-inside: avoid; }
.seg { display: inline-flex; gap: 4px; }
.fld textarea { font: inherit; }

/* Leads list: fixed columns so every row is one line (two with the sub-line); the row opens the lead. */
.leads-table { table-layout: fixed; }
.leads-table th, .leads-table td { padding: 6px 8px; }
.leads-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; line-height: 1.25; }
.leads-table .sub { display: block; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.leads-table .rowname { font-weight: 600; color: inherit; text-decoration: none; }
.leads-table .rule-pill { margin: 0 3px 0 0; padding: 1px 6px; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--panel-2); }
tr.rowlink:hover .rowname { text-decoration: underline; }
/* Lead detail */
.kv { display: grid; grid-template-columns: 11em 1fr; gap: 7px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12px; padding-top: 1px; }
.kv dd { margin: 0; }
.prewrap { white-space: pre-wrap; }
ul.plain.one-col { columns: 1; }
.leads-table td.num { font-variant-numeric: tabular-nums; }
.leads-table td.flag-bad { color: var(--bad); font-weight: 700; }

tr.is-dismissed td { opacity: .55; }
.btn.ghost { background: transparent; border-color: transparent; padding-left: 4px; padding-right: 4px; }
.dismiss-form { display: inline-flex; gap: 4px; align-items: center; }
.dismiss-form .cell-input { width: 11em; }

.care-table tr[data-id] { cursor: pointer; }
.care-table tr[data-id]:hover td { background: var(--panel-2); }
.care-table .st-link { margin-left: 4px; text-decoration: none; }
#care-modal .modal-card { max-width: 980px; width: calc(100% - 32px); }
#care-modal section h3.card-title { margin: 0 0 8px; }
#care-modal .grid.g2 { gap: 18px; }
#care-modal .kv { grid-template-columns: 9em 1fr; }
.hist-table td { vertical-align: top; }
.dot-bad { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); vertical-align: middle; }
/* Prop. / Faraday bands on the Leads list: red = act on it, amber = watch, green = fine. */
.band { display: inline-block; min-width: 2.6em; padding: 1px 7px; border-radius: 999px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.band-bad { background: var(--bad); color: #fff; }
.band-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.band-good { background: var(--ok-bg, rgba(46,160,90,.15)); color: var(--ok, #2a8a4f); border: 1px solid var(--ok, #2a8a4f); }

/* Performance: nested rows */
.perf-table .caret { background: none; border: 0; color: var(--muted); cursor: pointer; width: 18px; padding: 0; margin-right: 2px; font-size: 12px; }
.perf-table .caret-space { display: inline-block; width: 20px; }
.perf-table tr.depth-1 td { background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
.perf-table tr.depth-2 td { background: color-mix(in srgb, var(--panel-2) 85%, transparent); font-size: 12.5px; }
.perf-table tr.depth-0.has-kids td.mk-market { font-weight: 700; }

.leads-filters { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0 0 12px; }
.leads-filters .cell-input { max-width: 180px; }
.leads-filters input[type="date"] { width: 150px; }
/* Booking callouts: red alert = low propensity + high Faraday; green ! = high propensity + low Faraday */
.callout { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border-radius: 50%; margin-right: 6px; font-size: 12px; font-weight: 800; line-height: 1; vertical-align: -2px; }
.callout.callout-bad { background: var(--bad); color: #fff; }
.callout.callout-good { background: var(--ok, #2a8a4f); color: #fff; }
.callout.callout-warn { background: #e0a106; color: #1b1b1b; }
.callout.callout-block { background: #8b0000; color: #fff; }
.auto-tag.unknown { background: #fde8e8; color: #9b1c1c; text-transform: none; letter-spacing: 0; font-size: 11px; }
/* ServiceTitan already knows this number: repeat customer / DNC */
.repeat-pill { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; background: #e8eefb; color: #1f4e9c; margin-left: 6px; vertical-align: 1px; white-space: nowrap; }
.repeat-pill.dnc { background: #fde8e8; color: #9b1c1c; }
h1 .callout { width: 22px; height: 22px; font-size: 15px; margin-right: 8px; }

/* ---------- Book in ServiceTitan (/leads/<id>/book) ---------- */
.book-page .grid { display: grid; gap: 10px 14px; margin-bottom: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.book-page .fld { min-width: 0; }
.book-page .fld.span2 { grid-column: span 2; }
.book-page textarea { font: 13px var(--font-sans); color: var(--text); background: var(--panel); border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 8px; resize: vertical; }
.book-lookup { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.book-results:empty, .book-match:empty { display: none; }
.book-match { border: 1px solid var(--accent); background: var(--tint); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.book-match .match-head { font-weight: 700; margin-bottom: 6px; }
.cust { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; margin-top: 6px; background: var(--panel); }
.cust.selected { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.name-diff { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #fff4d6; color: #5a3b00; border: 1px solid #e0a106; font-size: 13px; line-height: 1.5; }
.name-diff .seg { margin-left: 6px; vertical-align: middle; }
.book-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.zone-badge { font-size: 12.5px; font-weight: 600; color: var(--info); background: var(--info-bg); border-radius: 999px; padding: 3px 10px; }
.zone-badge:empty { display: none; }
.zone-badge.bad { color: var(--bad); background: var(--bad-bg); }
.tag.bk-ok { background: var(--ok-bg); color: var(--ok); } .tag.bk-warn { background: var(--warn-bg); color: var(--warn); }
.tag.bk-bad { background: var(--bad-bg); color: var(--bad); } .tag.bk-info { background: var(--purple-bg); color: var(--purple-ink); }
.warn-text { color: var(--warn); }
.slot-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 12px; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.slot-grid:empty { display: none; }
#extra-day { margin-top: 12px; }
.daygroup { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--panel); }
.daygroup.extra { border-style: dashed; }
.daygroup.custom-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--tint); }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 13px; }
.day-tools { display: inline-flex; align-items: center; gap: 4px; }
.day-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.bslot { border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 4px; background: var(--panel); color: var(--text); cursor: pointer; font: inherit; text-align: center; }
.bslot .t { font-weight: 700; font-size: 13px; }
.bslot .s { font-size: 11px; margin-top: 2px; }
.bslot.open .s { color: var(--ok); }
.bslot.overbook { background: var(--bad-bg); } .bslot.overbook .s { color: var(--bad); }
.bslot.short { background: var(--warn-bg); } .bslot.short .s { color: var(--warn); }
.bslot.unchecked { border-style: dashed; } .bslot.unchecked .s { color: var(--muted); }
.bslot.closed { opacity: .45; cursor: not-allowed; background: var(--grey-bg); }
.bslot:not(.closed):hover { border-color: var(--accent); }
.bslot.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bslot.selected .s { color: inherit; }
.custom-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.custom-row label { display: inline-flex; align-items: center; gap: 6px; }
.book-cal { max-width: 340px; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 12px; background: var(--panel); }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; font-size: 12.5px; }
.cal-dow { color: var(--faint); font-size: 11px; font-weight: 600; }
.cal-day { padding: 5px 0; border-radius: 6px; cursor: pointer; }
.cal-day:hover:not(.off):not(.blank) { background: var(--tint); }
.cal-day.off { color: var(--faint); cursor: default; text-decoration: line-through; }
.cal-day.blank { cursor: default; }
.cal-day.in-grid { background: var(--info-bg); }
.cal-day.today { font-weight: 800; }
.cal-day.selected { background: var(--accent); color: var(--accent-ink); }
.book-summary { margin: 10px 0; }
.book-check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; font-size: 13px; cursor: pointer; }
.book-check small { display: block; }
.book-actionbar { position: sticky; bottom: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 16px; margin: 0 0 24px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.book-modal { max-width: 560px; }
.book-modal-actions { justify-content: flex-end; margin-top: 14px; }
@media (max-width: 820px) { .book-page .grid { grid-template-columns: 1fr 1fr; } .book-actionbar { flex-direction: column; align-items: stretch; } }
.book-lookup .form-row { flex-wrap: nowrap; } .book-lookup .cell-input { flex: 1 1 140px; min-width: 0; width: auto; }
