:root {
  --brand-500: #566220;
  --brand-600: #45501a;
  --brand-50: #eef0e2;
  --green-600: #387c2b;
  --ink-900: #302d1d;
  --ink-700: #4a4636;
  --ink-500: #625d4d;
  --ink-300: #cfcabb;
  --line: #e6e2d6;
  --surface: #ffffff;
  --canvas: #f5f3ee;

  --ok: #387c2b;      --ok-bg: #e7f2e3;
  --due: #b45309;     --due-bg: #fdf1dc;
  --overdue: #c62828; --overdue-bg: #fde8e8;
  --info: #566220;    --info-bg: #eef0e2;
  --muted: #625d4d;   --muted-bg: #efece4;

  /* surfaces & roles that change between themes */
  --accent-fill: #566220;        /* filled buttons, counters (white text on it) */
  --accent-fill-hover: #45501a;
  --danger-fill: #c62828;
  --danger-fill-hover: #a61f1f;
  --on-fill: #ffffff;
  --header-bg: rgba(255, 255, 255, .92);
  --raised: #ffffff;             /* menus, dialogs, inputs, pressed segments */
  --row-hover: #faf9f5;
  --table-head: #faf9f5;
  --photo-bg: #e7e3d8;
  --due-fill: #e08a00;
  --inverse-bg: #302d1d;         /* toast, offline banner, skip link */
  --inverse-fg: #ffffff;
  --footer-bg: #302d1d;
  --footer-fg: #d8d3c2;
  --footer-strong: #ffffff;
  --info-border: #d4d9bd;
  --ai-bg: #f7f7f0;
  --ai-border: #cfd5b3;
  --overlay: rgba(48, 45, 29, .45);
  --shadow-lg: 0 20px 60px rgba(48, 45, 29, .25);
  --shadow-menu: 0 12px 32px rgba(48, 45, 29, .14);
  --shadow-press: 0 1px 3px rgba(48, 45, 29, .12);
  --shadow-lift: 0 2px 4px rgba(48, 45, 29, .06), 0 12px 28px rgba(48, 45, 29, .12);
  --scroll-thumb: rgba(48, 45, 29, .2);        /* scrollbars: thin rounded thumb, no track */
  --scroll-thumb-hover: rgba(48, 45, 29, .38);

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(48, 45, 29, .06), 0 4px 16px rgba(48, 45, 29, .06);
  --header-h: 68px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

/* Dark palette: follows the device unless the person picked Light or Dark (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-500: #b5c46a;
    --brand-600: #cbd88a;
    --brand-50: #23280f;
    --green-600: #7cc06c;
    --ink-900: #eeebe2;
    --ink-700: #c9c4b4;
    --ink-500: #9a9483;
    --ink-300: #48443a;
    --line: #322f26;
    --surface: #1c1a14;
    --canvas: #12110d;
    --ok: #7cc06c;      --ok-bg: #16301a;
    --due: #f2a93b;     --due-bg: #36280f;
    --overdue: #ff7a7a; --overdue-bg: #3d1a1d;
    --info: #b5c46a;    --info-bg: #23280f;
    --muted: #b0aa98;   --muted-bg: #2b2920;
    --accent-fill: #566220;
    --accent-fill-hover: #67752a;
    --danger-fill: #c33a3a;
    --danger-fill-hover: #d24b4b;
    --on-fill: #ffffff;
    --header-bg: rgba(28, 26, 20, .9);
    --raised: #24221a;
    --row-hover: #211f18;
    --table-head: #201e17;
    --photo-bg: #24221a;
    --due-fill: #f2a93b;
    --inverse-bg: #eeebe2;
    --inverse-fg: #12110d;
    --footer-bg: #0d0c09;
    --footer-fg: #b5af9e;
    --footer-strong: #eeebe2;
    --info-border: #3d4520;
    --ai-bg: #1b1d12;
    --ai-border: #3f4723;
    --overlay: rgba(0, 0, 0, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
    --shadow-menu: 0 12px 32px rgba(0, 0, 0, .45);
    --shadow-press: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .4), 0 12px 28px rgba(0, 0, 0, .4);
    --scroll-thumb: rgba(238, 235, 226, .18);
    --scroll-thumb-hover: rgba(238, 235, 226, .34);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand-500: #b5c46a;
  --brand-600: #cbd88a;
  --brand-50: #23280f;
  --green-600: #7cc06c;
  --ink-900: #eeebe2;
  --ink-700: #c9c4b4;
  --ink-500: #9a9483;
  --ink-300: #48443a;
  --line: #322f26;
  --surface: #1c1a14;
  --canvas: #12110d;
  --ok: #7cc06c;      --ok-bg: #16301a;
  --due: #f2a93b;     --due-bg: #36280f;
  --overdue: #ff7a7a; --overdue-bg: #3d1a1d;
  --info: #b5c46a;    --info-bg: #23280f;
  --muted: #b0aa98;   --muted-bg: #2b2920;
  --accent-fill: #566220;
  --accent-fill-hover: #67752a;
  --danger-fill: #c33a3a;
  --danger-fill-hover: #d24b4b;
  --on-fill: #ffffff;
  --header-bg: rgba(28, 26, 20, .9);
  --raised: #24221a;
  --row-hover: #211f18;
  --table-head: #201e17;
  --photo-bg: #24221a;
  --due-fill: #f2a93b;
  --inverse-bg: #eeebe2;
  --inverse-fg: #12110d;
  --footer-bg: #0d0c09;
  --footer-fg: #b5af9e;
  --footer-strong: #eeebe2;
  --info-border: #3d4520;
  --ai-bg: #1b1d12;
  --ai-border: #3f4723;
  --overlay: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
  --shadow-menu: 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-press: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .4), 0 12px 28px rgba(0, 0, 0, .4);
  --scroll-thumb: rgba(238, 235, 226, .18);
  --scroll-thumb-hover: rgba(238, 235, 226, .34);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

/* App-style scrollbars everywhere (page, dialogs, menus, panels, wide tables): a thin rounded thumb on no track, no
   arrow buttons. Each bar stays hidden until its own view is in use and fades in when the pointer enters it or it
   scrolls, then fades out after (js/scrollbars.js sets .sb-on / .sb-scrolling on the scroll area). Over the bar the
   thumb grows from 6px to 8px and darkens (.sb-hot). The thumb's color and inset are animatable custom properties
   reset on every element, so a scroll area inside one in use stays hidden until it is in use itself.
   Chromium and Safari use the ::-webkit-scrollbar rules; setting scrollbar-width/-color would make Chromium ignore
   them, so the standard properties are only applied where ::-webkit-scrollbar isn't supported (Firefox). */
@property --sb-thumb { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --sb-inset { syntax: '<length>'; inherits: true; initial-value: 2px; }
:where(*) { --sb-thumb: transparent; --sb-inset: 2px; transition: --sb-thumb .4s ease-out .1s, --sb-inset .15s ease-out; }
/* The window's own bar on touch screens: phones and tablets draw an overlay bar that already shows only while
   scrolling, and Chromium never repaints a styled window bar when its color changes, so it keeps the plain thumb. */
:where(html) { --sb-thumb: var(--scroll-thumb); }
:where(.sb-on, .sb-scrolling) { --sb-thumb: var(--scroll-thumb); transition: --sb-thumb .15s ease-out, --sb-inset .15s ease-out; }
:where(.sb-hot) { --sb-thumb: var(--scroll-thumb-hover); --sb-inset: 1px; }
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-thumb { background: var(--sb-thumb); background-clip: padding-box; border: var(--sb-inset) solid transparent; border-radius: 999px; min-height: 32px; min-width: 32px; }
::-webkit-scrollbar-thumb:active { background-color: var(--scroll-thumb-hover); border-width: 1px; }
/* The page's own scrollbar (js/page-scrollbar.js) on mouse and trackpad screens: the browser's is hidden so the header
   spans the full width, and the app draws a matching thumb that runs from just under the header to the bottom. It
   fades in and out with the page like the others and grows on hover. */
html.app-scrollbar { scrollbar-width: none; }
html.app-scrollbar::-webkit-scrollbar, html.app-scrollbar body::-webkit-scrollbar { display: none; }
.page-scrollbar { position: fixed; right: 0; z-index: 25; width: 12px; opacity: 0; transition: opacity .4s ease-out .1s; }
html.sb-on .page-scrollbar, html.sb-scrolling .page-scrollbar, .page-scrollbar:hover, .page-scrollbar.is-dragging { opacity: 1; transition: opacity .15s ease-out; }
.page-scrollbar-thumb { position: absolute; top: 0; right: 2px; width: 6px; border-radius: 999px; background: var(--scroll-thumb); transition: background-color .15s, width .15s ease-out; }
.page-scrollbar:hover .page-scrollbar-thumb, .page-scrollbar.is-dragging .page-scrollbar-thumb { width: 8px; background: var(--scroll-thumb-hover); }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--sb-thumb) transparent; }
}
html { height: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + var(--env-banner-h, 0px) + 16px); }
/* Header, content, footer as one column that fills the window: short pages fit without scrolling and the footer sits at the bottom. */
body { margin: 0; min-height: 100%; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); background: var(--canvas); color: var(--ink-900); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
/* Never leave one word alone on the last line: body text wraps "pretty", short and centered text is balanced.
   The longhand text-wrap-style keeps any white-space: nowrap (text-wrap-mode) intact. */
body { text-wrap: pretty; }
h1, h2, h3, h4, h5, h6, legend, caption, figcaption, th, label, small, .empty, .empty-state, .login-card, .ai-hello,
.ai-foot, .toast, .dgrid-empty, .footer-inner, .env-banner, .finance-lock { text-wrap-style: balance; }
input, textarea, [contenteditable] { text-wrap-style: auto; }
h1, h2, p { margin: 0; }
a { color: var(--brand-500); }
/* Text links: light dashed underline that firms up on hover. */
a { text-decoration-line: underline; text-decoration-style: dashed; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); transition: text-decoration-color .15s; }
a:hover { text-decoration-color: currentColor; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .container { padding: 0 24px; } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 16px; top: -48px; background: var(--inverse-bg); color: var(--inverse-fg); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-500) 55%, transparent); outline-offset: 2px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ---------- header ---------- */
.site-header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--header-bg); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
/* Non-production deployments (TITLE_TAG): a thin strip pinned above the header on every screen. */
.env-banner { padding: 3px 16px; text-align: center; font-size: 12px; font-weight: 600; letter-spacing: .04em; line-height: 16px;
  color: var(--due); background: var(--due-bg); border-bottom: 1px solid color-mix(in srgb, var(--due) 25%, transparent); }
:root:has(.env-banner:not([hidden])) { --env-banner-h: 23px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); gap: 24px; }
.brand { flex: none; display: flex; align-items: center; gap: 10px; color: var(--ink-900); text-decoration: none; }
.brand-mark { width: 44px; height: 44px; border-radius: 50%; }
.brand-text { font-size: 17px; letter-spacing: -.01em; }
.brand-text strong { font-weight: 700; }

.primary-nav { display: flex; align-items: center; gap: 4px; }
.primary-nav > a { color: var(--ink-700); text-decoration: none; font-weight: 500; padding: 8px 12px; border-radius: var(--radius-sm); }
.primary-nav > a:hover { background: var(--canvas); color: var(--ink-900); }
.primary-nav > a[aria-current="page"] { color: var(--brand-600); background: var(--brand-50); }
.header-app { display: flex; align-items: center; gap: 12px; flex: 1; justify-content: flex-end; min-width: 0; }
.projects-picker .dd-trigger { font-size: 14px; font-weight: 600; border-color: var(--line); padding: 7px 10px 7px 12px; max-width: 260px; }
.account { position: relative; margin-left: 12px; padding-left: 16px; border-left: 1px solid var(--line); }
.account-btn { display: flex; align-items: center; gap: 8px; font: inherit; background: none; border: 0; padding: 4px 10px 4px 4px; border-radius: 999px; cursor: pointer; color: var(--ink-900); }
.account-btn:hover { background: var(--canvas); }
.account-name { font-weight: 500; font-size: 14px; }
.chev { width: 16px; height: 16px; fill: none; stroke: var(--ink-500); stroke-width: 2; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); width: 280px; max-width: calc(100vw - 24px); max-height: var(--menu-max, calc(100dvh - 90px)); overflow-y: auto; background: var(--raised); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-menu); padding: 6px; z-index: 30;
  transform-origin: top right; animation: dmenu-in .16s var(--ease-out); }
.menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; min-width: 0; }
.menu-who { display: grid; min-width: 0; line-height: 1.3; }
.menu-who strong { font-size: 15px; font-weight: 600; color: var(--ink-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-who span { font-size: 13px; color: var(--ink-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-group { display: grid; gap: 1px; padding: 5px 0; border-top: 1px solid var(--line); }
.menu-group[hidden] { display: none; }
.menu-group:last-child { padding-bottom: 0; }
.menu a, .menu button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; font-size: 15px; background: none; border: 0; padding: 10px 12px; border-radius: 9px; cursor: pointer; color: var(--ink-900); text-decoration: none;
  transition: background .15s, transform .12s var(--ease-out); -webkit-tap-highlight-color: transparent; }
.menu a[hidden], .menu button[hidden] { display: none; }
.menu a svg, .menu button svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--brand-600); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.menu a:hover, .menu a:focus-visible, .menu button:hover, .menu button:focus-visible { background: var(--canvas); outline: none; }
.menu a:active, .menu button:active { transform: scale(.97); background: var(--canvas); }
.menu .menu-signout { color: var(--overdue); }
.menu .menu-signout svg { stroke: var(--overdue); }
/* the account menu always ends above the phone tab bar, and CMI AI's floating button steps aside while it's open.
   When the menu is taller than that, only the middle scrolls: the person card stays pinned at the top and Sign Out at the
   bottom, so both are always in reach */
.menu { padding-block: 0; }
.menu-head { position: sticky; top: 0; z-index: 1; padding-top: 14px; background: var(--raised); border-bottom: 1px solid var(--line); }
.menu-head + .menu-group { border-top: 0; }
.menu-group:has(.menu-signout) { position: sticky; bottom: 0; z-index: 1; padding-bottom: 6px; background: var(--raised); }
@media (max-width: 860px) {
  /* hangs from the header's bottom edge, not the avatar, so it sits just inside the header and the tab bar (its height,
     --menu-max, is measured when it opens) */
  .account { position: static; }
  .menu { top: calc(100% + 8px); right: 12px; overscroll-behavior: contain; }
}
body:has(#account-menu:not([hidden])) .ai-fab { opacity: 0; pointer-events: none; transform: scale(.6); }


/* Phones and small tablets: pages move to the bottom tab bar; the header keeps the project picker and account menu. */
@media (max-width: 860px) {
  .primary-nav > a, .account-name, .chev { display: none; }
  .account { margin-left: 0; padding-left: 0; border-left: 0; }
  .account-btn { padding: 4px; }
  .projects-picker .dd-trigger { max-width: 52vw; }
}

/* ---------- buttons, badges ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px; border-radius: var(--radius-sm); border: 1px solid transparent; padding: 9px 16px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .12s var(--ease-out); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--accent-fill); color: var(--on-fill); }
.btn-primary:hover { background: var(--accent-fill-hover); }
.btn-secondary { background: var(--raised); color: var(--ink-900); border-color: var(--ink-300); }
.btn-secondary:hover { border-color: var(--ink-500); }
.btn-ghost { background: transparent; color: var(--ink-700); border-color: var(--line); }
.btn-ghost:hover { background: var(--canvas); }
.btn-danger { background: var(--danger-fill); color: var(--on-fill); }
.btn-danger:hover { background: var(--danger-fill-hover); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-due { color: var(--due); background: var(--due-bg); }
.badge-overdue { color: var(--overdue); background: var(--overdue-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-muted { color: var(--muted); background: var(--muted-bg); }

.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); color: var(--ink-500); background: none; border: 0; cursor: pointer; font-size: 22px; line-height: 1; transition: background .15s, color .15s, transform .12s var(--ease-out); }
.icon-btn:hover { background: var(--canvas); color: var(--ink-900); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand-50); color: var(--brand-600); font-size: 12px; font-weight: 700; flex: none; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

/* ---------- layout & cards ---------- */
main { flex: 1 0 auto; display: grid; gap: 20px; align-content: start; }
/* .container sets the side gutters; the space under the header is set here, the same on every page. */
main.container { padding-top: 32px; padding-bottom: 48px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }

/* projects summary */
.projects { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); overflow: hidden; }
.projects-photo { position: relative; background: var(--photo-bg); min-height: 240px; }
.projects-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-badge { position: absolute; top: 14px; left: 14px; box-shadow: var(--shadow); }
.projects-body { padding: 24px 28px; display: grid; gap: 20px; align-content: start; }
.projects-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.projects-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-500); }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.specs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 24px; margin: 0; }
.specs dt { font-size: 12px; color: var(--ink-500); }
.specs dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }

.kpis { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.kpi { display: grid; gap: 2px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); text-decoration: none; color: inherit; border-left-width: 4px; height: 100%; transition: background .15s, transform .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.kpi:hover { background: var(--canvas); }
.kpi-label { font-size: 12px; color: var(--ink-500); font-weight: 500; }
.kpi-value { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.kpi-note { font-size: 12px; color: var(--ink-500); }
.kpi-ok { border-left-color: var(--ok); }
.kpi-warn { border-left-color: var(--due); }
.kpi-danger { border-left-color: var(--overdue); }
.kpi-danger .kpi-value { color: var(--overdue); }
.kpi-neutral { border-left-color: var(--brand-500); }

@media (max-width: 900px) {
  .projects { grid-template-columns: 1fr; }
  .projects-photo { min-height: 0; aspect-ratio: 16 / 8; }
}
@media (max-width: 560px) {
  .projects-body { padding: 20px 16px; }
  .kpis { gap: 8px; }
  .kpi { padding: 10px; border-left-width: 3px; }
  .kpi-value { font-size: 15px; }
  .kpi-note { display: none; }
  .projects-actions, .projects-actions .btn { width: 100%; }
  .projects-actions .btn { flex: 1; }
}

/* section nav */

/* panels */
.panel { padding: 22px 0 8px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 0 24px 16px; flex-wrap: wrap; }
.panel-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.panel-sub { color: var(--ink-500); font-size: 14px; margin-top: 2px; }
.panel-sub strong { color: var(--ink-900); }
.panel-foot { display: flex; justify-content: center; padding: 12px 24px 16px; }
.empty { padding: 24px; text-align: center; color: var(--ink-500); }

.segmented { display: inline-flex; padding: 3px; background: var(--canvas); border-radius: 10px; border: 1px solid var(--line); }
.segmented button { font: inherit; font-size: 13px; font-weight: 500; border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--ink-700); }
.segmented button[aria-pressed="true"] { background: var(--raised); color: var(--ink-900); box-shadow: var(--shadow-press); }

.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }

