/* GRiN brand (2026-10-08). Source of each color:
 *   #029EC3 dark blue, #96D9F2 light blue, #EFC829 orange/yellow: GrinPediatric-LogoGuide.pdf (Drive)
 *     and the fills of the vector logo Grin-Logo.pdf;
 *   #037691 deeper blue and #13242B ink: grinpediatricdentistry.com CSS (#037691 = its darker brand blue).
 *   Other tints/shades below are derived for contrast (marked "derived").
 * Font (Colton 2026-10-09): Sora (SIL OFL 1.1, variable 100-800, self-hosted in /fonts/, license fonts/OFL-Sora.txt),
 *   falling back to system-ui. Numbers use tabular figures so columns line up. */
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/fonts/sora-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/fonts/sora-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root {
  --brand: #029ec3;        /* logo dark blue: accents, charts, focus (3.1:1 on white, so not for small text) */
  --brand-light: #96d9f2;  /* logo light blue (tooth outline) */
  --brand-yellow: #efc829; /* logo "GRiN" yellow/orange */
  --brand-ink: #037691;    /* website deeper blue: buttons, links, headings (5.2:1 on white) */
  --teal: var(--brand-ink);  /* legacy name kept (finance.css uses it) */
  --teal-dark: #03657c;    /* derived: hover/pressed */
  --ink: #13242b;          /* website text color */
  --muted: #4a6470;        /* derived: 6.3:1 on white */
  --bg: #f3fafd;           /* derived: light-blue tint */
  --card: #ffffff;
  --good: #047857;         /* green, 5.5:1 on white */
  --bad: #dc2626;          /* red, 4.8:1 on white */
  --warn: #b45309;         /* amber, 5.0:1 on white */
  --border: #cdeaf6;       /* derived: light-blue tint */
  --tint: #eef8fc;         /* derived: table heads, chips */
  --shadow: 0 8px 24px rgba(2,158,195,.09);
  --radius: 16px;
  font-family: "Sora", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body { font-family: "Sora", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
* { box-sizing: border-box; }
button, input, select, textarea { font-family: inherit; }
a { color: var(--brand-ink); }
a:hover { color: var(--teal-dark); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(150,217,242,.55) 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(239,200,41,.20) 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(2,158,195,.15);
  overflow-x: hidden;
}
.wrap {
  max-width: 1280px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right))
           calc(40px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
}
header {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start;
  justify-content: space-between; margin-bottom: 14px;
}
.brand { display: flex; gap: 12px; align-items: center; }
/* GRiN logo (real vector logo, /icons/grin-logo.svg) + tooth mark (/icons/grin-tooth.svg) */
.brand-logo { display: block; flex: 0 0 auto; height: 56px; width: auto; }
.brand-mark { display: none; flex: 0 0 auto; width: 40px; height: 40px; }
.brand-title { border-left: 2px solid var(--border); padding-left: 14px; min-width: 0; }
.logo { /* legacy tile, kept for any page still using it */
  flex: 0 0 auto;
  width: 48px; height: 48px; border-radius: 14px; background: #fff; border: 1px solid var(--border);
  display:grid; place-items:center; box-shadow: var(--shadow);
}
.logo img { width: 34px; height: 34px; }
.auth-logo { display: block; width: min(260px, 78%); height: auto; margin: 2px auto 18px; }
.auth-card .auth-title { text-align: center; }
h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.01em; font-weight: 800; color: var(--brand-ink); }
h2, h3 { color: var(--ink); }
.sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.badges { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.badge {
  display:inline-flex; align-items:center; gap:6px;
  padding: 6px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: #fff; border: 1px solid var(--border);
}
.badge.proto { background: #fdf3c4; border-color: var(--brand-yellow); color: #6b5200; }
.badge.asof { color: var(--muted); font-weight: 600; }
.controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.ctrl { display:flex; flex-direction:column; gap:4px; min-width: 140px; flex: 1; }
.ctrl label { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ctrl select {
  appearance: none; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: .95rem; background: #f7fcfe; color: var(--ink);
}
.ctrl select:disabled { background: var(--tint); color: var(--teal-dark); font-weight: 600; }
.audience {
  display: inline-flex; background: var(--tint); border-radius: 12px; padding: 4px; border: 1px solid var(--border);
}
.audience button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 9px;
  font-weight: 700; color: var(--muted); cursor: pointer;
}
.audience button.active { background: var(--brand-ink); color: white; box-shadow: 0 2px 6px rgba(3,118,145,.25); }
.audience button:not(.active):hover { color: var(--brand-ink); }
.lock-note {
  flex-basis: 100%; font-size: .85rem; color: var(--muted); padding-top: 2px;
}
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; box-shadow: var(--shadow); min-height: 112px;
  display: flex; flex-direction: column; gap: 4px; position: relative;
}
.card .label { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.card .value { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; }
.card .goal { font-size: .8rem; color: var(--muted); }
.card .tag-small { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: -2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.card .note { font-size: .72rem; color: var(--warn); line-height: 1.3; }
.card .status {
  position: absolute; top: 10px; right: 10px; width: 10px; height: 10px; border-radius: 50%;
}
.card .status.good { background: var(--good); }
.card .status.bad { background: var(--bad); }
.card .status.missing { background: #cbd5e1; }
.card.missing .value { color: var(--muted); font-size: 1.05rem; font-weight: 700; }
.charts {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px;
}
.chart-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; box-shadow: var(--shadow); min-height: 280px;
}
.chart-card h3 { margin: 0 0 8px; font-size: .95rem; color: var(--brand-ink); }
.footer {
  font-size: .78rem; color: var(--muted); line-height: 1.5;
  border-top: 1px solid var(--border); padding-top: 12px;
}
@media (max-width: 820px) {
  .charts { grid-template-columns: 1fr; }
  h1 { font-size: 1.15rem; }
  .card .value { font-size: 1.25rem; }
}

/* Auth / login */
#loginView, #newPasswordView, #offlineView, #mfaSetupView, #mfaCodeView {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right))
           calc(24px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
}
.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 5px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 22px;
}
.auth-card h1 { font-size: 1.25rem; margin: 0 0 4px; }
.auth-card .sub { margin-bottom: 18px; }
.auth-card label {
  display: block; font-size: .72rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  margin: 12px 0 4px;
}
.auth-card input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; font-size: .95rem; background: #f7fcfe; color: var(--ink);
}
.auth-card button.primary {
  width: 100%; margin-top: 18px; border: 0; border-radius: 10px;
  padding: 12px 14px; font-weight: 800; font-size: .95rem;
  background: var(--brand-ink); color: white; cursor: pointer;
}
.auth-card button.primary:hover:not(:disabled) { background: var(--teal-dark); }
.auth-card button.primary:disabled { opacity: .6; cursor: wait; }
.auth-error {
  margin-top: 12px; color: var(--bad); font-size: .85rem; min-height: 1.2em;
}
.user-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.user-bar .who { font-size: .8rem; color: var(--muted); font-weight: 600; }
.user-bar button.logout {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 6px 12px; font-size: .78rem; font-weight: 700; color: var(--ink); cursor: pointer;
}
#appView { display: none; }
#appView.ready { display: block; }
#audienceCtrl.hidden { display: none !important; }


/* ---------- Shared additions (PWA / mobile) ---------- */
.t-short { display: none; }
.auth-card input { font-size: 16px; min-height: 44px; } /* 16px stops iOS zoom-on-focus */
.auth-card button.primary { min-height: 48px; }
.auth-card button.secondary {
  width: 100%; margin-top: 10px; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-weight: 700; font-size: .95rem; min-height: 44px;
  background: #fff; color: var(--ink); cursor: pointer;
}
.user-bar button.logout { min-height: 32px; }
.icon-btn { font-size: .9rem; line-height: 1; }

.stepper { display: flex; gap: 6px; align-items: stretch; }
.stepper select { flex: 1; min-width: 0; }
.stepper .step {
  flex: 0 0 auto; width: 40px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--brand-ink); font-size: 1.4rem; font-weight: 700; line-height: 1;
  cursor: pointer; padding: 0;
}
.stepper .step:disabled { opacity: .35; cursor: default; }

