/* Planform CRM. One owner, one laptop. Calm, light, tool-like.
   System fonts only, no network assets: this works offline. */

:root {
  /* colour */
  --ink: #151a23;
  --accent: #1f4fd0;
  --accent-hover: #1a43b3;
  --accent-active: #153795;
  --n0: #f6f7f9;            /* page */
  --n1: #eceff3;            /* wells, column backgrounds */
  --line: #e3e6eb;          /* the one hairline */
  --n3: #aab1bd;            /* disabled edges */
  --n4: #566070;            /* secondary text (AA on white and page) */
  --n5: #151a23;
  --surface: #ffffff;
  --green: #176b3a;   --green-bg: #e6f4ec;
  --amber: #7a4f00;   --amber-bg: #fbf1d9;
  --red: #a8200f;     --red-bg: #fdeceb;
  --blue-bg: #e8eefc;

  /* type */
  --font: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --t12: 0.75rem; --t14: 0.875rem; --t16: 1rem; --t20: 1.25rem; --t24: 1.5rem; --t32: 2rem;

  /* space (4px scale) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px; --s12: 48px; --s16: 64px;

  --r: 6px;
  --control: 36px;
  --page: 1248px;           /* top bar and tabs */
  --page-inner: 1184px;     /* content, less the side padding */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--n0); color: var(--ink);
  font: 400 var(--t16)/1.5 var(--font);
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
a:active { color: var(--accent-active); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--t24); }
h2 { font-size: var(--t20); }
h3 { font-size: var(--t16); }
p { margin: 0 0 var(--s3); }
small, .small { font-size: var(--t14); }
.muted { color: var(--n4); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.skip-link { position: absolute; left: var(--s2); top: -64px; background: var(--surface); padding: var(--s2) var(--s4);
  border: 1px solid var(--line); border-radius: var(--r); z-index: 30; }
.skip-link:focus { top: var(--s2); }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #d7dbe2; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  max-width: var(--page); margin: 0 auto; padding: 0 var(--s8); min-height: 56px; }
.switcher { position: relative; }
.switcher > summary { list-style: none; display: inline-flex; align-items: center; gap: var(--s3); min-height: 44px;
  padding: 0 var(--s3) 0 0; margin: 0; cursor: pointer; color: #fff; border-radius: var(--r); }
.switcher > summary::-webkit-details-marker { display: none; }
.switcher > summary:hover .sw-now { background: #2b3445; }
.switcher > summary:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sw-brand { font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.sw-now { display: inline-flex; align-items: center; gap: var(--s2); min-height: 32px; padding: 0 var(--s3);
  border-radius: var(--r); background: #222a38; font-size: var(--t14); font-weight: 500;
  transition: background-color 140ms var(--ease); }
.switcher[open] .sw-now { background: var(--accent); }
.sw-chev { width: 7px; height: 7px; border-right: 2px solid #aab1bd; border-bottom: 2px solid #aab1bd;
  transform: translateY(-2px) rotate(45deg); transition: transform 140ms var(--ease); margin-left: -4px; }
.switcher[open] .sw-chev { transform: translateY(1px) rotate(-135deg); border-color: #fff; }
.sw-menu { position: absolute; left: 0; top: calc(100% + var(--s1)); z-index: 30; width: 300px; margin: 0; padding: var(--s2);
  list-style: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: 0 8px 24px rgba(21, 26, 35, 0.18); }
.sw-menu a { display: grid; gap: 2px; min-height: 44px; padding: var(--s2) var(--s3); border-radius: var(--r);
  color: var(--ink); text-decoration: none; border-left: 3px solid transparent; }
.sw-menu a:hover { background: var(--n0); color: var(--ink); }
.sw-menu a:focus-visible { outline-offset: -2px; }
.sw-menu a[aria-current] { border-left-color: var(--accent); background: var(--blue-bg); }
.sw-name { font-weight: 600; font-size: var(--t14); }
.sw-blurb { font-size: var(--t12); color: var(--n4); }
.topbar-end { display: flex; align-items: center; gap: var(--s2); font-size: var(--t14); }
.top-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s3); color: #d7dbe2;
  text-decoration: none; border-radius: var(--r); font: 500 var(--t14)/1 var(--font); }
.top-link:hover { color: #fff; background: #222a38; }
.top-link.current { color: #fff; background: #2b3445; }
.top-link:focus-visible, .topbar button:focus-visible { outline-color: #fff; }
button.top-link.as-button { background: none; border: 0; cursor: pointer; }
.topbar .who { color: #9aa3b2; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabbar { background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tabbar-in { display: flex; gap: var(--s1); list-style: none; margin: 0 auto; padding: 0 var(--s8); max-width: var(--page); width: 100%; min-width: max-content; }
.tabbar a { display: inline-flex; align-items: center; gap: var(--s2); min-height: 48px; padding: 0 var(--s4); white-space: nowrap;
  color: var(--n4); text-decoration: none; font-size: var(--t14); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 140ms var(--ease), background-color 140ms var(--ease); }
.tabbar a:hover { color: var(--ink); background: var(--n0); }
.tabbar a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabbar .count { background: var(--accent); color: #fff; }

.subtabs { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s6); }
.subtabs a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--s4); border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--n4); text-decoration: none; font-size: var(--t14); font-weight: 500; }
.subtabs a:hover { border-color: var(--n3); color: var(--ink); }
.subtabs a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.brand { font-weight: 600; font-size: var(--t16); letter-spacing: -0.01em; }
.count { font-size: var(--t12); font-weight: 600; background: #fff; color: var(--ink); border-radius: var(--r);
  padding: 0 var(--s2); min-width: 22px; text-align: center; line-height: 20px; }
.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline;
  text-underline-offset: 2px; cursor: pointer; min-height: 32px; }

.main { padding: var(--s8) var(--s8) var(--s16); min-height: 100vh; }
.main > .wrap { max-width: var(--page-inner); margin: 0 auto; }
.main.bare { display: grid; place-items: start center; padding-top: var(--s16); }
.main.bare > .wrap { width: 100%; max-width: 420px; }

.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: var(--s2) var(--s6); margin-bottom: var(--s6); }
.page-head p { margin: 0; color: var(--n4); font-size: var(--t14); }
.crumb { font-size: var(--t14); margin-bottom: var(--s2); }

/* ---------- flash ---------- */
.flashes { display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.flashes:empty { display: none; }
.flash { padding: var(--s3) var(--s4); border-radius: var(--r); border: 1px solid var(--line); background: var(--surface);
  border-left: 4px solid var(--accent); font-size: var(--t14); }
.flash.success { border-left-color: var(--green); }
.flash.error { border-left-color: var(--red); background: var(--red-bg); }
.flash strong { font-weight: 600; margin-right: var(--s1); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s6); }
.card + .card, .stack > * + * { margin-top: var(--s6); }
.card > h2, .card > h3 { margin-bottom: var(--s3); }
.card-tight { padding: var(--s4); }

.mt6 { margin-top: var(--s6); }
.section { margin-top: var(--s8); }
.section > h2 { margin-bottom: var(--s3); }
.well { background: var(--n0); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4); }
.grid { display: grid; gap: var(--s6); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split { display: grid; gap: var(--s6); grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: var(--t12); font-weight: 600; line-height: 20px; padding: 0 var(--s2);
  border-radius: 4px; background: var(--n1); color: var(--ink); white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--accent-active); }

/* ---------- buttons and forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--control); padding: 0 var(--s4); border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 500 var(--t14)/1.2 var(--font); text-decoration: none; cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), transform 140ms var(--ease);
}
.btn:hover { background: var(--n1); border-color: var(--n3); color: var(--ink); }
.btn:active { background: #dfe3e9; transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn.primary:active { background: var(--accent-active); border-color: var(--accent-active); }
.btn.danger { color: var(--red); border-color: #e7b9b4; }
.btn.danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn.small { min-height: 32px; padding: 0 var(--s3); }
.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--n1); border-color: var(--line); color: #737c8b; cursor: not-allowed; transform: none; }
.btn.primary:disabled, .btn.primary[aria-disabled="true"] { background: var(--n1); border-color: var(--line); color: #737c8b; }

label, .label { display: block; font-size: var(--t14); font-weight: 600; margin-bottom: var(--s1); }
.help { font-size: var(--t14); color: var(--n4); margin: var(--s1) 0 0; }
input[type=text], input[type=email], input[type=url], input[type=password], input[type=search], input[type=number],
select, textarea {
  width: 100%; min-height: var(--control); padding: var(--s2) var(--s3);
  border: 1px solid #b7bdc8; border-radius: var(--r); background: var(--surface); color: var(--ink);
  font: 400 var(--t14)/1.4 var(--font);
  transition: border-color 140ms var(--ease);
}
textarea { line-height: 1.6; font-size: var(--t16); resize: vertical; min-height: 120px; }
input:hover, select:hover, textarea:hover { border-color: var(--n4); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[readonly] { background: var(--n0); color: var(--ink); }
input:disabled, select:disabled, textarea:disabled { background: var(--n1); color: #737c8b; cursor: not-allowed; }
.field { margin-bottom: var(--s4); }
.field-row { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s4); }
.inline-form { display: inline-flex; gap: var(--s2); align-items: center; margin: 0; }
.inline-form select { width: auto; min-height: 32px; padding-top: 0; padding-bottom: 0; }
.check { display: flex; align-items: flex-start; gap: var(--s3); font-weight: 400; font-size: var(--t14); margin: 0; padding: var(--s2) 0; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check-grid { display: grid; gap: 0 var(--s6); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
fieldset { border: 0; padding: 0; margin: 0 0 var(--s4); min-width: 0; }
legend { font-size: var(--t14); font-weight: 600; padding: 0; margin-bottom: var(--s2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: var(--t14); }
th, td { text-align: left; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--n4); font-size: var(--t12); letter-spacing: 0.04em; text-transform: uppercase; background: var(--n0); white-space: nowrap; }
tbody th { text-transform: none; letter-spacing: 0; font-size: inherit; color: inherit; background: none; white-space: normal; font-weight: 600; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- filters ---------- */
.filters { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end;
  padding: var(--s4); margin-bottom: var(--s4); }
.filters .field { margin: 0; }
.filters .actions { margin: 0; }
.result-count { font-size: var(--t14); color: var(--n4); margin: 0 0 var(--s3); }

/* ---------- in-page filters (a row of links that narrows the list below) ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: var(--s1); border-bottom: 1px solid var(--line); margin-bottom: var(--s6); }
.tabs a { display: inline-flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s4);
  color: var(--n4); text-decoration: none; font-size: var(--t14); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); background: var(--n1); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { background: var(--n1); color: var(--ink); }

/* ---------- today ---------- */
.needs { list-style: none; margin: 0; padding: 0; }
.needs li + li { border-top: 1px solid var(--line); }
.needs a { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 48px; padding: var(--s3) var(--s2);
  color: var(--ink); text-decoration: none; font-weight: 500; border-radius: var(--r); }
.needs a:hover { background: var(--n0); }
.needs a::after { content: "Open"; font-size: var(--t14); font-weight: 400; color: var(--accent); flex: none; }
.allclear { color: var(--green); font-weight: 600; margin: 0; }
.figures { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.figure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4) var(--s6); }
.figure .n { font-size: var(--t32); font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.figure .n small { font-size: var(--t16); font-weight: 400; color: var(--n4); letter-spacing: 0; }
.figure .l { font-size: var(--t14); color: var(--n4); margin-top: var(--s1); }
.funnel { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.funnel a { display: block; padding: var(--s4); text-decoration: none; color: var(--ink); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.funnel a:hover { background: var(--n0); }
.funnel .n { font-size: var(--t24); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.funnel .l { font-size: var(--t14); color: var(--n4); }
.blockers { margin: 0; padding-left: var(--s6); }
.blockers li + li { margin-top: var(--s1); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 148px minmax(0, 1fr) auto; gap: var(--s4); padding: var(--s3) 0; border-bottom: 1px solid var(--line); font-size: var(--t14); align-items: baseline; }
.feed li:last-child { border-bottom: 0; }
.feed .when { color: var(--n4); white-space: nowrap; }

/* ---------- board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 272px; gap: var(--s4); overflow-x: auto; padding-bottom: var(--s4); align-items: start; }
.lane { background: var(--n1); border-radius: var(--r); padding: var(--s3); min-width: 0; }
.lane-head { display: flex; justify-content: space-between; align-items: baseline; padding: var(--s1) var(--s1) var(--s3); }
.lane-head h2 { font-size: var(--t14); }
.lane-head span { font-size: var(--t14); color: var(--n4); font-variant-numeric: tabular-nums; }
.deal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3); }
.deal + .deal { margin-top: var(--s2); }
.deal .name { font-weight: 600; font-size: var(--t14); display: block; overflow-wrap: anywhere; }
.deal .meta { font-size: var(--t12); color: var(--n4); margin: var(--s1) 0 var(--s3); }
.deal form { display: flex; gap: var(--s2); }
.deal select { min-height: 32px; padding: 0 var(--s2); font-size: var(--t12); }
.lane .empty { font-size: var(--t14); color: var(--n4); padding: var(--s2) var(--s1); margin: 0; }
.branches { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s6); }

/* ---------- account ---------- */
dl.facts { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr); gap: var(--s3) var(--s4); margin: 0; font-size: var(--t14); }
dl.facts dt { color: var(--n4); font-weight: 500; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.contact + .contact { border-top: 1px solid var(--line); margin-top: var(--s4); padding-top: var(--s4); }
.timeline { list-style: none; margin: 0; padding: 0; }
.tl { display: grid; grid-template-columns: 124px minmax(0, 1fr); gap: var(--s4); padding: var(--s4) 0; border-bottom: 1px solid var(--line); font-size: var(--t14); }
.tl:last-child { border-bottom: 0; }
.tl .when { color: var(--n4); }
.tl .what { font-weight: 600; margin-bottom: var(--s1); }
details > summary { cursor: pointer; color: var(--accent); min-height: 32px; display: inline-flex; align-items: center; }
details > summary:hover { color: var(--accent-hover); }
details[open] > summary { margin-bottom: var(--s2); }

/* ---------- emails ---------- */
.email-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s6); }
.email-card + .email-card { margin-top: var(--s6); }
.email-head { display: grid; grid-template-columns: minmax(80px, 120px) minmax(0, 1fr); gap: var(--s2) var(--s4); font-size: var(--t14); margin: 0 0 var(--s4); }
.email-head dt { color: var(--n4); }
.email-head dd { margin: 0; overflow-wrap: anywhere; }
.email-subject { font-size: var(--t20); font-weight: 600; margin: var(--s4) 0 var(--s3); }
.email-body { font-size: var(--t16); line-height: 1.6; max-width: 68ch; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--n0); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4) var(--s6); margin: 0; }
.hold { background: var(--amber-bg); border: 1px solid #ecd9a6; border-radius: var(--r); padding: var(--s3) var(--s4); margin-top: var(--s4); max-width: 68ch; }
.hold h3 { color: var(--amber); font-size: var(--t14); margin-bottom: var(--s1); }
.hold ul { margin: 0; padding-left: var(--s6); font-size: var(--t14); }
.email-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--line); }
.email-actions form { margin: 0; }
.notice { background: var(--blue-bg); border-radius: var(--r); padding: var(--s3) var(--s4); font-size: var(--t14); max-width: 68ch; }
.notice.warn { background: var(--amber-bg); color: #4d3200; }
.footer-preview { white-space: pre-wrap; font-size: var(--t14); line-height: 1.6; background: var(--n0); border: 1px dashed var(--n3); border-radius: var(--r); padding: var(--s3) var(--s4); max-width: 68ch; margin: 0; }
.step { padding: var(--s6) 0; border-top: 1px solid var(--line); }
.step:first-of-type { border-top: 0; padding-top: 0; }
.step textarea { max-width: 68ch; min-height: 220px; }
.lock { display: flex; gap: var(--s4); justify-content: space-between; align-items: center; flex-wrap: wrap; padding: var(--s4) 0; border-top: 1px solid var(--line); }
.lock:first-of-type { border-top: 0; }
.lock p { margin: 0; }
.state { font-weight: 600; }

/* ---------- empty / error ---------- */
.empty-state { background: var(--surface); border: 1px dashed var(--n3); border-radius: var(--r); padding: var(--s8); }
.empty-state h2 { font-size: var(--t16); margin-bottom: var(--s1); }
.empty-state p { color: var(--n4); max-width: 56ch; }
.empty-state .actions { margin-top: var(--s3); }
.error-page h1 { font-size: var(--t32); margin-bottom: var(--s3); }

.pager { display: flex; gap: var(--s2); align-items: center; margin-top: var(--s4); font-size: var(--t14); }

/* ---------- narrow ---------- */
@media (max-width: 899px) {
  :root { --control: 44px; }
  .topbar-in, .tabbar-in { padding-left: var(--s4); padding-right: var(--s4); }
  .topbar-in { gap: var(--s2); }
  .sw-menu { position: fixed; left: var(--s4); right: var(--s4); top: 60px; width: auto; }
  .main { padding: var(--s6) var(--s4) var(--s12); min-height: 0; }
  .main.bare { padding-top: var(--s8); }
  .grid.two, .split { grid-template-columns: minmax(0, 1fr); }
  .btn, .linklike, summary { min-height: 44px; }
  .btn.small { min-height: 44px; }
  .inline-form select, .deal select { min-height: 44px; }
  .check { padding: var(--s3) 0; }
  .feed li { grid-template-columns: minmax(0, 1fr); gap: var(--s1); }
  .tl { grid-template-columns: minmax(0, 1fr); gap: var(--s1); }
  dl.facts, .email-head { grid-template-columns: minmax(0, 1fr); gap: var(--s1); }
  dl.facts dd, .email-head dd { margin-bottom: var(--s3); }
  .card, .email-card { padding: var(--s4); }
  .email-body { padding: var(--s3) var(--s4); }
  .email-actions .btn, .email-actions form { flex: 1 1 100%; }
  .email-actions form .btn { width: 100%; }
  .actions .btn { flex: 1 1 100%; }
  .needs a { min-height: 56px; }
  .empty-state { padding: var(--s6) var(--s4); }
  .tabs a { min-height: 44px; }
  .board { grid-auto-columns: 82vw; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .btn:active { transform: none; }
}

.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
textarea.measure { max-width: 68ch; }
.flush { margin: 0; }
.plain { font-weight: 400; }
.help.gap2 { margin-bottom: var(--s2); }

/* ---------- customers (Stripe) ---------- */
.syncbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3) var(--s6);
  margin-bottom: var(--s6); font-size: var(--t14); }