/* ---------- tables ---------- */
/* position: relative keeps screen-reader-only labels inside the scroller, so a wide table never widens the page. */
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 12px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child, .table td:last-child { padding-right: 24px; }
.table thead th { border-top: 0; font-size: 12px; font-weight: 600; color: var(--ink-500); text-transform: uppercase; letter-spacing: .04em; padding-top: 8px; padding-bottom: 8px; background: var(--table-head); }
/* Long labels wrap to a second line only when the table would otherwise be wider than its card. */
.table thead .sort { display: inline; text-align: inherit; }
.table thead .sort::after { margin-left: 4px; white-space: nowrap; }
.table tbody th { font-weight: 600; }
.table tbody tr:hover { background: var(--row-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.sort { font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.sort::after { content: "↕"; font-size: 11px; opacity: .45; }
th[aria-sort="ascending"] .sort::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] .sort::after { content: "↓"; opacity: 1; }
.sort:hover { color: var(--ink-900); }
.row-actions { text-align: right; white-space: nowrap; }
/* With the space between them, at least 6px between side-by-side row buttons (layout check). */
.row-actions > * + * { margin-left: 4px; }

.remaining { display: block; font-weight: 600; white-space: nowrap; }
.interval { display: block; font-size: 12px; color: var(--ink-500); }
.row-overdue .remaining { color: var(--overdue); }
.row-due .remaining { color: var(--due); }

.col-status { min-width: 180px; }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter { flex: 1; max-width: 140px; height: 8px; border-radius: 999px; background: var(--muted-bg); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; }
.meter-ok span { background: var(--ok); }
.meter-due span { background: var(--due-fill); }
.meter-overdue span { background: var(--overdue); }
.meter-pct { font-size: 12px; color: var(--ink-500); width: 36px; font-variant-numeric: tabular-nums; }

.message { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-700); }
.invoice-link { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; }
.invoice-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.invoice-link:hover span { text-decoration: underline; }
.amount { font-weight: 600; }
.paid-note { font-size: 13px; color: var(--ink-500); }

/* stacked-card tables on small screens */
@media (max-width: 720px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table th, .table td { display: block; }
  .table tbody tr { border-top: 1px solid var(--line); padding: 14px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
  .table tbody tr:hover { background: none; }
  .table th, .table td, .table th:first-child, .table td:first-child, .table th:last-child, .table td:last-child { border: 0; padding: 0; text-align: left; }
  .table tbody th { grid-column: 1 / -1; font-size: 15px; }
  .table .num { text-align: left; }  /* stacked cards: every label/value pair aligns the same way */
  .table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); margin-bottom: 2px; }
  .table .col-status, .table .message, .table .row-actions { grid-column: 1 / -1; }
  .col-status { min-width: 0; }
  .meter { max-width: none; }
  .message { max-width: none; white-space: normal; }
  .row-actions { text-align: left; display: flex; gap: 4px; }
  .row-actions { flex-wrap: wrap; }
  .row-actions .btn { flex: 1 1 140px; }
  .panel { padding-top: 16px; }
  .panel-head { padding: 0 16px 16px; }
  .deleted-row { padding: 14px 16px; flex-wrap: wrap; }
  .deleted-actions { width: 100%; }
  .deleted-actions .btn { flex: 1; }
}
/* narrow phones: two columns get cramped, so card details stack in one */
@media (max-width: 380px) {
  .table tbody tr { grid-template-columns: 1fr; }
}

/* ---------- people ---------- */
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.person { display: grid; flex: 1; min-width: 160px; }
.person > span { font-size: 13px; color: var(--ink-500); } /* not nested badges, so they match everywhere else */
.person-email { font-size: 14px; overflow-wrap: anywhere; }

/* ---------- history timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 4px 24px 0 24px; }
.timeline li { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-content: start; padding: 0 0 18px 22px; border-left: 2px solid var(--line); margin-left: 5px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 14px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand-500); }
.timeline li.tl-invoice::before { border-color: var(--green-600); }
.timeline li.tl-request::before { border-color: var(--due-fill); }
.timeline li > :not(.tl-when) { grid-column: 1; }
.timeline li > .tl-type { grid-column: 1 / -1; }
/* Level with the item's title and byline, not its category label. */
.tl-when { grid-column: 2; grid-row: 2 / span 2; align-self: center; display: grid; justify-items: end; align-content: center; font-size: 12px; color: var(--ink-500); line-height: 1.4; text-align: right; white-space: nowrap; }
.tl-type { font-size: 12px; color: var(--ink-500); line-height: 1.4; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.timeline p { font-weight: 600; margin: 2px 0; }
.tl-by { font-size: 13px; color: var(--ink-500); }
@media (max-width: 720px) { .people li { padding: 14px 16px; } .timeline { padding: 4px 16px 0; } }

/* ---------- footer ---------- */
.site-footer { flex-shrink: 0; background: var(--footer-bg); color: var(--footer-fg); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 8px 32px; justify-content: center; align-items: baseline; padding-top: 32px; padding-bottom: 32px; font-size: 14px; }
/* Same wordmark as the header brand: bold "CMI", regular "Aviation". */
.footer-brand { color: var(--footer-strong); font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.footer-brand strong { font-weight: 700; }
.site-footer address { font-style: normal; }
.site-footer a { color: var(--footer-strong); }
/* Phones: stack name, address and phone, centered, so nothing gets clipped. */
@media (max-width: 560px) { .footer-inner { flex-direction: column; align-items: center; gap: 6px; text-align: center; } }

/* ---------- dialogs & toast ---------- */
.dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); background: var(--surface); color: var(--ink-900); }
.dialog-sm { width: min(380px, calc(100vw - 32px)); }
.dialog::backdrop { background: var(--overlay); }
.dialog form { padding: 20px 24px 24px; display: grid; gap: 16px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { font-size: 18px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.field em { font-style: normal; color: var(--ink-500); font-weight: 400; }
.field input, .field textarea { font: inherit; font-weight: 400; padding: 9px 12px; border: 1px solid var(--ink-300); border-radius: var(--radius-sm); width: 100%; background: var(--raised); color: var(--ink-900); }
.field input[readonly] { color: var(--ink-500); background: transparent; }
.field input:focus, .field textarea:focus { border-color: var(--brand-500); outline: 3px solid var(--brand-50); }
/* Password managers and browser autofill shouldn't tint fields: the inset shadow paints over the UA's
   (often !important) autofill background, and the text keeps our ink color in both themes. */
input:not([type="checkbox"]):not([type="radio"]):autofill,
textarea:autofill { box-shadow: inset 0 0 0 1000px var(--raised); -webkit-text-fill-color: var(--ink-900); caret-color: var(--ink-900); }
input:not([type="checkbox"]):not([type="radio"]):-webkit-autofill,
textarea:-webkit-autofill { box-shadow: inset 0 0 0 1000px var(--raised); -webkit-text-fill-color: var(--ink-900); caret-color: var(--ink-900); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--inverse-bg); color: var(--inverse-fg); padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; text-align: center; z-index: 50; max-width: calc(100vw - 32px); }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

/* ---------- app additions ---------- */
body:not(.is-staff) .staff-only { display: none !important; }
body.no-add-projects [data-action="add-projects"] { display: none !important; }
.muted { color: var(--ink-500); }
.btn-block { width: 100%; }
.btn-left { margin-right: auto; }
.btn[disabled] { opacity: .6; cursor: progress; }
.link-btn { font: inherit; color: var(--brand-500); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.row-link { color: var(--ink-900); font-weight: 600; }
.icon-btn { position: relative; }
.icon-btn .count { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent-fill); color: var(--on-fill); font-size: 10px; font-weight: 700; line-height: 16px; }
.alert { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--overdue-bg); color: var(--overdue); font-size: 14px; white-space: pre-line; }
.spec-edit { align-self: end; }
.panel-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.photo-upload { position: absolute; right: 14px; bottom: 14px; }
.app-main[hidden], #projects-view[hidden] { display: none; }
#projects-view { display: grid; gap: 20px; }

/* banners */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: var(--radius); font-size: 14px; flex-wrap: wrap; }
.banner-actions { display: flex; align-items: center; gap: 4px; }
.banner-install, .banner-push { background: var(--brand-50); border: 1px solid var(--info-border); color: var(--ink-900); }
/* About to be signed out (the most a sign-in lasts): amber like things coming due. */
.banner-signout { background: var(--due-bg); border: 1px solid color-mix(in srgb, var(--due) 35%, transparent); color: var(--ink-900); }
.banner-signout strong { color: var(--due); }
/* Lives inside the sticky header, so the two stay together instead of covering each other. */
.banner-offline { border-radius: 0; justify-content: center; background: var(--inverse-bg); color: var(--inverse-fg); padding: 8px 16px; }

/* login */
.login { display: grid; place-items: center; align-content: center; padding: 32px 16px; }
.login-card { width: 100%; max-width: 420px; padding: 32px 28px; display: grid; gap: 16px; text-align: center; }
.login-card img { margin: 0 auto; }
.login-card h1 { font-size: 22px; }
.login-card .stack { text-align: left; text-wrap-style: pretty; } /* left-aligned text fills the width; balance is for the centered lines */
/* Why a sign-in ended (public/js/app.js signedOutNotice): amber like things coming due, with a clock and a bold line. */
.login-notice { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--due-bg); border: 1px solid color-mix(in srgb, var(--due) 30%, transparent); border-left: 4px solid var(--due); }
.login-notice[hidden] { display: none; }
.login-notice-icon { flex: none; color: var(--due); margin-top: 1px; }
.login-notice strong { display: block; color: var(--ink-900); font-size: 15px; }
.login-notice p { margin: 2px 0 0; color: var(--ink-700, var(--ink-900)); font-size: 14px; }
.login-install { width: 100%; max-width: 420px; margin-top: 16px; padding: 16px 20px; display: flex; align-items: center; gap: 14px; text-align: left; }
.login-install img { flex: none; border-radius: 11px; box-shadow: 0 1px 3px rgb(0 0 0 / 0.15); }
.login-install-text { flex: 1; min-width: 0; }
.login-install h2 { font-size: 16px; margin: 0; }
.login-install p { font-size: 13px; margin: 2px 0 0; }
.login-install .btn { flex: none; }
.stack { display: grid; gap: 14px; }
.fine { font-size: 13px; color: var(--ink-500); margin: 4px 0 0; }
.empty-state { padding: 40px 24px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.empty-state h1 { font-size: 22px; }

/* dialog content */
.dialog-wide { width: min(640px, calc(100vw - 32px)); }
/* The title and the buttons stay put and only the fields between them scroll, so the scrollbar runs beside the
   fields only, never up into the title or down into the buttons. The body reaches the card's edges (negative margin,
   matching padding) so its bar sits at the card's right edge and focus rings aren't clipped. */
.dialog form { max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; overflow: hidden; }
.dialog form > * { flex: none; }
.dialog-body { display: grid; gap: 14px; }
.dialog form > .dialog-body { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: -6px -24px; padding: 6px 24px; }
.dialog-intro { margin: 0; }
.dialog-section { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); margin: 6px 0 0; }
.field small { font-weight: 400; color: var(--ink-500); font-size: 12px; }
.field .dd { width: 100%; }
.field-group { display: grid; gap: 6px; }
.field-hint { font-size: 12px; color: var(--ink-500); }
.field-hint > span { display: block; text-wrap: pretty; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }
.field-stack { display: grid; gap: 8px; align-content: start; }
/* first line is box-height; the 1px drop centers the box on the text's optical middle (between cap and x-height) */
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 22px; cursor: pointer; }
.check input {
  appearance: none; -webkit-appearance: none; flex: none; width: 22px; height: 22px; margin: 1px 0 0; border-radius: 6px; cursor: pointer;
  border: 1.5px solid var(--ink-300); background: var(--raised) center / 13px 13px no-repeat; transition: background-color .15s, border-color .15s;
}
.check input:hover { border-color: var(--ink-500); }
/* white check, drawn smaller than the box so it has room around it */
.check input:checked {
  border-color: var(--accent-fill); background-color: var(--accent-fill);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E");
}
.check input:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-500) 55%, transparent); outline-offset: 2px; }
/* radio buttons share the checkbox look, round, with a dot that grows in when picked */
.check input[type="radio"] {
  border-radius: 50%; background: var(--accent-fill); box-shadow: inset 0 0 0 11px var(--raised);
  transition: border-color .15s, box-shadow .2s var(--ease-out), transform .12s var(--ease-out);
}
.check input[type="radio"]:checked { border-color: var(--accent-fill); background-image: none; box-shadow: inset 0 0 0 4.5px var(--raised); }
.check input:active { transform: scale(.88); transition-duration: .06s; }
@media (prefers-reduced-motion: reduce) { .check input:active { transform: none; } }
.check small { display: block; color: var(--ink-500); line-height: 1.45; margin-top: 1px; }
/* Staff Role dropdown under Account Type; slides in when CMI Staff is picked. */
.staff-role-field { margin: -4px 0 4px 0; max-width: 340px; animation: field-in .2s ease-out; }
@keyframes field-in { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .staff-role-field { animation: none; } }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.device-on { margin: 0; align-self: center; line-height: 1.2; color: var(--ok); font-weight: 600; font-size: 14px; }
.version-ok { margin-left: 8px; white-space: nowrap; }
.install-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 14px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.detail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 0; padding: 12px 14px; background: var(--canvas); border-radius: var(--radius-sm); }
.detail-meta dt { font-size: 12px; color: var(--ink-500); }
.detail-meta dd { margin: 2px 0 0; font-weight: 600; font-size: 14px; }
.detail-message { margin: 0; white-space: pre-wrap; line-height: 1.6; }
.attachments { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.attachments li, .attachments a { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.attachments img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.attachments svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: none; }
.attachments small { color: var(--ink-500); margin-left: 4px; }
.edit-files li { justify-content: space-between; gap: 12px; }
.edit-files li > a { min-width: 0; }
.edit-files li > a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-files .check { flex: none; font-weight: 400; }
.ai-box { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px dashed var(--ai-border); background: var(--ai-bg); display: grid; gap: 6px; font-size: 14px; }
.ai-box p { margin: 0; }
.ai-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-600); }
.toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
.theme-picker { justify-self: start; }

/* ---------- pages ---------- */
/* Title on the left, the page's Add button at the top right, level with the title (phones too).
   The title never wraps: when the two don't fit side by side, the button shrinks instead (see data-fit below). */
.page-head { display: flex; flex-wrap: wrap; align-items: center; column-gap: 16px; padding: 0 2px; }
.page-head > div:first-child { display: contents; }
.page-head .eyebrow, .page-head .panel-sub { flex-basis: 100%; }
.page-head h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; text-wrap: balance; margin-top: 4px; flex: 1 0 min-content; order: 1; }
.page-head .panel-sub { margin-top: 6px; order: 3; }
/* negative margins keep the taller button from pushing the title away from its eyebrow */
.page-actions { order: 2; display: flex; gap: 8px; margin-block: -10px; }
.page-head:has(.page-actions) h1 { white-space: nowrap; flex-basis: auto; }
/* Add buttons shrink in steps when space runs out (fitPageHeads sets data-fit):
   1 drops the qualifier ("Add Request"), 2 leaves "Add", 3 is a "+" icon button. */
.btn-plus { display: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.page-head:is([data-fit="1"], [data-fit="2"]) .btn-extra, .page-head[data-fit="2"] .btn-target { display: none; }
.page-head[data-fit="3"] .btn-text { display: none; }
.page-head[data-fit="3"] .btn-plus { display: block; }
.page-head[data-fit="3"] .page-actions .btn { width: 44px; height: 44px; padding: 0; border-radius: 10px; }
.page-head.is-stacked .page-actions { margin-block: 8px 0; }
@media (max-width: 420px) {
  .page-head { column-gap: 10px; }
  .page-actions .btn { padding-left: 12px; padding-right: 12px; }
}
.page-actions:empty { display: none; }
[data-route="overview"] .full-only, body:not([data-route="overview"]) .compact-only { display: none !important; }
/* tools that only hold overview links leave no empty row (and extra space) under the intro on list pages */
body:not([data-route="overview"]) .panel-tools:not(:has(> :not(.compact-only))) { display: none; }
[data-route="schedule"] #schedule-title, [data-route="requests"] #requests-title, [data-route="invoices"] #invoices-title { display: none; }
[data-route="overview"] .table .sort { pointer-events: none; }
[data-route="overview"] .table .sort::after { display: none; }
.view-all { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; text-decoration: none; padding: 6px 2px; white-space: nowrap; }
/* Trailing "go" arrows ("View", "All Requests", CMI AI's link chips): an SVG in the text color, centered on the
   text line by its flex row, never the → glyph, which sits low in some phone fonts. */
.go-arrow, .view-all::after, .dcard-more::after { content: ""; flex: none; width: 1em; height: 1em; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8h10M9 4l4 4-4 4' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8h10M9 4l4 4-4 4' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
.go-arrow { display: inline-block; }
.view-all:hover { text-decoration: underline; }
.primary-nav > a[aria-current="page"] { color: var(--brand-600); background: var(--brand-50); }

/* contact */
.contact-page { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.contact-page .contact-card:last-child { grid-column: 1 / -1; }
.contact-list { margin: 0; padding: 0 24px 16px; display: grid; gap: 18px; }
.contact-list dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); }
.contact-list dd { margin: 4px 0 0; display: flex; gap: 8px 16px; align-items: center; }
.contact-list dd > :first-child { min-width: 0; }
.contact-list dd > .quick-actions { flex-wrap: nowrap; }
.contact-list address { font-style: normal; }
.contact-big { font-size: min(24px, 5.8vw); white-space: nowrap; font-weight: 700; letter-spacing: -.01em; text-decoration: none; color: var(--ink-900); font-variant-numeric: tabular-nums; user-select: all; }
.contact-cta { padding: 0 24px 20px; }
@media (max-width: 720px) {
  .contact-page { grid-template-columns: 1fr; }
  .contact-list, .contact-cta { padding-left: 16px; padding-right: 16px; }
  .page-head h1 { font-size: 24px; }
}

/* bottom tab bar (phones) */
.tabbar { display: none; }
@media (max-width: 860px) {
  .tabbar:not([hidden]) {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--header-bg); backdrop-filter: saturate(1.4) blur(10px); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 4px 0; font-size: 11px; font-weight: 500; color: var(--ink-500); text-decoration: none; border-radius: var(--radius-sm); }
  .tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a[aria-current="page"] { color: var(--brand-600); }
  .tabbar a[aria-current="page"] svg { stroke-width: 2.2; }
  /* labels never run into each other: a little smaller on narrow phones, icons only when there's no room at all */
  .tabbar a span { max-width: 100%; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body:has(.tabbar:not([hidden])) { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
  body:has(.tabbar:not([hidden])) .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 359px) {
  /* tabs size to their labels here, so the long one ("Schedule") gets the room it needs */
  .tabbar:not([hidden]) { display: flex; justify-content: space-between; padding-inline: 4px; }
  .tabbar a { flex: 1 1 auto; }
  .tabbar a span { font-size: 10px; padding: 0 1px; overflow: visible; }
}
@media (max-width: 299px) {
  .tabbar a { padding: 10px 0; }
  .tabbar a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tabbar svg { width: 24px; height: 24px; }
}
.primary-nav > a, .account-name { white-space: nowrap; }
@media (max-width: 1240px) {
  .primary-nav > a { padding: 8px 9px; }
  .account-name { display: none; }
  .account { margin-left: 6px; padding-left: 10px; }
}
/* Between phone and full nav widths the nav links need the room; phones (tab bar) have room for the name. */
@media (min-width: 861px) and (max-width: 1040px) { .brand-text { display: none; } }

/* ---------- dashboard ---------- */
.dashboard { display: grid; gap: 20px; }
.dashboard[hidden] { display: none; }
.section-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 4px 2px 12px; }
.text-overdue { color: var(--overdue); }

.attention { list-style: none; margin: 0; padding: 0; }
.attention-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "kind badge" "title badge" "detail badge"; align-items: center; column-gap: 12px;
  width: 100%; text-align: left; font: inherit; color: inherit; background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 24px 12px 21px; cursor: pointer; border-left: 3px solid transparent; }
