:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #0f1729;
  --ink-2: #4b5567;
  --muted: #7a8496;
  --line: #e3e7ee;
  --line-strong: #cfd5df;
  --accent: #1f5fae;
  --accent-soft: #e8f0fb;
  --s1: #2a78d6;
  --s2: #eb6834;
  --hot-bg: #fde9df;
  --hot-ink: #a8380f;
  --warm-bg: #fdf3d8;
  --warm-ink: #875c00;
  --cold-bg: #eef1f5;
  --cold-ink: #4b5567;
  --shadow: 0 1px 2px rgba(15, 23, 41, .04), 0 4px 16px rgba(15, 23, 41, .04);
  --skel: #eceff4;
  --skel-hi: #f6f7fa;
  --font: "Onest", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --logo-filter: none;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c1016;
    --surface: #141a23;
    --surface-2: #19202b;
    --ink: #eef1f6;
    --ink-2: #a9b2c1;
    --muted: #7d8799;
    --line: #242c39;
    --line-strong: #323c4c;
    --accent: #6ea8f0;
    --accent-soft: #1b2a40;
    --s1: #3987e5;
    --s2: #d95926;
    --hot-bg: #3a1d12;
    --hot-ink: #ffab85;
    --warm-bg: #33280d;
    --warm-ink: #f2c65a;
    --cold-bg: #1e2531;
    --cold-ink: #a9b2c1;
    --shadow: none;
    --logo-filter: invert(1) brightness(1.1);
    --skel: #1b222d;
    --skel-hi: #232b38;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1016;
  --surface: #141a23;
  --surface-2: #19202b;
  --ink: #eef1f6;
  --ink-2: #a9b2c1;
  --muted: #7d8799;
  --line: #242c39;
  --line-strong: #323c4c;
  --accent: #6ea8f0;
  --accent-soft: #1b2a40;
  --s1: #3987e5;
  --s2: #d95926;
  --hot-bg: #3a1d12;
  --hot-ink: #ffab85;
  --warm-bg: #33280d;
  --warm-ink: #f2c65a;
  --cold-bg: #1e2531;
  --cold-ink: #a9b2c1;
  --shadow: none;
  --logo-filter: invert(1) brightness(1.1);
  --skel: #1b222d;
  --skel-hi: #232b38;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
h1, h2 { text-wrap: balance; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 20px 40px;
}
@media (min-width: 720px) { .shell { padding-inline: 32px; padding-block: 28px 64px; } }