.syncbar-text { min-width: 0; }
.syncerr { color: var(--red); margin-top: var(--s2); overflow-wrap: anywhere; }
.page-head + .notice.warn, .notice.warn + .syncbar, .notice.warn + .card { margin-top: 0; }
.notice.warn { margin-bottom: var(--s4); }
form.search { margin-bottom: var(--s4); width: 100%; max-width: 480px; }
form.search input[type=search] { flex: 1 1 auto; min-width: 0; }
table.dense th, table.dense td { padding: var(--s3) var(--s3); }
table.dense th:first-child, table.dense td:first-child { padding-left: var(--s4); }
.breakable { white-space: nowrap; }
.help.below { margin-top: var(--s4); }
td.actions-cell { white-space: nowrap; }
a.figure { display: block; color: inherit; text-decoration: none; transition: border-color 140ms var(--ease), background-color 140ms var(--ease); }
a.figure:hover { border-color: var(--n3); background: #fafbfc; color: inherit; }
.figure .sub { font-size: var(--t12); color: var(--n4); margin-top: var(--s2); line-height: 1.5; }
.figure .n.money { font-size: var(--t24); }
.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); margin-bottom: var(--s3); }
.section-head h2 { margin: 0; }
.figures + .figures { margin-top: var(--s4); }