.attention-item:hover { background: var(--row-hover); }
.attention-item.tone-overdue { border-left-color: var(--overdue); }
.attention-item.tone-due { border-left-color: var(--due-fill); }
.attention-item.tone-info { border-left-color: var(--brand-500); }
.attention-kind { grid-area: kind; font-size: 12px; color: var(--ink-500); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.attention-item strong { grid-area: title; font-weight: 600; }
.attention-detail { grid-area: detail; font-size: 13px; color: var(--ink-500); }
.attention-item .badge { grid-area: badge; }
.card-empty { flex: 1; display: flex; align-items: center; gap: 10px; padding: 18px 24px 22px; border-top: 1px solid var(--line); color: var(--ink-500); font-weight: 600; }
.card-empty-ok { color: var(--ok); }
.card-empty svg, .can-list svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.account-card { display: grid; gap: 16px; padding: 0 24px 22px; }
.account-id { display: flex; align-items: center; gap: 12px; }
.account-id .person span { overflow-wrap: anywhere; }
.access { margin: 0; display: grid; gap: 14px; }
.access dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); }
.access dd { margin: 4px 0 0; font-size: 14px; }
.can-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.can-list li { display: flex; gap: 8px; align-items: flex-start; }
.can-list svg { color: var(--ok); margin-top: 1px; }

.signin-list { list-style: none; margin: 0; padding: 0; }
.signin-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 24px; border-top: 1px solid var(--line); }
.signin-info { display: grid; justify-items: start; gap: 4px; min-width: 0; font-size: 14px; }
.signin-info strong { font-size: 15px; overflow-wrap: anywhere; }
.signin-info strong .muted { font-weight: 500; font-size: 14px; }
.signin-email { -webkit-user-select: all; user-select: all; }
.signin-meta { color: var(--ink-500); font-size: 13px; overflow-wrap: anywhere; }
.signin-list li.empty { padding: 24px; text-align: center; color: var(--ink-500); border-top: 1px solid var(--line); }
.signin-row .tl-when { grid-row: auto; }
@media (max-width: 720px) { .signin-row { padding: 14px 16px; } }
/* A panel that folds away to its header (Sign-In Activity): the whole header toggles it, the chevron turns, and the body
   slides open from 0fr to 1fr. The subtitle carries the quick summary while it is closed. */
.fold-head { align-items: center; cursor: pointer; flex-wrap: nowrap; }
.fold-head .chips { cursor: auto; flex: none; }
.fold-title { flex: 1; min-width: 0; }
.fold-btn { flex: none; width: 38px; height: 38px; border-radius: 999px; }
.fold-btn svg { width: 20px; height: 20px; stroke-width: 2; transition: transform .3s var(--ease-out); }
@media (hover: hover) { .fold-head:hover .fold-btn { background: var(--canvas); color: var(--ink-900); } }
.fold-btn:active { transform: scale(.92); }
.fold.is-open .fold-btn svg { transform: rotate(180deg); }
.fold-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s var(--ease-out); }
.fold-body > div { min-height: 0; overflow: hidden; opacity: 0; transition: opacity .2s; }
.fold.is-open .fold-body { grid-template-rows: 1fr; }
.fold.is-open .fold-body > div { opacity: 1; transition-delay: .06s; }
.fold:not(.is-open) { padding-bottom: 6px; }
@media (max-width: 720px) {
  .fold-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; align-items: center; }
  .fold-title { display: contents; }
  .fold-head h2 { grid-area: 1 / 1; }
  .fold-head .panel-sub { grid-area: 2 / 1 / 3 / -1; }
  .fold-head .chips { grid-area: 3 / 1 / 4 / -1; margin-top: 14px; }
  .fold-head .fold-btn { grid-area: 1 / 2; margin-right: -6px; }
}
.deleted-list { list-style: none; margin: 0; padding: 0; }
.deleted-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; border-top: 1px solid var(--line); }
.deleted-info { display: grid; gap: 2px; min-width: 0; font-size: 14px; }
.deleted-info strong { font-size: 15px; }
.deleted-left { color: var(--ink-500); font-size: 13px; }
.deleted-actions { display: flex; gap: 8px; flex: none; }
.deleted-left.is-soon { color: var(--due); font-weight: 500; }
.portfolio { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.portfolio-card { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; width: 100%; height: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; padding: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.portfolio-card img { width: 100%; aspect-ratio: 16 / 7; object-fit: cover; background: var(--photo-bg); }
.portfolio-body { display: grid; gap: 8px; padding: 14px 16px; align-content: start; min-width: 0; }
.portfolio-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 6px 8px; }
/* when the name and role tag can't share a line, the tag drops under the name instead of running off the card */
.portfolio-head strong { font-size: 16px; flex: 1 1 140px; }
.portfolio-head .tag { flex: none; }
.portfolio-stats { display: grid; gap: 6px; font-size: 14px; }
/* each value starts on its label's line; anything under it stacks below */
.portfolio-stats > span { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; min-height: 26px; }
.portfolio-stats > span > :last-child { text-align: right; font-variant-numeric: tabular-nums; }
.portfolio-label { flex: none; }
.portfolio-value { display: grid; justify-items: end; min-width: 0; }
.portfolio-value > span { font-size: 13px; color: var(--ink-500); }
.portfolio-value > span.text-overdue { color: var(--overdue); }
.portfolio-label { color: var(--ink-700); }
/* narrow cards: every label sits above its value, and a badge gets its own line under that (like the stacked table cards) */
.portfolio-body { container-type: inline-size; }
@container (max-width: 230px) {
  .portfolio-stats { gap: 12px; }
  .portfolio-stats > span { flex-direction: column; align-items: flex-start; gap: 2px; min-height: 0; }
  .portfolio-stats > span > :last-child { text-align: left; }
  .portfolio-stats .portfolio-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); }
  .portfolio-value { justify-items: start; }
}

@media (max-width: 900px) {
}
@media (max-width: 720px) {
  .attention-item { padding-left: 13px; padding-right: 16px; }
  .account-card { padding: 0 16px 18px; }
  .card-empty { padding: 16px; }
  .portfolio { grid-template-columns: 1fr; }
}

/* role tags are labels, not statuses: no status dot */
.tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--brand-50); color: var(--brand-600); white-space: nowrap; }
.access-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.access-list li { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

/* empty states look the same in every list */
.timeline li.empty, .people li.empty { display: block; border: 0; margin: 0; padding: 24px; text-align: center; color: var(--ink-500); }
.timeline li.empty::before { display: none; }

/* ---------- projects area: back link, picker, sub-tabs ---------- */
.projects-bar { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px 16px; }
.back-link { font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.back-link::before { content: "← "; }
.back-link:hover { text-decoration: underline; }
.projects-bar .projects-picker { justify-self: start; }
.projects-bar .projects-picker .dd-trigger { font-size: 16px; font-weight: 700; max-width: min(420px, 100%); }
.subnav { grid-column: 1 / -1; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { flex: none; padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--ink-500); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--ink-900); }
.subnav a[aria-current="page"] { color: var(--brand-600); border-bottom-color: var(--green-600); }
/* The project name shows in the picker; the page sections carry their own titles. */
body:not([data-route="overview"]) #schedule-title, body:not([data-route="overview"]) #requests-title, body:not([data-route="overview"]) #invoices-title { display: none; }

/* ---------- dashboard: compact projects list ---------- */
.portfolio-mini { list-style: none; margin: 0; padding: 0; }
.portfolio-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: inherit;
  background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 24px; cursor: pointer; }
.portfolio-row:hover { background: var(--row-hover); }
.portfolio-row-name { display: grid; min-width: 0; }
.portfolio-row-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-row-name span { font-size: 13px; color: var(--ink-500); }
.portfolio-row-bal { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
.portfolio .empty-state { list-style: none; }
/* an empty or no-results notice in a card grid spans the whole content width, not one card cell */
.portfolio > .empty-state, .portfolio > .empty { grid-column: 1 / -1; }

/* projects list page */
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#list-head .page-actions { align-items: flex-end; }
.search input { font: inherit; font-size: 14px; padding: 8px 12px; border: 1px solid var(--ink-300); border-radius: var(--radius-sm); background: var(--raised); color: var(--ink-900); width: min(280px, 100%); }
.search input:focus { border-color: var(--brand-500); outline: 3px solid var(--brand-50); }

/* ---------- profile ---------- */
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
/* Each column stacks on its own so a tall card never leaves a gap beside it. */
.profile-col { display: grid; gap: 20px; align-content: start; min-width: 0; }
.profile-body { display: grid; gap: 14px; padding: 0 24px 22px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 220px; }

/* ---------- offline: waiting changes ---------- */
.sync-panel { border: 1px solid var(--info-border); background: var(--brand-50); border-radius: var(--radius); padding: 12px 16px; display: grid; gap: 8px; font-size: 14px; }
.sync-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.sync-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sync-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface); }
.sync-list li > span:first-child { display: grid; }
.sync-list .is-failed { box-shadow: inset 3px 0 0 var(--overdue); }
.sync-error { color: var(--overdue); font-size: 13px; }
.sync-list .is-conflict { box-shadow: inset 3px 0 0 var(--due); }
.sync-conflict { font-size: 13px; color: var(--muted); }

@media (max-width: 900px) {
  .profile-grid { grid-template-columns: 1fr; }
  /* One column: drop the column wrappers and keep the original reading order. */
  .profile-col { display: contents; }
  .profile-profile { order: 1; } .profile-access { order: 2; } .profile-notifications { order: 3; } .profile-appearance { order: 4; } .profile-app { order: 5; }
}
@media (max-width: 720px) {
  .portfolio-row { padding: 12px 16px; grid-template-columns: minmax(0, 1fr) auto; }
  .portfolio-row-bal { grid-column: 2; min-width: 0; }
  .profile-body { padding: 0 16px 18px; }
  .projects-bar { grid-template-columns: 1fr; }
  .projects-bar .projects-picker .dd, .projects-bar .projects-picker .dd-trigger { max-width: 100%; width: 100%; }
}

@media (max-width: 720px) { main.container { padding-top: 12px; } }

/* Design-preview strip: part of the page, scrolls away (never covers the sticky header). */
.banner-preview { justify-content: center; border-radius: 0; background: #566220; color: #ffffff; padding: 8px 16px; }

/* ---------- list pages: projects column ---------- */
.table:not(.show-projects) .col-projects { display: none; }
.table td.col-projects { font-weight: 600; }
.table td.col-projects span { white-space: nowrap; }
/* Items not linked to a project yet: a muted "No project" and, for staff who can, Link to Project under it. */
.table td.col-projects .no-projects { color: var(--ink-500); font-weight: 500; }
.link-projects { display: block; margin-top: 2px; font-size: 13px; font-weight: 600; white-space: nowrap;
  text-decoration: underline dashed 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); }
.link-projects:hover { text-decoration-style: solid; text-decoration-color: currentColor; }

/* ---------- list pages: search field, with sort and filter icon buttons that open their panels ---------- */
.filter-card { padding: 14px; display: grid; }
.find-row { display: flex; gap: 8px; align-items: center; }
.find-search { position: relative; flex: 1; min-width: 0; }
.find-search input { font: inherit; width: 100%; min-width: 0; height: 44px; padding: 0 12px 0 40px; border: 1px solid var(--ink-300); border-radius: 10px; background: var(--raised); color: var(--ink-900); }
.find-search input:focus { border-color: var(--brand-500); outline: 3px solid var(--brand-50); }
.find-icon { position: absolute; left: 13px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--ink-500); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.find-btn {
  position: relative; flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 10px;
  border: 1px solid var(--ink-300); background: var(--raised); color: var(--ink-700); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .12s var(--ease-out), box-shadow .15s;
}
.find-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s var(--ease-out); }
.find-btn:hover { border-color: var(--ink-500); color: var(--ink-900); box-shadow: var(--shadow-press); }
.find-btn:active { transform: scale(.92); transition-duration: .06s; }
.find-btn[aria-expanded="true"] { background: var(--brand-50); border-color: var(--brand-500); color: var(--brand-600); }
/* a non-default sort or any filter keeps the button tinted, with a dot or a count */
.find-btn.is-active { color: var(--brand-600); border-color: var(--brand-500); }
.find-btn .count, .find-dot {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent-fill); color: var(--on-fill); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface); animation: badge-pop .28s var(--ease-out);
}
.find-dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: -3px; right: -3px; }
.find-btn .count[hidden], .find-dot[hidden] { display: none; }
@keyframes badge-pop { from { transform: scale(0); } 60% { transform: scale(1.2); } }

/* very small phones: search is an icon button too, and its field opens in a panel below the row */
.find-row:not(.is-compact) .find-search-toggle { display: none; }
.find-row.is-compact .find-btn { flex: 1 1 0; width: auto; }
.find-panel .find-search { display: block; }
/* the clipped panel reaches 3px past the row so the field lines up with the buttons and its focus ring still shows */
.find-panel:has(> .find-panel-body > .find-search) .find-panel-body { margin-inline: -3px; padding: 0 3px 3px; }

/* panels slide open below the search row; only one is open at a time */
.find-panel { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .28s var(--ease-out), opacity .2s; }
.find-panel.is-open { grid-template-rows: 1fr; opacity: 1; }
.find-panel-body { min-height: 0; overflow: hidden; }
/* the space above a panel is part of it, so a closed panel takes no room */
.find-panel-body::before { content: ""; display: block; height: 14px; }
.find-panel-body { transform: translateY(-6px); transition: transform .28s var(--ease-out); }
.find-panel.is-open .find-panel-body { transform: none; }
.find-label { font-size: 13px; font-weight: 600; color: var(--ink-500); margin: 0 0 8px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-content: start; }
.filter-grid::before { grid-column: 1 / -1; height: 2px; }
.filter-card .field { gap: 4px; font-size: 13px; color: var(--ink-500); font-weight: 600; }
.filter-card .field[hidden] { display: none; }
.filter-grid .dd { width: 100%; }
.filter-card .dd-trigger { min-width: 0; }
.filter-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; margin-top: 12px; padding: 0 2px; }
.filter-foot:not(:has(> :not([hidden]))) { display: none; }

/* sort choices: app-styled pills, the picked one filled with a check */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--ink-300); background: var(--raised); color: var(--ink-700); font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .12s var(--ease-out), padding .2s var(--ease-out); -webkit-user-select: none; user-select: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:hover { border-color: var(--ink-500); color: var(--ink-900); }
.chip:active { transform: scale(.95); transition-duration: .06s; }
.chip::before { content: ""; width: 0; height: 14px; margin-right: -6px; background: currentColor; transition: width .2s var(--ease-out), margin .2s var(--ease-out);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E") center / contain no-repeat; }
.chip:has(input:checked) { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-fill); }
.chip:has(input:checked)::before { width: 14px; margin-right: 0; }
.chip:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand-500) 55%, transparent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .find-panel, .find-panel-body, .find-btn svg, .chip, .chip::before { transition: none; }
  .find-btn .count, .find-dot { animation: none; }
  .find-btn:active, .chip:active { transform: none; }
}