.range, .chips {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.range button, .chips button {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 12px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  transition: background .15s, color .15s;
}
.range button:hover, .chips button:hover { color: var(--ink); background: var(--surface-2); }
.range button[aria-checked="true"], .chips button[aria-checked="true"] {
  background: var(--ink); color: var(--surface);
}

.notice {
  margin-bottom: 16px; padding: 10px 14px; border-radius: 10px;
  background: var(--accent-soft); color: var(--ink); font-size: 13px;
  border: 1px solid var(--line);
}
.notice.error { background: var(--hot-bg); color: var(--hot-ink); }

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; min-height: 112px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.kpi-label .swatch { width: 8px; height: 8px; }
.kpi-value {
  font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-value small { font-size: 16px; font-weight: 600; color: var(--ink-2); margin-left: 2px; }
.kpi-meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 1px 6px; border-radius: 999px; background: var(--cold-bg); color: var(--ink-2);
}
.delta.up { color: var(--accent); background: var(--accent-soft); }

/* Panels */
.grid {
  display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
  gap: 16px; margin-bottom: 16px;
}
@media (max-width: 960px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.panel-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
h2 { font-size: 16px; font-weight: 600; letter-spacing: -.005em; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.legend { list-style: none; margin: 0; padding: 0; display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.swatch.s1 { background: var(--s1); }
.swatch.s2 { background: var(--s2); }

/* Chart */
.chart { position: relative; width: 100%; height: 260px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
/* The chart card is stretched to the height of the card next to it, so the chart fills it. The svg
   is taken out of the flow so its own size never pushes the card taller. */
.chart-panel { display: flex; flex-direction: column; }
.chart-panel .chart { flex: 1 1 auto; height: auto; min-height: 260px; }
.chart-panel .chart > svg, .chart-panel .chart > .skel-chart, .chart-panel .chart > .chart-empty { position: absolute; inset: 0; height: auto; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .bar1 { fill: var(--s1); }
.chart .bar2 { fill: var(--s2); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hover-band { fill: var(--ink); opacity: 0; transition: opacity .1s; }
.chart .hover-band.on { opacity: .05; }
.chart-empty {
  height: 100%; display: grid; place-items: center; text-align: center;
  color: var(--muted); font-size: 13px; border: 1px dashed var(--line-strong); border-radius: 10px;
}

.tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--ink); color: var(--surface);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.45;
  box-shadow: 0 6px 24px rgba(0,0,0,.18); min-width: 150px;
}
.tip b { display: block; font-weight: 600; margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tip .row span:first-child { display: flex; align-items: center; gap: 6px; opacity: .85; }
.tip .num { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Focus list */
.focus { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.focus li.item {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
  background: var(--accent-soft); color: var(--accent);
}
.focus .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.focus .why { font-size: 12px; color: var(--ink-2); }
.focus .when { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.focus-empty { color: var(--muted); font-size: 13px; padding: 18px 4px; }

/* Table */
.table-head { align-items: center; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chips button { padding: 5px 10px; font-size: 12.5px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 10px; color: var(--muted); height: 36px; min-width: 0; flex: 1 1 200px; max-width: 280px;
}
.search:focus-within { border-color: var(--accent); }
.search input {
  border: 0; outline: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 13px; width: 100%; min-width: 0;
}
.table-wrap { overflow-x: auto; margin-inline: -18px; }
table.clients { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.clients th, .clients td { padding: 11px 18px; text-align: left; white-space: nowrap; }
.clients th {
  font-size: 12px; font-weight: 500; color: var(--muted);
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.clients th button {
  border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: inherit;
  display: inline-flex; align-items: center; gap: 4px;
}
.clients th button:hover { color: var(--ink); }
.clients th button[aria-sort]::after { content: ""; border: 4px solid transparent; }
.clients th button[aria-sort="descending"]::after { border-top-color: currentColor; margin-top: 4px; }
.clients th button[aria-sort="ascending"]::after { border-bottom-color: currentColor; margin-bottom: 4px; }
.clients th button[aria-sort] { color: var(--ink); }
.clients .num { text-align: right; }
.clients th.num button { flex-direction: row-reverse; }
.clients td { border-bottom: 1px solid var(--line); }
.clients tbody tr:last-child td { border-bottom: 0; }
.clients tbody tr:hover td { background: var(--surface-2); }
.clients .who-cell { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.clients .who-cell .avatar { width: 30px; height: 30px; font-size: 12px; }
.clients .zero { color: var(--muted); }
.clients .last { color: var(--ink-2); }
.spark { display: block; }
.spark .b1 { fill: var(--s1); }
.spark .base { stroke: var(--line-strong); stroke-width: 1; }
.empty-row td { text-align: center; color: var(--muted); padding: 32px 18px; white-space: normal; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.hot { background: var(--hot-bg); color: var(--hot-ink); }
.pill.warm { background: var(--warm-bg); color: var(--warm-ink); }
.pill.cold { background: var(--cold-bg); color: var(--cold-ink); }
.pill.none { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }
.pill.none::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }

.table-foot { display: flex; justify-content: center; padding-top: 12px; }
.table-foot:empty { display: none; }
.more {
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer;
  border-radius: 9px; padding: 7px 16px; font-size: 13px; font-weight: 500;
}
.more:hover { background: var(--surface-2); }

.foot { color: var(--muted); font-size: 12px; margin-top: 16px; max-width: 70ch; }

/* Phones: each homeowner row becomes a compact card */
@media (max-width: 640px) {
  .panel { padding: 14px; }
  .kpi { padding: 14px; min-height: 100px; }
  .kpi-value { font-size: 26px; }
  .search { max-width: none; }
  .chips { flex-wrap: wrap; }
  .chips button { white-space: nowrap; }
  .table-wrap { margin-inline: 0; overflow: visible; }
  table.clients, .clients tbody { display: block; }
  .clients thead { display: none; }
  .clients tbody tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas: "who who status" "v a last";
    gap: 8px 10px; padding: 12px 0; border-bottom: 1px solid var(--line);
  }
  .clients tbody tr:last-child { border-bottom: 0; }
  .clients tbody tr:hover td { background: none; }
  .clients td { display: block; padding: 0; border: 0; white-space: normal; text-align: left; }
  .clients td.trend { display: none; }
  .clients .who-td { grid-area: who; min-width: 0; }
  .clients .status-td { grid-area: status; justify-self: end; }
  .clients td[data-label="Opens"] { grid-area: v; }
  .clients td[data-label="Adjustments"] { grid-area: a; }
  .clients td[data-label="Last active"] { grid-area: last; }
  .clients td[data-label] { padding-left: 40px; font-size: 13px; color: var(--ink); }
  .clients td[data-label="Adjustments"], .clients td[data-label="Last active"] { padding-left: 0; }
  .clients td[data-label]::before {
    content: attr(data-label); display: block;
    font-size: 11px; color: var(--muted); font-weight: 500;
  }
  .clients tr.empty-row { display: block; }
  .clients tr.empty-row td { padding: 24px 0; text-align: center; }
}

/* Skeletons */
.skel {
  background: linear-gradient(90deg, var(--skel) 25%, var(--skel-hi) 50%, var(--skel) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear;
  border-color: transparent; box-shadow: none;
}
.skel-chart { height: 100%; border-radius: 10px; }
.skel-row { height: 58px; border-radius: 10px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
  * { transition: none !important; }
}

/* Homeowner names open their profile in Follow Up Boss */
.focus .name { display: block; }
.cname { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.fub-link { color: inherit; text-decoration: none; }
.fub-link .ext { margin-left: 5px; vertical-align: -1px; color: var(--muted); opacity: 0; transition: opacity .15s; }
.fub-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.fub-link:hover .ext, .fub-link:focus-visible .ext { opacity: 1; color: var(--accent); }
@media (hover: none) { .fub-link .ext { opacity: 1; } }

/* ---------- App shell: side panel + content ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 22px 14px 16px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.side-brand { padding: 0 10px; }
.side-brand .brand-logo { height: 40px; }
.brand-logo { display: block; width: auto; filter: var(--logo-filter); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--ink-2); text-decoration: none; font-weight: 500;
  transition: background .15s, color .15s;
}
.side-nav a:hover { background: var(--surface-2); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-foot {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 10px 4px; border-top: 1px solid var(--line);
}
.side-foot .avatar { width: 34px; height: 34px; flex: none; }
.who-text { min-width: 0; }
.who-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { font-size: 12px; color: var(--muted); }
.content { min-width: 0; }
.mobile-top { display: none; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 14px; margin-bottom: 20px;
}
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; }
.page-head .sub { font-size: 14px; margin-top: 4px; }

@media (max-width: 820px) {
  .app { display: block; }
  .mobile-top {
    display: flex; align-items: center; padding: 14px 16px;
    background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .mobile-top .brand-logo { height: 32px; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 30; height: auto;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .side-brand, .side-foot { display: none !important; }
  .side-nav { flex-direction: row; width: 100%; }
  .side-nav a { flex: 1; flex-direction: column; gap: 3px; padding: 6px 4px; font-size: 11px; justify-content: center; }
  .content { padding-bottom: 76px; }
  .page-head h1 { font-size: 21px; }
}

/* ---------- Forms ---------- */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.form-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1080px) { .form-layout { grid-template-columns: minmax(0, 1fr); } }
.panel h2 + .sub { margin-bottom: 0; }
.panel-note {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500;
  color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px;
}
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.fields .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .fields { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > .label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--hot-ink); font-weight: 500; }
.input, .textarea {
  width: 100%; min-width: 0; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px;
  padding: 8px 11px; transition: border-color .15s, box-shadow .15s;
}
.input { height: 38px; }
.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.input:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[readonly] { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.field.invalid .input, .field.invalid .textarea { border-color: var(--hot-ink); }
.input-row { display: flex; gap: 10px; align-items: center; }
.input-row .avatar { width: 38px; height: 38px; flex: none; overflow: hidden; }
.input-row .avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Toggle rows */
.toggles { display: flex; flex-direction: column; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer;
}
.toggle-row:first-child { border-top: 0; padding-top: 2px; }
.toggle-row .t-text { display: flex; flex-direction: column; gap: 2px; }
.toggle-row .t-title { font-weight: 600; font-size: 14px; }
.toggle-row .t-hint { font-size: 12px; color: var(--muted); }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; cursor: pointer; margin: 0;
  width: 40px; height: 24px; border-radius: 999px; position: relative;
  background: var(--line-strong); transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.sub-field { padding: 0 0 12px; max-width: 360px; }

/* Color pickers */
.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.color-field {
  display: grid; grid-template-columns: 38px minmax(0, 1fr); grid-template-rows: auto auto; gap: 2px 10px;
  align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.color-field input[type="color"] {
  grid-row: 1 / 3; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line-strong);
  border-radius: 8px; background: none; cursor: pointer;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.color-field input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.color-field .c-name { font-size: 13px; font-weight: 600; }
.color-field .c-hint { font-size: 11.5px; color: var(--muted); }
.link-btn {
  border: 0; background: none; padding: 0; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--accent);
}
.link-btn:hover { text-decoration: underline; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.segmented button {
  border: 0; background: none; cursor: pointer; padding: 6px 14px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.segmented button[aria-checked="true"] { background: var(--ink); color: var(--surface); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 9px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; border: 1px solid transparent;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary[disabled] { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; color: inherit; border-color: currentColor; opacity: .85; }
.btn.ghost:hover { opacity: 1; }

/* Save bar and toast */
.savebar {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: space-between;
  width: min(560px, calc(100% - 32px));
  padding: 10px 10px 10px 18px; border-radius: 14px;
  background: var(--ink); color: var(--surface); box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.savebar p { font-weight: 500; font-size: 14px; }
.savebar-actions { display: flex; gap: 8px; }
.savebar .btn.primary { background: var(--surface); color: var(--ink); }
@media (min-width: 821px) { .savebar { left: calc(50% + 116px); } }
@media (max-width: 820px) { .savebar { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); } }
.toast {
  position: fixed; z-index: 50; top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px;
  max-width: min(380px, calc(100% - 32px));
  padding: 11px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  background: var(--ink); color: var(--surface); box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.toast.error { background: var(--hot-ink); color: #fff; }

/* Locked / empty states */
.state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 48px 20px; color: var(--ink-2);
}
.state .state-icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 4px;
}
.state h2 { color: var(--ink); }
.state p { max-width: 46ch; }

/* ---------- Report preview (always light, like the real report) ---------- */
.preview-wrap { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 10px; }
.preview-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); }
.preview-label strong { font-size: 13px; color: var(--ink); }
.rp {
  color-scheme: light; background: #f6f7f9; color: #1d2433;
  border: 1px solid var(--line-strong); border-radius: 22px; overflow: hidden;
  font-size: 12px; line-height: 1.45; box-shadow: var(--shadow);
}
.rp-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: #fff; border-bottom: 1px solid #e6e8ee; }
.rp-top img { height: 22px; max-width: 140px; object-fit: contain; }
.rp-top .rp-co { font-weight: 700; font-size: 13px; }
.rp-body { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.rp-card { background: #fff; border: 1px solid #e6e8ee; border-radius: 12px; padding: 12px; }
.rp-msg { display: grid; grid-template-columns: 30px 1fr; gap: 10px; border: 0; }
.rp-av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 11px; background: #fff; color: #1d2433; overflow: hidden; }
.rp-av img { width: 100%; height: 100%; object-fit: cover; }
.rp-sign { margin-top: 6px; font-weight: 600; }
.rp-value { color: #fff; border: 0; }
.rp-value .rp-k { opacity: .85; font-size: 11px; }
.rp-value .rp-v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0; }
.rp-value .rp-range { font-size: 11px; opacity: .9; }
.rp-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.rp-stat { flex: 1 1 0; min-width: 84px; background: #fff; border: 1px solid #e6e8ee; border-radius: 10px; padding: 8px; }
.rp-stat b { display: block; font-size: 13px; }
.rp-stat span { color: #6b7385; font-size: 10.5px; }
.rp-chart svg { display: block; width: 100%; height: 88px; }
.rp-chart .rp-k { font-weight: 600; margin-bottom: 6px; }
.rp-outline { display: inline-block; margin-top: 8px; border: 1px solid; border-radius: 8px; padding: 4px 10px; font-weight: 600; font-size: 11px; background: #fff; }
.rp-disc { font-size: 10px; color: #6b7385; }
.rp-btn { display: block; text-align: center; color: #fff; border-radius: 9px; padding: 8px; font-weight: 600; }
.rp-agent { border: 0; }
.rp-agent .rp-name { font-weight: 700; font-size: 13px; }
.rp-agent .rp-meta { color: #4a5263; font-size: 11px; }
.rp-foot { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 0 2px; color: #6b7385; font-size: 10px; }
.rp-foot img { height: 16px; }

/* Report layout picker */
.layout-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 480px) { .layout-choices { grid-template-columns: minmax(0, 1fr); } }
.layout-choice {
  display: flex; flex-direction: column; gap: 4px; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px;
}
.layout-choice:hover { border-color: var(--line-strong); }
.layout-choice[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.layout-name { font-weight: 600; font-size: 13px; margin-top: 4px; }
.layout-text { font-size: 12px; color: var(--muted); line-height: 1.35; }
.layout-hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.layout-thumb {
  display: flex; flex-direction: column; gap: 4px; height: 84px; overflow: hidden;
  padding: 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line);
}
.layout-thumb i { display: block; height: 7px; border-radius: 3px; background: var(--line-strong); }
.layout-thumb.classic i:nth-child(1) { width: 40%; }
.layout-thumb.classic i:nth-child(2) { height: 14px; }
.layout-thumb.classic i:nth-child(3) { height: 20px; background: var(--accent); }
.layout-thumb.classic i:nth-child(4) { width: 70%; }
.layout-thumb.modern i:nth-child(1) { width: 50%; }
.layout-thumb.modern i:nth-child(2) { width: 65%; height: 14px; background: var(--ink-2); }
.layout-thumb.modern i:nth-child(3) { height: 5px; background: var(--accent); }
.layout-thumb.modern i:nth-child(4) { height: 18px; }
.layout-thumb.modern i:nth-child(5) { margin-top: auto; height: 11px; background: var(--accent); }

/* Live preview of the new layout (reportLayout MODERN) */
.rpm { position: relative; background: #f5f7fa; }
.rpm-logo { display: flex; align-items: center; justify-content: center; padding: 16px 12px; }
.rpm-logo img { display: block; width: 100%; max-width: 150px; height: auto; max-height: 48px; object-fit: contain; }
.rpm-body { display: flex; flex-direction: column; gap: 10px; padding: 12px 12px 8px; }
.rpm-card { background: #fff; border: 1px solid #e6e9ef; border-radius: 12px; padding: 12px; }
.rpm-muted { color: #6b7385; font-size: 11px; }
.rpm-lab { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #6b7385; }
.rpm-v { font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rpm-chip { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 99px; background: #e3f5ec; color: #0f7a55; font-size: 10.5px; font-weight: 700; }
.rpm-chip span { font-weight: 500; }
.rpm-track { position: relative; height: 6px; border-radius: 99px; margin-top: 8px; }
.rpm-track span { position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; transform: translate(-50%, -50%); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.rpm-ends { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10px; color: #6b7385; }
.rpm-ends b { display: block; color: #1d2433; font-size: 11px; }
.rpm-ends span:last-child { text-align: right; }
.rpm-h { font-weight: 700; font-size: 12.5px; margin-bottom: 6px; }
.rpm-chart { padding-bottom: 0; overflow: hidden; }
.rpm-chart svg { display: block; width: 100%; height: 88px; }
.rpm-stats { display: flex; flex-wrap: wrap; margin: 10px -12px 0 -13px; }
.rpm-stats div { flex: 1 1 90px; padding: 8px 12px; border-top: 1px solid #e6e9ef; border-left: 1px solid #e6e9ef; }
.rpm-stats b { display: block; font-size: 13px; font-variant-numeric: tabular-nums; }
.rpm-stats span { color: #6b7385; font-size: 10px; }
.rpm-note { display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.rpm-link { display: flex; justify-content: space-between; font-weight: 600; }
.rpm .rp-outline { margin-top: 8px; }
.rpm .rp-disc { margin: 0 2px; }
.rpm-dock { position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: rgba(255,255,255,.95); border-top: 1px solid #e6e9ef; }
.rpm-who { flex: 1; min-width: 0; line-height: 1.25; }
.rpm-who b { display: block; font-size: 11.5px; }
.rpm-who span { display: block; font-size: 10px; color: #6b7385; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rpm-ghost { border: 1px solid #d9dee6; border-radius: 8px; padding: 5px 8px; font-weight: 700; font-size: 11px; white-space: nowrap; }
.rpm-cta { color: #fff; border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 11px; white-space: nowrap; }

/* ---------- Users ---------- */
.users .who-cell .you { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; }
.pill.role-owner { background: var(--accent-soft); color: var(--accent); }
.pill.role-member { background: var(--cold-bg); color: var(--cold-ink); }
.pill.role-owner::before, .pill.role-member::before { display: none; }
.team-summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.team-summary .kpi { flex: 1 1 200px; min-height: 0; }
@media (max-width: 640px) {
  .users td[data-label="Email"] { grid-area: v; padding-left: 40px; word-break: break-all; }
  .users tbody tr { grid-template-areas: "who who status" "v v v" "r r last"; }
  .users td[data-label="Reports"] { grid-area: r; text-align: left; }
  .users td[data-label="Added"] { grid-area: last; padding-left: 0; text-align: right; }
}

/* Searchable picker (Follow Up Boss action plans) */
.combo { position: relative; }
.combo-btn { display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; }
.combo-btn:disabled { cursor: default; background: var(--surface-2); }
.combo-btn:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.combo-btn[aria-expanded="true"] { border-color: var(--accent); }
.combo-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo .muted { color: var(--muted); }
.combo-id { flex: none; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.combo-chev { flex: none; color: var(--muted); }
.combo-pop {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(15, 23, 41, .16); padding: 8px;
}
.combo-search { margin-bottom: 6px; }
.combo-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.combo-list li {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px;
  font-size: 14px; cursor: pointer;
}
.combo-list li.active { background: var(--accent-soft); }
.combo-list li[aria-selected="true"] .combo-name { font-weight: 600; color: var(--accent); }
.combo-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-tag { flex: none; font-size: 11px; font-weight: 600; color: var(--cold-ink); background: var(--cold-bg); padding: 1px 7px; border-radius: 999px; }
.combo-list .combo-empty { cursor: default; color: var(--muted); }