@media (max-width: 899px) {
  form.search { max-width: none; }
  table.stack-narrow, table.stack-narrow tbody, table.stack-narrow tr, table.stack-narrow td, table.stack-narrow th { display: block; }
  table.stack-narrow thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack-narrow tr { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
  table.stack-narrow tbody tr:last-child { border-bottom: 0; }
  table.stack-narrow td, table.stack-narrow th { border: 0; padding: var(--s1) 0; text-align: left !important; }
  table.stack-narrow th[scope=row] { font-size: var(--t16); padding-bottom: var(--s2); }
  table.stack-narrow td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 96px; color: var(--n4); font-size: var(--t12);
    letter-spacing: 0.04em; text-transform: uppercase; margin-right: var(--s2); }
  table.stack-narrow td.actions-cell { padding-top: var(--s2); }
  table.stack-narrow td.actions-cell a { display: inline-flex; align-items: center; min-height: 44px; }
  table.stack-narrow tbody tr:hover td { background: none; }
}

@media (max-width: 520px) {
  .topbar .who { display: none; }
  .sw-brand { font-size: var(--t14); }
  .switcher > summary { gap: var(--s2); }
  .top-link { padding: 0 var(--s2); }
}

/* ---------- hub: strip, periods, funnel, setup ---------- */
.hub-strip { display: grid; gap: 0; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: var(--s6);
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.hub-strip a { display: block; padding: var(--s3) var(--s4); color: var(--ink); text-decoration: none; border-left: 1px solid var(--line);
  transition: background-color 140ms var(--ease); }
.hub-strip a:first-child { border-left: 0; }
.hub-strip a:hover { background: var(--n0); color: var(--ink); }
.hub-strip .n { font-size: var(--t20); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.hub-strip .l { font-size: var(--t12); color: var(--n4); margin-top: 2px; }

.periods { display: inline-flex; gap: 2px; padding: 2px; margin-bottom: var(--s4); background: var(--n1); border-radius: var(--r); }
.periods a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 var(--s4); border-radius: 4px; color: var(--n4);
  text-decoration: none; font-size: var(--t14); font-weight: 500; }
.periods a:hover { color: var(--ink); }
.periods a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(21, 26, 35, 0.12); }

