/* The Booked Pro brand: thebookedpro.com orange on charcoal, Outfit headings, Inter text.
   Fonts are served from /assets/fonts (OFL, Fontsource) so the page needs nothing from Google. */
@font-face { font-family: "Inter"; src: url("fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Outfit"; src: url("fonts/outfit.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --brand: #f15f1a;          /* thebookedpro.com orange */
  --brand-deep: #e05018;     /* logo orange */
  --ink: #141416;            /* site charcoal */
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #f2f2f3;
  --border: #e5e5e8;
  --text: #141416;
  --muted: #5c5c63;
  --faint: #9b9b9f;
  --accent: var(--brand-deep);   /* fills: buttons, active states */
  --accent-text: #c2410c;        /* orange text on white (readable at small sizes) */
  --accent-soft: #fdede5;
  --good: #137333;
  --good-soft: #e6f4ea;
  --bad: #c5221f;
  --bad-soft: #fce8e6;
  --warn: #7a5b00;
  --warn-soft: #fef7e0;
  --series-1: #2e2e33;       /* leads, speed, calls: charcoal */
  --series-2: var(--brand);  /* booked: orange */
  --series-3: #1f628e;       /* lines (booking rate, under 5 min): site blue */
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 22, 0.06);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Outfit", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --hover: rgba(0, 0, 0, 0.04);
  --overlay: rgba(255, 255, 255, 0.55);
  --bad-border: #f4c7c3;
  color-scheme: light;
}

/* ---------- dark mode (theme.js sets data-theme on <html>) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e10;             /* site near-black */
  --surface: #17171a;
  --surface-2: #202024;
  --border: #2d2d33;
  --text: #ededf0;
  --muted: #a3a3ab;
  --faint: #74747c;
  --ink: #2a2a30;            /* tooltips, dark table headers */
  --accent-text: #ff8f5a;    /* orange text, readable on dark */
  --accent-soft: rgba(241, 95, 26, 0.16);
  --good: #4ade80;
  --good-soft: rgba(74, 222, 128, 0.12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.14);
  --bad-border: rgba(248, 113, 113, 0.35);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --series-1: #c9c9cf;       /* leads / speed / calls bars: light grey on dark */
  --series-3: #5aaae6;       /* lines: lighter site blue */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  --hover: rgba(255, 255, 255, 0.05);
  --overlay: rgba(14, 14, 16, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 3px solid var(--brand);
}
.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; font-family: var(--display); font-weight: 600; font-size: 17px; }
/* The logo PNG has padding around the artwork; show just the artwork (27..694 x 86..635 of 733px). */
.brand-logo {
  width: 49px; height: 40px; flex: none;
  background: url("logo.png") no-repeat;
  background-size: 53.3px 53.3px; background-position: -2px -6.3px;
}
.brand-divider { width: 1px; height: 24px; background: var(--border); }
/* Dark mode: the white-lettered logo from the brand kit (artwork at 186..853 x 245..795 of 1024px). */
:root[data-theme="dark"] .brand-logo { background-image: url("logo-white.png"); background-size: 74.5px 74.5px; background-position: -13.5px -17.8px; }
:root[data-theme="dark"] .login-logo { background-image: url("logo-white.png"); background-size: 230.9px 230.9px; background-position: -41.9px -55.2px; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab {
  border: 0; background: none; padding: 7px 12px; border-radius: 8px;
  color: var(--muted); cursor: pointer; font-weight: 500; font-family: var(--display); font-size: 15px;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 -2px 0 var(--brand); }
.spacer { flex: 1; }
.updated { font-size: 12px; color: var(--faint); white-space: nowrap; }
.updated.stale { color: var(--warn); }

.control { display: flex; align-items: center; gap: 8px; }
.control label { font-size: 12px; color: var(--muted); }
select, input[type="search"], input[type="password"] {
  height: 34px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
}
select:focus, input:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type="checkbox"] { accent-color: var(--brand-deep); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none !important;
  height: 32px; padding: 0 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-weight: 550; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #c94612; border-color: #c94612; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 32px; padding: 0; }
/* Moon in light mode, sun in dark mode, drawn with CSS so it follows the theme colours. */
.theme-icon { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset -4px -3px 0 1px var(--text); transform: rotate(-20deg); }
:root[data-theme="dark"] .theme-icon {
  width: 10px; height: 10px; box-shadow: none; background: var(--brand); transform: none;
  outline: 2px dotted var(--brand); outline-offset: 2px;
}

/* ---------- layout ---------- */
main { padding: 20px; max-width: 1600px; margin: 0 auto; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
main > div { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head:has(.client-picker) { justify-content: flex-start; align-items: center; gap: 16px; }
/* Company page: ‹ All clients ▾ › */
.client-picker { display: flex; align-items: center; gap: 4px; }
.client-picker .btn.icon { width: 34px; height: 34px; font-size: 20px; line-height: 1; padding-bottom: 2px; }
.client-picker select { min-width: 200px; max-width: 260px; font-weight: 600; }
.swatch.big { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 10px; vertical-align: 1px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.card-body { padding: 16px; }
/* ---------- lead source checkbox dropdown (trend chart) ---------- */
.filter-dropdown { position: relative; }
.filter-dropdown > summary { list-style: none; cursor: pointer; user-select: none; }
.filter-dropdown > summary::-webkit-details-marker { display: none; }
.filter-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  width: 280px; max-width: calc(100vw - 32px); max-height: 360px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); padding: 8px 12px 12px;
}
.filter-actions { display: flex; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.filter-group { border: 0; margin: 0; padding: 6px 0; }
.filter-group + .filter-group { border-top: 1px solid var(--border); }
.filter-group label { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; font-size: 13px; }
.filter-category { font-weight: 600; }
.filter-source { padding-left: 22px !important; }
.card-body.loading { opacity: 0.5; transition: opacity 0.15s; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.grid-2 > * { min-width: 0; }

/* ---------- KPIs ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(160px, 40%), 1fr)); }
.kpi { padding: 14px 16px; }
.kpi::before { content: ""; display: block; width: 22px; height: 3px; border-radius: 2px; background: var(--brand); margin-bottom: 10px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 550; }
.kpi .value { font-family: var(--display); font-size: 28px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .sub { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; max-width: 100%; }
.table-wrap.tall { max-height: 70vh; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th.left, td.left { text-align: left; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px;
}
thead tr.group th { top: 0; text-align: center; color: var(--text); border-bottom: 1px solid var(--border); }
thead tr.cols th { top: 31px; }
th[title] { cursor: help; text-decoration: underline dotted var(--faint); text-underline-offset: 3px; }
tbody tr:hover td { background: rgba(241, 95, 26, 0.05); }
tr.total td { font-weight: 650; background: var(--surface-2); }
tr.manager td { color: var(--muted); font-style: italic; }
tr.section td { background: var(--surface); font-weight: 650; text-align: left; padding-top: 14px; color: var(--text); }
td.group-cell { text-align: left; vertical-align: middle; font-weight: 600; background: var(--surface); border-right: 1px solid var(--border); }
td.empty, .empty-state { color: var(--faint); text-align: center; padding: 28px; }
.sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); }
thead .sticky-col { z-index: 3; background: var(--surface-2); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }

/* ---------- client blocks (company view) ---------- */
.client-block { border-top: 1px solid var(--border); }
.client-block > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
}
.client-block > summary::-webkit-details-marker { display: none; }
.client-block > summary::before { content: "▸"; color: var(--faint); width: 10px; }
.client-block[open] > summary::before { content: "▾"; }
.client-block > summary:hover { background: var(--surface-2); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.client-name { font-weight: 650; min-width: 180px; }
.chips { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.chips b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- chart ---------- */
.chart { width: 100%; height: auto; max-height: 320px; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.stacked-charts .chart-title { font-family: var(--display); }
.chart .grid { stroke: var(--border); }
.chart .bar.s1 { fill: var(--series-1); }
.chart .bar.s2 { fill: var(--series-2); }
.chart .bar.bad { fill: var(--bad); }
.legend .bad { background: var(--bad); }
.chart .bar.dim { opacity: 0.3; }
.chart .line { fill: none; stroke: var(--series-3); stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--surface); stroke: var(--series-3); stroke-width: 2; }
.chart .dot.dim { opacity: 0.4; }
.chart .line-axis { fill: var(--series-3); }
.stacked-charts .chart-title { margin: 20px 0 2px; font-size: 13px; font-weight: 600; }
.stacked-charts .chart-note { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--hover); }
.legend i.line { height: 3px; border-radius: 2px; width: 14px; }
.legend .s3 { background: var(--series-3); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .s1 { background: var(--series-1); }
.legend .s2 { background: var(--series-2); }
.chart-tip {
  position: fixed; pointer-events: none; z-index: 50; padding: 8px 10px; border-radius: 8px;
  background: var(--ink); color: #fff; font-size: 12px; line-height: 1.5; box-shadow: 0 4px 12px rgba(0,0,0,.2); border-left: 3px solid var(--brand);
}

/* ---------- call tracking ---------- */
.calls-table { min-width: 680px; }
.calls-table td { white-space: normal; }
.calls-table tr.title td { background: var(--ink); color: #fff; font-weight: 700; }
.calls-table tr.subtitle td { background: var(--accent-soft); color: var(--accent-text); }
.calls-table tr.sectionTree td { background: #3a3a40; color: #fff; font-weight: 700; }
.calls-table tr.sectionWater td { background: var(--ink); color: #fff; font-weight: 700; }
.calls-table tr.sectionCalls td { background: var(--brand-deep); color: #fff; font-weight: 700; }
.calls-table tr.header td { background: var(--surface-2); font-weight: 650; color: var(--muted); }
.calls-table tr.total td { background: var(--warn-soft); font-weight: 700; }
.calls-table tr.store td { background: var(--warn-soft); color: var(--warn); }
.calls-table tr.blank td { border: 0; padding: 4px; }
.calls-table td.e-good { background: var(--good-soft); color: var(--good); }
.calls-table td.e-bad { background: var(--bad-soft); color: var(--bad); }
.calls-table td.e-store { background: var(--warn-soft); color: var(--warn); }
.calls-table td { text-align: left; }

/* ---------- states ---------- */
.loading { position: relative; }
.loading::after {
  content: ""; position: absolute; inset: 0; background: var(--overlay); border-radius: inherit;
}
.banner {
  padding: 10px 14px; border-radius: 8px; font-size: 13px;
  background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-border);
}
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--surface); padding: 8px 14px; border-radius: 8px; font-size: 13px;
}

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 0%, rgba(241, 95, 26, 0.25), transparent 60%), #0e0e10;
}
.login { width: 100%; max-width: 380px; padding: 32px 28px 28px; display: grid; gap: 14px; border: 0; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); }
.login-logo { width: 150px; height: 124px; margin: 0 auto 4px; background: url("logo.png") no-repeat; background-size: 164.7px 164.7px; background-position: -6px -19.3px; }
.login h1 { text-align: center; font-size: 22px; }
.login > p { text-align: center; margin: 0; }
.login input { width: 100%; height: 40px; }
.login .btn { height: 40px; }

/* ---------- embedded client view ---------- */
body.embed main { padding: 16px; }
body.embed .topbar { position: static; }

@media (max-width: 720px) {
  main { padding: 12px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .tab { font-size: 14px; padding: 6px 9px; }
  .brand { font-size: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpi .value { font-size: 20px; }
  .client-name { min-width: 0; }
}