/* ---------- people: phone above email ---------- */
.person-contact { display: grid; justify-items: end; gap: 2px; text-align: right; }
.person-phone { font-weight: 600; text-decoration: none; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.person-phone > span { user-select: all; }
.person-phone:hover > span, .person-email:hover > span { text-decoration: underline; }
/* A small phone or envelope before the number and email says a tap calls or writes. */
.person-phone, .person-email { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.person-phone svg, .person-email svg { width: 14px; height: 14px; flex: none; fill: none; stroke: var(--ink-500); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.person-email > span { min-width: 0; overflow-wrap: anywhere; }

/* ---------- quick actions: round icon buttons (Call, Text, Email, Directions, Copy) ---------- */
.quick-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qa { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; padding: 0; border: 0; border-radius: 999px;
  background: var(--brand-50); color: var(--brand-600); cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent;
  transition: background .15s, color .15s, box-shadow .2s var(--ease-out), transform .2s var(--ease-out); }
.qa > svg, .qa > span { grid-area: 1 / 1; display: grid; place-items: center; }
.qa svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.qa .qa-ico, .qa .qa-done, .btn-copy .qa-ico, .btn-copy .qa-done { transition: opacity .15s, transform .25s var(--ease-out); }
.qa .qa-done { opacity: 0; transform: scale(.4); }
.qa.is-copied { background: var(--ok-bg); color: var(--ok); }
.qa.is-copied .qa-ico { opacity: 0; transform: scale(.4) rotate(-20deg); }
.qa.is-copied .qa-done { opacity: 1; transform: none; }
.qa:active { transform: scale(.9); box-shadow: none; transition-duration: .06s; }
.qa:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
/* The name of the action floats above it on hover or keyboard focus, and "Copied" shows there after a copy. */
.qa::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; z-index: 5; padding: 5px 9px; border-radius: 6px;
  background: var(--inverse-bg); color: var(--inverse-fg); font-size: 12px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  box-shadow: var(--shadow-menu); opacity: 0; pointer-events: none; transform: translate(-50%, 4px); transition: opacity .15s, transform .2s var(--ease-out); }
.qa:focus-visible::after, .qa.is-copied::after { opacity: 1; transform: translate(-50%, 0); }
.qa.is-copied::after { content: "Copied"; }
/* The last button's label lines up with its right edge, so it never pokes past a right-aligned row (a dialog would scroll
   sideways for it, even while it's hidden). */
.quick-actions > .qa:last-child::after { left: auto; right: 0; transform: translate(0, 4px); }
.quick-actions > .qa:last-child:is(:focus-visible, .is-copied)::after { transform: none; }
@media (hover: hover) {
  .qa:hover { background: var(--accent-fill); color: var(--on-fill); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
  .qa:hover::after { opacity: 1; transform: translate(-50%, 0); }
  .quick-actions > .qa:last-child:hover::after { transform: none; }
  .qa.is-copied:hover { background: var(--ok-bg); color: var(--ok); }
}
/* Text buttons that copy (the sign-in code) show the same copy icon, turning into a check once copied. */
.btn-copy { display: inline-flex; align-items: center; gap: 6px; }
.btn-copy svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.copy-swap { display: inline-grid; flex: none; }
.copy-swap > span { grid-area: 1 / 1; display: grid; place-items: center; }
.btn-copy .qa-done { opacity: 0; transform: scale(.4); }
.btn-copy.is-copied .qa-ico { opacity: 0; transform: scale(.4); }
.btn-copy.is-copied .qa-done { opacity: 1; transform: none; color: var(--ok); }
.person-card-side .quick-actions { justify-content: flex-end; }
@media (max-width: 720px) { .person-card-side .quick-actions { justify-content: flex-start; } }
/* A single contact line (an email alone, a number, an address) has its quick actions inline right beside it, never on a
   line of their own; the text gives way first (an email breaks after the @). Two or more lines stacked (phone above
   email) share one row of buttons under them. */
.contact-qa { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.contact-qa > .person-email { min-width: 0; }
.contact-qa > .person-email > span { overflow-wrap: break-word; }
.contact-qa > .quick-actions { flex-wrap: nowrap; }
@media (max-width: 720px) { .contact-qa { justify-content: flex-start; } }
.menu-mobile-only { display: none !important; }
@media (max-width: 860px) { .menu .menu-mobile-only { display: flex !important; } }
@media (max-width: 720px) {
  .person-contact { justify-items: start; text-align: left; flex-basis: 100%; padding-left: 52px; }
  .table tbody th { order: -1; }
  .filter-card { padding: 12px; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- six-slot code input ---------- */
.otp { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
/* the real input sits over the slots, invisible, so typing, paste and SMS/email auto-fill all work */
.otp input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; border: 0; padding: 0; cursor: text; z-index: 1; }
.otp-cell { height: 52px; display: grid; place-items: center; border: 1px solid var(--ink-300); border-radius: var(--radius-sm); background: var(--raised);
  font-size: 24px; font-weight: 700; color: var(--ink-900); font-variant-numeric: tabular-nums; transition: border-color .15s, box-shadow .15s; }
.otp-cell:not(.filled)::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-300); }
.otp-cell.active { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-50); }
.otp-cell.active:not(.filled)::after { width: 2px; height: 26px; border-radius: 1px; background: var(--brand-500); animation: otp-caret 1s steps(1) infinite; }
@keyframes otp-caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .otp-cell.active:not(.filled)::after { animation: none; } }
.field > label[for] { font-size: 14px; font-weight: 500; }
.otp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 22px; }
.otp-paste { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; font-size: 14px; font-weight: 600; white-space: nowrap; }
.otp-paste svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- profile editor ---------- */
img.avatar { object-fit: cover; padding: 0; background: var(--brand-50); }
.avatar-xl { width: 72px; height: 72px; font-size: 24px; }
.photo-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.photo-actions { display: grid; gap: 6px; }
.email-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.email-row > div { display: grid; min-width: 0; }
.email-row strong { overflow-wrap: anywhere; }

/* summary cards that open a page */
a.kpi { position: relative; cursor: pointer; }
.kpi-go { display: inline-flex; align-items: center; gap: 3px; justify-self: start; font-size: 12px; font-weight: 600; color: var(--brand-500); margin-top: 2px; }

/* ---------- People ---------- */
.panel-actions { display: inline-flex; align-items: center; gap: 12px; }
.pending-note { font-style: normal; color: var(--due); font-weight: 600; }
/* clip, not hidden: hidden makes the card a scroller, and the column header couldn't stay pinned under the app header. */
.directory-card { padding: 0; overflow: clip; }
.directory { list-style: none; margin: 0; padding: 0; }
/* One grid for the header and every row, so names, projects, contacts and statuses line up row to row. */
.directory-head, .dir-row { display: grid; grid-template-columns: 44px minmax(170px, 1.2fr) minmax(200px, 1.2fr) minmax(170px, 1fr) 140px 92px; gap: 16px; align-items: center; padding: 14px 24px; }
.directory-head { padding-top: 12px; padding-bottom: 12px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-500); background: var(--canvas); }
/* The column header row stays under the app header while the list scrolls past, like table headers (sticky-head.js). */
.directory-head { position: sticky; top: var(--sticky-head-top, 0px); z-index: 2; transition: box-shadow .15s ease; }
.directory-head.is-stuck { box-shadow: inset 0 -1px 0 var(--line), 0 6px 8px -6px rgb(0 0 0 / .18); }
.dir-row { border-top: 1px solid var(--line); }
.dir-row.is-disabled > :not(.dir-open) { opacity: .6; }
.dir-name { display: grid; gap: 2px; min-width: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.dir-name strong { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.dir-name:hover strong { text-decoration: underline; }
.dir-name > span { font-size: 13px; color: var(--ink-500); overflow-wrap: anywhere; }
.dir-projects { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; min-width: 0; }
.dir-projects li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dir-ac { min-width: 0; overflow-wrap: anywhere; }
.dir-projects .tag { flex-shrink: 0; }
.dir-row .person-contact { justify-items: start; text-align: left; min-width: 0; }
.dir-open { justify-self: end; }
.dir-status { display: grid; justify-items: start; gap: 4px; min-width: 0; }
.last-active { font-size: 12px; color: var(--ink-500); }
.person-card-status .last-active { font-size: 13px; }
.app-use { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.app-use svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app-use.is-browser { color: var(--ink-500); }
.app-versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.app-versions li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; color: var(--ink-700); }
.app-device { white-space: nowrap; }
.app-versions svg, .device-list svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--ink-500); }
.app-versions .badge { padding: 1px 8px; font-size: 11px; }
.device-list { list-style: none; margin: 0 0 4px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.device-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.device-side { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
@media (max-width: 520px) {
  .device-list li { grid-template-columns: auto minmax(0, 1fr); }
  .device-list li .device-side { grid-column: 2; justify-content: flex-start; }
}
.device-list li:first-child { border-top: 0; }
.device-list svg { width: 20px; height: 20px; }
.device-what { display: grid; min-width: 0; }
.device-what small { font-size: 12px; color: var(--ink-500); }
.device-what small > span { display: block; }
.act-tabs { margin: 0 0 12px; }
.act-find { margin: 0 0 14px; }
.act-find .filter-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.act-path .act-hit { border-color: var(--brand-500); background: var(--brand-50); }
.act-body { min-height: 40px; }
.act-timeline { padding: 4px 0 0 0; }
.act-timeline q { quotes: "“" "”"; }
.act-changes { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; gap: 2px; font-size: 14px; grid-column: 1; }
.timeline .act-changes li { padding: 0; border: 0; margin: 0; display: block; overflow-wrap: anywhere; }
.timeline .act-changes li::before { content: none; }
.act-field { color: var(--ink-500); }
.act-nw { white-space: nowrap; }
.act-changes del { color: var(--ink-500); }
.act-changes ins { text-decoration: none; font-weight: 600; color: var(--ink-900); }
.act-more { margin: 0 0 8px; }
.act-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
.act-sum > div { display: grid; gap: 2px; align-content: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.act-sum strong { font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.act-sum span { font-size: 12px; color: var(--ink-500); }
.act-visits { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.act-visit { padding: 10px 14px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.act-visit-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin: 0 0 8px; font-size: 14px; }
.act-visit-head time { color: var(--ink-500); font-size: 13px; }
.act-path { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.act-path li { font-size: 13px; line-height: 1.3; padding: 4px 10px; border-radius: 999px; background: var(--canvas); border: 1px solid var(--line); overflow-wrap: anywhere; }
.act-path li small { color: var(--ink-500); margin-left: 6px; font-size: 12px; white-space: nowrap; }
.act-path .act-tap, .act-path .act-dialog { border-style: dashed; }
.act-path .act-save { border-color: var(--green-600); }
.act-path .act-cancel { border-color: var(--due-fill); }
.act-path .act-pause { background: none; color: var(--ink-500); }
.act-note { margin: 4px 0 0; }
.act-signins { border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 0 8px; }
.act-signins .signin-row { padding: 10px 14px; }
.act-signins .signin-row:first-child { border-top: 0; }
@media (max-width: 500px) { .act-sum strong { font-size: 16px; } .act-sum > div { padding: 8px 10px; } }
.person-card-status .fine { margin: 0; }
/* Company / portfolio headings in the People list: a band across the whole row. */
/* Pinned under the column header (or the app header on phones, where there's no column header) while its people scroll past;
   the next group's heading slides over it. --dir-head-h comes from sticky-head.js. */
.dir-group { position: sticky; top: calc(var(--sticky-head-top, 0px) + var(--dir-head-h, 0px)); z-index: 1; display: flex; align-items: center; gap: 10px; padding: 12px 24px; border-top: 1px solid var(--line); background: var(--canvas); }
.dir-group h3 { margin: 0; font-size: 15px; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.dir-group-count { margin-left: auto; font-size: 13px; color: var(--ink-500); white-space: nowrap; }
.dir-name > .dir-also { font-size: 12px; font-style: italic; }
.find-label-next { margin-top: 14px; }
@media (max-width: 1000px) { .dir-group { padding: 12px 16px; } }
.directory .empty { display: block; padding: 32px 24px; text-align: center; color: var(--ink-500); border-top: 1px solid var(--line); }
@media (max-width: 1000px) {
  .directory-head { display: none; }
  .dir-row { grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "av name open" ". status status" ". ac ac" ". contact contact"; row-gap: 10px; padding: 16px; }
  .dir-row > .avatar { grid-area: av; }
  .dir-name { grid-area: name; }
  .dir-open { grid-area: open; }
  .dir-projects { grid-area: ac; }
  .dir-row .person-contact { grid-area: contact; padding-left: 0; flex-basis: auto; }
  .dir-status { grid-area: status; justify-self: start; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
  .dir-status .app-versions { flex-basis: 100%; }
}

.person-card { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.person-card .person { gap: 2px; }
.person-card-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.person-card-side { margin-left: auto; display: grid; justify-items: end; gap: 10px; }
@media (max-width: 720px) {
  .person-card-side { margin-left: 0; flex-basis: 100%; justify-items: start; padding-left: 52px; }
  .person-card-side .person-contact { padding-left: 0; }
}
.person-card-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
@media (max-width: 720px) { .person-card-actions { justify-content: flex-start; } }

/* shared sign-in code: made on screen for staff to text or read to someone whose emails aren't arriving */
.alert-info { background: var(--info-bg); color: var(--info); }
.code-length { border: 0; padding: 0; margin: 0; min-width: 0; }
.code-length legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 500; }
.shared-code { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px;
  border: 1px solid var(--info-border); background: var(--brand-50); border-radius: var(--radius); }
.shared-code-digits { font-size: 34px; font-weight: 700; letter-spacing: .08em; font-variant-numeric: tabular-nums; color: var(--ink-900);
  -webkit-user-select: all; user-select: all; }
.shared-code-digits > span { display: inline-block; width: .35em; }
.shared-code-until { margin: 0; }
.shared-code-message { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.shared-code-text { margin: 0; font-size: 14px; color: var(--ink-700); -webkit-user-select: text; user-select: text; }
.shared-code-send { display: flex; flex-wrap: wrap; gap: 8px; }

.person-section h3, .person-section-title { font-size: 15px; margin: 4px 0 8px; }
.person-section .fine { margin: 0 0 8px; }
.grant-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.grant-list li { display: grid; grid-template-columns: minmax(0, 1fr) 150px 36px; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; border-top: 1px solid var(--line); min-height: 52px; }
.grant-list li:first-child { border-top: 0; }
.grant-list li.empty { display: block; color: var(--ink-500); min-height: 0; padding: 14px; }
.grant-list .dd { width: 100%; }
.grant-list .tag { justify-self: start; }
.access-ac { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.access-portfolio { white-space: normal; }
.access-portfolio small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-500); overflow: hidden; text-overflow: ellipsis; }
.grant-all { background: var(--table-head); }
.access-add { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; gap: 12px; align-items: end; margin-top: 12px; }
.access-add:empty { display: none; }
.access-add .dd { width: 100%; }
@media (max-width: 520px) {
  .grant-list li { grid-template-columns: minmax(0, 1fr) 120px 36px; padding-left: 12px; }
  .access-add { grid-template-columns: 1fr 1fr; }
  .access-add .btn { grid-column: 1 / -1; }
}
.person-open, .dir-open { min-width: 80px; justify-content: center; }

/* Roles & permissions: controls the signed-in person can't use on this page */
.no-perm { display: none !important; }

/* On-page assignment in a project's People card: one grid so every row lines up. */
#people-list .crew-row { display: grid; grid-template-columns: 44px minmax(0, 1.2fr) 150px minmax(0, 1fr) 36px; align-items: center; gap: 14px; flex-wrap: nowrap; }
.crew-role .dd { width: 100%; }
.crew-role .tag { justify-self: start; }
#people-list .crew-row .person-contact { justify-items: end; text-align: right; padding-left: 0; flex-basis: auto; }
.crew-spacer { width: 36px; }
@media (max-width: 720px) {
  #people-list .crew-row { grid-template-columns: 44px minmax(0, 1fr) 36px; grid-template-areas: "av name x" ". role role" ". contact contact"; row-gap: 8px; }
  #people-list .crew-row > .avatar { grid-area: av; }
  #people-list .crew-row > .dir-name { grid-area: name; }
  #people-list .crew-row > .crew-role { grid-area: role; }
  #people-list .crew-row > .person-contact { grid-area: contact; justify-items: start; text-align: left; }
  #people-list .crew-row > .icon-btn, #people-list .crew-row > .crew-spacer { grid-area: x; }
}

/* Add bands at the foot of the overview cards (Schedule, Service Requests, Invoices, and Assign on People).
   The tinted band runs edge to edge and follows the card's rounded bottom corners. Collapsed it's one Add
   button; tapping it folds the button away and unfolds the form (height + fade + slight drop), Cancel reverses. */
.panel-add, #people-list .crew-assign { display: block; padding: 0; background: var(--canvas); border-top: 1px solid var(--line); border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px); }
#people-list .crew-assign.muted { padding: 14px 24px; }
[data-route="overview"] .panel:has(> .panel-add:not(.no-perm)), .panel:has(> .people > .crew-assign:last-child) { padding-bottom: 0; }
.panel-add-toggle, .panel-add-body { display: grid; transition: grid-template-rows .28s var(--ease-out), opacity .22s var(--ease-out); }
.panel-add-toggle > div, .panel-add-body > div { min-height: 0; overflow: hidden; }
.panel-add-toggle { grid-template-rows: 1fr; }
.panel-add-body { grid-template-rows: 0fr; opacity: 0; }
.is-open > .panel-add-toggle { grid-template-rows: 0fr; opacity: 0; }
.is-open > .panel-add-body { grid-template-rows: 1fr; opacity: 1; }
.is-settled > .panel-add-body > div { overflow: visible; }
.panel-add-content { padding: 16px 24px 18px; transform: translateY(-8px); transition: transform .28s var(--ease-out); }
.is-open .panel-add-content { transform: none; }
.is-settled .panel-add-content { transform: none; transition: none; } /* no transform once open, so popovers anchor normally */
.add-toggle { display: flex; align-items: center; gap: 8px; width: 100%; padding: 14px 24px; font: inherit; font-size: 14px; font-weight: 600; color: var(--brand-500); background: none; border: 0; border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px); cursor: pointer; text-align: left; transition: background .15s, transform .12s var(--ease-out); }
.add-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; transition: transform .2s var(--ease-out); }
@media (hover: hover) { .add-toggle:hover { background: color-mix(in srgb, var(--brand-500) 8%, transparent); } .add-toggle:hover svg { transform: rotate(90deg); } }
.add-toggle:active { transform: scale(.99); background: color-mix(in srgb, var(--brand-500) 12%, transparent); }
.add-toggle:focus-visible { outline: 2px solid var(--brand-500); outline-offset: -2px; }
.panel-add-content:not(:has(.crew-assign-fields)) { display: flex; align-items: flex-end; gap: 12px; }
.crew-assign-fields { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; align-items: end; gap: 12px; }
.panel-add-fields { flex: 1; min-width: 0; display: grid; gap: 12px; align-items: end; }
#schedule-add .panel-add-fields { grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); }
#requests-add .panel-add-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
#invoices-add .panel-add-fields { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); } /* 3 fields, 4 with Custom Date */
/* The "Due Nov 11, 2026" line under Terms hangs below the row so the fields and buttons stay level. */
#invoices-add .field:has(select[name="terms"]) { position: relative; }
#invoices-add .field:has(select[name="terms"]) small { position: absolute; top: 100%; left: 0; margin-top: 4px; white-space: nowrap; }
#invoices-add .panel-add-content:has(.panel-add-fields small:not([hidden])) { padding-bottom: 38px; }
.panel-add .field > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-add .dd, .crew-assign .dd { width: 100%; }
.panel-add-actions { display: flex; gap: 8px; }
@media (max-width: 1100px) {
  .panel-add-content:not(:has(.crew-assign-fields)) { flex-direction: column; align-items: stretch; }
  .panel-add-actions { justify-content: flex-end; }
  #invoices-add .panel-add-content:has(.panel-add-fields small:not([hidden])) { padding-bottom: 18px; }
  #invoices-add .panel-add-fields:has(small:not([hidden])) { margin-bottom: 20px; }
  #schedule-add .panel-add-fields { grid-template-columns: 1fr 1fr; }
  #schedule-add .panel-add-fields > :first-child { grid-column: 1 / -1; }
  #schedule-add .panel-add-fields > :nth-child(3) { grid-column: 1 / -1; order: 1; } /* Last completed under hours + tach */
}
@media (max-width: 720px) {
  .panel-add-content { padding: 14px 16px 16px; }
  .add-toggle { padding: 14px 16px; }
  #people-list .crew-assign.muted { padding: 14px 16px; }
  .crew-assign-fields { grid-template-columns: 1fr 1fr; }
  .crew-assign-fields .panel-add-actions { grid-column: 1 / -1; }
  #requests-add .panel-add-fields, #invoices-add .panel-add-fields { grid-template-columns: 1fr 1fr; }
  #requests-add .panel-add-fields > *, #invoices-add .panel-add-fields > :first-child { grid-column: 1 / -1; }
  #invoices-add .panel-add-fields { grid-auto-flow: row; }
  #invoices-add .panel-add-fields > :nth-child(4) { grid-column: 1 / -1; }
  .panel-add-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .panel-add-content { transform: none; } }

/* Roles & permissions table */
.session-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; padding: 0 24px 18px; }
@media (max-width: 640px) { .session-fields { padding: 0 16px 14px; } }
.matrix-card { margin-top: 24px; padding-bottom: 0; }
/* Reset to Defaults sits at the top right, level with the title; on phones it drops under the description. */
@media (min-width: 601px) {
  .matrix-card .panel-head { flex-wrap: nowrap; }
  .matrix-card .panel-head > div { flex: 1; min-width: 0; }
  .matrix-card .panel-head > .btn { flex-shrink: 0; }
}
/* The table runs to the card's bottom edge, so column tints and dividers fill its rounded corners. */
.matrix tbody tr:last-child > :first-child { border-bottom-left-radius: calc(var(--radius) - 1px); }
.matrix tbody tr:last-child > :last-child { border-bottom-right-radius: calc(var(--radius) - 1px); }
.matrix { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 820px; }
.matrix th, .matrix td { padding: 10px 12px; border-top: 1px solid var(--line); text-align: center; vertical-align: middle; }
.matrix thead th { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-500); background: var(--canvas); border-top: 0; white-space: nowrap; }
.matrix thead th small { display: block; text-transform: none; letter-spacing: 0; color: var(--brand-600); font-weight: 600; }
.matrix th[scope="row"], .matrix thead th:first-child { text-align: left; font-weight: 500; color: var(--ink-900); padding-left: 24px; }
.matrix thead th:first-child { color: var(--ink-500); font-weight: 600; }
.matrix th[scope="row"] { position: sticky; left: 0; background: var(--surface); }
.matrix .matrix-section th { text-align: left; padding: 10px 24px; font-size: 13px; font-weight: 700; color: var(--brand-600); background: var(--surface); }
/* The label stays in view while the table scrolls sideways on phones. */
.matrix .matrix-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 20px; }
.matrix .matrix-section-head > span { position: sticky; left: 24px; }
/* Per-section reset: sits at the row's right end, centered in the row, and stays in view while the table scrolls sideways. */
.matrix .matrix-reset { position: sticky; right: 12px; margin: -6px -12px -6px 0; padding: 4px 10px; font-size: 12px; }
.matrix .is-mine { background: var(--brand-50); }
.matrix thead .matrix-groups th, .matrix thead .matrix-groups td { padding-top: 12px; padding-bottom: 0; background: var(--canvas); border-top: 0; font-size: 11px; color: var(--ink-500); }
.matrix thead .matrix-groups + tr th { border-top: 0; }
/* Admin's header spans both header rows, so it reads like the group headings, not a column under one. */
.matrix thead .matrix-groups .matrix-admin-head { padding: 12px; font-size: 12px; color: var(--ink-500); vertical-align: middle; }
.matrix thead .matrix-groups .matrix-admin-head.is-mine { background: var(--brand-50); }
.matrix .matrix-group-start { border-left: 1px solid var(--line); }
/* Table borders don't travel with a pinned header, so the header draws its part of the divider itself. */
.matrix thead .matrix-group-start { border-left-color: transparent; --divider: inset 1px 0 0 var(--line); box-shadow: var(--divider); }
.matrix thead :is(th, td):first-child { position: sticky; left: 0; z-index: 3; }
/* Header rows stay under the app header while their table scrolls past it (sticky-head.js). */
.table-wrap.has-sticky-head.is-fit { overflow: visible; }
/* The whole header pins as one block, so stacked header rows (column groups over names) never part. */
.has-sticky-head.is-fit thead { position: sticky; top: var(--sticky-head-top, 0px); z-index: 3; background: var(--table-head); }
/* Solid behind the cells too, so nothing shows through the hairline seams between them while scrolling. */
.has-sticky-head.is-fit .matrix thead { background: var(--canvas); }
.has-sticky-head:not(.is-fit) thead :is(th, td) { position: relative; z-index: 3; transform: translateY(var(--head-shift, 0px)); }
/* Section heading rows (one heading cell across the table) pin just below the header row while their rows scroll past;
   the next section's heading slides over it. Below the header row, above the pinned row labels. (sticky-head.js)
   Tucked 2px under the header row: table borders don't travel with a pinned cell, so its top edge would leave a sliver
   of the rows scrolling underneath showing between the two. */
.has-sticky-head.is-fit .table-section > th { position: sticky; top: calc(var(--sticky-head-top, 0px) + var(--thead-h, 0px) - 2px); z-index: 2; }
.has-sticky-head:not(.is-fit) .table-section > th { position: relative; z-index: 2; transform: translateY(var(--section-shift, 0px)); }
.has-sticky-head .table-section.is-stuck > th { box-shadow: inset 0 -1px 0 var(--line); }
.has-sticky-head thead th { transition: box-shadow .15s ease; }
.has-sticky-head.is-stuck thead tr:last-child :is(th, td) { box-shadow: var(--divider, 0 0 transparent), inset 0 -1px 0 var(--line), 0 6px 8px -6px rgb(0 0 0 / .18); }
.has-sticky-head .matrix thead :is(th, td):first-child { position: sticky; z-index: 4; }
/* The group row's cells reach 2px into the row below, so the seam between the two header rows (often on a half
   pixel) never lets the rows scrolling underneath show through. */
.has-sticky-head .matrix thead .matrix-groups > :not(.matrix-admin-head) { box-shadow: var(--divider, 0 0 transparent), 0 2px 0 var(--canvas); }
.matrix th[scope="row"] { z-index: 1; }
.matrix-yes svg { width: 18px; height: 18px; fill: none; stroke: var(--ok); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.matrix-no { color: var(--ink-300); }
/* block-level flex so no text strut adds space under the box; the cell centers it */
.matrix-check, .matrix-yes { display: flex; justify-content: center; margin: 0; }
.matrix-check input { margin: 0; }
@media (max-width: 720px) { #people-list .crew-row > .dir-name > span { white-space: normal; } }

/* ---------- native-feel touch feedback ---------- */
/* Tappable cards lift with a softer shadow on hover and sink when pressed, like app cards.
   Hover only applies on devices with a real pointer, so it never sticks after a tap on a phone. */
@media (hover: hover) {
  .portfolio-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
  a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); background: var(--surface); }
}
.portfolio-card:active, a.kpi:active { transform: scale(.98); box-shadow: var(--shadow-press); transition-duration: .08s; }
.btn:active:not(:disabled), .icon-btn:active { transform: scale(.97); transition-duration: .06s; }
.attention-item, .portfolio-row { transition: background .15s; }
.attention-item:active, .portfolio-row:active { background: var(--canvas); }
.tabbar svg { transition: transform .12s var(--ease-out); }
.tabbar a:active svg { transform: scale(.86); transition-duration: .06s; }

/* ---------- drop zones (js/dropzone.js) ---------- */
/* Every file input is a dashed zone to drag files onto or tap to browse. The native input covers the
   zone invisibly, so a click or tap opens the picker and form validation still points at it. */
.dz { display: grid; gap: 8px; min-width: 0; }
.dz-target {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 22px 16px; text-align: center; font-size: 14px; font-weight: 400; color: var(--ink-700);
  background: var(--raised); border: 1.5px dashed var(--ink-300); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .2s var(--ease-out), transform .2s var(--ease-out);
}
.dz-icon { width: 36px; height: 36px; padding: 7px; border-radius: 50%; background: var(--brand-50); fill: none; stroke: var(--brand-500); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s var(--ease-out); }
.dz-browse { color: var(--brand-500); font-weight: 600; }
.dz-touch { display: none; font-weight: 600; color: var(--brand-500); }
@media (pointer: coarse) { .dz-mouse { display: none; } .dz-touch { display: inline; } }
.field .dz-native, .dz-native { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; margin: 0; border: 0; opacity: 0; cursor: pointer; font-size: 0; }
@media (hover: hover) {
  .dz-target:hover { border-color: var(--brand-500); background: var(--brand-50); }
  .dz-target:hover .dz-icon { transform: translateY(-2px); }
}
.dz-target:has(.dz-native:focus-visible) { border-color: var(--brand-500); outline: 3px solid var(--brand-50); outline-offset: 0; }
.dz-target:active { transform: scale(.98); background: var(--canvas); transition-duration: .06s; }
/* Files dragged anywhere on the page: zones light up; over a zone it lifts and the icon jumps. */
.is-dragging-files .dz-target { border-color: var(--brand-500); }
.dz.is-over .dz-target { border-style: solid; border-color: var(--brand-500); background: var(--brand-50); transform: scale(1.02); box-shadow: var(--shadow-lift); }
.dz.is-over .dz-icon { transform: translateY(-4px) scale(1.08); }
.dz.is-over .dz-target * { pointer-events: none; }
.dz.is-disabled .dz-target { opacity: .55; cursor: not-allowed; }
.dz-note { margin: 0; font-size: 13px; color: var(--overdue); }
.dz-note:empty { display: none; }
.dz-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dz-files:empty { display: none; }
.dz-file { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; font-weight: 400; animation: dz-in .22s var(--ease-out); }
.dz-thumb { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 6px; background: var(--brand-50); overflow: hidden; }
.dz-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dz-thumb svg { width: 20px; height: 20px; fill: none; stroke: var(--brand-500); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dz-name { display: grid; flex: 1; min-width: 0; }
.dz-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-900); }
.dz-name small { color: var(--ink-500); font-size: 12px; }
.dz-remove { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--ink-500); cursor: pointer; transition: background .15s, color .15s, transform .12s var(--ease-out); }
.dz-remove svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (hover: hover) { .dz-remove:hover { background: var(--overdue-bg); color: var(--overdue); } }
.dz-remove:active { transform: scale(.88); transition-duration: .06s; }
@keyframes dz-in { from { opacity: 0; transform: translateY(-4px); } }
/* One-line zone (profile photo): sits in a button row and uploads as soon as a photo lands. */
.dz-compact .dz-target { flex-direction: row; gap: 8px; padding: 6px 14px 6px 8px; font-size: 14px; font-weight: 500; }
.dz-compact .dz-icon { width: 26px; height: 26px; padding: 5px; }
.dz-compact.is-over .dz-target { transform: scale(1.04); }
@media (prefers-reduced-motion: reduce) {
  .dz-target, .dz-target:active, .dz.is-over .dz-target, .dz-icon, .dz-file { transform: none !important; animation: none; }
}

/* ---------- dropdowns (js/select.js) ---------- */
/* An app-styled button opens a rounded, animated list. The native <select> stays underneath for forms;
   on touch screens it covers the button invisibly so a tap opens the phone's own picker. */
.dd { position: relative; display: inline-grid; max-width: 100%; min-width: 0; vertical-align: middle; }
.dd-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; font-size: 16px; appearance: none; border: 0; }
@media (pointer: coarse) { .dd-native { pointer-events: auto; cursor: pointer; } }
.dd-trigger {
  display: flex; align-items: center; gap: 8px; min-width: 0; width: 100%; text-align: left; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--ink-900); padding: 9px 10px 9px 12px;
  background: var(--raised); border: 1px solid var(--ink-300); border-radius: var(--radius-sm);
  transition: border-color .15s, background .15s, box-shadow .15s, transform .2s var(--ease-out);
}
.dd-value { display: grid; flex: 1; min-width: 0; }
.dd-value > span { grid-area: 1 / 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-sizer { visibility: hidden; }
.dd-chevron { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--ink-500); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s var(--ease-out); }
@media (hover: hover) { .dd-trigger:hover:not(:disabled) { border-color: var(--ink-500); } }
.dd-trigger:focus-visible, .dd.is-open .dd-trigger { border-color: var(--brand-500); outline: 3px solid var(--brand-50); outline-offset: 0; }
.dd-trigger:active:not(:disabled), .dd:has(.dd-native:active) .dd-trigger { transform: scale(.98); background: var(--canvas); transition-duration: .06s; }
.dd:has(.dd-native:focus-visible) .dd-trigger { border-color: var(--brand-500); outline: 3px solid var(--brand-50); outline-offset: 0; }
.dd.is-open .dd-chevron { transform: rotate(180deg); }
.dd-trigger:disabled { opacity: .55; cursor: not-allowed; }