.figures.traffic { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.figure.chosen { border-color: var(--accent); }
.figure .n.second { margin-top: var(--s4); }
.delta { font-weight: 500; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.h-sm { font-size: var(--t14); margin-bottom: var(--s3); }
.gap-top { margin-top: var(--s6); }
.card-tight table { margin: 0; }
.refresh { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin-top: var(--s4); }

.funnel-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.funnel-steps li { padding: var(--s4) var(--s6); border-bottom: 1px solid var(--line); }
.funnel-steps li:last-child { border-bottom: 0; }
.fs-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); margin-bottom: var(--s2); }
.fs-name { font-weight: 600; }
.fs-bar { height: 8px; background: var(--n1); border-radius: 4px; overflow: hidden; margin-bottom: var(--s2); }
.fs-bar span { display: block; height: 100%; background: var(--accent); min-width: 2px; border-radius: 4px; }
.fs-num { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); align-items: baseline; font-size: var(--t20); }
.fs-num .muted { font-size: var(--t14); }

.setup { padding: var(--s8); }
.setup h2 { font-size: var(--t20); margin: var(--s3) 0 var(--s4); }
.setup h3 { font-size: var(--t14); margin-bottom: var(--s2); }
.setup-grid { display: grid; gap: var(--s8); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.plain-list { margin: 0; padding-left: var(--s6); }
.plain-list li + li { margin-top: var(--s2); }
.setup .plain-list { color: var(--ink); }

.ads-table .sub-row th, .ads-table .sub-row td { background: var(--n0); font-size: var(--t12); }
.ads-table .sub-row th { font-weight: 500; }
.ads-table .indent { padding-left: var(--s4); display: inline-block; }
.ads-table .other-row th, .ads-table .other-row td { border-top: 1px solid var(--n3); }
.ads-table td[colspan] { font-size: var(--t12); }
code { font: 500 0.85em ui-monospace, 'SF Mono', Menlo, monospace; background: var(--n1); padding: 1px 5px; border-radius: 4px; }
.breakable-code { overflow-wrap: anywhere; }

@media (max-width: 899px) {
  .hub-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hub-strip a:nth-child(3) { border-left: 0; }
  .hub-strip a:nth-child(n+3) { border-top: 1px solid var(--line); }
  .figures.traffic { grid-template-columns: minmax(0, 1fr); }
  .setup { padding: var(--s6) var(--s4); }
  .setup-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s6); }
  .funnel-steps li { padding: var(--s4); }
  .periods a { min-height: 44px; }
  table.stack-narrow td[colspan] { display: block; }
}
.grid > .card, .grid > .card + .card { margin-top: 0; }

