/* =============================================================================
   Smart Page - shared design system  (theme.css)
   -----------------------------------------------------------------------------
   One stylesheet that all Smart Page pages link. It provides:

     1. DESIGN TOKENS   - surfaces, text, borders, shadows, radii, spacing.
                          Light by default; a `[data-theme="dark"]` block flips
                          the whole suite to dark. The per-business BRAND color
                          (--brand / --brand2 / --accent) is independent of the
                          light/dark mode, so a business's color drives accents
                          on either background.

     2. BASE + RESET    - typography, links, form controls, focus rings,
                          scrollbars - so every page starts polished.

     3. SHARED PARTS    - top bar, buttons, cards/panels, stat tiles, badges,
                          pills, bars, tables, theme toggle. Pages may still
                          add page-specific rules in their own <style>; because
                          those load after this file, they win on ties.

   How to use on a page:
     <link rel="stylesheet" href="theme.css">
     (and put the no-flash theme init snippet in <head> - see theme.js)
============================================================================= */

/* ----------------------------------------------------------------------------
   1. TOKENS
---------------------------------------------------------------------------- */
:root {
  /* Brand (per-business - JS overrides --brand/--brand2/--accent at runtime) */
  --brand:   #178a3b;          /* primary (qrowlocal green; balanced for readable green text/links ~4.4:1, paired with bold) */
  --brand2:  #10702f;          /* deeper partner for gradients */
  --accent:  #f59e0b;          /* stars / highlight (amber) */

  /* Brand, expressed as tints that read well on light surfaces */
  --brand-weak:  color-mix(in srgb, var(--brand) 10%, transparent);
  --brand-soft:  color-mix(in srgb, var(--brand) 14%, #ffffff);
  --brand-ring:  color-mix(in srgb, var(--brand) 35%, transparent);

  /* Neutral surfaces - light, professional */
  --bg:        #f5f7fb;        /* app background */
  --bg-2:      #eef2f8;        /* subtle banding */
  --surface:   #ffffff;        /* cards / panels */
  --surface-2: #f3f6fb;        /* insets, inputs, bar tracks */
  --surface-3: #e9eef6;        /* hovered insets */

  /* Text */
  --text:      #0f1729;        /* near-black slate */
  --text-2:    #334155;        /* secondary text */
  --muted:     #475569;        /* captions / labels - darkened for readability */
  --faint:     #64748b;        /* timestamps - darkened (old value failed contrast on white) */

  /* Lines - strong enough that cards read as cards on the light bg */
  --ring:      #d8dfe9;        /* default border */
  --ring-2:    #c3cdda;        /* stronger border */

  /* Semantic */
  --good:      #16a34a;
  --good-soft: color-mix(in srgb, var(--good) 12%, #ffffff);
  --warn:      #dc2626;
  --warn-soft: color-mix(in srgb, var(--warn) 10%, #ffffff);
  --info:      var(--brand);

  /* Elevation - soft, layered (key to the "clean SaaS" feel) */
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 1px rgba(15,23,42,.04);
  --shadow:    0 1px 3px rgba(15,23,42,.07), 0 6px 16px -6px rgba(15,23,42,.10);
  --shadow-lg: 0 8px 30px -8px rgba(15,23,42,.18), 0 2px 6px rgba(15,23,42,.06);
  --shadow-brand: 0 8px 22px -6px color-mix(in srgb, var(--brand) 50%, transparent);

  /* Geometry */
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(.2,.7,.2,1);

  color-scheme: light;
}

/* ----------------------------------------------------------------------------
   DARK MODE  - deeper neutrals, not navy-glow. Toggled via data-theme on <html>.
---------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  /* Brand green lightened for dark ONLY (light mode keeps #178a3b). The base green fails AA as
     TEXT on dark (~3.9:1); #1f9e48 reads ~5:1 as text yet keeps white-on-green buttons at
     AA-large (~3.5:1). Measured, not eyeballed - see the green-contrast probe. */
  --brand:       #1f9e48;
  --brand-weak:  color-mix(in srgb, var(--brand) 22%, transparent);
  --brand-soft:  color-mix(in srgb, var(--brand) 24%, #0d121c);
  --brand-ring:  color-mix(in srgb, var(--brand) 45%, transparent);

  --bg:        #0b0f17;
  --bg-2:      #0e131d;
  --surface:   #141a25;
  --surface-2: #1b2230;
  --surface-3: #232c3c;

  --text:      #e8eef8;
  --text-2:    #c2cde0;
  --muted:     #a6b4cb;
  --faint:     #8493ac;

  --ring:      rgba(255,255,255,.09);
  --ring-2:    rgba(255,255,255,.16);

  --good-soft: color-mix(in srgb, var(--good) 24%, #0d121c);
  --warn-soft: color-mix(in srgb, var(--warn) 22%, #0d121c);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 2px 8px rgba(0,0,0,.45);
  --shadow-lg: 0 12px 36px -8px rgba(0,0,0,.6);

  color-scheme: dark;
}

/* Follow the OS when the user hasn't explicitly chosen (data-theme="auto"). */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --brand:       #1f9e48;   /* match the explicit-dark brand lift (a11y: green text on dark) */
    --brand-weak:  color-mix(in srgb, var(--brand) 22%, transparent);
    --brand-soft:  color-mix(in srgb, var(--brand) 24%, #0d121c);
    --brand-ring:  color-mix(in srgb, var(--brand) 45%, transparent);
    --bg:#0b0f17; --bg-2:#0e131d; --surface:#141a25; --surface-2:#1b2230; --surface-3:#232c3c;
    --text:#e8eef8; --text-2:#c2cde0; --muted:#a6b4cb; --faint:#8493ac;
    --ring:rgba(255,255,255,.09); --ring-2:rgba(255,255,255,.16);
    --good-soft: color-mix(in srgb, var(--good) 24%, #0d121c);
    --warn-soft: color-mix(in srgb, var(--warn) 22%, #0d121c);
    --shadow-sm:0 1px 2px rgba(0,0,0,.4); --shadow:0 2px 8px rgba(0,0,0,.45); --shadow-lg:0 12px 36px -8px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

/* ----------------------------------------------------------------------------
   2. BASE / RESET
---------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  font-size: 15.5px;
  line-height: 1.55;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}

h1, h2, h3, h4 { color: var(--text); }
a { color: var(--brand); font-weight: 600; }

::selection { background: color-mix(in srgb, var(--brand) 24%, transparent); }

/* Inputs / textareas / selects - consistent, light, focus-ringed */
input, textarea, select, button { font-family: inherit; }
input, textarea, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  padding: 11px 12px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
textarea { min-height: 88px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; font-weight: 500; }

/* Keyboard focus visibility everywhere */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Skip-to-content link: hidden until a keyboard user tabs to it (first focusable
   element on every app page), then it drops in at top-left so they can jump past
   the fixed navigation rail instead of tabbing through every nav item. */
.sp-skip {
  position: fixed; top: 8px; left: -9999px; z-index: 200;
  background: var(--brand); color: #fff; text-decoration: none;
  padding: 10px 16px; border-radius: 10px; font-weight: 700; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.sp-skip:focus { left: 8px; }

/* Quiet, modern scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--ring-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--ring-2); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ----------------------------------------------------------------------------
   3. SHARED COMPONENTS
   (Pages may override; their inline <style> loads after this file.)
---------------------------------------------------------------------------- */

/* --- Top bar -------------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px;
  /* Opaque on purpose. A sticky element with backdrop-filter forces the whole
     scrolling page onto a composited layer, which rasterizes text blurry on
     fractional-DPI displays (Windows @125/150%). Solid surface keeps text crisp. */
  background: var(--surface);
  border-bottom: 1px solid var(--ring);
}
/* "Back to …" crumb that lives INSIDE the top bar (left of the title) so it never
   adds a row above the bar. A compact pill, vertically centered in the flex row. */
.topback {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 600; color: var(--brand);
  text-decoration: none; white-space: nowrap; flex: 0 0 auto;
  padding: 6px 11px 6px 8px; border-radius: 999px;
  border: 1px solid var(--ring); background: var(--surface-2);
  transition: border-color .12s, background .12s;
}
.topback:hover { border-color: var(--brand); background: var(--brand-weak); }
/* Phone: tighten the bar and let the title hold row 1 so nav wraps neatly below. */
@media (max-width: 600px) {
  .top { padding: 10px 14px; gap: 8px 7px; }
  .top h1 { font-size: 15px; flex-basis: calc(100% - 46px); }
}
/* Customer logo mark - just the logo, no badge/frame/gradient. */
.top .mark {
  height: 34px; width: auto; max-width: 180px;
  display: flex; align-items: center;
  background-size: contain; background-position: left center; background-repeat: no-repeat;
}
.top .mark img { height: 34px; max-width: 180px; object-fit: contain; display: block; }
/* Dark mode: most business logos are drawn for a light background, so on the dark top bar they
   vanish (a dark wordmark takes the business NAME with it). Sit the logo on a small white chip so
   it always reads - same trick the login card uses. Light mode needs none: the bar is already light. */
:root[data-theme="dark"] .top .mark { background-color: #fff; border-radius: 8px; padding: 3px 7px; box-shadow: 0 1px 2px rgba(0,0,0,.35); }
/* Product brand badge (U-Q) keeps its colored chip. */
.top .brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 14px; letter-spacing: .3px;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  box-shadow: var(--shadow-sm);
}
.top h1 { font-size: 16px; margin: 0; flex: 1; min-width: 0; font-weight: 650; letter-spacing: -.01em; }
.top .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 13px; font-weight: 550;
  color: var(--text-2); background: var(--surface);
  border: 1px solid var(--ring); border-radius: var(--radius-sm);
  padding: 8px 13px; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s var(--ease), background-color .15s var(--ease),
              color .15s var(--ease), transform .08s var(--ease), box-shadow .15s var(--ease);
}
.btn:hover { border-color: var(--ring-2); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  box-shadow: var(--shadow-brand);
}
.btn.primary:hover { filter: brightness(1.05); background: linear-gradient(135deg, var(--brand), var(--brand2)); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--ring); }
.btn.danger:hover { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Layout shell -------------------------------------------------------- */
/* Consistent content width across the app (was a jumble of per-page caps: 680/780/900/1320…
   plus a few unbounded pages). TWO deliberate tiers, so widths never look random:
     - default = full width: data-dense pages (dashboards, lists, analytics, browse grids) use
       the whole monitor, per the owner's preference. Fluid side padding keeps edges comfortable.
     - `.narrow` = a calm reading/flow column for focused pages (detail, wizards, short forms),
       where full width would sprawl text or leave a grid half-empty.
   Phones always fill the screen with tight padding and never scroll horizontally. */
.wrap { position: relative; z-index: 1; width: 100%; max-width: none; margin: 0 auto; padding: 26px clamp(16px, 3vw, 44px) 72px; }
.wrap.narrow { max-width: 940px; }
@media (max-width: 768px) { .wrap { padding: 18px 16px 80px; } }

/* --- Cards / panels ------------------------------------------------------ */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel { padding: 18px; }
.panel h2, .card h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin: 0 0 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

/* --- Stat tiles ---------------------------------------------------------- */
.stat {
  background: var(--surface); border: 1px solid var(--ring);
  border-radius: var(--radius); padding: 16px 16px 14px; box-shadow: var(--shadow-sm);
}
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 7px; font-weight: 600; }
.stat .k .d { width: 8px; height: 8px; border-radius: 50%; }
.stat .v { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: -.02em; }
.stat .x { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* --- Badges / pills ------------------------------------------------------ */
.badge { font-size: 10.5px; padding: 2px 8px; border-radius: var(--radius-pill); font-weight: 700; letter-spacing: .3px; }
.count-tag {
  margin-left: auto; background: var(--brand-weak); color: var(--brand);
  font-size: 11px; padding: 2px 9px; border-radius: var(--radius-pill); letter-spacing: 0; font-weight: 600;
}
.pill {
  display: inline-block; font-size: 12.5px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--ring);
  padding: 5px 12px; border-radius: var(--radius-pill);
}

/* --- Progress bars ------------------------------------------------------- */
.bar { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 55%, var(--accent))); }

/* --- Tables -------------------------------------------------------------- */
table.sp { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.sp th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--ring); }
table.sp td { padding: 11px 10px; border-bottom: 1px solid var(--ring); }
table.sp tr:last-child td { border-bottom: 0; }

/* --- Theme toggle button ------------------------------------------------- */
.theme-toggle {
  width: 36px; height: 36px; padding: 0; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--ring);
  background: var(--surface); color: var(--muted); cursor: pointer;
  box-shadow: var(--shadow-sm); transition: color .15s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease);
}
.theme-toggle:hover { color: var(--text); border-color: var(--ring-2); background: var(--surface-2); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .i-sun  { display: none; }
.theme-toggle .i-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .i-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* --- Empty state --------------------------------------------------------- */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty a { color: var(--brand); }
/* Guided empty state (icon + headline + one next action). Built by the shared
   window.spEmpty() helper (partials/page.php) so every goal page reads the same
   when it has no data yet, instead of a lone gray line in a big panel. */
.es { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 34px 20px 30px; }
.es-ic { font-size: 34px; line-height: 1; margin-bottom: 12px; }
.es-h { font-size: 16px; font-weight: 700; margin: 0 0 5px; color: var(--text); }
.es-p { font-size: 13px; color: var(--muted); max-width: 400px; line-height: 1.55; margin: 0 0 16px; }
.es .btn { text-decoration: none; }

/* --- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- Card elevation (light mode) ------------------------------------------
   In light mode, borders alone wash out on the pale background - give every
   card-like container a soft lift. Dark mode keeps flat borders (shadows go
   muddy on dark). Pages don't set box-shadow, so this applies everywhere. */
.panel, .tile, .gcard, .ccard, .card, .box, .addcard, .add, .lb-card, .doc, details {
  box-shadow: var(--shadow-sm);
}
:root[data-theme="dark"] :is(.panel, .tile, .gcard, .ccard, .card, .box, .addcard, .add, .lb-card, .doc, details) {
  box-shadow: none;
}

/* --- App navigation (bottom tab bar on mobile, side rail on desktop) ------
   Rendered by sp_app_nav() on every authed app page. The body gets
   .has-appnav so its content clears the fixed nav. */
.appnav { position: fixed; z-index: 50; background: var(--surface); }
.navtab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--muted); text-decoration: none; background: none; border: 0;
  cursor: pointer; font: inherit; font-weight: 600; -webkit-tap-highlight-color: transparent;
}
.navtab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navtab svg { width: 23px; height: 23px; display: block; }
/* Unread-count dot (team messages) - small red pill pinned to the tab's top-right. */
.navdot {
  position: absolute; top: 4px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: #e5484d; color: #fff; font-size: 10px; font-weight: 700;
  line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--surface);
}
.navtab span { font-size: 10.5px; letter-spacing: .01em; }
.navtab.active { color: var(--brand); }
.navtab:not(.active):hover { color: var(--text); }
.navsub { display: none; }   /* Activity sub-links: desktop rail only (see the min-width block) */