.dd-list {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; inset: auto; margin: 0;
  padding: 6px; overflow: auto; overscroll-behavior: contain; max-height: 320px; width: max-content;
  background: var(--raised); color: var(--ink-900); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-menu);
  font-size: 14px; transform-origin: top center;
}
.dd-list:not([popover]) { top: calc(100% + 6px); left: 0; }
.dd-list[popover] { position: fixed; }
.dd-list.is-up { transform-origin: bottom center; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
@keyframes dd-in-up { from { opacity: 0; transform: translateY(6px) scale(.97); } }
@keyframes dd-out { to { opacity: 0; transform: scale(.97); } }
.dd-list.is-open { animation: dd-in .18s var(--ease-out); }
.dd-list.is-open.is-up { animation-name: dd-in-up; }
.dd-list.is-closing { animation: dd-out .12s ease-in forwards; }
.dd-list [role=option] {
  display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 8px; padding: 9px 12px 9px 8px; border-radius: 8px;
  cursor: pointer; white-space: nowrap; transition: background .12s, transform .12s var(--ease-out);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.dd-list [role=option] > span { overflow: hidden; text-overflow: ellipsis; }
.dd-list [role=option].is-active { background: var(--canvas); }
.dd-list [role=option]:active { transform: scale(.98); background: var(--line); transition-duration: .06s; }
.dd-list [role=option][aria-selected="true"] { font-weight: 600; color: var(--brand-600); }
.dd-list [role=option][aria-disabled="true"] { opacity: .5; cursor: default; }
.dd-check { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
[aria-selected="true"] > .dd-check { visibility: visible; }
@media (prefers-reduced-motion: reduce) {
  .dd-list.is-open, .dd-list.is-closing { animation: none; }
  .dd-trigger:active:not(:disabled), .dd-list [role=option]:active { transform: none; }
}

/* ---------- date fields (js/datepicker.js): same button and popover as the dropdowns, with a calendar ---------- */
.dp .dp-icon { transform: none !important; }
.dp.is-empty .dd-current { color: var(--ink-500); }
.dp-cal { width: 296px; max-height: none; padding: 12px; overflow: visible; }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.dp-title {
  display: inline-flex; align-items: center; gap: 4px; font: inherit; font-size: 15px; font-weight: 700; color: var(--ink-900);
  background: none; border: 0; border-radius: 8px; padding: 6px 10px; cursor: pointer; transition: background .15s, transform .12s var(--ease-out);
}
/* a small chevron says the title opens the month / year view */
.dp-title:not(:disabled)::after { content: ""; width: 7px; height: 7px; border: solid var(--ink-500); border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); margin-left: 4px; }
@media (hover: hover) { .dp-title:hover:not(:disabled) { background: var(--canvas); } }
.dp-title:active:not(:disabled) { transform: scale(.96); background: var(--line); transition-duration: .06s; }
.dp-title:disabled { cursor: default; }
.dp-title:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-500) 55%, transparent); outline-offset: 0; }
.dp-tiles { display: grid; grid-template-rows: repeat(4, 1fr); gap: 6px; height: 232px; padding: 4px 0; }
.dp-tiles [role=row] { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dp-tile {
  border: 0; border-radius: 10px; background: none; color: var(--ink-900); font: inherit; font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums;
  cursor: pointer; transition: background .12s, color .12s, transform .12s var(--ease-out);
}
@media (hover: hover) { .dp-tile:hover:not(:disabled) { background: var(--canvas); } }
.dp-tile:active:not(:disabled) { transform: scale(.94); background: var(--line); transition-duration: .06s; }
.dp-tile.is-today { color: var(--brand-600); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--brand-500); }
.dp-tile[aria-pressed="true"] { background: var(--accent-fill); color: var(--on-fill); font-weight: 700; box-shadow: none; }
@media (hover: hover) { .dp-tile[aria-pressed="true"]:hover { background: var(--accent-fill-hover); } }
.dp-tile:disabled { opacity: .3; cursor: default; }
.dp-tile:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-500) 55%, transparent); outline-offset: 0; }
@keyframes dp-zoom { from { opacity: 0; transform: scale(.94); } }
.dp-body.is-zooming { animation: dp-zoom .2s var(--ease-out); }
.dp-nav { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; color: var(--ink-700); cursor: pointer; transition: background .15s, transform .12s var(--ease-out); }
.dp-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .dp-nav:hover:not(:disabled) { background: var(--canvas); } }
.dp-nav:active:not(:disabled) { transform: scale(.9); background: var(--line); transition-duration: .06s; }
.dp-nav:disabled { opacity: .35; cursor: default; }
.dp-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.dp-grid th { font-size: 12px; font-weight: 600; color: var(--ink-500); padding: 4px 0 6px; text-align: center; }
.dp-grid td { padding: 1px; text-align: center; }
.dp-day {
  width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: var(--ink-900); font: inherit; font-size: 14px; font-variant-numeric: tabular-nums;
  cursor: pointer; transition: background .12s, color .12s, transform .12s var(--ease-out);
}
@media (hover: hover) { .dp-day:hover:not(:disabled) { background: var(--canvas); } }
.dp-day:active:not(:disabled) { transform: scale(.9); background: var(--line); transition-duration: .06s; }
.dp-day.is-outside { color: var(--ink-500); opacity: .55; }
.dp-day.is-today { color: var(--brand-600); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--brand-500); }
.dp-day[aria-pressed="true"] { background: var(--accent-fill); color: var(--on-fill); font-weight: 700; opacity: 1; box-shadow: none; }
@media (hover: hover) { .dp-day[aria-pressed="true"]:hover { background: var(--accent-fill-hover); } }
.dp-day:disabled { opacity: .3; cursor: default; text-decoration: line-through; }
.dp-day:focus-visible, .dp-nav:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-500) 55%, transparent); outline-offset: 0; }
.dp-foot { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.dp-foot .link-btn { font-size: 14px; font-weight: 600; padding: 4px 6px; }
@media (prefers-reduced-motion: reduce) {
  .dp-day:active:not(:disabled), .dp-nav:active:not(:disabled), .dp-tile:active:not(:disabled), .dp-title:active:not(:disabled) { transform: none; }
  .dp-body.is-zooming { animation: none; }
}

/* Long-pressing controls and cards shouldn't select their text or pop the link/image callout. */
.btn, .icon-btn, .dd-trigger, .account-btn, .primary-nav, .tabbar, .menu, .segmented, .sort, .view-all, .link-btn, .find-btn,
.portfolio-card, a.kpi, .attention-item, .portfolio-row, .dir-name, .subnav, .back-link, .check, .qa {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
/* Like a native app, none of the interface selects as text, only what people typed: form fields, and the
   messages and notes they wrote when shown back (.detail-message). Phone numbers and emails keep their
   one-tap select-all (user-select: all) for copying. Dialogs and popovers are named too: in the top layer
   they don't pick it up from body. */
body, dialog, [popover] { -webkit-user-select: none; user-select: none; }
input, textarea, [contenteditable], .detail-message { -webkit-user-select: text; user-select: text; }

/* Page transitions: a page fades and rises in when it's shown. No fill mode, so no transform is
   left on the section afterwards (that would re-anchor fixed-position children). */
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
#main [data-routes]:not([hidden]) { animation: page-in .24s var(--ease-out); }

/* Loading placeholders: shimmering bars in a list or table until its first data arrives.
   Every renderer fills these lists (with an "empty" row when there's nothing), so :empty only matches before the first load. */
@keyframes skeleton-pulse { 50% { opacity: .45; } }
#dash-greeting:empty::before, #dash-kpis:empty::before, #dash-attention:empty::before, #dash-portfolio:empty::before,
#portfolio-list:empty::before, #portfolio-list:empty::after, #directory:empty::before, #profile:empty::before,
.panel:has(tbody:empty):has(> .empty[hidden]) .table-wrap::after {
  content: ""; display: block; animation: skeleton-pulse 1.4s ease-in-out infinite;
  --bar: var(--line);
  background: repeating-linear-gradient(to bottom, var(--bar) 0 12px, transparent 12px 30px) 0 0 / 100% 100% no-repeat;
}
#dash-greeting:empty::before { width: min(260px, 70%); height: 30px; background: var(--bar); border-radius: 8px; }
#dash-kpis:empty::before { grid-column: 1 / -1; height: 74px; background: var(--bar); border-radius: var(--radius-sm); }
#dash-attention:empty::before, #dash-portfolio:empty::before, #directory:empty::before { height: 102px; margin: 18px 24px 22px; }
.panel:has(tbody:empty):has(> .empty[hidden]) .table-wrap::after { height: 72px; margin: 16px 24px 20px; }
#profile:empty::before { height: 192px; margin: 4px 0; }
#portfolio-list:empty::before, #portfolio-list:empty::after { height: 230px; border-radius: var(--radius); background: var(--bar); }

/* Pull-to-refresh indicator (js/pull-refresh.js). The browser's own pull-to-reload and its rubber-band bounce are
   turned off on every screen: an app page doesn't stretch past its ends, and the bounce would pull the page away from
   the app-drawn scrollbar (js/page-scrollbar.js). */
html, body { overscroll-behavior-y: none; }
.ptr { position: fixed; left: 50%; top: calc(var(--header-h) + var(--env-banner-h, 0px) + env(safe-area-inset-top, 0px) - 30px); z-index: 15; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: var(--raised); color: var(--ink-500); box-shadow: var(--shadow-menu); opacity: 0; transform: translate(-50%, 0); pointer-events: none; }
.ptr.settling { transition: transform .25s var(--ease-out), opacity .25s; }
.ptr svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transform: rotate(var(--ptr-turn, 0deg)); }
.ptr.ready, .ptr.spinning { color: var(--brand-600); }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
.ptr.spinning svg { animation: ptr-spin .7s linear infinite; }

/* Dialogs slide down and fade in on larger screens and slide up as a bottom sheet on phones. Closing plays
   the reverse (.is-closing, set by app.js) before the dialog actually closes. */
@keyframes dialog-in { from { opacity: 0; transform: translateY(-24px); } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(-24px); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes backdrop-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.dialog[open] { animation: dialog-in .26s var(--ease-out); }
.dialog[open]::backdrop { animation: backdrop-in .26s ease-out; }
.dialog[open].is-closing { animation: dialog-out .18s ease-in forwards; pointer-events: none; }
.dialog[open].is-closing::backdrop { animation: backdrop-out .18s ease-in forwards; }
/* While a dialog is open (closing included) the page behind it doesn't scroll. If the page had a scrollbar its
   space is kept (.keep-gutter, set by app.js) so nothing shifts sideways, and scrolling inside the dialog stops
   at its ends instead of carrying on to the page (iOS included). */
html:has(.dialog[open]) { overflow: hidden; }
html.keep-gutter:has(.dialog[open]) { scrollbar-gutter: stable; }
.dialog form { overscroll-behavior: contain; }
@media (max-width: 640px) {
  .dialog, .dialog-sm, .dialog-wide { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .dialog[open] { animation: sheet-up .32s var(--ease-out); }
  .dialog[open].is-closing { animation: sheet-down .24s cubic-bezier(.4, 0, 1, 1) forwards; }
  .dialog[open].is-closing::backdrop { animation-duration: .24s; }
  .dialog::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--ink-300); margin: 8px auto 0; }
  .dialog form { max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px); padding-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-card:hover, a.kpi:hover, .portfolio-card:active, a.kpi:active, .btn:active, .icon-btn:active, .tabbar a:active svg, .qa:hover, .qa:active { transform: none; }
  #main [data-routes]:not([hidden]) { animation: none; }
  /* Dialogs and their backdrop just fade, without moving. */
  .dialog[open], .dialog[open]::backdrop { animation: fade-in .15s ease-out; }
  .dialog[open].is-closing, .dialog[open].is-closing::backdrop { animation: fade-out .12s ease-in forwards; }
  .ptr.spinning svg { animation-duration: 1.6s; }
}

/* ---------- rotate your device (phones in portrait, on wide tables) ---------- */
.rotate-prompt {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 8px 12px;
  padding: 14px 14px 14px 14px; border-radius: 16px; background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: rotate-in .32s var(--ease-out);
}
.rotate-prompt[hidden] { display: none; }
.rotate-prompt.is-leaving { animation: rotate-out .2s ease-in forwards; }
body:has(.tabbar:not([hidden])) .rotate-prompt { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
/* icon beside the heading, the message under both at the card's full width */
.rotate-prompt > div { display: contents; }
.rotate-head { display: flex; align-items: flex-start; gap: 4px; }
.rotate-prompt h2 { flex: 1; font-size: 16px; line-height: 20px; font-weight: 700; color: var(--brand-600); margin: 0; }
.rotate-prompt p { grid-column: 1 / -1; font-size: 14px; line-height: 1.4; color: var(--ink-700); margin: 0; }
/* close button centered on the heading's first line (34px button, 20px line) */
.rotate-prompt .icon-btn { flex: none; margin: -7px -6px -7px 0; }
.rotate-icon { width: 40px; height: 40px; fill: none; stroke: var(--ink-900); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.rotate-icon circle { fill: var(--ink-900); stroke: none; }
.rotate-arrows { stroke: var(--brand-600); transform-box: view-box; transform-origin: 24px 24px; animation: rotate-arrows 2.8s var(--ease-out) infinite; }
.rotate-phone { transform-box: view-box; transform-origin: 24px 24px; animation: rotate-phone 2.8s var(--ease-out) infinite; }
/* Upright, turn a quarter counterclockwise into landscape (the way people rotate a phone), hold, then fade back upright and repeat. */
@keyframes rotate-phone {
  0%, 18% { transform: rotate(0); opacity: 1; }
  48%, 80% { transform: rotate(-90deg); opacity: 1; }
  90% { transform: rotate(-90deg); opacity: 0; }
  91% { transform: rotate(0); opacity: 0; }
  100% { transform: rotate(0); opacity: 1; }
}
@keyframes rotate-arrows {
  0%, 12% { opacity: .35; transform: rotate(20deg); }
  42%, 80% { opacity: 1; transform: rotate(0); }
  100% { opacity: .35; transform: rotate(20deg); }
}
@keyframes rotate-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }
@keyframes rotate-out { to { opacity: 0; transform: translateY(24px) scale(.98); } }
@media (prefers-reduced-motion: reduce) {
  .rotate-prompt, .rotate-prompt.is-leaving, .rotate-arrows { animation: none; }
  /* Show the end state: the phone already sideways. */
  .rotate-phone { animation: none; transform: rotate(-90deg); }
}

/* ---------- update available (a new deploy while the app is open) ---------- */
.update-card {
  position: fixed; right: 24px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 45; width: min(400px, calc(100vw - 24px));
  display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 12px;
  padding: 14px; border-radius: 16px; background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: update-in .32s var(--ease-out);
}
.update-card[hidden] { display: none; }
.update-card.is-leaving { animation: update-out .2s ease-in forwards; }
.update-card h2 { font-size: 16px; line-height: 20px; font-weight: 700; color: var(--brand-600); margin: 0; }
.update-card p { font-size: 14px; line-height: 1.4; color: var(--ink-700); margin: 2px 0 0; }
.update-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-600); }
.update-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; animation: update-spin 1.1s var(--ease-out) .25s; }
.update-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.update-actions .btn { min-width: 96px; }
/* the toast and the rotate prompt share the bottom of the screen: keep the toast clear, and let the update go first */
body:has(.update-card:not([hidden])) .toast { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
body:has(.update-card:not([hidden])) .rotate-prompt { display: none; }
@media (max-width: 860px) {
  .update-card { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: auto; }
  .update-actions .btn { flex: 1; }
  body:has(.tabbar:not([hidden])) .update-card { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  body:has(.tabbar:not([hidden])) .update-card:not([hidden]) ~ .toast { bottom: calc(210px + env(safe-area-inset-bottom, 0px)); }
}
@keyframes update-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }
@keyframes update-out { to { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes update-spin { from { transform: rotate(-200deg); } }
@media (prefers-reduced-motion: reduce) { .update-card, .update-card.is-leaving, .update-icon svg { animation: none; } }


/* "Installing Update" styles live in index.html, so the screen and its styles always arrive together. */
.toast:has(.toast-link) { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 14px; text-align: center; }
.toast-link { color: inherit; font-weight: 600; white-space: nowrap; }

/* ---------- dashboard: card grid (public/js/dash-grid.js, sizes in public/js/dash-layout.js) ---------- */
/* 12 columns (Small ¼, Medium ⅓, Large ½, Wide ⅔, Full), then 6 and 2 as the grid narrows. Rows are short tracks
   (--ru, six to a "row"): each card spans as many as its height needs (set by dash-grid.js), so a tall card runs down
   beside several shorter ones, and "dense" lets a card fill any gap left earlier in the order. */
.dgrid-wrap { container: dgrid / inline-size; }
.dgrid { --ru: 20px; display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: var(--ru);
  grid-auto-flow: row dense; align-items: stretch; }
.dcard { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding-top: 22px; grid-column: span 3;
  grid-row-end: span 3; container: dcard / inline-size; transition: box-shadow .2s var(--ease-out), opacity .2s; }
.dcard.sz-m { grid-column: span 4; } .dcard.sz-l { grid-column: span 6; } .dcard.sz-w { grid-column: span 8; } .dcard.sz-f { grid-column: span 12; }
@container dgrid (max-width: 899px) {
  .dgrid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .dcard, .dcard.sz-m { grid-column: span 3; } .dcard.sz-l, .dcard.sz-w, .dcard.sz-f { grid-column: span 6; }
}
@container dgrid (max-width: 559px) {
  .dgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .dcard { grid-column: span 1; } .dcard.sz-m, .dcard.sz-l, .dcard.sz-w, .dcard.sz-f { grid-column: span 2; }
  .dcard-kpi .kpi-note { display: block; }
}
/* While dash-grid.js measures how tall each card's content is. */
.dgrid.dgrid-measure .dcard { grid-row-end: auto !important; align-self: start; }
.dgrid.dgrid-measure .dcard-body, .dgrid.dgrid-measure .card-empty { flex: none; }
/* The link and ⋯ sit on the title's line and the subtitle runs the card's full width beneath; on a narrow card the link
   drops under the subtitle so the title never gets squeezed. */
.dcard .panel-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0 12px; align-items: center; }
.dcard .panel-head > div { display: contents; }
.dcard .panel-head h2 { grid-area: 1 / 1; }
.dcard .panel-head .panel-sub { grid-area: 2 / 1 / 3 / -1; }
.dcard .panel-head .view-all { grid-area: 1 / 2; }
.dcard .panel-head .dcard-menu-btn { grid-area: 1 / 3; margin-top: 0; }
@container dcard (max-width: 300px) {
  .dcard .panel-head .view-all { grid-area: 3 / 1; justify-self: start; padding: 4px 0 0; }
  .dcard .panel-head .dcard-menu-btn { grid-area: 1 / 2 / 2 / -1; justify-self: end; }
}
.dcard-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: 8px; }
.dcard:not(.ht-a) .dcard-body { overflow: hidden; }
.dgrid:not(.is-locked) .dcard:not(.dcard-kpi) .dcard-body { padding-bottom: 26px; } /* room for the grip and corner */
.dgrid-empty { grid-column: 1 / -1; padding: 32px 24px; text-align: center; color: var(--ink-500); }

/* summary tiles: the whole card is the link */
.dcard-kpi { padding: 0; overflow: hidden; }
.dcard-kpi .dcard-body { padding: 0; }
.dcard-kpi .kpi { flex: 1; border-width: 0 0 0 4px; border-radius: 0; padding: 14px 16px; align-content: center; }
.dcard-kpi a.kpi:hover, .dcard-kpi a.kpi:active { transform: none; box-shadow: none; }
/* the tile lifts as a whole, like every other clickable card */
@media (hover: hover) { .dcard-kpi:has(a.kpi:hover) { transform: translateY(-2px); box-shadow: var(--shadow-lift); } }
.dcard-kpi:has(a.kpi:active) { transform: scale(.98); box-shadow: var(--shadow-press); transition-duration: .08s; }
.dcard-kpi { transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), opacity .2s; }