/* ---------- alerts ---------- */
.tick { justify-content: flex-end; padding: 0; }
.tick input { margin: 0; }
.device-list { list-style: none; padding: 0; margin: var(--s4) 0 0; }
.device-list li { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); align-items: center; justify-content: space-between;
  padding: var(--s3) 0; border-top: 1px solid var(--line); font-size: var(--t14); overflow-wrap: anywhere; }
.device-list li + li { margin-top: 0; }

/* ---------- installed on a phone ---------- */
.bottom-nav { display: none; }
.topbar { padding-top: env(safe-area-inset-top); }
@media (max-width: 899px) {
  /* The sections move to the thumb: a bar along the bottom, clear of the home indicator. */
  .bottom-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 16px rgba(21, 26, 35, 0.06); }
  .bottom-nav a { display: flex; align-items: center; justify-content: center; min-height: 56px; padding: 0 var(--s1);
    color: var(--n4); text-decoration: none; font-size: var(--t14); font-weight: 500; border-top: 3px solid transparent; margin-top: -1px; }
  .bottom-nav a:hover { color: var(--ink); background: var(--n0); }
  .bottom-nav a[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); font-weight: 600; }
  .bottom-nav a:focus-visible { outline-offset: -3px; }
  .main { padding-bottom: calc(var(--s12) + 56px + env(safe-area-inset-bottom)); padding-left: max(var(--s4), env(safe-area-inset-left)); padding-right: max(var(--s4), env(safe-area-inset-right)); }
  .topbar-in, .tabbar-in { padding-left: max(var(--s4), env(safe-area-inset-left)); padding-right: max(var(--s4), env(safe-area-inset-right)); }
  /* The top switcher is just the title here; the bottom bar does the switching. */
  .tick { min-height: 44px; min-width: 44px; align-items: center; }
  .switcher > summary { pointer-events: none; }
  .sw-chev, .sw-menu { display: none !important; }
}