/* Mobile: a bottom bar */
@media (max-width: 768px) {
  .appnav { left: 0; right: 0; bottom: 0; display: flex; border-top: 1px solid var(--ring);
    padding: 5px 2px calc(5px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 14px rgba(0,0,0,.05); }
  /* min-width:0 is the load-bearing part: flex items default to min-width:auto and
     refuse to go narrower than their label, so with five tabs the bar measured 399px
     and gave the whole page a horizontal scroll at 375px. `flex: 1` alone could not
     shrink them. Scoped to the phone bar - the desktop rail is a COLUMN, where
     growing tabs would stretch them down the full height. */
  .navtab { flex: 1; min-width: 0; padding: 5px 2px; border-radius: 10px; }
  .navtab.active { background: var(--brand-weak); }
  .navgroup, .navtab-tool, .navcollapse { display: none; }  /* the phone bar shows the 4 goals + one "Tools" entry, not the desktop list */
  .navnew { display: none; }  /* phone bar stays 4 goals + Tools; "make new" is reached via Codes there */
  body.has-appnav { padding-bottom: 70px; }
}
/* Desktop: a LABELED left menu (goals + a Tools group), EXPANDED by default. A
   hamburger in the top bar hides/shows the whole menu (remembered per device). No
   icon-only state, no hover - just labels, or hidden for full width. */
.navtoggle { display: none; }   /* shown only inside the desktop top bar (below) */
@media (min-width: 769px) {
  .appnav { top: 0; bottom: 0; left: 0; width: 214px; display: flex; flex-direction: column;
    align-items: stretch; gap: 2px; border-right: 1px solid var(--ring); padding: 14px 10px;
    background: var(--surface); overflow-y: auto; z-index: 30; transition: transform .16s ease; }
  .navtab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); }
  .navtab svg { width: 20px; height: 20px; flex: 0 0 auto; }
  .navtab span { font-size: 14px; white-space: nowrap; }
  .navtab:not(.active):hover { background: var(--surface-2); color: var(--text); }
  .navtab.active { background: var(--brand-weak); color: var(--brand); }
  /* Create action, quiet ghost below the goals - reachable, but it doesn't shout over
     the results the manager comes here for. */
  .navnew { color: var(--brand); font-weight: 600; background: transparent;
    border: 1px solid var(--ring); margin-top: 8px; }
  .navnew:hover, .navnew.active { color: var(--brand); background: var(--brand-weak); border-color: var(--brand); }
  .navtab-toolslink { display: none; }   /* desktop lists the tools below, under the heading */
  .navgroup { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); padding: 14px 12px 5px; white-space: nowrap; }
  /* Activity sub-links, indented under the Activity tab (Reviews / Leads / Appointments / Giveaways). */
  .navsub { display: flex; flex-direction: column; gap: 1px; margin: 1px 0 4px; }
  .navsubi { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 30px; border-radius: 9px;
    color: var(--text-2); text-decoration: none; font-size: 13px; white-space: nowrap; }
  .navsubi svg { width: 15px; height: 15px; flex: 0 0 auto; opacity: .85; }
  .navsubi:not(.active):hover { background: var(--surface-2); color: var(--text); }
  .navsubi.active { color: var(--brand); font-weight: 600; background: var(--brand-weak); }
  body.has-appnav { padding-left: 214px; }
  /* Hamburger toggle, lives at the left of the top bar. */
  .top .navtoggle { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
    border: 1px solid var(--ring); background: var(--surface-2); color: var(--text-2); border-radius: 9px; cursor: pointer; flex: 0 0 auto; }
  .top .navtoggle:hover { border-color: var(--brand); color: var(--brand); }
  /* Hidden: the menu slides off to the left and content takes the full width. */
  body.nav-hidden .appnav { transform: translateX(-100%); }
  body.nav-hidden.has-appnav { padding-left: 0; }
}

