/* ==========================================================================
   Design system
   One set of tokens drives every page. Colours were chosen for contrast on
   the white card surface (text ≥ 4.5:1); the two chart series colours and
   the teal sequential ramp were checked with a colour-blindness validator.
   Fonts are self-hosted (static/fonts, SIL Open Font Licence) so no
   third-party request is made from a logged-in page.
   ========================================================================== */

@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/space-grotesk-latin-600-normal.woff2") format("woff2"); }

:root {
  /* surfaces */
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-2: #FAF9F6;
  --surface-3: #F1EEE7;
  --line: #E7E2D8;
  --line-strong: #D6CFC2;

  /* ink */
  --ink: #1B2127;
  --ink-2: #4E5864;
  --ink-3: #6B7480;

  /* brand */
  --brand: #0E6B5C;
  --brand-600: #0B5C4F;
  --brand-700: #08473D;
  --brand-50: #EAF4F1;
  --brand-100: #D3E9E3;

  /* data (validated pair + neutrals) */
  --series-1: #00846F;
  --series-1-hover: #006B5A;
  --series-2: #D3802F;
  --series-soft: #74B6A8;
  --compare: #B7B0A3;
  --muted-bar: #D9D3C7;
  --grid: #EEEAE2;
  --axis: #D8D2C6;
  --track: #F1EEE7;

  /* status — always shown with an icon or word, never colour alone */
  --good: #1B7A36;   --good-bg: #E8F4EB;
  --warn: #8A5A00;   --warn-bg: #FDF3DC;
  --bad: #B42318;    --bad-bg: #FDECEA;
  --hot: #B8420B;    --hot-bg: #FFF0E6;
  --cool: #4A5A70;   --cool-bg: #EEF1F5;

  /* shape */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(27, 33, 39, 0.05);
  --shadow-md: 0 1px 2px rgba(27, 33, 39, 0.04), 0 6px 20px rgba(27, 33, 39, 0.06);
  --shadow-lg: 0 16px 40px rgba(27, 33, 39, 0.14);

  /* type */
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-brand: "Space Grotesk", var(--font);

  --topbar-h: 64px;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
h1.h2 { font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
p { margin: 0 0 12px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
strong { font-weight: 600; }
img, svg { vertical-align: middle; }
.icon { flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { top: 10px; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.fine { font-size: 0.8rem; color: var(--ink-3); margin: 10px 0 0; line-height: 1.45; }

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

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 24px; padding: 0 24px;
  background: rgba(246, 244, 239, 0.92); border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-name {
  font-family: var(--font-brand); font-weight: 600; font-size: 1.02rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}
.tabs { display: flex; gap: 4px; }
.tabs a {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px;
  border-radius: 10px; color: var(--ink-2); font-weight: 500; font-size: 0.93rem; white-space: nowrap;
}
.tabs a:hover { background: rgba(27, 33, 39, 0.05); color: var(--ink); text-decoration: none; }
.tabs a.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm);
  outline: 1px solid var(--line); }
.tab-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--bad);
  color: #fff; font-size: 0.72rem; font-weight: 700; display: inline-grid; place-items: center;
}
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-link {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; font-size: 0.9rem;
}
.icon-link:hover { background: rgba(27, 33, 39, 0.05); color: var(--ink); text-decoration: none; }
button.icon-link { border: 0; background: transparent; font: inherit; cursor: pointer; }
.logout-form { margin: 0; }
.icon-link.active { color: var(--ink); background: var(--surface); outline: 1px solid var(--line); }

/* Bottom tab bar (phones) */
.bottom-nav { display: none; }

/* ---------------------------------------------------------------- page */
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 72px; }
.page-narrow { max-width: 560px; }
.page-medium { max-width: 780px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 2px; }
.page-sub { color: var(--ink-2); font-size: 0.93rem; margin: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; font-size: 0.9rem; font-weight: 500; }