/* a card set shorter than its content: the rest fades under See All */
.dcard.clip .dcard-body::after { content: ""; position: absolute; left: 1px; right: 1px; bottom: 1px; height: 64px; border-radius: 0 0 var(--radius) var(--radius);
  background: linear-gradient(to bottom, transparent, var(--surface) 70%); pointer-events: none; }
.dcard-more { display: none; position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 2; font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.dcard.clip .dcard-more { display: flex; align-items: center; gap: 4px; }

/* card controls: ⋯ menu in the header, grip (move) and corner (resize) along the bottom; none while locked */
.dcard-menu-btn { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; margin: -2px -10px 0 -4px; padding: 0; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--ink-500); cursor: pointer; transition: background .15s, color .15s, transform .12s var(--ease-out); }
.dcard-menu-btn svg { width: 18px; height: 18px; fill: currentColor; }
.dcard-menu-btn:hover, .dcard-menu-btn[aria-expanded="true"] { background: var(--canvas); color: var(--ink-900); }
.dcard-menu-btn:active { transform: scale(.92); }
.dcard-kpi .dcard-menu-btn { position: absolute; top: 6px; right: 6px; margin: 0; z-index: 2; opacity: 0; transition: opacity .15s, background .15s; }
.dcard-kpi:hover .dcard-menu-btn, .dcard-kpi .dcard-menu-btn:focus-visible, .dcard-kpi .dcard-menu-btn[aria-expanded="true"] { opacity: 1; }
.dcard-grip, .dcard-corner { position: absolute; bottom: 3px; z-index: 2; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--ink-500); touch-action: none; opacity: 0; transition: opacity .15s, color .15s, background .15s; }
.dcard-grip { left: 3px; cursor: grab; }
.dcard-corner { right: 3px; cursor: nwse-resize; }
.dcard-grip svg { width: 16px; height: 16px; fill: currentColor; }
.dcard-corner svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dcard:hover .dcard-grip, .dcard:hover .dcard-corner, .dcard-grip:focus-visible, .dcard-corner:focus-visible, .dcard.is-sizing .dcard-corner { opacity: 1; }
.dcard-grip:hover, .dcard-corner:hover { color: var(--brand-600); background: var(--canvas); }
@media (hover: none) { .dcard-grip, .dcard-corner, .dcard-kpi .dcard-menu-btn { opacity: .6; } }
.dcard.is-moving { opacity: .35; box-shadow: none; outline: 2px dashed var(--brand-500); outline-offset: 2px; }
.dcard.is-sizing { outline: 2px dashed var(--brand-500); outline-offset: 2px; user-select: none; }
.dcard-ghost { position: fixed !important; left: 0; top: 0; z-index: 80; margin: 0; pointer-events: none; box-shadow: var(--shadow-lg); cursor: grabbing; }
body:has(.dcard-ghost) { cursor: grabbing; user-select: none; }