/* "More" sheet + scrim */
.navsheet { position: fixed; z-index: 56; background: var(--surface); border: 1px solid var(--ring);
  border-radius: 15px; box-shadow: var(--shadow-lg); padding: 7px; display: none; min-width: 184px; }
.navsheet.open { display: block; }
.navsheet a, .navsheet button {
  display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box;
  padding: 11px 13px; color: var(--text); text-decoration: none; background: none; border: 0;
  font: inherit; font-size: 14px; font-weight: 600; border-radius: 10px; cursor: pointer; text-align: left; }
.navsheet a:hover, .navsheet button:hover { background: var(--surface-2); }
.navsheet svg { width: 20px; height: 20px; color: var(--muted); flex: 0 0 auto; }
.navscrim { position: fixed; inset: 0; z-index: 55; background: rgba(8,12,20,.32); display: none; }
.navscrim.open { display: block; }
@media (max-width: 768px) { .navsheet { left: 10px; right: 10px; bottom: 74px; min-width: 0; } }

/* --- Tools side menu (manager's secondary tools - option B) ----------------
   Desktop: a fixed left side menu below the top bar, content shifts right.
   Phone: a horizontal scroll strip of chips below the top bar. */
.toolside { background: var(--surface); }
.toolside-h { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.toolside-i { display: flex; align-items: center; gap: 10px; color: var(--text-2); text-decoration: none; font-weight: 600; }
.toolside-i svg { width: 19px; height: 19px; flex: 0 0 auto; }
.toolside-i.active { color: var(--brand); }
@media (min-width: 769px) {
  .toolside { position: fixed; left: 0; top: 63px; bottom: 0; width: 210px; overflow-y: auto;
    border-right: 1px solid var(--ring); padding: 16px 12px; display: flex; flex-direction: column; gap: 3px; z-index: 19; }
  .toolside-h { padding: 2px 11px 9px; }
  .toolside-i { padding: 9px 11px; border-radius: 10px; font-size: 14px; }
  .toolside-i:hover { background: var(--surface-2); color: var(--text); }
  .toolside-i.active { background: var(--brand-weak); }
  body.has-tools .wrap { margin-left: 210px; }
}
@media (max-width: 768px) {
  .toolside { display: flex; gap: 8px; overflow-x: auto; padding: 9px 14px; border-bottom: 1px solid var(--ring); }
  .toolside-h { display: none; }
  .toolside-i { flex: 0 0 auto; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--ring); font-size: 13px; white-space: nowrap; }
  .toolside-i.active { background: var(--brand-weak); border-color: var(--brand); color: var(--brand); }
}
/* Desktop: a popover beside the rail; JS sets `top` to align it with the More
   button (bottom is a fallback if JS hasn't positioned it yet). No page dimming -
   the scrim stays click-catchable but invisible so it reads as a flyout. */