/* ---------------------------------------------------------------- buttons */
.btn, .secondary-button, .btn-secondary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 16px;
  border-radius: 10px; font: inherit; font-size: 0.92rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  text-decoration: none;
}
.btn { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(8, 71, 61, 0.25); }
.btn:hover { background: var(--brand-600); text-decoration: none; }
.secondary-button, .btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.secondary-button:hover, .btn-secondary:hover { border-color: var(--ink-3); text-decoration: none; background: var(--surface); }
.btn-ghost { background: transparent; color: var(--brand); padding: 0 10px; }
.btn-ghost:hover { background: var(--brand-50); text-decoration: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 0.85rem; border-radius: 8px; }
.btn-block { width: 100%; }
button:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.mini-button {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit;
  font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.mini-button:hover { border-color: var(--brand); color: var(--brand); }
.mini-quiet { color: var(--ink-3); }

/* ---------------------------------------------------------------- forms */
input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="time"],
input[type="email"], input[type="tel"], select, textarea {
  font: inherit; font-size: 0.95rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; min-height: 42px;
  transition: border-color 0.12s, box-shadow 0.12s; width: 100%;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
label { font-size: 0.85rem; color: var(--ink-2); font-weight: 500; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-hint { font-size: 0.8rem; color: var(--ink-3); }
.field-error { color: var(--bad); font-weight: 600; margin-top: 6px; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px 22px; min-width: 0; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
/* …but not side by side in a grid, where it would knock every card after the first out of line */
.grid-main > .card, .grid-2 > .card, .tiles > .card, .an-row > .card, .settings-grid > .card,
.stat-row > .stat { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { flex: 1 1 auto; min-width: 0; font-size: 1.02rem; display: flex; align-items: center; gap: 8px; }
.card-head h2 .count {
  font-size: 0.78rem; font-weight: 700; color: var(--ink-2); background: var(--surface-3);
  border-radius: var(--r-pill); padding: 1px 9px;
}
.card-head h2 .count.is-alert { background: var(--bad-bg); color: var(--bad); }
.card-sub { font-size: 0.87rem; color: var(--ink-2); margin: -8px 0 14px; }
.card-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--grid); display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.card-note { font-size: 0.8rem; color: var(--ink-3); white-space: nowrap; }
.card-link { display: inline-flex; align-items: center; gap: 4px; font-size: 0.88rem; font-weight: 600; }
.card-tools { display: flex; gap: 8px; align-items: center; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.section-gap { margin-top: 16px; }

/* ---------------------------------------------------------------- tags, pills, deltas */
.tag {
  display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 2px 8px; border-radius: 11px;
  font-size: 0.74rem; font-weight: 600; line-height: 1.35; background: var(--surface-3); color: var(--ink-2);
  max-width: 100%;
}
.tag .icon { width: 12px; height: 12px; }
.tag-urgent { background: var(--bad-bg); color: var(--bad); }
.tag-hot { background: var(--hot-bg); color: var(--hot); }
.tag-warm { background: var(--warn-bg); color: var(--warn); }
.tag-cool { background: var(--cool-bg); color: var(--cool); }
.tag-good { background: var(--good-bg); color: var(--good); }
.tag-brand { background: var(--brand-50); color: var(--brand-700); }
.tag-risk { background: transparent; color: var(--bad); padding: 0; }

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.delta .icon { width: 14px; height: 14px; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.neutral { color: var(--ink-3); font-weight: 500; }
.tone-good { color: var(--good); }
.tone-bad { color: var(--bad); }
.tone-neutral { color: var(--ink-3); }

/* ---------------------------------------------------------------- segmented control */
.segmented { display: inline-flex; background: var(--surface-3); border-radius: 11px; padding: 3px; gap: 2px; }
.segmented a, .segmented button {
  border: 0; background: transparent; font: inherit; font-size: 0.88rem; font-weight: 500; color: var(--ink-2);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; line-height: 1.4;
}
.segmented a:hover, .segmented button:hover { color: var(--ink); text-decoration: none; }
.segmented .is-active, .segmented [aria-current="page"], .segmented [aria-checked="true"], .segmented [aria-selected="true"] {
  background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------- flash + notices */
.flash {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r-md);
  margin-bottom: 18px; font-size: 0.93rem; border: 1px solid; background: var(--surface);
}
.flash .icon { margin-top: 1px; }
.flash > span { flex: 1; }
.flash-action { margin: -4px 0; }
.flash-error, .flash-message { background: var(--bad-bg); border-color: #F3C9C4; color: #7A1A12; }
.flash-success { background: var(--good-bg); border-color: #C6E3CD; color: #14552A; }
.flash-info { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }

.notice {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-md);
  border: 1px solid; font-size: 0.93rem; margin-bottom: 16px;
}
.notice-busy { background: var(--warn-bg); border-color: #F1DCA9; color: #5F3F00; }
.notice-quiet { background: var(--bad-bg); border-color: #F3C9C4; color: #7A1A12; }

.empty-state { text-align: center; padding: 26px 16px; color: var(--ink-2); }
.empty-state .empty-icon {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 10px;
  background: var(--good-bg); color: var(--good);
}
.empty-state strong { display: block; color: var(--ink); font-size: 0.98rem; margin-bottom: 2px; }
.empty { color: var(--ink-3); font-size: 0.92rem; }

/* ---------------------------------------------------------------- dashboard */
.greeting h1 { font-size: 1.85rem; }
.briefing {
  display: flex; gap: 18px; align-items: flex-start; padding: 22px 24px; margin-bottom: 16px;
  background: linear-gradient(135deg, #FFFFFF 0%, #FFFFFF 55%, var(--brand-50) 100%);
}
.briefing-mark {
  width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; display: grid;
  place-items: center; flex-shrink: 0;
}
.briefing-text { font-size: 1.12rem; font-weight: 500; line-height: 1.5; margin: 0 0 10px; color: var(--ink); }
.health { display: flex; flex-wrap: wrap; gap: 8px; }

.inbox { list-style: none; margin: 0; padding: 0; }
.inbox-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; padding: 14px 0; border-top: 1px solid var(--grid); align-items: start; }
.inbox-item:first-child { border-top: 0; padding-top: 2px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600;
  font-size: 0.9rem; background: var(--brand-50); color: var(--brand-700);
}
.avatar-urgent { background: var(--bad-bg); color: var(--bad); }
.avatar-hot { background: var(--hot-bg); color: var(--hot); }
.inbox-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.inbox-name { font-weight: 600; color: var(--ink); }
.inbox-name:hover { text-decoration: underline; }
.inbox-wait { font-size: 0.8rem; color: var(--ink-3); white-space: nowrap; }
.inbox-wait.is-late { color: var(--bad); font-weight: 600; }
.inbox-snippet {
  margin: 2px 0 6px; color: var(--ink-2); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.inbox-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.inbox-actions { display: flex; gap: 6px; align-items: center; }
.inbox-actions form { margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; }
.tile-label { font-size: 0.84rem; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.tile-top { display: flex; align-items: center; gap: 4px; }
.tile { position: relative; }
.tile-info { position: static; }
.tile-info summary { list-style: none; cursor: pointer; color: var(--ink-3); display: inline-flex; padding: 2px; border-radius: 50%; }
.tile-info summary::-webkit-details-marker { display: none; }
.tile-info summary:hover, .tile-info[open] summary { color: var(--brand); }
.tile-info p {
  position: absolute; z-index: 10; left: 10px; right: 10px; top: 42px; margin: 0; padding: 9px 11px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-md);
  font-size: 0.8rem; font-weight: 400; color: var(--ink-2); line-height: 1.4;
}
.tile-value { font-size: 1.95rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; color: var(--ink); }
.tile-value.is-empty { color: #B4AEA3; }
.tile-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; }
/* The trend line gives way before the card does: it shrinks to fit beside
   the change label, and on a very narrow card drops below it. */
.tile-row { flex-wrap: wrap; row-gap: 4px; min-width: 0; }
.tile .spark { flex: 1 1 36px; min-width: 36px; max-width: 96px; height: auto; margin-left: auto; }
.tile-vs { font-size: 0.76rem; color: var(--ink-3); font-weight: 400; }
.tile-sub { font-size: 0.8rem; color: var(--ink-3); line-height: 1.4; }
.spark { color: var(--compare); flex-shrink: 0; }
.spark-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }

.changes { list-style: none; margin: 0; padding: 0; }
.change { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding: 16px 0; border-top: 1px solid var(--grid); }
.change:first-child { border-top: 0; padding-top: 2px; }
.change-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.change-icon.good { background: var(--good-bg); color: var(--good); }
.change-icon.bad { background: var(--bad-bg); color: var(--bad); }
.change-head { font-weight: 600; font-size: 0.98rem; color: var(--ink); margin: 0; }
.change-detail { font-size: 0.82rem; color: var(--ink-3); margin: 1px 0 6px; }
.change-why { font-size: 0.9rem; color: var(--ink-2); margin: 0; }
.change-action {
  display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--brand-50); color: var(--brand-700); font-size: 0.88rem;
}
.change-action .icon { margin-top: 2px; }

.opps { list-style: none; margin: 0; padding: 0; counter-reset: opp; }
.opp { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--grid); }
.opp:first-child { border-top: 0; padding-top: 2px; }
.opp::before {
  counter-increment: opp; content: counter(opp); width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-50); color: var(--brand-700); font-weight: 700; font-size: 0.8rem; display: grid; place-items: center;
}
.opp-title { font-weight: 600; font-size: 0.94rem; margin: 0; color: var(--ink); }
.opp-title a { color: inherit; }
.opp-detail { font-size: 0.86rem; color: var(--ink-2); margin: 2px 0 0; }
.opp-action { font-size: 0.85rem; color: var(--brand-700); margin: 6px 0 0; }
.opp-estimate { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; margin: 6px 0 0; color: var(--ink); font-size: 0.95rem; }
.opp-estimate strong { font-weight: 700; white-space: nowrap; }
.opp-estimate span { font-size: 0.75rem; font-weight: 500; color: var(--ink-3); }

.agenda { list-style: none; margin: 0; padding: 0; }
.agenda-item { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-top: 1px solid var(--grid); }
.agenda-item:first-child { border-top: 0; padding-top: 0; }
.agenda-when { font-weight: 600; font-size: 0.86rem; color: var(--brand-700); line-height: 1.3; }
.agenda-when span { display: block; font-size: 0.74rem; color: var(--ink-3); font-weight: 500; }
.agenda-title { font-weight: 600; font-size: 0.92rem; margin: 0; }
.agenda-meta { font-size: 0.82rem; color: var(--ink-3); margin: 1px 0 0; }
.agenda-note { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 0.86rem; color: var(--ink-2); display: flex; gap: 8px; }

.ask-card { background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%); }
.ask-form { display: flex; gap: 10px; }
.ask-input-wrap { position: relative; flex: 1; }
.ask-input-wrap .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--brand); pointer-events: none; }
.ask-input-wrap input { padding-left: 42px; min-height: 48px; border-radius: 12px; font-size: 1rem; }
.ask-form .btn { height: 48px; border-radius: 12px; padding: 0 20px; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font: inherit; font-size: 0.84rem; font-weight: 500; border-radius: var(--r-pill);
  padding: 6px 12px; cursor: pointer; line-height: 1.3;
}
.chip:hover { border-color: var(--brand); color: var(--brand-700); }
.chip[aria-pressed="true"] { background: var(--brand-50); border-color: var(--brand); color: var(--brand-700); }
.chip-count { font-variant-numeric: tabular-nums; font-size: 0.76rem; opacity: 0.8; }
.ask-answer { margin-top: 16px; padding: 16px 18px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.ask-answer[hidden] { display: none; }
.ask-q { font-size: 0.8rem; color: var(--ink-3); margin: 0 0 6px; }
.ask-text { font-size: 0.98rem; color: var(--ink); margin: 0; }
.ask-bullets { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 0.92rem; }
.ask-bullets li { margin: 4px 0; }
.ask-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.ask-source { font-size: 0.75rem; color: var(--ink-3); display: inline-flex; align-items: center; gap: 5px; }
.ask-loading { display: inline-flex; gap: 4px; align-items: center; color: var(--ink-3); font-size: 0.9rem; }
.ask-loading i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); animation: pulse 1s infinite ease-in-out; }
.ask-loading i:nth-child(2) { animation-delay: 0.15s; }
.ask-loading i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

.welcome ol { margin: 10px 0 0; padding-left: 20px; color: var(--ink-2); }
.welcome li { margin: 6px 0; }

/* ---------------------------------------------------------------- analytics */
.page.page-wide { max-width: 1180px; padding-top: 24px; }
.an-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.an-head h1 { margin-bottom: 2px; }
.an-range-caption { color: var(--ink-2); font-size: 0.92rem; margin: 0; }
.an-head-tools { display: flex; gap: 10px; align-items: center; }
.range-picker { position: relative; display: inline-flex; align-items: center; margin: 0; }
.range-picker .icon { position: absolute; left: 12px; color: var(--brand); pointer-events: none; }
.range-picker select { width: auto; min-height: 40px; padding: 7px 34px 7px 36px; font-weight: 600; font-size: 0.92rem; cursor: pointer; }

.an-download { position: relative; }
.an-download summary { list-style: none; }
.an-download summary::-webkit-details-marker { display: none; }
.an-download[open] summary { border-color: var(--brand); color: var(--brand-700); }
.an-download-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 25; width: min(320px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); padding: 6px;
}
.an-download-menu a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--ink); font-weight: 500; font-size: 0.92rem; }
.an-download-menu a span { display: block; color: var(--ink-3); font-weight: 400; font-size: 0.8rem; }
.an-download-menu a:hover { background: var(--brand-50); text-decoration: none; }