.dmenu { position: fixed; z-index: 90; width: 284px; max-height: calc(100vh - 16px); overflow-y: auto; padding: 6px; background: var(--raised); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-menu); transform-origin: top right; animation: dmenu-in .16s var(--ease-out); }
.dmenu.dmenu-up { transform-origin: bottom right; }
@keyframes dmenu-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
.dmenu-head { margin: 8px 10px 2px; font-size: 12px; font-weight: 600; color: var(--ink-500); text-transform: uppercase; letter-spacing: .04em; user-select: none; }
.dmenu-head em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 500; }
.dmenu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.dmenu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink-900); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.dmenu button:hover:not(:disabled), .dmenu button:focus-visible { background: var(--canvas); outline: none; }
.dmenu button:disabled { opacity: .45; cursor: default; }
.dmenu-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 6px 4px; }
.dmenu .dmenu-chip { width: auto; min-width: 34px; justify-content: center; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-700); }
.dmenu .dmenu-chip[aria-checked="true"] { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-fill); }
.dmenu .dmenu-chip[aria-checked="true"]:hover, .dmenu .dmenu-chip[aria-checked="true"]:focus-visible { background: var(--accent-fill-hover); filter: brightness(1.1); }
.dmenu button svg, .dmenu-pad { width: 16px; height: 16px; flex: none; }
.dmenu button svg { fill: none; stroke: var(--brand-600); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* card versions */
.dcounts { list-style: none; margin: 0; padding: 16px 24px 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; flex: 1; align-content: start; }
/* Each count is a small summary card, the same as the ones at the top of the dashboard. */
.dcount { overflow: hidden; display: flex; transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.dcount .kpi { flex: 1; border-width: 0 0 0 4px; border-radius: 0; padding: 14px 16px; align-content: center; }
.dcount a.kpi:hover, .dcount a.kpi:active { transform: none; box-shadow: none; }
.dcount .kpi-note { display: block; }
@media (hover: hover) { .dcount:has(a.kpi:hover) { transform: translateY(-2px); box-shadow: var(--shadow-lift); } }
.dcount:has(a.kpi:active) { transform: scale(.98); box-shadow: var(--shadow-press); transition-duration: .08s; }
.dgroup { display: flex; gap: 8px; align-items: baseline; margin: 0; padding: 12px 24px 6px; border-top: 1px solid var(--line); font-size: 12px; font-weight: 700;
  color: var(--ink-700); text-transform: uppercase; letter-spacing: .04em; user-select: none; }
.dgroup span { font-weight: 500; color: var(--ink-500); text-transform: none; letter-spacing: 0; }
.dgroup + ul > li:first-child > * { border-top-color: transparent; }
.attention-item.tone-ok { border-left-color: var(--ok); }
.portfolio-row-static { cursor: default; }
.portfolio-row-static:hover { background: none; }
.dphotos { list-style: none; margin: 0; padding: 16px 24px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.dphoto { display: grid; gap: 8px; width: 100%; padding: 0 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface);
  font: inherit; color: inherit; text-align: left; cursor: pointer; transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.dphoto:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.dphoto:active { transform: scale(.98); }
.dphoto img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--canvas); }
.dphoto-name { display: grid; padding: 0 12px; min-width: 0; }
.dphoto-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dphoto-name span { font-size: 13px; color: var(--ink-500); }
.dphoto .badge { justify-self: start; margin: 0 12px; }
.dbars { list-style: none; margin: 0; padding: 0; }
.dbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; width: 100%; padding: 12px 24px; border: 0; border-top: 1px solid var(--line); background: none;
  font: inherit; color: inherit; text-align: left; cursor: pointer; transition: background .15s; }
.dbar:hover { background: var(--row-hover); }
.dbar-name { display: grid; min-width: 0; }
.dbar-name strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbar-name span { font-size: 13px; color: var(--ink-500); }
.dbar-left { font-size: 13px; font-weight: 600; color: var(--ink-700); align-self: center; font-variant-numeric: tabular-nums; }
.dbar-track { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--canvas); overflow: hidden; }
.dbar-fill { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.dbar-fill.tone-due { background: var(--due-fill); } .dbar-fill.tone-overdue { background: var(--overdue); }
@media (max-width: 720px) { .dcounts, .dphotos { padding-left: 16px; padding-right: 16px; } .dgroup, .dbar { padding-left: 16px; padding-right: 16px; } }

/* an admin editing a role's default layout */
.dash-editing { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; padding: 12px 16px;
  border: 1px solid var(--brand-500); border-radius: var(--radius); background: var(--brand-50); color: var(--ink-900); font-size: 14px; }
.dash-editing p { margin: 0; flex: 1 1 320px; }
/* the greeting wraps rather than pushing the lock and customize buttons under it */
#sec-dashboard .page-head h1 { white-space: normal; flex: 1 1 0; min-width: 0; }
.dash-tools { align-self: flex-start; margin-block: 2px 0; flex: none; }
.dash-tools .find-btn:disabled { opacity: .45; cursor: not-allowed; }
.dash-tools .find-btn[aria-pressed="true"] { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-fill); }

/* Customize Dashboard */
.dz-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 0; }
.dz-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.dz-row .check { font-weight: 600; }
.dz-move { display: inline-flex; gap: 2px; }
.dz-opts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 12px; padding-left: 30px; }
.dz-opts .field { margin: 0; }
.dz-row:has(input[type=checkbox]:not(:checked)) .dz-opts { opacity: .5; }
.dz-roles { margin: 0 0 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.dz-roles legend { padding: 0 6px; font-weight: 600; }
.dz-roles legend em { font-style: normal; font-weight: 400; color: var(--ink-500); }
.dz-roles .muted { margin: 0 0 10px; font-size: 13px; }
.dz-role-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px 12px; }
.dz-edit-role { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.dz-edit-role .field { flex: 1 1 220px; margin: 0; }
@media (max-width: 560px) { .dz-opts { padding-left: 0; } }

/* ---------- Share to App (js/share.js): what to start with a shared screenshot, photo or file ---------- */
.share-files { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; overflow-x: auto; }
.share-thumb { flex: 0 0 auto; width: 88px; height: 88px; border-radius: var(--radius-sm); overflow: hidden; background: var(--canvas); border: 1px solid var(--line); }
.share-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.share-files.is-single .share-thumb:not(.share-doc) { width: 100%; height: auto; max-height: 240px; display: flex; justify-content: center; }
.share-files.is-single .share-thumb img { width: auto; max-width: 100%; height: auto; max-height: 240px; object-fit: contain; }
.share-doc { display: grid; place-items: center; align-content: center; gap: 4px; padding: 8px; color: var(--ink-500); }
.share-doc svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.share-doc span { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-choices { display: grid; gap: 8px; }
.share-choice { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); color: var(--ink-900); font: inherit; text-align: left; cursor: pointer; transition: transform .14s var(--ease-out), box-shadow .14s var(--ease-out), background .15s; -webkit-user-select: none; user-select: none; }
@media (hover: hover) { .share-choice:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); } }
.share-choice:active { transform: scale(.98); box-shadow: var(--shadow-press); transition-duration: .08s; }
.share-choice:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.share-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-600); }
.share-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.share-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.share-text strong { font-size: 15px; font-weight: 600; }
.share-text small { font-size: 13px; color: var(--ink-500); }
.share-chev { flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: var(--ink-500); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) { .share-choice, .share-choice:hover, .share-choice:active { transform: none; } }

/* ---------- What's New (js/whats-new.js): every change people can see, by the day it shipped ---------- */
.wn-days { display: grid; gap: 16px; }
.wn-day { padding: 18px 22px 6px; }
.wn-date { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-500); padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.wn-list { list-style: none; margin: 0; padding: 0; }
.wn-item { padding: 16px 0; display: grid; gap: 8px; }
.wn-item + .wn-item { border-top: 1px solid var(--line); }
.wn-item h3 { font-size: 16px; font-weight: 600; line-height: 1.35; }
.wn-notes { color: var(--ink-700); font-size: 14.5px; line-height: 1.55; display: grid; gap: 6px; }
.wn-notes p, .wn-notes ul { margin: 0; }
.wn-notes ul { padding-left: 20px; display: grid; gap: 3px; }
.wn-pic { display: block; justify-self: start; max-width: min(100%, 560px); margin-top: 4px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .14s var(--ease-out), box-shadow .14s var(--ease-out); }
@media (hover: hover) { .wn-pic:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); } }
.wn-pic:active { transform: scale(.99); box-shadow: var(--shadow-press); }
.wn-pic img { display: block; width: 100%; height: auto; max-height: 340px; object-fit: cover; object-position: top; }
.wn-first .wn-item h3 { font-size: 17px; }
.wn-loading { padding: 24px 4px; }
.wn-empty { padding: 32px 24px; }
@media (min-width: 641px) { .dialog-picture { width: min(1100px, calc(100vw - 32px)); } }
.wn-full { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
@media (max-width: 560px) { .wn-day { padding: 16px 16px 4px; } }
@media (max-width: 640px) { .share-files.is-single .share-thumb:not(.share-doc), .share-files.is-single .share-thumb img { max-height: 180px; } }

/* ---------- CMI AI (js/assistant.js): round button bottom-right, chat panel above it; a bottom sheet on phones ---------- */
.ai-fab { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 42; width: 56px; height: 56px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; background: var(--accent-fill); color: var(--on-fill); box-shadow: var(--shadow-lift); cursor: pointer;
  transition: transform .18s var(--ease-out), box-shadow .18s, background .15s, opacity .15s; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ai-fab[hidden] { display: none; }
.ai-fab:hover { background: var(--accent-fill-hover); transform: translateY(-2px) scale(1.04); box-shadow: var(--shadow-lg); }
.ai-fab:active { transform: scale(.93); box-shadow: var(--shadow-press); transition-duration: .08s; }
.ai-fab svg { grid-area: 1 / 1; width: 26px; height: 26px; transition: transform .26s var(--ease-out), opacity .18s; }
.ai-spark { fill: currentColor; stroke: none; }
.ai-x { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.ai-fab .ai-x { opacity: 0; transform: rotate(-90deg) scale(.6); }
.ai-fab.on .ai-spark { opacity: 0; transform: rotate(90deg) scale(.6); }
.ai-fab.on .ai-x { opacity: 1; transform: none; }
.ai-fab:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 3px; }

.ai-backdrop { display: none; }
.ai-panel { position: fixed; right: 20px; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); z-index: 41; width: 400px; max-width: calc(100vw - 40px);
  height: min(640px, calc(100vh - var(--header-h) - 120px)); height: min(640px, calc(100dvh - var(--header-h) - 120px)); min-height: 320px;
  display: flex; flex-direction: column; background: var(--raised); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden;
  transform-origin: bottom right; animation: ai-in .24s var(--ease-out); }
.ai-panel[hidden] { display: none; }
.ai-panel.is-closing { animation: ai-out .18s ease-in forwards; pointer-events: none; }
@keyframes ai-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes ai-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }

.ai-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 12px 16px; border-bottom: 1px solid var(--line); }
.ai-head h2 { display: flex; align-items: center; gap: 8px; margin: 0 auto 0 0; font-size: 16px; font-weight: 700; color: var(--ink-900); }
.ai-head h2 svg { width: 20px; height: 20px; color: var(--brand-500); }
.ai-head .icon-btn svg { width: 20px; height: 20px; }

.ai-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text;
  animation: ai-msg-in .22s var(--ease-out); }
@keyframes ai-msg-in { from { opacity: 0; transform: translateY(6px); } }
.ai-me { align-self: flex-end; background: var(--accent-fill); color: var(--on-fill); border-bottom-right-radius: 6px; }
.ai-bot { align-self: flex-start; background: var(--canvas); color: var(--ink-900); border-bottom-left-radius: 6px; }
.ai-bot.ai-err { background: var(--overdue-bg); color: var(--overdue); }
.ai-text p { margin: 0 0 8px; }
.ai-text ul { margin: 0 0 8px; padding-left: 20px; }
.ai-text li + li { margin-top: 2px; }
.ai-text > :last-child { margin-bottom: 0; }
.ai-text code { font-size: 13px; padding: 1px 4px; border-radius: 4px; background: var(--muted-bg); }
.ai-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ai-links .chip { padding: 6px 12px; font-size: 13px; }
.ai-links .chip:active, .ai-ideas .chip:active { transform: scale(.96); }

.ai-prop { margin-top: 10px; padding: 12px; border: 1px solid var(--info-border); border-radius: 12px; background: var(--raised); -webkit-user-select: none; user-select: none; }
.ai-prop-head { display: grid; gap: 2px; margin-bottom: 8px; }
.ai-prop-head span { font-size: 13px; color: var(--ink-500); }
.ai-prop dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; font-size: 13.5px; }
.ai-prop dt { color: var(--ink-500); }
.ai-prop dd { margin: 0; color: var(--ink-900); white-space: pre-line; -webkit-user-select: text; user-select: text; }
.ai-prop-actions { display: flex; gap: 8px; }
.ai-prop-done { margin: 0; font-size: 13px; }

.ai-looked { margin-top: 8px; font-size: 12px; color: var(--ink-500); -webkit-user-select: none; user-select: none; }
.ai-looked summary { cursor: pointer; width: fit-content; }
.ai-looked ul { margin: 4px 0 0; padding-left: 18px; }

.ai-thinking { padding: 12px 16px; }
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-500); animation: ai-dot 1.1s infinite ease-in-out; }
.ai-dots i:nth-child(2) { animation-delay: .15s; }
.ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.ai-hello { margin: auto 0; text-align: center; padding: 8px 4px; }
.ai-hello-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--brand-50); color: var(--brand-500); margin-bottom: 8px; }
.ai-hello-icon svg { width: 26px; height: 26px; }
.ai-hello p { margin: 0 0 8px; font-size: 14.5px; }
.ai-ideas { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.ai-ideas .chip { font-size: 13px; padding: 7px 12px; }

.ai-ask { position: relative; display: flex; padding: 10px 12px 6px; border-top: 1px solid var(--line); }
.ai-ask textarea { flex: 1; min-width: 0; resize: none; min-height: 40px; max-height: 140px; padding: 9px 48px 9px 14px; border: 1px solid var(--ink-300); border-radius: 20px;
  font: inherit; font-size: 15px; line-height: 1.4; background: var(--surface); color: var(--ink-900); transition: border-color .15s, box-shadow .15s;
  overflow-y: hidden; scrollbar-width: none; }
/* Send sits inside the field's right end, bottom-aligned so it stays put as a long question grows. */
/* No scrollbar inside the rounded field (it showed as a grey bar at the right end); long questions still scroll by touch. */
.ai-ask textarea::-webkit-scrollbar { display: none; }
.ai-ask textarea.is-full { overflow-y: auto; }
.ai-ask textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-50); }
.ai-send { position: absolute; right: 16px; bottom: 10px; width: 32px; height: 32px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--accent-fill); color: var(--on-fill);
  cursor: pointer; transition: background .15s, transform .12s var(--ease-out), opacity .15s; -webkit-user-select: none; user-select: none; }
.ai-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ai-send:hover:not(:disabled) { background: var(--accent-fill-hover); }
.ai-send:active:not(:disabled) { transform: scale(.9); }
.ai-send:disabled { background: var(--muted-bg); color: var(--ink-500); cursor: default; }
.ai-foot { margin: 0; padding: 0 12px 10px; font-size: 11px; color: var(--ink-500); text-align: center; }

/* Phones: the button sits above the tab bar; the chat is a bottom sheet over a dimmed page (tap outside to close). */
@media (max-width: 860px) {
  body:has(.tabbar:not([hidden])) .ai-fab { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); right: 16px; width: 52px; height: 52px; }
  body:has(.tabbar:not([hidden])) .ai-panel { bottom: calc(144px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 640px) {
  .ai-backdrop { display: block; position: fixed; inset: 0; z-index: 43; background: var(--overlay); animation: backdrop-in .26s ease-out; }
  .ai-backdrop[hidden] { display: none; }
  .ai-backdrop.is-closing { animation: backdrop-out .24s ease-in forwards; }
  .ai-panel, body:has(.tabbar:not([hidden])) .ai-panel { left: 0; right: 0; bottom: 0; z-index: 44; width: 100%; max-width: 100%; height: 88vh; height: 88dvh; border-radius: 18px 18px 0 0;
    border-width: 1px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); animation: sheet-up .32s var(--ease-out); }
  .ai-panel.is-closing { animation: sheet-down .24s cubic-bezier(.4, 0, 1, 1) forwards; }
  .ai-panel::before { content: ""; display: block; flex: none; width: 36px; height: 5px; border-radius: 3px; background: var(--ink-300); margin: 8px auto 0; }
  .ai-head { padding-top: 6px; }
  html.ai-open { overflow: hidden; }
  html.ai-open .ai-fab { opacity: 0; pointer-events: none; transform: scale(.6); }
  .ai-msg { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-panel, .ai-panel.is-closing, .ai-backdrop, .ai-msg, .ai-dots i { animation: none !important; }
}

/* ---------- Get the App (js/get-app.js) ---------- */
.ga { display: grid; gap: 16px; max-width: 760px; }
.ga-card { padding: 20px 24px; }
.ga-card h2 { margin: 0 0 6px; font-size: 18px; }
.ga-card > p { margin: 0 0 12px; }
.ga-card > p:last-child, .ga-card > .btn-row:last-child { margin-bottom: 0; }
.ga-compare { margin: 12px -24px -20px; width: calc(100% + 48px); }
.ga-compare th[scope="row"] { font-weight: 500; }
.ga-compare td { text-align: center; white-space: nowrap; width: 1%; color: var(--ink-500); font-size: 13px; }
.ga-compare thead th:not(:first-child) { text-align: center; white-space: nowrap; }
.ga-yes { color: var(--ok); font-weight: 700; font-size: 16px; }
.ga-no { color: var(--ink-500); }
.ga-steps { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 20px; }
.ga-step { display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start; }
.ga-step h3 { margin: 4px 0 6px; font-size: 15px; }
.ga-step p { margin: 0 0 10px; }
.ga-num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--brand-50); color: var(--brand-600); }
.ga-step.is-done .ga-num { background: var(--ok-bg); color: var(--ok); }
.ga-devices { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.ga-devices li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 14px; }
.ga-url { display: block; width: fit-content; font-weight: 600; }
@media (min-width: 721px) { .ga-fold-head { display: flex; gap: 16px; } }
.ga-fold-head h2 { margin: 0; }
.ga-card.fold:not(.is-open) { padding-bottom: 20px; }
.ga-publish .fold-body > div > :first-child { margin-top: 16px; }
.ga-sub { margin: 24px 0 6px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-500); }
.ga-publish .fold-body p { margin: 0 0 10px; }
.ga-state { font-weight: 600; color: var(--ink-500); white-space: nowrap; }
.ga-state.is-ready { color: var(--ok); }
@media (max-width: 600px) {
  .ga-card { padding: 16px; }
  .ga-compare { margin: 12px -16px -16px; width: calc(100% + 32px); }
  .ga-compare th:first-child, .ga-compare td:first-child { padding-left: 16px; }
  .ga-compare th:last-child, .ga-compare td:last-child { padding-right: 16px; }
  .ga-compare th, .ga-compare td { padding: 10px 8px; }
}
.ga-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.ga-option { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; display: grid; align-content: start; gap: 8px; }
.ga-option h3 { margin: 0; font-size: 15px; }
.ga-option p { margin: 0; }
.ga-pros, .ga-cons { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.ga-pros li, .ga-cons li { padding-left: 20px; position: relative; }
.ga-pros li::before { content: '+'; position: absolute; left: 2px; color: var(--ok); font-weight: 700; }
.ga-cons li::before { content: '–'; position: absolute; left: 2px; color: var(--ink-500); font-weight: 700; }
.ga-current { color: var(--ok); font-weight: 600; }
.ga-note { margin: 12px 0 0 !important; font-size: 13px; }
@media (max-width: 600px) { .ga-options { grid-template-columns: 1fr; } }

/* ---------- Review Mode (js/review.js; admins and staff whose role allows it): comments pinned to text or elements, a bar bottom-left, a side panel ---------- */
body:not(.is-admin) .admin-only { display: none !important; }
body:not(.can-review) .review-only { display: none !important; }
.menu .review-toggle .menu-switch { position: relative; flex: none; width: 34px; height: 20px; margin-left: auto; border-radius: 999px; background: var(--ink-300); transition: background .18s; }
.menu .review-toggle .menu-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-press); transition: transform .2s var(--ease-out); }
.menu .review-toggle[aria-checked="true"] .menu-switch { background: var(--accent-fill); }
.menu .review-toggle[aria-checked="true"] .menu-switch::after { transform: translateX(14px); }