.office-tabs { display: none; }

.net-banner {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: calc(8px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 8px calc(14px + env(safe-area-inset-left));
  background: #fef3c7; color: #92400e; border-bottom: 1px solid #fcd34d;
  font-size: .85rem; font-weight: 700; text-align: center; line-height: 1.3;
}
.net-banner[hidden] { display: none; }
.net-banner.error { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.net-banner button {
  border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 999px;
  padding: 6px 14px; min-height: 36px; font-weight: 800; cursor: pointer;
}
body.stale #main { opacity: .6; filter: grayscale(.35); }
body.stale .badge.asof { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
body.loading #refreshBtn { opacity: .5; }

.chart-body { height: 220px; position: relative; }

.asof-mobile { display: none; font-size: .78rem; color: var(--muted); font-weight: 600; }

/* ---------- Phone layout (≈375–430px, up to small tablets) ---------- */
@media (max-width: 640px) {
  .wrap {
    padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
             calc(28px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }
  body.has-banner .wrap { padding-top: 10px; }
  header { gap: 8px; margin-bottom: 10px; align-items: center; flex-wrap: nowrap; }
  header .brand { min-width: 0; gap: 10px; }
  header .logo { width: 40px; height: 40px; border-radius: 12px; font-size: 16px; }
  header .brand-logo { display: none; }
  header .brand-mark { display: block; }
  header .brand-title { border-left: 0; padding-left: 0; }
  header .sub { display: none; }
  .t-long { display: none; }
  .t-short { display: inline; }
  h1 { font-size: 1.25rem; }
  .badges { flex-wrap: nowrap; gap: 6px; }
  .badge.proto, .badge.asof, .user-bar .who { display: none; }
  .user-bar { flex-wrap: nowrap; gap: 6px; }
  .user-bar button.logout { min-height: 44px; min-width: 44px; padding: 0 14px; font-size: .85rem; }
  .btn-text { display: none; }
  .icon-btn { font-size: 1.15rem; padding: 0 !important; width: 44px; }

  .controls {
    display: grid; grid-template-columns: 1fr; gap: 10px; padding: 10px; margin-bottom: 12px;
  }
  .ctrl { min-width: 0; }
  #audienceCtrl { order: 1; }
  #audienceCtrl > label { display: none; }
  .office-tabs { order: 2; }
  #officeCtrl { order: 3; }
  .month-ctrl { order: 4; }
  #doctorCtrl { order: 5; }
  .lock-note { order: 6; }
  .asof-mobile { order: 7; }
  .ctrl select { min-height: 44px; font-size: 16px; }
  .stepper .step { width: 48px; min-height: 44px; }
  .audience { display: flex; width: 100%; }
  .audience button { flex: 1; min-height: 44px; font-size: .95rem; padding: 8px 6px; }
  .controls.has-tabs #officeCtrl { display: none !important; }
  .controls.has-tabs .office-tabs {
    display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    margin: 0 -10px; padding: 2px 10px 4px;
  }
  .office-tabs::-webkit-scrollbar { display: none; }
  .office-tabs button {
    flex: 0 0 auto; scroll-snap-align: start; min-height: 44px; padding: 0 16px;
    border: 1px solid var(--border); border-radius: 999px; background: #f7fcfe;
    color: var(--ink); font-weight: 700; font-size: .95rem; cursor: pointer; white-space: nowrap;
  }
  .office-tabs button[aria-selected="true"] { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
  .office-tabs button .code { font-weight: 600; opacity: .7; font-size: .78rem; margin-left: 4px; }
  .lock-note { font-size: .8rem; line-height: 1.35; }
  .asof-mobile { display: block; }

  .cards { grid-template-columns: 1fr; gap: 10px; margin-bottom: 14px; }
  .card { min-height: 0; padding: 14px 16px; gap: 2px; border-radius: 14px; }
  .card .label { font-size: .8rem; padding-right: 18px; }
  .card .value { font-size: 2rem; line-height: 1.15; }
  .card.missing .value { font-size: 1.05rem; }
  .card .goal { font-size: .9rem; }
  .card .note { font-size: .8rem; }
  .card .status { top: 14px; right: 14px; width: 12px; height: 12px; }

  .charts { grid-template-columns: 1fr; gap: 10px; }
  .chart-card { min-height: 0; padding: 12px; }
  .chart-card h3 { font-size: .92rem; }
  .chart-body { height: 210px; }
  .footer { font-size: .78rem; }
}

@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}

/* Flagged (suspicious but kept) values */
.card .status.flag { background: var(--warn); }
.card.flagged { border-color: #fcd34d; background: #fffbeb; }
.card .flag-label { font-size: .72rem; font-weight: 700; color: #b45309; }


/* ---------- Phone (Patient Prism) ---------- */
.card .status.info { background: var(--brand); }
.card .info { font-size: .72rem; color: var(--muted); line-height: 1.3; }
.phone-card, .ortho-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 14px;
}
.phone-card.stale, .ortho-card.stale { border-color: #fcd34d; background: #fffbeb; }
.phone-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; }
.phone-head h3 { margin: 0; font-size: .95rem; }
.phone-period { font-size: .78rem; color: var(--muted); font-weight: 600; }
.phone-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.phone-stat { background: #f7fcfe; border: 1px solid #dbeff7; border-radius: 12px; padding: 8px 10px; min-width: 0; }
.phone-stat .label { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.phone-stat .value { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.phone-stat .prev { font-size: .74rem; color: var(--muted); }
.phone-foot { font-size: .74rem; color: var(--muted); margin-top: 8px; line-height: 1.35; }
.phone-empty { color: var(--muted); font-size: .9rem; padding: 6px 0; }
.phone-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; }
.phone-seg button { min-height: 36px; }
.phone-title { font-size: .92rem; }
.phone-banner {
  font-size: .8rem; color: var(--muted); background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; line-height: 1.4;
}
.phone-banner.stale { background: #fffbeb; border-color: #fcd34d; color: #92400e; font-weight: 600; }
.phone-table-card, .ortho-table-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 18px; min-width: 0;
}
.phone-table-card h3, .ortho-table-card h3 { margin: 0 0 8px; font-size: .95rem; }
.phone-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.phone-table { border-collapse: collapse; width: 100%; font-size: .82rem; font-variant-numeric: tabular-nums; }
.phone-table th, .phone-table td { padding: 6px 7px; text-align: right; white-space: nowrap; border-bottom: 1px solid #dbeff7; }
.phone-table thead th { font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--tint); }
.phone-table th[scope="row"], .phone-table thead th:first-child {
  text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; box-shadow: 1px 0 0 #dbeff7;
}
.phone-table thead th:first-child { background: var(--tint); }
.phone-table tr.total th, .phone-table tr.total td { font-weight: 800; border-top: 2px solid var(--border); }
.phone-table tr.sel th[scope="row"], .phone-table tr.sel td { background: #e3f4fb; }
@media (max-width: 1000px) {
  .phone-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .phone-card, .ortho-card { padding: 12px; margin-bottom: 12px; }
  .phone-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phone-stat:last-child { grid-column: 1 / -1; }
  .phone-stat .value { font-size: 1.45rem; }
  .phone-bar { flex-direction: column; align-items: stretch; }
  .phone-seg { display: flex; width: 100%; }
  .phone-seg button { flex: 1; min-height: 44px; }
  .phone-table-card, .ortho-table-card { padding: 12px; }
  .card .info { font-size: .8rem; }
  #audienceSwitch button { padding: 8px 4px; font-size: .9rem; }
  .cards.phone-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cards.phone-cards .card { padding: 12px; }
  .cards.phone-cards .card .label { font-size: .72rem; padding-right: 14px; }
  .cards.phone-cards .card .value { font-size: 1.45rem; }
  .cards.phone-cards .card .goal { font-size: .8rem; }
  .cards.phone-cards .card .info { font-size: .72rem; }
  .cards.phone-cards .card .status { top: 12px; right: 12px; width: 10px; height: 10px; }
}
/* Phone: answer rate graded vs the sheet goal (92%) once filtered like Patient Prism "Call Metrics" */
.phone-table td.good { color: var(--good); font-weight: 800; }
.phone-table td.bad { color: var(--bad); font-weight: 800; }
.phone-stat.good { border-color: #86efac; background: #f0fdf4; }
.phone-stat.good .value { color: var(--good); }
.phone-stat.bad { border-color: #fda4af; background: #fff1f2; }
.phone-stat.bad .value { color: var(--bad); }
/* Sources of truth (2026-10-07) */
.card .src { font-size: .68rem; color: var(--brand-ink); font-weight: 600; line-height: 1.3; }
.card .ref { font-size: .68rem; color: #64748b; line-height: 1.3; }
.ortho-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ortho-table-card { margin-top: 12px; }
@media (max-width: 640px) {
  .ortho-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card .src, .card .ref { font-size: .74rem; }
}
/* Three sets of production & collections (2026-10-07) */
.sets-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 14px; }
.sets-table th[scope="row"] { text-align: left; white-space: normal; min-width: 150px; }
.sets-table th[scope="row"] .kind { font-size: .66rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.sets-table th[scope="row"] .sub { display: block; font-size: .66rem; font-weight: 500; color: var(--brand-ink); line-height: 1.3; margin-top: 2px; }
.sets-table td { font-size: .9rem; }
@media (max-width: 640px) {
  .sets-card { padding: 12px; margin-bottom: 12px; }
  .sets-table th[scope="row"] { min-width: 0; }
  .sets-table td { font-size: .82rem; padding: 6px 4px; }
}

/* GRiN brand touches (2026-10-08) */
header { padding-bottom: 12px; border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--brand) 0 60%, var(--brand-light) 60% 85%, var(--brand-yellow) 85% 100%) 1; }
.user-bar button.logout:hover { border-color: var(--brand); color: var(--brand-ink); }
.ctrl select:focus, .auth-card input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(2,158,195,.22); }
@media (max-width: 640px) {
  header { padding-bottom: 8px; }
  .auth-logo { width: min(230px, 80%); }
}

/* Owner deep-dive tabs: Pedo (Denticon only) / Ortho (Ortho2 + OrthoFi only), 2026-10-08 */
.spec-head { margin-bottom: 10px; }
.spec-title { margin: 0 0 4px; font-size: 1.1rem; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spec-pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .05em; }
.spec-pill.pedo { background: var(--brand-ink); color: #fff; }
.spec-pill.ortho { background: var(--brand-yellow); color: var(--ink); }
.spec-src { font-size: .82rem; color: var(--muted); line-height: 1.4; }
.spec-src strong { color: var(--brand-ink); }
.spec-phones { display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--tint); border: 1px solid var(--border); border-left: 4px solid var(--brand-light);
  border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; font-size: .8rem; color: var(--muted); line-height: 1.35; }
.spec-phones strong { color: var(--ink); }
.spec-link { flex: 0 0 auto; border: 1px solid var(--brand-ink); background: #fff; color: var(--brand-ink); border-radius: 999px;
  padding: 6px 12px; min-height: 36px; font-weight: 800; font-size: .8rem; cursor: pointer; }
.spec-link:hover { background: var(--brand-ink); color: #fff; }
.card.notconn { border-style: dashed; border-color: #9fd3e6; background: #f7fcfe; }
.card.notconn .value { color: var(--brand-ink); }
.spec-table .phone-table td { font-size: .82rem; }
@media (max-width: 640px) {
  /* Six audience buttons: two rows of three, each a 44px tap target */
  #audienceSwitch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  #audienceSwitch button[hidden] { display: none; }
  .spec-title { font-size: 1rem; }
  .spec-phones { padding: 8px 10px; gap: 8px; }
  .spec-link { min-height: 44px; padding: 6px 10px; }
}
.spec-providers .phone-table { max-width: 680px; }

/* Sunbit patient financing section on the Owner view (owner-only), 2026-10-08 */
.sunbit-section { margin-top: 22px; padding-top: 16px; border-top: 3px solid var(--brand-light); }
.spec-pill.sunbit { background: #13242b; color: #fff; }
.sb-cov { font-size: .82rem; line-height: 1.4; color: var(--ink); background: var(--tint); border: 1px solid var(--border);
  border-left: 4px solid var(--brand); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; }
.sb-cov.min { border-left-color: var(--brand-yellow); background: #fffbeb; border-color: #fcd34d; }
.sb-min { display: inline-block; font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  background: #fdf3c4; color: #6b5200; border: 1px solid var(--brand-yellow); border-radius: 999px; padding: 0 6px; vertical-align: middle; }
.sb-stale { color: var(--warn); }
.sb-table th[scope="row"] { text-align: left; white-space: normal; min-width: 130px; }
.sb-table th[scope="row"] .sub { display: block; font-size: .66rem; font-weight: 500; color: var(--brand-ink); line-height: 1.3; margin-top: 2px; }
.sb-table tr.sb-nc td { color: var(--muted); font-style: italic; text-align: left; }
.sb-table .phone-table { max-width: 860px; }
@media (max-width: 640px) {
  .sunbit-section { margin-top: 16px; padding-top: 12px; }
  .sb-table th[scope="row"] { min-width: 108px; }
  .sb-cov { padding: 8px 10px; }
}
@media (max-width: 640px) {
  /* Phone: Fee $ and Avg ticket stay on the cards; tables keep Financed / Gross / Net funded / Fee % so they fit 390px */
  .sb-table .sb-opt, .sb-table .sb-opt-inline { display: none; }
  .sb-table .phone-table th, .sb-table .phone-table td { padding: 6px 4px; }
}
.sb-table .sb-short { display: none; }
@media (max-width: 640px) {
  .sb-table .sb-long { display: none; }
  .sb-table .sb-short { display: inline; }
  .sb-table th[scope="row"] { min-width: 96px; }
  .sb-table .phone-table td { font-size: .78rem; }
}

/* Finances tab (owner-only): summary + OrthoFi fees + Sunbit + credit cards, 2026-10-08 */
.spec-pill.finances { background: #037691; color: #fff; }
.spec-pill.orthofi { background: #029ec3; color: #fff; }
.spec-pill.cards { background: #4a6470; color: #fff; }
.fin-section { margin-top: 20px; padding-top: 14px; border-top: 2px solid var(--border); }
.fin-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
@media (max-width: 640px) {
  /* Owner + Pedo + Ortho + Finances + Managers + Doctors + Phone = up to 7 buttons */
  #audienceSwitch { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #audienceSwitch button { font-size: .78rem; padding: 8px 4px; min-height: 44px; }
}


/* Owner TOTP MFA (enrollment + code prompt) */
.mfa-card .mfa-steps {
  margin: 0 0 16px; padding-left: 1.2em;
  font-size: .88rem; color: var(--ink); line-height: 1.45;
}
.mfa-card .mfa-steps li { margin-bottom: 6px; }
.mfa-qr-wrap {
  display: grid; place-items: center;
  margin: 8px auto 14px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: fit-content; max-width: 100%;
}
.mfa-qr-wrap img, .mfa-qr-wrap canvas { display: block; width: 200px; height: 200px; max-width: min(200px, 70vw); height: auto; }
.mfa-secret-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 4px; }
.mfa-secret {
  flex: 1; min-width: 0;
  display: block;
  padding: 10px 12px;
  background: #f7fcfe;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .78rem;
  letter-spacing: .04em;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
}
.mfa-copy { width: auto !important; margin-top: 0 !important; flex: 0 0 auto; padding: 8px 12px !important; min-height: 44px; }
.mfa-card input#mfaSetupCode,
.mfa-card input#mfaCode {
  letter-spacing: .35em;
  font-size: 1.35rem !important;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Owner sign-in security (2026-10-08): passkey button, trust checkbox, Security panel */
.passkey-btn { width: 100%; margin-top: 10px; }
.trust-row { display: flex !important; align-items: center; gap: 8px; margin: 12px 0 2px !important; font-size: .9rem !important; color: var(--ink) !important; font-weight: 600; cursor: pointer; }
.trust-row input { width: 20px !important; height: 20px; margin: 0; accent-color: var(--brand-ink); }
.sec-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(19,36,43,.45); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto;
  padding: calc(20px + env(safe-area-inset-top)) 12px calc(20px + env(safe-area-inset-bottom)); }
.sec-overlay[hidden] { display: none; }
.sec-card { background: #fff; border-radius: var(--radius); border-top: 5px solid var(--brand); box-shadow: var(--shadow); width: 100%; max-width: 520px; padding: 18px 20px; }
.sec-head { display: flex; justify-content: space-between; align-items: center; }
.sec-head h2 { margin: 0; font-size: 1.15rem; color: var(--brand-ink); }
.sec-x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); min-width: 44px; min-height: 44px; }
.sec-card section { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.sec-card h3 { margin: 0 0 6px; font-size: 1rem; }
.sec-card button.primary, .sec-card button.secondary { width: 100%; margin-top: 8px; min-height: 44px; font: inherit; font-weight: 700; border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.sec-card button.primary { background: var(--brand-ink); color: #fff; border: 0; }
.sec-card button.primary:disabled { opacity: .5; cursor: not-allowed; }
.sec-card button.secondary { background: #fff; border: 1px solid var(--border); color: var(--ink); }
.sec-muted { color: var(--muted); font-size: .88rem; margin: 4px 0; }
.sec-list { list-style: none; padding: 0; margin: 8px 0; }
.sec-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--tint); font-size: .92rem; }
.sec-small { font: inherit; font-size: .85rem; padding: 6px 10px; min-height: 36px; border-radius: 10px; background: #fff; border: 1px solid var(--border); cursor: pointer; }
.sec-bad, .sec-danger { color: var(--bad) !important; border-color: #fca5a5 !important; }
.sec-chip { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--tint); color: var(--brand-ink); }
.sec-msg { min-height: 1.2em; margin-top: 10px; font-size: .9rem; color: var(--good); }
.sec-msg.bad { color: var(--bad); }


/* Chairside rename + two tab rows + Lead DA + Sage P&L (2026-10-08) */
.app-name { font-size: 1.45rem; font-weight: 900; letter-spacing: -0.015em; color: var(--brand-ink); line-height: 1.1; }
.app-tagline { font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--brand-light, #029ec3); margin-top: 2px; }
.auth-card .app-name { font-size: 1.9rem; }
.auth-card .app-tagline { margin-bottom: 6px; }
#audienceSwitch { display: flex; flex-direction: column; gap: 6px; background: transparent; border: 0; padding: 0; }
#audienceSwitch .aud-row { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--tint); border-radius: 12px; padding: 4px; border: 1px solid var(--border); align-self: flex-start; }
#audienceSwitch .aud-row-2 { background: #fff; }
#audienceSwitch .aud-row:not(:has(button:not([hidden]))) { display: none; }
#audienceSwitch button[hidden] { display: none; }
@media (max-width: 640px) {
  #audienceSwitch { display: flex !important; flex-direction: column; gap: 6px; width: 100%; }
  #audienceSwitch .aud-row { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    width: 100%; align-self: stretch; gap: 4px; scroll-snap-type: x proximity; }
  #audienceSwitch .aud-row::-webkit-scrollbar { display: none; }
  #audienceSwitch .aud-row button { flex: 1 0 auto; min-width: 64px; min-height: 44px; font-size: .84rem; padding: 8px 10px; white-space: nowrap; scroll-snap-align: start; }
  .app-name { font-size: 1.2rem; }
  .app-tagline { font-size: .66rem; }
}
.spec-pill.sage { background: #0b5d1e; color: #fff; }
.spec-pill.leadda { background: #6b3fa0; color: #fff; }
.sage-section { margin-top: 22px; padding-top: 16px; border-top: 3px solid #0b5d1e33; }
.fin-section.sage-section { border-top: 2px solid var(--border); }
.sage-table .phone-table td { font-size: .82rem; white-space: nowrap; }
.sage-table tr.sage-office th, .sage-table tr.sage-office td { font-weight: 800; border-top: 2px solid var(--border); }
.sage-table tr.sage-sub th { padding-left: 18px; font-weight: 600; }
.sage-table tr.sage-mgmt th, .sage-table tr.sage-mgmt td { border-top: 2px solid var(--border); font-style: italic; }
.phone-table .neg { color: #be123c; }
.sage-flags { margin-top: 12px; background: #fff8e6; border: 1px solid #f4d98a; border-left: 4px solid #efc829; border-radius: 12px; padding: 10px 14px; }
.sage-flags h3 { margin: 0 0 6px; font-size: .92rem; }
.sage-flags ul { margin: 0; padding-left: 0; list-style: none; }
.sage-flags li { font-size: .82rem; line-height: 1.4; padding: 3px 0; color: var(--ink); }
.sage-flags .sf-tag { display: inline-block; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  border-radius: 999px; padding: 1px 8px; margin-right: 4px; background: #13242b; color: #fff; }
.sage-flags .sf-negative_expense .sf-tag { background: #be123c; }
.sage-flags .sf-unusual_spike .sf-tag { background: #b45309; }
.sage-owner-only { font-size: .68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-left: 6px; }
.leadda-office-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-top: 12px; }
.leadda-office-list div { background: #fff; border: 1px dashed #c9b5e3; border-radius: 12px; padding: 10px 12px; font-weight: 700; color: var(--ink); }
.leadda-office-list div span { display: block; font-weight: 600; font-size: .78rem; color: var(--muted); }
.sage-table th[scope="row"] .sub, .sb-table th[scope="row"] .sub { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); font-style: normal; }
@media (max-width: 640px) {
  #audienceSwitch .aud-row button { flex: 1 1 auto; min-width: 0; padding: 8px 7px; font-size: .8rem; }
  .sage-table th[scope="row"] { min-width: 120px; }
}

/* Month / Year-to-date toggle + year picker + YoY (2026-10-08) */
.period-row { display: flex; gap: 6px; align-items: stretch; }
.seg { display: inline-flex; background: var(--tint, #eef7fa); border: 1px solid var(--border, #d6e4ea); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: .88rem; cursor: pointer; color: inherit; white-space: nowrap; }
.seg button.active { background: #029ec3; color: #fff; font-weight: 600; }
#yearSelect { min-width: 92px; flex: 0 0 auto; }
.period-ctrl { flex: 0 0 auto; }
.period-banner { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: #eef7fa; border: 1px solid #bfe3ef; font-size: .86rem; line-height: 1.45; }
.period-banner.prior { background: #fff7ed; border-color: #fed7aa; }
.period-banner .cov { display: block; margin-top: 4px; color: #7c2d12; }
.yoy { margin: 16px 0; }
.yoy .sets-head h3 { margin: 0 0 2px; }
.yoy .sub { font-size: .8rem; color: #64748b; margin-bottom: 6px; }
.yoy-table td.pos { color: #047857; font-weight: 600; }
.yoy-table td.neg { color: #be123c; font-weight: 600; }
@media (max-width: 640px) {
  .period-ctrl { order: 3; width: 100%; }
  .seg { flex: 1; } .seg button { flex: 1; min-height: 44px; }
  #yearSelect { min-height: 44px; }
}

/* Sora (2026-10-09): tabular figures on tables, KPI numbers and stats; long values shrink instead of overflowing */
table, td, th, .card .value, .card .goal, .kpi-num, .phone-stat .value, .spec-card .value, .reviews-big, select, .stepper select,
.sets-table, .phone-table, .yoy-table { font-variant-numeric: tabular-nums; }
.card .value { overflow-wrap: anywhere; font-size: clamp(1.15rem, 1rem + 1vw, 1.6rem); letter-spacing: -0.01em; }
.card .label { overflow-wrap: anywhere; }
#audienceSwitch button, .office-tabs button, .seg button { letter-spacing: -0.005em; }
.reviews-big { font-size: .95rem; color: var(--muted); margin: 4px 0 10px; }
.reviews-big .kpi-num { font-size: 1.8rem; font-weight: 700; color: var(--ink); margin-right: 4px; }
.reviews-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; align-items: start; }
.reviews-grid > :only-child { grid-column: 1 / -1; }
@media (max-width: 640px) { .reviews-grid { grid-template-columns: minmax(0, 1fr); } }

/* Passkey auto sign-in (2026-10-09): big Face ID button first when the browser needs a tap */
.faceid-hero { margin: 0 0 16px; text-align: center; }
.faceid-btn { width: 100%; min-height: 56px; font-size: 1.1rem; font-weight: 700; border-radius: 14px; }
.faceid-sub { font-size: .82rem; color: var(--muted); margin-top: 8px; }
.faceid-status { text-align: center; color: var(--muted); font-size: .9rem; margin: 0 0 12px; }

/* Enterprise tab on phones (2026-10-09): never clip a tab label; drop " View" on narrow screens */
@media (max-width: 640px) { #audienceSwitch .aud-row button { flex: 1 0 auto; min-width: max-content; } }
@media (max-width: 430px) { #audienceSwitch .aud-suffix { display: none; } }

/* Sign-in: Face ID or password (2026-10-11) */
#loginForm[data-mode="faceid"] .pw-only, #loginForm[data-mode="password"] .faceid-only { display: none !important; }
#loginForm[data-mode="faceid"][data-known="1"] .email-row { display: none; }
.linkish { background: none; border: 0; padding: 6px 0; color: var(--brand-ink); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; box-shadow: none; }
.switch-btn { display: block; margin: 14px auto 0; min-height: 44px; font-size: .95rem; }
.faceid-btn { width: 100%; min-height: 58px; font-size: 1.12rem; font-weight: 700; border-radius: 14px; margin-top: 4px; }
.faceid-who { text-align: center; font-size: .9rem; color: var(--muted); margin: 0 0 12px; overflow-wrap: anywhere; }
.faceid-who .linkish { padding: 0; font-size: .9rem; }
.faceid-status { text-align: center; color: var(--muted); font-size: .88rem; margin-top: 8px; min-height: 1.2em; }
.faceid-offer { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; background: #fff; border: 1px solid var(--border);
  border-left: 4px solid var(--brand); border-radius: 14px; padding: 12px 14px; margin: 10px 0; box-shadow: var(--shadow); }
.faceid-offer[hidden] { display: none; }
.faceid-offer-sub { font-size: .85rem; color: var(--muted); margin-top: 2px; }
.faceid-offer-btns { display: flex; gap: 8px; }
.faceid-offer-btns button { min-height: 44px; }
.faceid-offer-msg { flex-basis: 100%; font-size: .85rem; color: var(--muted); }
.faceid-offer-msg:empty { display: none; }

/* Doctors preview: compensation hidden unless toggled (2026-10-12) */
.comp-toggle { display: flex; justify-content: flex-end; margin: 0 0 8px; font-size: .85rem; color: var(--muted); }
.comp-toggle label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; min-height: 32px; }

/* Budgets sub-tabs in Managers / Lead DA (2026-10-16) */
.sub-tabs { display:flex; gap:8px; flex-wrap:wrap; margin:0 0 12px; }
.sub-tabs button { border:1px solid var(--border); background:#fff; color:var(--ink); border-radius:999px; padding:7px 14px; font:inherit; font-weight:700; font-size:.88rem; cursor:pointer; min-height:38px; }
.sub-tabs button[aria-selected="true"] { background:var(--teal); color:#fff; border-color:var(--teal); }

/* Quarter view + office-manager quarterly bonus (2026-10-21) */
@media (max-width: 640px) { .seg button { padding: 6px 6px; font-size: .84rem; } }
.bonus-card .phone-head h3 { margin: 0; }
.bonus-st { font-weight: 700; }
.bonus-st.final { color: var(--good); }
.bonus-st.in-progress { color: #b45309; }
.bonus-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0 10px; }
.bonus-sum > div { background: var(--tint, #eef7fa); border-radius: 10px; padding: 8px 10px; font-size: .84rem; color: var(--muted); }
.bonus-sum .big { display: block; font-size: 1.35rem; font-weight: 800; color: var(--ink); }
.bonus-sum.proj > div { background: #fff7ed; }
.bonus-sum.empty { grid-template-columns: minmax(0, 1fr); }
.bonus-sum.empty > div { color: var(--ink); line-height: 1.45; }
.bonus-table td.pos { color: var(--good); font-weight: 700; }
.bonus-table td.neg { color: #be123c; font-weight: 700; }
.bonus-table td .gap { font-size: .72rem; font-weight: 400; color: var(--muted); }
.bonus-table td.bonus-prog { min-width: 130px; }
.bonus-prog .bar { display: inline-block; vertical-align: middle; width: 80px; height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden; margin-right: 6px; }
.bonus-prog .bar span { display: block; height: 100%; background: #be123c; }
.bonus-prog .bar.hit span { background: var(--good); }
.bonus-prog .pv { font-size: .78rem; }
.bonus-tiers { display: flex; gap: 6px; margin: 10px 0 4px; flex-wrap: wrap; }
.bonus-tier { flex: 1 1 90px; border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; font-size: .8rem; display: flex; flex-direction: column; align-items: flex-start; }
.bonus-tier .t-p { font-size: 1.05rem; font-weight: 800; }
.bonus-tier .t-a { color: var(--muted); }
.bonus-tier.on { border-color: #029ec3; background: #e3f4fb; box-shadow: inset 0 0 0 1px #029ec3; }
.bonus-qtd, .bonus-owner, .bonus-hint { font-size: .8rem; line-height: 1.45; margin: 8px 0 0; }
.bonus-owner { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 6px 10px; }
.bonus-hint { color: var(--muted); }
@media (max-width: 640px) {
  .bonus-sum { grid-template-columns: minmax(0, 1fr); }
  .bonus-sum > div { display: flex; align-items: baseline; gap: 8px; }
  .bonus-sum .big { display: inline; font-size: 1.15rem; }
  .bonus-table th.bonus-prog-h, .bonus-table td.bonus-prog { display: none; }
  .bonus-table th, .bonus-table td { white-space: normal; }
}
/* Bonus card v2 (2026-10-21): bonus $ to the side, no tier / % of wages display */
.bonus-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, 220px); gap: 14px; align-items: start; margin-top: 8px; }
.bonus-amt { background: #e3f4fb; border: 1px solid #bfe3ef; border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; text-align: center; align-self: stretch; justify-content: center; }
.bonus-amt .amt { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); font-weight: 800; color: var(--ink); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.bonus-amt .lbl { font-size: .85rem; font-weight: 600; color: var(--muted); }
.bonus-amt .note { font-size: .75rem; color: var(--muted); }
.bonus-amt.proj { background: #fff7ed; border-color: #fed7aa; }
@media (max-width: 640px) {
  .bonus-main { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .bonus-amt { order: -1; flex-direction: row; flex-wrap: wrap; align-items: baseline; justify-content: flex-start; gap: 4px 10px; text-align: left; padding: 10px 14px; }
}

/* KPI tile → 3-year monthly chart (2026-10-21): Enterprise + Managers tiles with history only */
.card.hist-click { cursor: pointer; position: relative; transition: box-shadow .15s, border-color .15s; padding-bottom: 22px; }
.card.hist-click:hover, .card.hist-click:focus-visible { border-color: #029ec3; box-shadow: 0 0 0 2px rgba(2,158,195,.25); outline: none; }
.card.hist-click::after { content: "3-yr chart ›"; position: absolute; right: 10px; bottom: 6px; font-size: .68rem; font-weight: 600; color: #0b7894; }
body.hist-open { overflow: hidden; }
.hist-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.hist-modal[hidden] { display: none; }
.hist-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.hist-dialog { position: relative; background: #fff; border-radius: 16px; box-shadow: 0 20px 50px rgba(15,23,42,.3); width: min(860px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 16px 18px 14px; font-family: "Sora", system-ui, sans-serif; }
.hist-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.hist-head h3 { margin: 0; font-size: 1.05rem; }
.hist-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.hist-close { border: 1px solid var(--border); background: #fff; border-radius: 10px; width: 40px; height: 40px; font-size: 1.4rem; line-height: 1; cursor: pointer; flex: 0 0 auto; font-family: inherit; }
.hist-body { position: relative; height: 340px; margin: 10px 0 6px; }
.hist-legend { display: flex; gap: 8px; flex-wrap: wrap; }
.hist-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; min-height: 36px; }
.hist-chip .sw { width: 14px; height: 4px; border-radius: 2px; background: repeating-linear-gradient(90deg, #94a3b8 0 4px, transparent 4px 7px); }
.hist-chip .yr { font-weight: 700; }
.hist-chip .nd { font-size: .74rem; color: var(--muted); }
.hist-chip .pop { display: none; white-space: nowrap; background: #0f172a; color: #fff; font-size: .76rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.hist-chip .pop.pos { background: #047857; } .hist-chip .pop.neg { background: #be123c; }
.hist-chip:hover .pop, .hist-chip:focus-visible .pop, .hist-chip.on .pop { display: inline-block; }
.hist-chip.on { border-color: #029ec3; box-shadow: inset 0 0 0 1px #029ec3; }
.hist-chip.none { color: var(--muted); }
.hist-live { font-size: .84rem; margin: 8px 0 4px; min-height: 1.3em; }
.hist-foot { font-size: .74rem; color: var(--muted); line-height: 1.45; }
.hist-foot details { margin-top: 4px; } .hist-foot ul { margin: 4px 0 0; padding-left: 18px; }
@media (max-width: 640px) {
  .hist-modal { padding: 0; align-items: flex-end; }
  .hist-dialog { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; padding: 14px 14px 18px; }
  .hist-body { height: 260px; }
  .hist-chip { flex: 1 1 auto; justify-content: center; min-height: 44px; }
}

/* Break-even point (Colton 2026-10-22): owner Finances section + manager tile */
.spec-pill.be { background: #9a3412; color: #fff; }
.be-pct { font-weight: 800; font-size: 1rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
.be-pct-sub { font-size: .72rem; color: var(--muted); margin-top: 1px; }
.card .value .be-per { font-size: .62em; font-weight: 700; color: var(--muted); margin-left: 2px; }
.be-table td.be-strong { font-weight: 800; }
.be-table .pos { color: #047857; } .be-table .neg { color: #be123c; }
.be-band { font-weight: 800; }
.be-tag { display: inline-block; font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; border-radius: 999px; padding: 0 6px; vertical-align: middle; }
.be-tag.amb { background: #fefce8; color: #854d0e; border-color: #fde68a; }
.be-table tr.be-callout th, .be-table tr.be-callout td { background: #fff7ed; }
.be-table th[scope="row"] .be-why { white-space: normal; font-weight: 500; max-width: 46ch; }
.be-details { margin-top: 12px; }
.be-details > summary { cursor: pointer; font-weight: 700; color: var(--brand-ink); padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); list-style-position: inside; overflow-wrap: anywhere; }
.be-details[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.be-details > .ortho-table-card { margin-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.be-notes { border: 1px solid var(--border); border-top: none; border-radius: 0 0 12px 12px; padding: 8px 14px; font-size: .82rem; line-height: 1.45; background: var(--card); }
.be-notes ul { margin: 0; padding-left: 18px; }
.be-charts { margin-top: 12px; margin-bottom: 4px; }
.be-charts .chart-card { min-width: 0; }
.be-charts .chart-card .sub { font-size: .74rem; color: var(--muted); margin: -4px 0 6px; }
.be-charts .chart-body { height: 240px; }
.be-charts .be-wide { grid-column: 1 / -1; }
.be-charts .be-wide .chart-body { height: 280px; }
@media (max-width: 640px) { .be-charts .chart-body, .be-charts .be-wide .chart-body { height: 230px; } .be-table th[scope="row"] .be-why { max-width: 30ch; } }
/* Cash left after everything (owner only, 2026-10-22) */
.spec-pill.cad { background: #065f46; color: #fff; }
.cad-section { margin-top: 18px; }
.cad-pct { font-weight: 800; font-size: 1rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
.cad-pct.pos, .cad-pct .pos { color: #047857; } .cad-pct.neg, .cad-pct .neg { color: #be123c; }
.cad-src { display: inline-block; font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; border-radius: 999px; padding: 0 6px; border: 1px solid; white-space: nowrap; }
.cad-src[data-src="statement"] { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.cad-src[data-src="estimated"] { background: #fefce8; color: #854d0e; border-color: #fde68a; }
.cad-src[data-src="needed"] { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.cad-src-wrap { margin-top: 4px; }
.cad-table td .sub, .cad-section td .sub { display: block; font-size: .7rem; color: var(--muted); margin-top: 2px; white-space: normal; }
.cad-section td.cad-why { white-space: normal; min-width: 28ch; max-width: 52ch; font-size: .76rem; line-height: 1.35; }
@media (max-width: 640px) { .cad-section td.cad-why { min-width: 22ch; max-width: 34ch; } }
.cad-src[data-src="schedule"] { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.cad-src[data-src="covered"] { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.cad-notcounted { margin: 4px 0 0 18px; padding: 0; }
.cad-notcounted li { margin: 2px 0; }

/* Marketing view: marketing budget (Colton 2026-10-22). Same $ / % formats as the owner Budgets tab. */
.mkt-budget .mkt-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 6px 0 12px; }
.mkt-budget .mkt-kpi { background: var(--tint); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.mkt-budget .mkt-kpi .label { font-size: .78rem; color: var(--muted, #5b6b73); }
.mkt-budget .mkt-kpi .value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.mkt-budget .mkt-over { color: #c2410c; }
.mkt-budget .mkt-bar { height: 6px; border-radius: 3px; background: #e5edf0; margin-top: 6px; overflow: hidden; }
.mkt-budget .mkt-bar span { display: block; height: 100%; background: var(--brand, #029ec3); }
.mkt-budget .mkt-bar span.over { background: #c2410c; }
.mkt-budget .mkt-tables { display: grid; gap: 12px; }
.mkt-budget .mkt-table td { font-variant-numeric: tabular-nums; }
.mkt-budget .mkt-table tr.sel th, .mkt-budget .mkt-table tr.sel td { background: rgba(2,158,195,.08); }
@media (max-width: 640px) { .mkt-budget .mkt-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .mkt-budget .mkt-table th, .mkt-budget .mkt-table td { padding-left: 6px; padding-right: 6px; font-size: .8rem; } }

/* GRiNside intranet link (Colton 2026-10-22): small header link, every signed-in role (header lives in #appView) */
.badges a.intranet-link {
  display: inline-flex; align-items: center; gap: 3px; min-height: 32px; padding: 0 6px;
  font-family: inherit; font-size: .78rem; font-weight: 700; color: var(--brand-ink); text-decoration: none;
  border-radius: 999px; white-space: nowrap;
}
.badges a.intranet-link .ext { font-size: .72rem; opacity: .7; }
.badges a.intranet-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.badges a.intranet-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (max-width: 640px) {
  /* Phone header row is already full (brand + up to 3 pill buttons): keep the buttons as they were and put the
     link on its own small right-aligned line beneath them */
  .badges { flex-direction: column; align-items: flex-end; gap: 2px; }
  .badges a.intranet-link { order: 2; min-height: 32px; padding: 0 8px; margin-right: -4px; font-size: .8rem; }
}

/* AR aging (PEDO) · Enterprise, owner only (2026-10-23): neutral tones (no KPI_COLOR_SCALE rule for AR) */
.ar-table th[scope="row"] .gap { font-size: .68rem; font-weight: 500; color: var(--muted); }
.ar-table td.ar-tot { color: var(--muted); }
.ar-table .ar-mix { width: 34%; min-width: 120px; }
.ar-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #eef2f6; }
.ar-seg { display: inline-block; height: 100%; }
.ar-seg0 { background: #9fb3c8; } .ar-seg1 { background: #6b829b; } .ar-seg2 { background: #4a5f78; } .ar-seg3 { background: #24344d; }
.ar-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .72rem; color: var(--muted); margin-top: 8px; }
.ar-table .ar-s { display: none; }
.ar-key { display: inline-flex; align-items: center; gap: 5px; }
.ar-key .ar-seg { width: 12px; height: 12px; border-radius: 3px; }
@media (max-width: 640px) {
  .ar-table .ar-mix { display: none; }
  .ar-table th, .ar-table td { padding: 6px 4px; font-size: .76rem; }
  .ar-table .ar-tot { display: none; }
  .ar-aging-card .ar-legend { display: none; }
  .ar-table .ar-l { display: none; }
  .ar-table .ar-s { display: inline; }
  .ar-table thead th { letter-spacing: 0; }
}