.an-custom { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.88rem; color: var(--ink-2); margin-bottom: 12px; padding: 12px 16px; }
.an-custom[hidden] { display: none; }
.an-custom label { display: inline-flex; align-items: center; gap: 8px; }
.an-custom input[type="date"] { width: auto; min-height: 36px; padding: 5px 8px; font-size: 0.88rem; }

.an-sections {
  position: sticky; top: var(--topbar-h); z-index: 19; background: var(--bg);
  display: flex; gap: 4px; overflow-x: auto; padding: 10px 0; margin-bottom: 4px;
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.an-sections[hidden] { display: none; }
.an-sections::-webkit-scrollbar { display: none; }
.an-sections a {
  padding: 6px 13px; border-radius: var(--r-pill); color: var(--ink-2); font-size: 0.87rem; font-weight: 500; white-space: nowrap;
}
.an-sections a:hover { background: rgba(27, 33, 39, 0.05); text-decoration: none; color: var(--ink); }
.an-sections a.is-active { background: var(--ink); color: #fff; }

.an-loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 72px 16px; color: var(--ink-2); font-size: 0.95rem; }
.an-loading[hidden] { display: none; }
.an-error { display: flex; align-items: center; gap: 12px; margin-top: 16px; background: var(--bad-bg); border-color: #F3C9C4; color: #7A1A12; }
.an-error[hidden] { display: none; }
.an-error p { margin: 0; flex: 1; }
.an-empty { margin-top: 16px; }
.an-empty[hidden] { display: none; }

.an-body { transition: opacity 0.15s; }
.an-body[hidden] { display: none; }
.an-body.is-loading { opacity: 0.5; pointer-events: none; }

.an-section { scroll-margin-top: calc(var(--topbar-h) + 60px); padding-top: 30px; }
.an-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.an-section-head h2 { font-size: 1.35rem; letter-spacing: -0.02em; }
.an-lead { margin: 4px 0 0; color: var(--ink); font-size: 1rem; max-width: 72ch; }
.an-lead[hidden] { display: none; }
.an-notes {
  list-style: none; margin: 0 0 16px; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
}
.an-notes[hidden] { display: none; }
.an-notes li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; font-size: 0.9rem; color: var(--ink); line-height: 1.45; }
.an-notes li.tone-good .insight-icon { color: var(--good); }
.an-notes li.tone-bad .insight-icon { color: var(--bad); }
.an-notes li.tone-neutral .insight-icon { color: var(--series-1); }
.notice-info { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.notice[hidden] { display: none; }
.notice .card-link { margin-left: auto; white-space: nowrap; }
.an-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.an-body .card { margin-top: 0; }
.an-section > .card { margin-bottom: 16px; }
.card[hidden] { display: none; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px 13px; min-width: 0; box-shadow: var(--shadow-sm); }
.kpi-label { font-size: 0.82rem; font-weight: 500; color: var(--ink-2); margin: 0 0 4px; }
.kpi-value { font-size: 1.75rem; font-weight: 600; line-height: 1.15; color: var(--ink); margin: 0 0 6px; letter-spacing: -0.02em; }
.kpi-empty .kpi-value { color: #B4AEA3; }
.kpi-delta { margin: 0 0 4px; }
.kpi-sub { font-size: 0.78rem; color: var(--ink-3); margin: 0; line-height: 1.4; }
.kpi-note { font-size: 0.74rem; color: var(--warn); margin: 4px 0 0; line-height: 1.35; }

.view-toggle, .select-wrap select {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: inherit;
  font-size: 0.8rem; font-weight: 500; border-radius: 8px; padding: 4px 10px; cursor: pointer; min-height: 30px; width: auto;
}
.view-toggle:hover, .select-wrap select:hover { border-color: var(--brand); color: var(--brand-700); }
.view-toggle[aria-pressed="true"] { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand); }
.view-toggle[hidden] { display: none; }

.insights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.insights li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; font-size: 0.92rem; color: var(--ink); line-height: 1.45; }
.insight-icon { display: grid; place-items: center; height: 21px; }
.insights li.tone-good .insight-icon { color: var(--good); }
.insights li.tone-bad .insight-icon { color: var(--bad); }
.insights li.tone-neutral .insight-icon { color: var(--series-1); }

.change-empty .change-why { margin-top: 6px; }
.changes .worth { padding: 14px 0 0; border-top: 1px solid var(--grid); list-style: none; }
.change-more { margin-top: 8px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.seg button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: inherit; font-size: 0.83rem;
  font-weight: 500; border-radius: var(--r-pill); padding: 5px 12px; cursor: pointer; display: inline-flex; gap: 7px; align-items: baseline;
}
.seg button:hover { border-color: var(--series-1); color: var(--ink); }
.seg button[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg-count { font-variant-numeric: tabular-nums; opacity: 0.7; font-size: 0.76rem; }
.seg-block { margin-bottom: 12px; }
.trend-summary { font-size: 0.86rem; color: var(--ink-2); margin: 0 0 10px; }

.chart-box { position: relative; height: 240px; }
.chart-tall { height: 300px; }

.table-box { max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.table-box[hidden] { display: none; }
.table-foot { margin: 0; padding: 8px 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.data-table thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--ink-2); font-size: 0.78rem; z-index: 1; }
.data-table tbody th { font-weight: 500; color: var(--ink); }
.data-table .num { text-align: right; }
.data-table.compact th, .data-table.compact td { padding: 5px 8px; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table.wrap td, .data-table.wrap th { white-space: normal; }

.heat {
  display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px;
  font-size: 0.7rem; color: var(--ink-3); user-select: none;
}
.heat-hour { white-space: nowrap; overflow: visible; height: 16px; font-variant-numeric: tabular-nums; }
.heat-day { display: flex; align-items: center; font-weight: 500; color: var(--ink); font-size: 0.75rem; }
.heat-cell { aspect-ratio: 1 / 1.1; border-radius: 3px; background: #F4F1EB; min-height: 14px; outline: 2px solid transparent; outline-offset: -1px; }
.heat-cell:hover { outline-color: var(--ink); }
.heat-legend, .map-legend { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--ink-3); margin-top: 12px; }
.heat-legend i, .map-legend-ramp { display: block; width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #EEF5F3, #A5D1C6, #46998A, #0E5B4F); }
.map-legend { justify-content: center; }

.funnel { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.funnel-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.funnel-label { font-weight: 500; font-size: 0.92rem; }
.funnel-count strong { font-size: 1.05rem; }
.funnel-pct { color: var(--ink-3); font-size: 0.84rem; }
.funnel-track { background: var(--track); border-radius: 5px; height: 12px; overflow: hidden; }
.funnel-bar { height: 100%; background: var(--series-1); border-radius: 5px; transition: width 0.3s; }
.funnel-note { font-size: 0.78rem; color: var(--ink-3); margin: 5px 0 0; }

.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hbars li { display: grid; grid-template-columns: minmax(110px, 190px) minmax(40px, 1fr) minmax(72px, max-content); gap: 12px; align-items: center; font-size: 0.88rem; }
.hbars.hbars-wide li { grid-template-columns: minmax(96px, 160px) minmax(40px, 1fr) minmax(108px, max-content); }
.hbars li.empty { display: block; }
.hbar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-label a { color: var(--ink); font-weight: 500; }
.hbar-track { background: var(--track); height: 10px; border-radius: 5px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--series-1); border-radius: 5px; }
.hbar-fill-muted { background: var(--muted-bar); }
.hbar-fill-warn { background: var(--series-2); }
.hbar-value { text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 0.82rem; white-space: nowrap; }
.hbar-value strong { color: var(--ink); font-weight: 600; }
.hbar-value-stack { display: flex; flex-direction: column; line-height: 1.3; }

.people-tools { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 12px; }
.people-tools input[type="search"] { min-width: 220px; width: auto; min-height: 38px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips[hidden] { display: none; }
.people-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.data-table.people th button.sort { border: 0; background: transparent; font: inherit; color: inherit; padding: 0; cursor: pointer; font-weight: 600; }
.data-table.people th button.sort:hover { color: var(--ink); }
.person { display: flex; flex-direction: column; }
.person a { font-weight: 600; }
.person-number { font-size: 0.76rem; color: var(--ink-3); font-weight: 400; }
.person-meta { font-size: 0.76rem; color: var(--ink-3); font-weight: 400; }
.show-sm { display: none; }
.ask-jump { order: 3; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: var(--r-pill); padding: 2px 9px; font-size: 0.76rem; font-weight: 600; }
.st-good { background: var(--good-bg); color: var(--good); }
.st-neutral { background: var(--brand-50); color: var(--brand-700); }
.st-warn { background: var(--warn-bg); color: var(--warn); }
.st-bad { background: var(--bad-bg); color: var(--bad); }
.st-hot { background: var(--hot-bg); color: var(--hot); }
.people-more { display: flex; justify-content: center; }
.people-more .show-more { margin-top: 12px; }
.urgent-flag { display: inline-flex; align-items: flex-start; gap: 4px; color: var(--bad); font-size: 0.74rem; font-weight: 600; white-space: normal; margin-top: 2px; }

.an-footnote { max-width: 80ch; margin-top: 32px; font-size: 0.85rem; color: var(--ink-2); }
.an-footnote summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.an-footnote p { margin: 10px 0 0; }

.tip {
  position: absolute; z-index: 50; pointer-events: none; background: var(--surface); border: 1px solid rgba(27, 33, 39, 0.12);
  border-radius: 8px; padding: 7px 10px; box-shadow: var(--shadow-md); font-size: 0.8rem;
}
.tip[hidden] { display: none; }
.tip-value { font-weight: 600; color: var(--ink); font-size: 0.86rem; }
.tip-label { color: var(--ink-3); }

.ausmap { display: grid; gap: 8px; margin: 4px auto 14px; max-width: 420px; grid-template-columns: repeat(var(--map-cols, 3), 1fr); grid-auto-rows: 1fr; }
.ausmap-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 12px; border: 1px solid var(--line); background: #F4F1EB; min-height: 62px;
  padding: 6px; text-align: center; outline: 2px solid transparent;
}
.ausmap-tile.is-empty { opacity: 0.55; }
.ausmap-tile.is-dark { color: #fff; border-color: transparent; }
.ausmap-tile:hover, .ausmap-tile:focus-visible { outline-color: var(--ink); }
.ausmap-code { font-size: 0.74rem; font-weight: 600; }
.ausmap-count { font-size: 1.15rem; font-weight: 600; }
.geo-unplaceable { margin-top: 16px; border-top: 1px solid var(--grid); padding-top: 12px; }
.geo-un-title { font-size: 0.82rem; color: var(--ink-3); margin: 0 0 8px; }
.geo-un-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.geo-un-list li { display: flex; justify-content: space-between; font-size: 0.88rem; }
.geo-un-value { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.geo-un-value strong { color: var(--ink); }
.timing-strip { display: flex; gap: 16px; margin-top: 16px; border-top: 1px solid var(--grid); padding-top: 14px; }
.timing-strip[hidden] { display: none; }
.timing-tile { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.timing-label { font-size: 0.78rem; color: var(--ink-3); }
.timing-value { font-size: 1.3rem; font-weight: 600; color: var(--brand-700); }
.timing-sub { font-size: 0.74rem; color: var(--ink-3); }

/* Analytics building blocks */
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.stat-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-row.is-single { grid-template-columns: minmax(0, 1fr); }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; min-width: 0; }
.stat-row-4 .stat { background: var(--surface); box-shadow: var(--shadow-sm); }
.stat-label { font-size: 0.78rem; color: var(--ink-2); margin: 0 0 2px; }
.stat-value { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; margin: 0; color: var(--ink); }
.stat-sub { font-size: 0.76rem; color: var(--ink-3); margin: 2px 0 0; }
.big-figure { font-size: 2.1rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; margin: 0 0 6px; color: var(--ink); }
.big-figure small { font-size: 0.88rem; font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin-left: 8px; }

.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--grid); align-items: baseline; }
.lines li:first-child { border-top: 0; }
.lines .line-label { font-weight: 600; font-size: 0.92rem; color: var(--ink); }
.lines a.line-label { color: var(--brand-700); }
.lines .line-count { font-size: 0.84rem; color: var(--ink-3); }
.lines .line-value { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.lines .line-how { grid-column: 1 / -1; font-size: 0.78rem; color: var(--ink-3); }

.range-wrap { margin: 4px 0 10px; }
.range-bar { position: relative; height: 16px; border-radius: 8px; background: var(--track); overflow: hidden; }
.range-booked { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series-1); border-radius: 8px 0 0 8px; }
.range-band { position: absolute; top: 3px; bottom: 3px; background: var(--series-soft); opacity: 0.8; border-radius: 4px; }
.range-mid { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--brand-700); border-radius: 2px; }
.range-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 8px; font-size: 0.8rem; color: var(--ink-2); }
.range-legend .key { display: inline-block; width: 12px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.key-booked { background: var(--series-1); }
.key-band { background: var(--series-soft); }
.range-total { margin-left: auto; font-weight: 600; color: var(--ink); }

.journey { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.journey li { display: grid; grid-template-columns: minmax(0, 1fr) 56px; gap: 12px; align-items: center; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.journey li.empty-row { display: block; background: transparent; padding: 0; }
.journey-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 0.82rem; color: var(--ink-2); }
.journey-steps .step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 2px 9px; white-space: nowrap; }
.journey-steps .arrow { color: var(--ink-3); font-size: 0.8rem; }
.journey-steps .outcome-booked { background: var(--good-bg); border-color: #C6E3CD; color: var(--good); font-weight: 600; }
.journey-steps .outcome-lost { background: var(--bad-bg); border-color: #F3C9C4; color: var(--bad); font-weight: 600; }
.journey-steps .outcome-open { background: var(--warn-bg); border-color: #F1DCA9; color: var(--warn); font-weight: 600; }
.journey-count { text-align: right; font-variant-numeric: tabular-nums; }
.journey-count strong { display: block; font-size: 1rem; }
.journey-count span { font-size: 0.76rem; color: var(--ink-3); }

.people-list { list-style: none; margin: 0 0 6px; padding: 0; }
.people-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 12px; padding: 9px 0; border-top: 1px solid var(--grid); align-items: baseline; }
.people-list li:first-child { border-top: 0; padding-top: 2px; }
.people-list li.empty-row { display: block; }
.people-list .who { font-weight: 600; font-size: 0.92rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-list .who span { color: var(--ink); }
.people-list .who a { color: var(--brand-700); }
.people-list .what { grid-column: 1 / -1; font-size: 0.8rem; color: var(--ink-3); }
.people-list .val { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.mini-heading + .people-list { margin-top: 2px; }
.people-list + .mini-heading { margin-top: 18px; }

.cover-group + .cover-group { margin-top: 18px; }
.cover-list { list-style: none; margin: 0; padding: 0; }
.cover-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--grid); font-size: 0.9rem; flex-wrap: wrap; }
.cover-list li:first-child { border-top: 0; padding-top: 0; }
.cover-value { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cover-value strong { color: var(--ink); }
.cover-group .fine { margin-top: 6px; }

.quote-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.quote-list li { padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); font-size: 0.88rem; }
.quote-list .quote { color: var(--ink); margin: 0; }
.quote-list .quote-meta { font-size: 0.78rem; color: var(--ink-3); margin: 6px 0 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.quote-list .quote-meta a { font-weight: 600; }

.faq-list { list-style: none; margin: 0; padding: 0; }
.faq-list > li { padding: 12px 0; border-top: 1px solid var(--grid); }
.faq-list > li:first-child { border-top: 0; padding-top: 0; }
.faq-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.faq-label { font-weight: 600; font-size: 0.92rem; }
.faq-count { font-size: 0.84rem; color: var(--ink-2); white-space: nowrap; }
.faq-example { font-size: 0.84rem; color: var(--ink-3); margin: 4px 0 0; }
.faq-suggest { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-top: 8px; padding: 9px 12px; border-radius: 10px; background: var(--brand-50); color: var(--brand-700); font-size: 0.86rem; flex-wrap: wrap; }
.faq-done { font-size: 0.82rem; color: var(--good); margin: 6px 0 0; display: inline-flex; align-items: center; gap: 4px; }

.sim { display: grid; gap: 14px; }
.sim-control { display: grid; gap: 8px; }
.sim-control label { display: flex; justify-content: space-between; align-items: baseline; color: var(--ink); font-size: 0.95rem; }
.sim-control label strong { font-size: 1.3rem; color: var(--brand-700); }
.sim-control input[type="range"] { width: 100%; accent-color: var(--brand); min-height: 0; padding: 0; border: 0; box-shadow: none; }
.sim-now { font-size: 0.8rem; color: var(--ink-3); margin: 0; }
.sim-result { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sim-hint { grid-column: 1 / -1; margin: 0; }
.sim-result .stat-value { font-size: 1.12rem; white-space: nowrap; }
.sim-result .stat { padding: 10px 12px; }
.sim-assume { font-size: 0.8rem; color: var(--ink-3); margin: 0; }

.an-more { padding: 0; }
.an-more summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; font-weight: 600; font-size: 1.02rem; }
.an-more summary::-webkit-details-marker { display: none; }
.an-more summary > span { display: inline-flex; align-items: center; gap: 8px; }
.an-more summary > .icon { color: var(--ink-3); transition: transform 0.15s; }
.an-more[open] summary > .icon { transform: rotate(180deg); }
.an-more > :not(summary) { margin-left: 22px; margin-right: 22px; }
.an-more > :last-child { margin-bottom: 20px; }
.an-more .card-sub { margin-top: 0; }

/* ---------------------------------------------------------------- customers */
.search-form { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.search-form input[type="search"] { flex: 1; }
.clear-search { font-size: 0.85rem; white-space: nowrap; color: var(--ink-3); }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.conversation-list { display: flex; flex-direction: column; gap: 8px; }
.list-more { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 16px; }
.list-more .fine { margin: 4px 0 0; }
.customer-row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px;
  color: var(--ink); box-shadow: var(--shadow-sm);
}
.customer-row:hover { border-color: var(--line-strong); text-decoration: none; }
.customer-main { min-width: 0; }
.customer-top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.customer-name { font-weight: 600; }
.customer-subnumber { font-size: 0.8rem; color: var(--ink-3); }
.conversation-preview { display: block; color: var(--ink-2); font-size: 0.88rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-time { color: var(--ink-3); font-size: 0.8rem; white-space: nowrap; text-align: right; }
.customer-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* ---------------------------------------------------------------- thread */
.thread-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.thread-head .avatar { width: 48px; height: 48px; font-size: 1rem; flex-shrink: 0; }
.thread-head > div { min-width: 0; }
.thread-empty { text-align: center; padding: 18px 8px; }
.thread-head h1 { font-size: 1.45rem; }
.summary { color: var(--ink-2); font-size: 0.9rem; margin: 2px 0 0; }
.thread-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.thread-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.thread-toolbar form { margin: 0; }
.label-form { display: flex; gap: 8px; margin: 0; flex: 1 1 280px; }
.label-form input[type="text"] { flex: 1; min-height: 40px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 14px; }
.mini-heading { font-size: 0.8rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 8px; }
.thread-job { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--grid); }
.thread-job:first-of-type { border-top: 0; padding-top: 0; }
.thread-job-when { font-weight: 600; font-size: 0.86rem; color: var(--brand-700); }
.thread-job-title { flex: 1; font-size: 0.9rem; }
.thread-job-status { font-size: 0.75rem; color: var(--ink-3); text-transform: capitalize; }
.thread-job.job-done { opacity: 0.65; }
.thread-job.job-cancelled { opacity: 0.5; text-decoration: line-through; }

.booking { margin-bottom: 14px; }
.booking summary { list-style: none; cursor: pointer; }
.booking summary::-webkit-details-marker { display: none; }
.booking[open] summary { border-color: var(--brand); color: var(--brand-700); }
.booking-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.booking-form label { display: flex; flex-direction: column; gap: 5px; }
.booking-row { display: flex; gap: 10px; flex-wrap: wrap; }
.booking-row label { flex: 1; min-width: 120px; }
.booking-row label.grow { flex: 2 1 220px; }
.booking-form .btn { align-self: flex-start; }

.recording { padding: 10px 0; border-top: 1px solid var(--grid); }
.recording:first-of-type { border-top: 0; padding-top: 0; }
.recording-meta { font-size: 0.78rem; color: var(--ink-3); margin: 0 0 4px; }
.transcript { font-size: 0.9rem; margin: 0; color: var(--ink); }
.transcript-pending { color: var(--ink-3); font-style: italic; }

.thread { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 16px; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; margin: 0; font-size: 0.94rem; line-height: 1.45; }
.bubble.inbound { background: var(--surface); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.outbound { background: var(--brand-50); align-self: flex-end; color: var(--brand-700); border-bottom-right-radius: 6px; }
.bubble-meta { display: block; font-size: 0.72rem; color: var(--ink-3); margin-top: 3px; }
.bubble.outbound .bubble-meta { color: var(--brand-600); opacity: 0.8; text-align: right; }
.reply-form { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 12px 0 4px; background: var(--bg); }
.reply-form textarea { flex: 1; min-height: 48px; }
.reply-form .btn { height: 48px; }
.reply-note { font-size: 0.78rem; color: var(--ink-3); margin: 4px 0 0; }
.reply-form { flex-wrap: wrap; }
.suggest-reply {
  flex: 1 1 100%; display: flex; gap: 8px; align-items: flex-start; text-align: left; cursor: pointer;
  background: var(--brand-50); border: 1px dashed var(--brand-100); border-radius: var(--r-md); padding: 9px 12px;
  color: var(--ink); font: inherit; font-size: 0.88rem; line-height: 1.4;
}
.suggest-reply .icon { color: var(--brand-700); flex: none; margin-top: 2px; }
.suggest-reply strong { color: var(--brand-700); margin-right: 4px; }
.suggest-reply:hover { border-style: solid; border-color: var(--brand); }
.suggest-reply[hidden] { display: none; }

/* ---------------------------------------------------------------- the assistant's note */
.brief { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: var(--r-md); padding: 12px 16px; margin: 0 0 14px; }
.brief-urgent { border-left-color: var(--hot); }
.brief-unhappy { border-left-color: var(--warn); }
.brief-summary { margin: 0; font-size: 1rem; line-height: 1.45; color: var(--ink); }
.brief-next { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; margin: 8px 0 0; font-size: 0.9rem; color: var(--ink-2); }
.brief-next .icon { color: var(--brand-700); align-self: center; }
.brief-said { color: var(--ink-3); font-size: 0.85rem; }
.brief-name { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0 0; font-size: 0.86rem; color: var(--ink-2); }
.suggest { border: 1px solid var(--brand-100); background: linear-gradient(180deg, var(--brand-50), var(--surface) 70%); margin-bottom: 14px; }
.suggest-head { display: flex; gap: 12px; align-items: flex-start; }
.suggest-head h2 { font-size: 1.05rem; margin: 0 0 2px; }
.suggest-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand);
  color: #fff; flex: none; }
.suggest-from { margin: 0; font-size: 0.84rem; color: var(--ink-3); overflow-wrap: anywhere; }
.suggest-check { display: flex; gap: 6px; align-items: flex-start; margin: 10px 0 0; font-size: 0.85rem; color: var(--warn);
  background: var(--warn-bg); border-radius: 8px; padding: 7px 10px; }
.suggest-check .icon { flex: none; margin-top: 2px; }
.field-note { display: block; font-size: 0.76rem; color: var(--warn); font-weight: 500; margin-top: 3px; }
.suggest-actions { display: flex; gap: 10px; align-items: center; }
.suggest-dismiss { margin-top: 6px; }
.recording-summary { margin: 2px 0 6px; font-size: 0.95rem; color: var(--ink); }
.transcript-box summary { cursor: pointer; font-size: 0.82rem; color: var(--brand-700); font-weight: 600; margin-bottom: 4px; }
.note-line { display: block; color: var(--ink-2); font-size: 0.86rem; margin-top: 2px; }
.conversation-note { color: var(--ink); }
.ask-cards { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ask-card-link { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); }
.ask-card-link:hover { border-color: var(--brand); text-decoration: none; }
.ask-card-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ask-card-text { display: block; font-size: 0.86rem; color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }
.inbox-summary { margin: 3px 0 2px; font-size: 0.92rem; color: var(--ink); line-height: 1.4; }
.inbox-snippet-quiet { font-size: 0.82rem; color: var(--ink-3); }
.slip { margin-top: 14px; border-top: 1px solid var(--grid); padding-top: 12px; }
.slip-title { display: flex; gap: 6px; align-items: center; font-size: 0.9rem; margin: 0 0 6px; color: var(--ink-2); }
.slip-list { list-style: none; margin: 0; padding: 0; }
.slip-list li a { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 9px 0; color: var(--ink);
  border-top: 1px solid var(--grid); font-size: 0.9rem; }
.slip-list li:first-child a { border-top: 0; }
.slip-list li a:hover { text-decoration: none; background: var(--surface-2); }
.slip-go { margin-left: auto; color: var(--brand-700); font-weight: 600; display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.tag-ready { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }

/* ---------------------------------------------------------------- schedule */
.sched-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.cal-help { font-size: 0.85rem; color: var(--ink-2); margin: 4px 6px 8px; }
.cal-url { font-size: 0.78rem !important; font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important; background: var(--surface-2) !important; }
.an-download-menu .fine { margin: 8px 6px 4px; }
.sheet-head { display: none; }
.cal-option { display: flex !important; align-items: center; gap: 10px; }
.cal-option .icon { color: var(--brand-700); flex: none; }
.an-download-menu a.cal-option > span { color: var(--ink); font-weight: 600; font-size: inherit; }
.cal-option small { display: block; color: var(--ink-3); font-weight: 400; font-size: 0.8rem; }
.cal-copy-row { display: flex; gap: 6px; margin: 6px 6px 0; }
.cal-copy-row .cal-url { flex: 1; min-width: 0; }
.cal-reset { margin: 2px 6px 6px; }
.link-button { background: none; border: 0; padding: 4px 0; color: var(--brand-700); font: inherit; font-size: 0.82rem;
  font-weight: 600; cursor: pointer; text-align: left; }
.link-button:hover { text-decoration: underline; }
.sched-days { display: flex; flex-direction: column; gap: 22px; }
.sched-overdue { margin-bottom: 22px; }
.sched-overdue .job { box-shadow: none; }
.sched-date { display: flex; align-items: baseline; gap: 8px; font-size: 1rem; margin: 0 0 10px; }
.sched-date span { color: var(--ink-3); font-weight: 400; }
.today-pill { background: var(--brand); color: #fff; border-radius: var(--r-pill); padding: 1px 10px; font-size: 0.72rem; font-weight: 600; }
.sched-day.is-today .sched-date { color: var(--brand-700); }
.job { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow-sm); }
.job-time { font-weight: 600; font-size: 1.02rem; color: var(--brand-700); min-width: 62px; display: flex; flex-direction: column; line-height: 1.15; }
.job-time span { font-size: 0.7rem; color: var(--ink-3); font-weight: 500; }
.job-body { flex: 1; min-width: 0; }
.job-title { font-size: 0.98rem; margin: 0 0 3px; font-weight: 600; }
.job-meta { font-size: 0.84rem; color: var(--ink-3); margin: 0; }
.job-notes { font-size: 0.84rem; color: var(--ink); margin: 6px 0 0; }
.job-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.job-actions form { margin: 0; }
.job-status { font-size: 0.78rem; color: var(--ink-3); text-transform: capitalize; }
.job-done { opacity: 0.65; }
.job-done .job-title { text-decoration: line-through; }
.job-cancelled { opacity: 0.5; }

/* ---------------------------------------------------------------- settings */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.preview-phone { background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.preview-phone .bubble { max-width: 92%; }
.preview-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 0.78rem; color: var(--ink-3); margin-top: 8px; }
.preview-meta .is-over { color: var(--warn); font-weight: 600; }
.suggest-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.setup-list { list-style: none; margin: 0; padding: 0; }
.setup-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 11px 0; border-top: 1px solid var(--grid); font-size: 0.9rem; }
.setup-list li:first-child { border-top: 0; padding-top: 0; }
.setup-list .icon { color: var(--brand); margin-top: 2px; }
.setup-list strong { display: block; font-size: 0.86rem; }
.setup-list span { color: var(--ink-2); font-size: 0.86rem; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- login */
.login-card { max-width: 400px; margin: 56px auto 0; }
.login-card .brand-mark { width: 44px; height: 44px; border-radius: 13px; margin-bottom: 18px; }
.login-card h1 { margin-bottom: 8px; }
.login-card p { color: var(--ink-2); font-size: 0.95rem; }
.login-card form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.login-card .btn { margin-top: 10px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .tiles, .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs a { padding: 0 10px; }
}
@media (max-width: 900px) {
  .grid-main, .grid-2, .an-row, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .ask-jump.show-sm { display: inline-flex; }
  .card-head { flex-wrap: wrap; }
  .urgent-flag .icon { margin-top: 1px; }
  .stat-row, .stat-row-4, .sim-result { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  :root { --topbar-h: 56px; }
  body { font-size: 15px; }
  .topbar { padding: 0 16px; gap: 12px; }
  .topbar .tabs { display: none; }
  .brand-name { max-width: 58vw; }
  .icon-link .label { display: none; }
  .logout-form { display: none; }   /* on a phone, sign-out lives on the Settings page */
  .icon-link { padding: 0 10px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  }
  .bottom-nav a {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
    color: var(--ink-3); font-size: 0.7rem; font-weight: 600; border-radius: 10px;
  }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a.active { color: var(--brand-700); }
  .bottom-nav a.active .icon { stroke-width: 2.3; }
  .bottom-nav .tab-badge { position: absolute; top: 0; left: calc(50% + 6px); height: 18px; min-width: 18px; font-size: 0.66rem; }
  .page { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page.page-wide { padding-left: 16px; padding-right: 16px; }
  h1, .greeting h1 { font-size: 1.5rem; }
  .card { padding: 16px; border-radius: 14px; }
  .briefing { padding: 18px; gap: 12px; }
  .briefing-mark { width: 34px; height: 34px; border-radius: 10px; }
  .briefing-text { font-size: 1.02rem; }
  .tiles { gap: 10px; }
  .tile { padding: 14px; }
  .tile-value { font-size: 1.5rem; }
  .tile .spark { max-width: 64px; }
  .inbox-item { grid-template-columns: 36px minmax(0, 1fr); }
  .avatar { width: 36px; height: 36px; }
  .inbox-actions { grid-column: 2; }
  .ask-form { flex-direction: column; }
  .ask-form .btn { width: 100%; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 1.45rem; }
  .kpi-delta-vs { display: none; }
  .chart-tall { height: 250px; }
  .heat { grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 2px; }
  .heat-hour { font-size: 0.6rem; }
  .heat-cell { min-height: 10px; border-radius: 2px; }
  .hbars li, .hbars.hbars-wide li { grid-template-columns: minmax(0, 1fr) auto; }
  .hbars .hbar-track { grid-column: 1 / -1; grid-row: 2; }
  .people-tools input[type="search"] { min-width: 0; width: 100%; }
  .data-table.people th, .data-table.people td { white-space: normal; }
  .data-table.people .pill { white-space: nowrap; }
  .an-head-tools { width: 100%; }
  .range-picker { flex: 1; }
  .range-picker select { width: 100%; }
  .an-download .label { display: none; }
  /* On a phone every popover menu becomes a bottom sheet: pinned to the
     screen, not to its button (the button can sit anywhere on a wrapped
     header, which is what pushed the old menu off the left edge). */
  .an-download[open]::before {
    content: ""; position: fixed; inset: 0; z-index: 55; background: rgba(17, 24, 39, 0.38);
  }
  .an-download-menu {
    position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto; z-index: 60; max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
    padding: 8px 8px 10px; border-radius: 18px; animation: sheet-up 0.18s ease-out;
  }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 6px 2px 10px; }
  .sheet-head strong { font-size: 1rem; }
  .sheet-close { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px;
    background: var(--surface-2); color: var(--ink-2); cursor: pointer; }
  .an-download-menu a, .an-download-menu button.link-button { min-height: 48px; }
  .an-download-menu a { padding: 12px; font-size: 1rem; }
  .cal-copy-row .mini-button { min-height: 44px; padding: 0 16px; }
  .an-download > summary { min-height: 44px; }
  .cal-url { font-size: 16px !important; }   /* 16px+ stops iOS zooming the page when it's tapped */
  .an-section-head h2 { font-size: 1.2rem; }
  .stat-row, .sim-result { grid-template-columns: minmax(0, 1fr); }
  .stat-row-4, .stat-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-more summary { padding: 16px; }
  .an-more > :not(summary) { margin-left: 16px; margin-right: 16px; }
  .notice { flex-wrap: wrap; align-items: flex-start; }
  .notice > span { flex: 1 1 200px; min-width: 0; }
  .range-total { margin-left: 0; width: 100%; }
  .journey li { grid-template-columns: minmax(0, 1fr); }
  .journey-count { text-align: left; display: flex; gap: 8px; align-items: baseline; }
  .customer-row { grid-template-columns: 36px minmax(0, 1fr); }
  .customer-row .conversation-time { grid-column: 2; text-align: left; }
  .bubble { max-width: 88%; }
  .job { flex-wrap: wrap; }
  .job-actions { flex-direction: row; width: 100%; justify-content: flex-end; }
  .reply-form { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .timing-strip { flex-direction: column; gap: 12px; }
  .ausmap { max-width: 320px; }
  .ausmap-tile { min-height: 52px; }
}

@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .bottom-nav, .an-head-tools, .an-sections, .ask-card, .view-toggle { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}