@media (min-width: 769px) { .navsheet { left: 90px; bottom: 16px; }
  .navscrim { background: transparent; } }

/* ---- Touch targets -------------------------------------------------------
   On a phone every control has to be reachable with a thumb. Measured at 375px,
   the action buttons landed at 33-38px tall - hittable if you aim, annoying if
   you don't, and below the 44px minimum both Apple and WCAG use.

   Scoped to `pointer: coarse` on purpose: a mouse is precise, so desktop keeps
   its tighter density and nothing about the current look changes there. Height
   is added with min-height rather than padding so labels stay put and rows do
   not reflow. Controls inside a run of text are exempt - stretching an inline
   link would break the line it sits in. */
@media (pointer: coarse) {
  .btn,
  button:not(.lm-play):not([class*="close"]),
  [role="button"],
  select,
  textarea,
  /* Negation, not a list of types: `<input>` with no type attribute behaves as text
     but never matches input[type="text"], which is how several fields stayed at 40px. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]):not([type="color"]):not([type="file"]) {
    min-height: 44px;
  }
  /* Checkboxes and radios measured 13-22px. A 44px checkbox looks wrong, so give the
     control a comfortable size rather than a full target - the label beside it is the
     large hit area, and browsers already extend the box slightly for touch. */
  input[type="checkbox"], input[type="radio"] { min-width: 22px; min-height: 22px; }
  /* Links that are dressed as controls. A bare `a` rule would stretch every link in
     a sentence, so these are named: tabs, quick-actions and row actions that a thumb
     is meant to hit. Measured at 375px they came in at 20-42px. */
  a.cm-tab, a.tab, a.chip, .rec .qk, .it-rowacts a, .it-rowacts button, .thinrow,
  .cloc a {
    min-height: 44px;
  }
  /* The address on a public card opens maps - a customer taps it with a thumb.
     The anchor is the target, not its .cloc wrapper. */
  .cloc a { display: inline-flex; align-items: center; }
  /* Icon-only and chip-style controls need width too, not just height. */
  .btn.icon, .iconbtn, .chip, .rec .qk { min-width: 44px; }
  /* Icon-only controls centre their glyph once they are given a bigger box. */
  .rec .qk, a.chip { display: inline-flex; align-items: center; justify-content: center; }
  /* Inline links inside prose keep their natural size. */
  p a, li a, small a, .sub a, .muted a, .hint a, .review-sub a { min-height: 0; }
}