/* While reviewing, any text on the page can be selected to comment on (normally only what people typed can be). */
html.review-on body :not(.rv-ui, .rv-ui *), html.review-on dialog, html.review-on [popover] { -webkit-user-select: text !important; user-select: text !important; }
html.review-pick body :not(.rv-ui, .rv-ui *) { cursor: crosshair !important; }
::highlight(review) { background-color: rgba(250, 190, 20, .32); }
::highlight(review-active) { background-color: rgba(250, 170, 0, .62); color: inherit; }

.rv-layer { position: fixed; inset: 0; z-index: 35; pointer-events: none; overflow: hidden; }
.rv-hover, .rv-box { position: fixed; border-radius: 8px; pointer-events: none; }
.rv-hover { border: 2px solid var(--brand-500); background: rgba(11, 90, 153, .06); transition: left .08s, top .08s, width .08s, height .08s; }
.rv-hover[hidden] { display: none; }
.rv-hover::after { content: attr(data-label); position: absolute; left: -2px; bottom: calc(100% + 4px); max-width: 280px; padding: 3px 8px; border-radius: 6px; background: var(--inverse-bg); color: var(--inverse-fg);
  font: 600 12px/1.4 Inter, system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-hover.label-below::after { bottom: auto; top: calc(100% + 4px); }
.rv-box { border: 2px solid rgba(232, 160, 0, .9); background: rgba(250, 190, 20, .1); }
.rv-box.is-active, .rv-box.is-draft { border-color: #e08a00; background: rgba(250, 190, 20, .2); box-shadow: 0 0 0 4px rgba(250, 190, 20, .25); }
.rv-box.is-draft { border-style: dashed; }
.rv-pin { position: fixed; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border: 2px solid var(--surface); border-radius: 11px 11px 11px 3px;
  background: #e08a00; color: #fff; font: 700 11px/1 Inter, system-ui, sans-serif; cursor: pointer; pointer-events: auto; box-shadow: var(--shadow-press);
  transition: transform .14s var(--ease-out); -webkit-user-select: none; user-select: none; }
.rv-pin:hover { transform: scale(1.15); }
.rv-pin.is-active { background: var(--accent-fill); transform: scale(1.15); }
.rv-pin.is-resolved { background: var(--muted); }

.rv-bar { position: fixed; left: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 46; display: flex; align-items: center; gap: 2px; padding: 5px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lift); animation: rv-up .24s var(--ease-out); -webkit-user-select: none; user-select: none; }
.rv-bar[hidden] { display: none; }
@keyframes rv-up { from { opacity: 0; transform: translateY(12px); } }
.rv-bar svg, .rv-add svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.rv-bar-title { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px 0 6px; font-size: 14px; font-weight: 700; color: #b06a00; }
.rv-bar-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 0; border-radius: 9px; background: none; color: var(--ink-700); font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .15s, color .15s, transform .12s var(--ease-out); }
.rv-bar-btn:hover { background: var(--canvas); color: var(--ink-900); }
.rv-bar-btn:active { transform: scale(.95); }
.rv-bar-btn[aria-pressed="true"], .rv-bar-btn[aria-expanded="true"] { background: var(--brand-50); color: var(--brand-600); }
.rv-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #e08a00; color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.rv-count.is-zero { background: var(--muted-bg); color: var(--ink-500); }
.rv-bar-x { width: 34px; padding: 0; justify-content: center; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rv-bar-title { color: var(--due); } }
:root[data-theme="dark"] .rv-bar-title { color: var(--due); }

.rv-add { position: fixed; z-index: 47; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 12px; border: 0; border-radius: 18px; background: var(--accent-fill);
  color: var(--on-fill); font: inherit; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lift); cursor: pointer; animation: rv-pop .16s var(--ease-out); -webkit-user-select: none; user-select: none; }
.rv-add[hidden] { display: none; }
.rv-add:hover { background: var(--accent-fill-hover); }
.rv-add:active { transform: scale(.95); }
@keyframes rv-pop { from { opacity: 0; transform: scale(.85); } }

.rv-backdrop { display: none; }
.rv-panel { position: fixed; right: 16px; top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 12px); bottom: 16px; z-index: 48; width: 380px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; background: var(--raised); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rv-in .24s var(--ease-out); -webkit-user-select: none; user-select: none; }
.rv-panel[hidden] { display: none; }
@keyframes rv-in { from { opacity: 0; transform: translateX(16px); } }
.rv-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 10px 16px; }
.rv-head > div { margin-right: auto; min-width: 0; }
.rv-head h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink-900); }
.rv-sub { margin: 1px 0 0; font-size: 13px; color: var(--ink-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-all { font-size: 13px; font-weight: 600; color: var(--brand-500); text-decoration: none; border-bottom: 1px dashed currentColor; white-space: nowrap; }
.rv-all:hover { border-bottom-style: solid; }
.rv-tabs { margin: 0 16px 10px; align-self: flex-start; }
.rv-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 16px; display: grid; align-content: start; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.rv-empty { margin: 24px 8px; text-align: center; color: var(--ink-500); font-size: 14px; text-wrap: balance; }

.rv-thread { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.rv-panel .rv-thread { cursor: pointer; }
.rv-panel .rv-thread:hover { border-color: var(--ink-300); }
.rv-thread.is-active { border-color: #e08a00; box-shadow: 0 0 0 3px rgba(250, 190, 20, .22); cursor: default; }
.rv-thread.is-resolved { opacity: .8; }
.rv-thread-head { display: flex; align-items: flex-start; gap: 6px; }
.rv-quote { display: flex; align-items: flex-start; gap: 8px; flex: 1; min-width: 0; padding: 0; border: 0; background: none; font: inherit; text-align: left; color: var(--ink-700); cursor: pointer; text-decoration: none; }
.rv-quote q, .rv-draft-on q { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-left: 8px; border-left: 3px solid #e8a000; font-size: 13.5px; quotes: "“" "”"; }
.rv-el { font-size: 13.5px; font-weight: 600; color: var(--ink-700); }
.rv-num { display: grid; place-items: center; flex: none; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px 11px 11px 3px; background: #e08a00; color: #fff; font-size: 11px; font-weight: 700; }
.rv-thread.is-resolved .rv-num { background: var(--muted); }
.rv-resolve { flex: none; width: 30px; height: 30px; margin: -4px -4px 0 0; }
.rv-resolve svg { width: 18px; height: 18px; }
.rv-resolve[data-rv="resolve"]:hover { color: var(--ok); background: var(--ok-bg); }
.rv-kind { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0 0 30px; font-size: 12.5px; }
.rv-kind .link-btn { color: var(--ink-500); }
.rv-kind .link-btn:hover { color: var(--brand-500); }
.rv-kind-pick { justify-self: start; }
.rv-missing { margin: 8px 0 0; font-size: 12px; color: var(--due); }
.rv-missing[hidden] { display: none; }
.rv-resolved-by { margin: 8px 0 0; font-size: 12px; color: var(--ink-500); }
.rv-comments { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 12px; }
.rv-comment { display: flex; gap: 10px; }
.rv-comment .avatar { width: 28px; height: 28px; font-size: 11px; }
.rv-comment-main { flex: 1; min-width: 0; }
.rv-who { margin: 0; font-size: 13px; color: var(--ink-500); }
.rv-who strong { color: var(--ink-900); font-weight: 600; margin-right: 4px; }
.rv-text { margin: 2px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink-900); white-space: pre-wrap; overflow-wrap: anywhere; text-wrap: pretty; -webkit-user-select: text; user-select: text; }
.rv-own { display: flex; gap: 12px; margin: 4px 0 0; font-size: 12.5px; }
.rv-own .link-btn { color: var(--ink-500); }
.rv-own .link-btn:hover { color: var(--brand-500); }

.rv-form { display: grid; gap: 8px; }
.rv-reply { margin-top: 10px; }
.rv-form textarea { width: 100%; min-height: 36px; resize: none; padding: 8px 12px; border: 1px solid var(--ink-300); border-radius: 10px; background: var(--raised); color: var(--ink-900);
  font: inherit; font-size: 14px; line-height: 1.4; transition: border-color .15s, box-shadow .15s; }
.rv-form textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-50); }
.rv-form-actions { display: flex; justify-content: flex-end; gap: 6px; }
/* A reply's button shows once something is typed in it. */
.rv-reply .rv-form-actions { display: none; }
.rv-reply:focus-within .rv-form-actions, .rv-reply:has(textarea:not(:placeholder-shown)) .rv-form-actions { display: flex; }
.rv-draft { padding: 12px; border: 1px dashed #e08a00; border-radius: 12px; background: var(--surface); }
.rv-draft-on { margin: 0; }

/* Phones: the bar sits above the tab bar; the panel is a bottom sheet over a lightly dimmed page. */
@media (max-width: 860px) {
  body:has(.tabbar:not([hidden])) .rv-bar { left: 12px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .rv-bar-title span { display: none; }
}
@media (max-width: 640px) {
  .rv-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 47; background: var(--overlay); opacity: .5; animation: backdrop-in .26s ease-out; }
  .rv-panel { left: 0; right: 0; top: auto; bottom: 0; width: 100%; max-width: 100%; height: 62vh; height: 62dvh; border-radius: 18px 18px 0 0; border-width: 1px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px); animation: sheet-up .32s var(--ease-out); }
  .rv-panel::before { content: ""; display: block; flex: none; width: 36px; height: 5px; border-radius: 3px; background: var(--ink-300); margin: 8px auto 0; }
  .rv-head { padding-top: 6px; }
  html.rv-panel-open .rv-bar { opacity: 0; pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) { .rv-bar, .rv-add, .rv-panel, .rv-hover { animation: none !important; transition: none !important; } }

/* Review Comments (/review) */
.rv-intro { margin: 6px 2px 0; max-width: 64ch; text-wrap: pretty; }
.rv-find { gap: 10px; }
.rv-batch:not([hidden]) { display: flex; align-items: flex-start; gap: 14px; padding: 16px 20px; }
.rv-batch > svg { flex: none; width: 24px; height: 24px; margin-top: 1px; fill: none; stroke: var(--brand-500); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rv-batch-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; }
.rv-batch-text { margin: 4px 0 0; max-width: 72ch; }
.rv-show { justify-self: start; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.rv-show button { white-space: nowrap; }
.rv-list { display: grid; gap: 16px; }
.rv-page { padding: 6px 0; }
.rv-page-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; padding: 12px 18px 6px; }
.rv-page-head h2 { margin: 0; font-size: 17px; }
.rv-page-head .muted { font-size: 13px; }
.rv-row { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 14px 18px; background: none; }
.rv-page-head + .rv-row { border-top: 0; }
.rv-row .rv-quote:hover q, .rv-row .rv-quote:hover .rv-el { color: var(--brand-500); }
.rv-row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0 38px; }
.rv-list, .rv-page, .rv-row { min-width: 0; }
@media (max-width: 560px) {
  .rv-row { padding: 14px; }
  .rv-row .rv-comments, .rv-row-actions, .rv-row .rv-kind { margin-left: 0; }
}
.rv-row .rv-comments { margin-left: 30px; }
.rv-loading { padding: 24px 4px; }

/* ---------- live updates (js/live.js): what someone else just changed ---------- */
/* Changed: a soft amber glow that fades back. New: slides in with the same glow. Deleted: fades out first. */
:root { --live-glow: color-mix(in srgb, var(--due-fill) 24%, transparent); --live-ring: color-mix(in srgb, var(--due-fill) 60%, transparent); }
@keyframes live-glow { from, 30% { background-color: var(--live-glow); } }
@keyframes live-ring { from, 30% { box-shadow: 0 0 0 3px var(--live-ring), 0 0 24px 4px var(--live-glow); } }
@keyframes live-field { from, 30% { box-shadow: 0 0 0 3px var(--live-glow); background-color: var(--live-glow); } }
@keyframes live-in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes live-out { to { opacity: 0; } }
tr.live-changed > *, .dir-row.live-changed, .specs.live-changed { animation: live-glow 3s var(--ease-out); }
tr.live-new > * { animation: live-glow 3s var(--ease-out), live-in .35s var(--ease-out); }
.dir-row.live-new { animation: live-glow 3s var(--ease-out), live-in .35s var(--ease-out); }
li.live-changed > .portfolio-card { animation: live-ring 3s var(--ease-out); }
li.live-new > .portfolio-card { animation: live-ring 3s var(--ease-out), live-in .35s var(--ease-out); }
.live-leaving, .live-leaving > * { animation: live-out .4s var(--ease-out) forwards; pointer-events: none; }
.live-changed :is(input, textarea, .dd-trigger), .check.live-changed { animation: live-field 3s var(--ease-out); }
.live-note { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 6px; font-size: 13px; font-weight: 400; color: var(--due); }
.live-note strong { font-weight: 600; overflow-wrap: anywhere; }
.live-banner { margin: 0 0 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--due-bg); color: var(--due); font-size: 14px; }
/* Deleted while it was open: everything but the banner is greyed out and can't be used. */
#dialog-body.is-locked > :not(.live-banner) { opacity: .55; pointer-events: none; }
#dialog-body.is-locked :is(input, textarea, .dd-trigger) { background: var(--muted-bg); box-shadow: none; }
.live-banner.is-danger { background: var(--overdue-bg); color: var(--overdue); }
/* Phones show each table row as a card: the whole card glows, not each cell. */
@media (max-width: 720px) {
  .table tr.live-changed > *, .table tr.live-new > * { animation: none; }
  .table tr.live-changed { animation: live-glow 3s var(--ease-out); }
  .table tr.live-new { animation: live-glow 3s var(--ease-out), live-in .35s var(--ease-out); }
}
@media (prefers-reduced-motion: reduce) {
  tr.live-new > *, .dir-row.live-new, .table tr.live-new { animation: live-glow 3s linear; }
  li.live-new > .portfolio-card { animation: live-ring 3s linear; }
  .live-leaving, .live-leaving > * { animation: none; opacity: .4; }
}

/* ---------- passkey lock on financial areas (app.js financeLockHtml, src/lib/finance.ts) ---------- */
.finance-lock { display: grid; justify-items: center; gap: 12px; padding: 36px 24px 32px; text-align: center; }
/* On the Invoices page the section has no title of its own (the page has it), so the lock card is the whole card. */
body[data-route="invoices"] #sec-invoices.is-locked .panel-head { display: none; }
.finance-lock h3 { margin: 4px 0 0; font-size: 20px; }
.finance-lock p { max-width: 460px; color: var(--ink-500); }
.lock-badge { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--brand-50); color: var(--brand-600); animation: lock-in .45s var(--ease-out) both; }
.lock-badge svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes lock-in { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.lock-actions { display: grid; gap: 10px; width: min(300px, 100%); margin-top: 4px; }
.btn > svg:not([class]) { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.lock-fine { font-size: 13px; }
/* While locked, nothing about money shows in the Invoices section, its search, or its Add button. */
#sec-invoices.is-locked :is(.table-wrap, .empty, #balance-line, .panel-add, .view-all) { display: none !important; }
body.invoices-locked[data-route="invoices"] :is(#list-find, [data-action="add-invoice"].btn) { display: none !important; }
#sec-invoices:not(.is-locked) .finance-lock-slot:empty { display: none; }
.finance-lock-btn svg { width: 17px; height: 17px; }
.kpi-locked { border-left-color: var(--ink-300); }
.kpi-locked .kpi-value { display: inline-flex; align-items: center; gap: 6px; }
.kpi-locked .kpi-value svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.card-locked { color: var(--ink-500); font-weight: 500; }
.bal-locked { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-500); font-weight: 500; font-size: 13px; }
.bal-locked svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.passkey-points { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-700, var(--ink-900)); }
.passkey-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--canvas); }
.passkey-status > span { flex: 1; min-width: 180px; }
.passkey-status svg, .passkey-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.passkey-status.is-open svg { color: var(--ok); }
.passkey-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.passkey-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.passkey-list li:last-child { border-bottom: 0; }
.passkey-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand-50); color: var(--brand-600); flex: none; }
.passkey-name { flex: 1; min-width: 0; display: grid; }
.session-finance { padding: 0 24px 20px; display: grid; gap: 10px; }
.session-finance .session-fields { padding: 0; }
@media (max-width: 640px) { .session-finance { padding: 0 16px 16px; } }

/* ---------- Privacy (public/privacy.html): a plain page that opens signed out too ---------- */
.container.privacy { display: grid; gap: 16px; max-width: 840px; padding-top: 28px; padding-bottom: 40px; flex: 1 0 auto; }
.privacy .page-head { row-gap: 12px; }
.privacy .page-head .btn { order: 2; }
.privacy-card { padding: 28px; }
.privacy-card h2 { font-size: 18px; margin: 24px 0 8px; }
.privacy-card p { margin: 0 0 10px; }
.privacy-card .lede { font-size: 16px; }
.privacy-list { margin: 0; display: grid; gap: 4px; }
.privacy-list dt { font-weight: 600; margin-top: 10px; }
.privacy-list dd { margin: 0; color: var(--ink-700); }
.login-privacy { margin-top: -6px; }
@media (max-width: 560px) { .privacy-card { padding: 20px 18px; } }

/* Send a New Code, under an emailed code's boxes (app.js codeDialog) */
.code-resend { display: flex; justify-content: center; margin-top: -4px; }
.code-resend .link-btn { font-size: 14px; font-weight: 600; padding: 4px 6px; }
