/* Firmdesk's stylesheet. No build step: this file is what the browser gets.

   1. Tokens       the values everything else is made of: colour, type, space, radius, shadow
   2. Base         the page, links, headings
   3. App shell    sidebar, phone top bar, menus
   4. Pages        one section per part of the app (deadlines, tasks, time, billing, portal...)
   5. Components   buttons, fields, tables, badges, tabs, page headers, filters, search

   Colours come from tokens only, so the light and dark themes are each a list of values. The theme follows the
   computer's setting unless someone picks one (the user menu; kept in this browser): <html data-theme="light|dark">. */

@font-face {
  font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght-normal.1ad231aac0a8.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.260c81a4759b.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- 1. Tokens ---------------------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Space: a 4px scale */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px;
  --space-8: 32px; --space-10: 40px; --space-12: 48px;

  /* Type */
  --font: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.75rem; --text-sm: 0.8125rem; --text-base: 0.875rem; --text-md: 0.9375rem; --text-lg: 1.0625rem;
  --text-xl: 1.25rem; --text-2xl: 1.5rem; --text-3xl: 1.875rem;

  /* Shape */
  --radius-sm: 4px; --radius-md: 6px; --radius: 8px; --radius-lg: 12px; --radius-full: 999px;
  --control-height: 34px;
  --touch-target: 44px;

  /* Surfaces and text */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f1f3f6;
  --text: #182230;
  --text-2: #344054;
  --muted: #5d6b82;
  --border: #e4e7ec;
  --border-strong: #cfd4dc;
  --control-off: #c3c8d0;

  /* Brand and links */
  --primary: #2458d6;
  --primary-hover: #1c47b0;
  --primary-soft: #e8effd;
  --on-primary: #ffffff;
  --link: #2458d6;
  --focus-ring: rgba(36, 88, 214, 0.32);

  /* Status: what the colour means, the same everywhere */
  --danger: #c93434;  /* overdue, errors, destructive */
  --danger-solid: #c93434;
  --danger-bg: #fdecec;
  --danger-border: #f1b5b5;
  --warning: #d98a1c;  /* due soon, needs a look */
  --warning-text: #8f4d00;
  --warning-bg: #fdf0dc;
  --warning-bg-soft: #fffaf2;
  --warning-border: #d98a1c;
  --warning-border-soft: #f0cf9b;
  --success: #1d8a52;  /* done, paid, approved */
  --success-text: #1d6b3f;
  --success-bg: #e8f6ee;
  --success-border: #a8dbbd;
  --info-text: #2458d6;  /* in progress, new */
  --info-bg: #e7eefc;
  --info-border: #b9ccf5;
  --purple: #8a5cf6;  /* waiting on the client, meetings */
  --purple-text: #6d3fd6;
  --purple-bg: #efe9fe;
  --error-bg: var(--danger-bg);

  --status-overdue: var(--danger);
  --status-soon: var(--warning);
  --status-waiting: var(--purple);
  --status-progress: var(--primary);
  --status-done: var(--success);

  /* The sidebar keeps its own dark surface in both themes */
  --sidebar-bg: #131c2b;
  --sidebar-text: #b9c3d3;
  --sidebar-heading: #8492a8;
  --sidebar-active: #22304a;
  --sidebar-hover: #1b2740;
  --sidebar-border: rgba(255, 255, 255, 0.08);

  /* Depth */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.12);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, 0.18);
  --backdrop: rgba(16, 22, 32, 0.45);

  /* Charts */
  --series-1: #2a78d6; --series-2: #eb6834; --chart-grid: #eceef1; --chart-base: #c3c8d0;
}

/* The dark theme, chosen in the user menu. The same list follows for computers set to dark. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116; --surface: #161a21; --surface-2: #1b2029; --surface-3: #232935;
  --text: #e6e9ee; --text-2: #c9cfd9; --muted: #98a2b3; --border: #2a303b; --border-strong: #3d4554;
  --control-off: #3a4452;
  --primary: #2f5fd6; --primary-hover: #3b6ae0; --primary-soft: #1a2744; --link: #8fb0ff;
  --focus-ring: rgba(143, 176, 255, 0.4);
  --danger: #ef6464; --danger-solid: #c93434; --danger-bg: #3a1c1c; --danger-border: #6b2c2c;
  --warning: #e0a040; --warning-text: #f3c27a; --warning-bg: #3a2a14; --warning-bg-soft: #241c10;
  --warning-border: #a86a14; --warning-border-soft: #5a4220;
  --success: #4cc38a; --success-text: #8fd9ad; --success-bg: #173324; --success-border: #2a5a40;
  --info-text: #9bb8f5; --info-bg: #1c2a47; --info-border: #2c3f66;
  --purple: #a78bfa; --purple-text: #c4b0fb; --purple-bg: #2a2145;
  --sidebar-bg: #0a0d12; --sidebar-active: #1c2638; --sidebar-hover: #141b28;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6);
  --backdrop: rgba(0, 0, 0, 0.6);
  --series-1: #3987e5; --series-2: #d95926; --chart-grid: #262e3a; --chart-base: #3a4452;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1116; --surface: #161a21; --surface-2: #1b2029; --surface-3: #232935;
    --text: #e6e9ee; --text-2: #c9cfd9; --muted: #98a2b3; --border: #2a303b; --border-strong: #3d4554;
    --control-off: #3a4452;
    --primary: #2f5fd6; --primary-hover: #3b6ae0; --primary-soft: #1a2744; --link: #8fb0ff;
    --focus-ring: rgba(143, 176, 255, 0.4);
    --danger: #ef6464; --danger-solid: #c93434; --danger-bg: #3a1c1c; --danger-border: #6b2c2c;
    --warning: #e0a040; --warning-text: #f3c27a; --warning-bg: #3a2a14; --warning-bg-soft: #241c10;
    --warning-border: #a86a14; --warning-border-soft: #5a4220;
    --success: #4cc38a; --success-text: #8fd9ad; --success-bg: #173324; --success-border: #2a5a40;
    --info-text: #9bb8f5; --info-bg: #1c2a47; --info-border: #2c3f66;
    --purple: #a78bfa; --purple-text: #c4b0fb; --purple-bg: #2a2145;
    --sidebar-bg: #0a0d12; --sidebar-active: #1c2638; --sidebar-hover: #141b28;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6);
    --backdrop: rgba(0, 0, 0, 0.6);
    --series-1: #3987e5; --series-2: #d95926; --chart-grid: #262e3a; --chart-base: #3a4452;
  }
}

/* --- 2. Base ------------------------------------------------------------------------------------------ */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: var(--text-base)/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";  /* Inter: single-storey a, open digits */
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text); letter-spacing: -0.011em; }
h1 { font-size: var(--text-2xl); font-weight: 650; line-height: 1.25; margin: 0; }
h2 { font-size: var(--text-lg); font-weight: 600; margin: 0 0 12px; }
h3 { font-size: var(--text-md); font-weight: 600; margin: 20px 0 8px; }
strong, b { font-weight: 600; }
code { font-family: var(--font-mono); font-size: 0.92em; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-soft); }

/* --- 3. App shell: sidebar (a slide-in drawer below 900px), phone top bar, main content ------------------- */
.layout { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; padding: 28px 36px 48px; max-width: 1240px; }
.content:focus { outline: none; }  /* focused by the skip link */
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: var(--radius-md); background: #1c47b0; color: #fff; }
.skip-link:focus { top: 12px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--radius-md); background: none; color: inherit; cursor: pointer;
}
.icon-button:hover { background: rgba(127, 137, 150, 0.16); }
.icon-button .icon { width: 20px; height: 20px; }
.sidebar .icon-button:hover, .topbar .icon-button:hover { background: rgba(255, 255, 255, 0.1); }

.sidebar {
  width: 244px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px; padding: 12px 12px 10px;
  background: var(--sidebar-bg); color: var(--sidebar-text); font-size: var(--text-sm);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding: 0 0 0 8px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: #fff; font-weight: 650; font-size: 1.05rem; letter-spacing: -0.015em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0; }
.sidebar-close, .sidebar-toggle { display: none; }
/* Wider screens: the menu button beside the brand hides the sidebar down to a strip that keeps just
   that button (static/js/app.js; base.html's <head> script brings the choice back on every page). */
@media (min-width: 900px) {
  .js .sidebar-toggle { display: inline-flex; }
  /* Collapsed: a rail of icons (each link keeps its name as a tooltip), without the names and headings. */
  .sidebar-hidden .sidebar { width: 64px; padding-left: 10px; padding-right: 10px; }
  .sidebar-hidden .brand, .sidebar-hidden .nav a > span, .sidebar-hidden .nav-heading,
  .sidebar-hidden .menu-button-text, .sidebar-hidden .menu-button .chevron,
  .sidebar-hidden .search-button span, .sidebar-hidden .search-button kbd { display: none; }
  .sidebar-hidden .sidebar-top { padding: 0; justify-content: center; }
  .sidebar-hidden .nav a, .sidebar-hidden .menu-button, .sidebar-hidden .search-button { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar-hidden .nav-group + .nav-group { border-top: 1px solid var(--sidebar-border); padding-top: 8px; }
  .sidebar-hidden .menu-panel { left: 0; right: auto; min-width: 240px; }
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 6px 10px; border-radius: var(--radius-md); color: var(--sidebar-text); font-weight: 500; }
.nav a .icon { width: 17px; height: 17px; opacity: 0.85; }
.nav a:hover { background: var(--sidebar-hover); text-decoration: none; color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav a.active .icon { opacity: 1; color: #8fb0ff; }
.nav a:focus-visible, .menu-button:focus-visible, .search-button:focus-visible { outline: 2px solid #8fb0ff; outline-offset: 1px; }
.sidebar .nav { flex: 1; gap: 16px; margin-top: 4px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-heading { padding: 0 10px 5px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sidebar-heading); }
.nav-bottom { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--sidebar-border); }

/* Search: a button that looks like a field; it opens the search box (Ctrl+K) */
.search-button {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 6px 10px; margin: 2px 0 4px;
  border: 1px solid var(--sidebar-border); border-radius: var(--radius-md); background: rgba(255, 255, 255, 0.04);
  color: var(--sidebar-text); font: inherit; text-align: left; cursor: pointer;
}
.search-button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; text-decoration: none; }
.search-button .icon { width: 16px; height: 16px; }
.search-button span { flex: 1; }
.search-button kbd, .kbd {
  padding: 1px 6px; border: 1px solid var(--sidebar-border); border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.06);
  font: 500 0.6875rem/1.5 var(--font); color: var(--sidebar-heading);
}

/* Menu panels: <details class="menu"> (static/js/app.js closes them on an outside click or Escape) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-button { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-md); cursor: pointer; color: #fff; }
.menu-button:hover, .menu[open] > .menu-button { background: var(--sidebar-hover); }
.menu-button-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.menu-button .chevron { width: 15px; height: 15px; opacity: 0.6; transition: transform 0.15s; }
.menu[open] > .menu-button .chevron { transform: rotate(180deg); }
.sidebar-workspace-name, .user-name, .user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-workspace-name { font-weight: 600; font-size: var(--text-base); }
.user-name { font-weight: 600; }
.user-email { font-size: var(--text-xs); color: var(--sidebar-heading); }
.workspace-mark {
  width: 28px; height: 28px; flex-shrink: 0; display: grid; place-items: center; border-radius: 7px;
  background: var(--primary); color: #fff; font-weight: 700; font-size: var(--text-sm); object-fit: contain;
}
img.workspace-mark { background: #fff; padding: 2px; }
.avatar {
  width: 28px; height: 28px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%;
  background: #334463; color: #fff; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.02em;
}
.menu-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; padding: 5px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-md); font-size: var(--text-base);
}
.user-menu .menu-panel { top: auto; bottom: calc(100% + 4px); }
.menu form { margin: 0; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px; border: 0; border-radius: var(--radius-md);
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; white-space: nowrap;
}
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item:focus-visible { background: var(--surface-3); outline: 2px solid var(--primary); outline-offset: -2px; }
.menu-item .icon { width: 16px; height: 16px; color: var(--muted); }
.menu-item.is-current { font-weight: 600; cursor: default; }
.menu-item.is-current:hover { background: none; }
.menu-item.is-current .icon { color: var(--primary); }
.menu-item.is-danger, .menu-item.is-danger .icon { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-bg); }
.menu-heading { padding: 8px 10px 4px; font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.menu-divider { height: 1px; margin: 5px 4px; background: var(--border); }
.workspace-menu { margin-bottom: 2px; }
.user-menu { margin-top: auto; }  /* at the bottom even when there's no nav (no workspace yet) */
.help-menu { margin-top: auto; }  /* then Help is the first thing at the bottom, the user menu under it */
.help-menu + .user-menu { margin-top: 0; }
.help-menu .menu-panel { top: auto; bottom: calc(100% + 4px); }
.help-menu .menu-button { color: var(--sidebar-text); font-weight: 500; }
.help-menu .menu-button > .icon { width: 17px; height: 17px; opacity: 0.85; }
.help-menu .menu-item { white-space: normal; }

/* Theme: system, light or dark (static/js/app.js) */
.theme-switch { display: flex; gap: 2px; margin: 2px 4px 4px; padding: 2px; border-radius: var(--radius-md); background: var(--surface-3); }
.theme-switch button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 28px; padding: 3px 6px; border: 0;
  border-radius: var(--radius-sm); background: none; color: var(--muted); font: 500 var(--text-xs)/1 var(--font); cursor: pointer;
}
.theme-switch button .icon { width: 14px; height: 14px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.no-js .theme-switch { display: none; }

.topbar, .nav-backdrop { display: none; }
.nav-backdrop { cursor: pointer; }  /* iOS only sends taps on clickable-looking elements */

@media (max-width: 899px) {
  .layout { flex-direction: column; }
  .content { padding: 20px 16px 40px; }
  .nav a, .menu-item { min-height: var(--touch-target); }  /* a finger's width */
  .sidebar { font-size: var(--text-base); }

  /* Without JS the sidebar is a block at the top of the page. */
  .no-js .sidebar { position: static; width: auto; height: auto; overflow: visible; }
  .no-js .nav { flex-direction: row; flex-wrap: wrap; }
  .no-js .nav-bottom { margin: 0; padding: 0; border: 0; }
  .no-js .user-menu, .no-js .help-menu { margin-top: 0; }

  /* With JS it's a drawer, opened from the top bar. */
  .js .topbar {
    display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 30;
    height: 56px; padding: 0 8px; background: var(--sidebar-bg); color: #fff;
  }
  .topbar .icon-button { width: var(--touch-target); height: var(--touch-target); }
  .topbar-brand { color: #fff; font-weight: 650; font-size: 1.05rem; }
  .topbar-brand:hover { text-decoration: none; }
  .topbar-workspace {
    margin-left: auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; font-size: var(--text-sm); color: var(--sidebar-text);
  }
  .js .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: min(300px, 86vw); height: auto;
    transform: translateX(-100%); visibility: hidden; box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
  }
  .js.nav-open .sidebar { transform: none; visibility: visible; }
  /* Slide only while opening or closing (app.js sets nav-animate), not when the layout changes. */
  .js.nav-animate .sidebar { transition: transform 0.2s ease, visibility 0s linear 0.2s; }
  .js.nav-animate.nav-open .sidebar { transition: transform 0.2s ease; }
  .js .sidebar-close { display: inline-flex; }
  .js.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10, 15, 25, 0.5); }
  .js { scroll-padding-top: 64px; }  /* links to #sections land below the sticky top bar */
  .js.nav-open body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .menu-button .chevron { transition: none !important; }
  * { scroll-behavior: auto !important; }
}

/* --- 4. Pages ----------------------------------------------------------------------------------------- */
/* Deadlines (the tracker) */
.content.wide { max-width: none; }
.tracker-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
.segmented a { padding: 6px 14px; color: var(--text); font-size: 0.9rem; }
.segmented a + a { border-left: 1px solid var(--border); }
.segmented a:hover { text-decoration: none; background: var(--bg); }
.segmented a.active { background: var(--primary); color: #fff; }
.tracker-nav { display: flex; gap: 6px; align-items: center; }
.tracker-nav .btn.active { border-color: var(--primary); color: var(--link); }
.range-label { margin-left: 6px; font-weight: 600; }
.tracker-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.tracker-filters input[type="search"] { min-width: 200px; }
@media (max-width: 720px) {  /* two filters per row */
  .tracker-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tracker-filters input[type="search"] { grid-column: 1 / -1; min-width: 0; }
  .tracker-filters select { width: 100%; min-width: 0; }
}
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 0.9rem; white-space: nowrap; }
.count { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 999px; background: var(--border); color: var(--muted); font-size: 0.75rem; text-align: center; font-weight: 600; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
@media (max-width: 720px) {  /* one column at a time, swiped */
  .board { grid-auto-columns: 86%; scroll-snap-type: x mandatory; }
  .board-column { scroll-snap-align: start; }
}
.board-column { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.board-column.overdue { border-color: var(--danger); }
.board-column.overdue .column-title { color: var(--danger); }
.board-column.current { border-color: var(--primary); }
.column-header { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.column-title { font-weight: 600; }
.column-sub { font-size: 0.8rem; color: var(--muted); }
.column-items { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.column-empty { margin: 4px; }

.deadline-card { border: 1px solid var(--border); border-left-width: 3px; border-radius: 6px; padding: 8px 10px; background: var(--bg); font-size: 0.88rem; }
.deadline-card.statutory { border-left-color: var(--danger); }
.deadline-card.contractual { border-left-color: var(--primary); }
.deadline-card.meeting { border-left-color: var(--purple); }
.client-handled { opacity: 0.55; }
.is-done .card-title { text-decoration: line-through; }
.card-date { font-size: 0.8rem; font-weight: 600; }
.card-entity { display: block; font-weight: 600; margin-top: 2px; }
.card-title { margin: 2px 0 6px; }
.card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.card-actions { display: flex; gap: 6px; }
.overdue-text { color: var(--danger); font-weight: 600; }

/* Tags: what a tracker item is */
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.badge.badge-filing { background: var(--error-bg); color: var(--danger); }
.badge.badge-payment { background: var(--warning-bg); color: var(--warning-text); }
.badge.badge-contractual { background: var(--info-bg); color: var(--info-text); }
.badge.badge-meeting { background: var(--purple-bg); color: var(--purple-text); }

.group-row th { background: var(--bg); color: var(--text); text-transform: none; letter-spacing: 0; font-size: 0.9rem; }
.group-row.overdue th { color: var(--danger); }
.group-row.current th { color: var(--link); }
.tracker-table tr.statutory td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.tracker-table tr.contractual td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.tracker-table tr.meeting td:first-child { box-shadow: inset 3px 0 0 var(--purple); }

/* Tasks */
.tick {
  width: 18px; height: 18px; padding: 0; border: 1.5px solid var(--muted); border-radius: 4px;
  background: var(--surface); color: #fff; font-size: 12px; line-height: 1; cursor: pointer; flex-shrink: 0;
}
.tick:hover { border-color: var(--primary); }
.tick.done { background: var(--primary); border-color: var(--primary); }
.task-progress { margin: 4px 0 6px; font-size: 0.85rem; }
.progress-line { display: inline-flex; align-items: center; gap: 6px; }
.task-progress progress, .progress-line progress { width: 70px; height: 6px; accent-color: var(--primary); }
.next-task { display: flex; align-items: center; gap: 6px; margin-top: 4px; min-width: 0; }
.next-task-title { flex: 1; min-width: 0; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.success-text { color: var(--success-text); font-weight: 600; }
.deadline-card.task { border-left-style: dashed; border-left-color: var(--muted); }
.card-for { margin: -4px 0 6px; }
.badge.badge-task { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.who { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.who-chip {
  display: inline-block; min-width: 1.9em; padding: 1px 5px; border-radius: 999px; text-align: center;
  background: var(--border); color: var(--text); font-size: 0.72rem; font-weight: 700;
}
.task-table td { vertical-align: top; }
.tick-cell { width: 28px; }
.task-row.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-row.skipped { opacity: 0.55; }
a.task-title { font-weight: 600; color: var(--text); }
a.task-title:hover { color: var(--link); }
.task-for { margin-top: 2px; }
.link-action { background: none; border: 0; padding: 0; font: inherit; font-size: 0.85rem; color: var(--muted); cursor: pointer; }
.link-action:hover { color: var(--text); text-decoration: underline; }
.later-tasks { margin-top: 8px; }
.later-tasks summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; margin: 8px 0; }
.card > details > table th:first-child, .card > details > table td:first-child { padding-left: 0; }
.card > details > table th:last-child, .card > details > table td:last-child { padding-right: 0; }

/* My work */
.work-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 16px; }
.work-filters input[type="search"] { flex: 1; min-width: 200px; }
.filter-group { display: inline-flex; align-items: center; gap: 8px; }
.filter-label { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.segmented a { white-space: nowrap; }
/* Radio segmented controls (My work filters): the radio is hidden, its label is the button. */
.segmented label { position: relative; padding: 6px 14px; font-size: 0.9rem; cursor: pointer; white-space: nowrap; }
.segmented label + label { border-left: 1px solid var(--border); }
.segmented label:hover { background: var(--bg); }
.segmented label.active, .segmented label:has(input:checked) { background: var(--primary); color: #fff; }
.segmented label:has(input:focus-visible) { outline: 2px solid currentColor; outline-offset: -4px; }
.segmented input[type="radio"] { position: absolute; inset: 0; opacity: 0; margin: 0; pointer-events: none; }
.segmented .count { margin-left: 2px; }
.segmented .active .count, .segmented label:has(input:checked) .count { background: rgba(255, 255, 255, 0.25); color: #fff; }
.work-list .task-table td { padding-top: 12px; padding-bottom: 12px; }
.work-list .task-main { min-width: 200px; }
.work-list .task-for-cell { min-width: 180px; }
.empty-state p { margin: 0; }
.more-later { margin: -8px 0 20px; padding: 10px 14px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
.filter-group { flex-wrap: wrap; }

@media (max-width: 720px) { .segmented a, .segmented label { padding: 6px 10px; } }
@media (max-width: 360px) { .segmented a, .segmented label { padding: 6px 8px; } }

/* A narrow task list (tasks/_task_row.html rows in a .task-list inside a .task-list-box) shows each
   task as a small card: phones, and small laptops where the sidebar takes room. */
.task-list-box { container: task-list / inline-size; }
@container task-list (max-width: 760px) {
  .task-list, .task-list tbody { display: block; }
  .task-list tr.group-row, .task-list tr.group-row th { display: block; }
  .task-list tr.task-row {
    display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; column-gap: 8px; row-gap: 2px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
  }
  table.task-list tr.task-row > td { padding: 0; border: 0; }  /* beats .table-wrap's first/last-cell padding */
  .task-list .tick-cell { grid-row: 1 / 4; width: auto; }
  .task-list .task-main { grid-column: 2; min-width: 0; }
  .task-list .who-cell { grid-column: 3; grid-row: 1; }
  .task-list .task-for-cell { grid-column: 2 / 4; min-width: 0; }
  .task-list .due-cell { grid-column: 2; white-space: normal; }  /* beside the timer and Not needed buttons */
  .task-list .due-cell div { display: inline; }
  .task-list .due-cell div::before { content: " · "; }
  .task-list .actions-cell { grid-column: 3; }
  .card:not(.table-wrap) > .task-list tr.task-row, .card > details > .task-list tr.task-row { padding-left: 0; padding-right: 0; }  /* the card pads it */
}

/* Time: the timer bar (on every page while a timer runs), timer buttons, the timesheet and the report */
#timer-bar { position: sticky; top: 0; z-index: 25; }
#timer-bar:has(.timer-bar) { margin-top: -8px; padding-top: 8px; background: var(--bg); }  /* nothing shows through above it */
@media (max-width: 899px) { .js #timer-bar { top: 56px; } }  /* below the phone top bar */
.timer-bar {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 16px; padding: 8px 12px;
  border: 1px solid var(--primary); border-radius: var(--radius); background: var(--surface);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08); font-size: 0.92rem;
}
.timer-dot { width: 9px; height: 9px; flex-shrink: 0; border-radius: 50%; background: var(--danger); animation: timer-pulse 1.6s ease-in-out infinite; }
@keyframes timer-pulse { 50% { opacity: 0.3; } }
.timer-clock { font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
@media (prefers-reduced-motion: reduce) { .timer-dot { animation: none; } }

.icon.icon-fill { fill: currentColor; stroke: none; }
.timer-toggle {
  display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; vertical-align: middle;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer;
}
.timer-toggle .icon { width: 11px; height: 11px; }
.timer-toggle:not(.is-running) .icon { margin-left: 2px; }  /* the triangle looks centred */
.timer-toggle:hover { color: var(--link); border-color: var(--primary); }
.timer-toggle.is-running { background: var(--danger); border-color: var(--danger); color: #fff; }
.timer-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.actions-cell .timer-toggle { margin-right: 10px; }

.time-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; }
.time-totals { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; margin-bottom: 8px; }
.time-totals a { margin-left: auto; font-size: 0.9rem; }

/* Week grid: hours per client (rows) and day (columns); the client column stays put while a phone scrolls the days. */
.week-grid th, .week-grid td { padding: 9px 10px; }
.week-grid thead th { text-align: right; white-space: nowrap; }
.week-grid thead th:first-child { text-align: left; }
.week-grid abbr { text-decoration: none; }
.week-grid th[scope="row"] { min-width: 170px; text-transform: none; letter-spacing: 0; font-size: 0.92rem; font-weight: 600; color: var(--text); }
.week-grid th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.week-grid .today { background: rgba(59, 106, 224, 0.08); }
.week-grid thead .today { color: var(--link); }
.week-grid .total { font-weight: 700; }
.week-grid tfoot th, .week-grid tfoot td { border-top: 2px solid var(--border); font-weight: 700; }
@media (max-width: 560px) {  /* more room for the days */
  .week-grid th[scope="row"] { min-width: 110px; max-width: 150px; font-size: 0.85rem; }
  .week-grid th, .week-grid td { padding: 8px; }
}

/* Entries by day (timesheet), and on a client's or task's page */
.day-list { padding-top: 6px; padding-bottom: 6px; }
.day + .day { border-top: 1px solid var(--border); }
.day-header { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding: 10px 0; }
.day-title { margin: 0; font-size: 0.98rem; }
.day-total { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.entry-list { list-style: none; margin: 0 0 6px; padding: 0; }
.entry { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; border-top: 1px dashed var(--border); }
.entry-hours { flex: 0 0 3.2rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.entry-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.entry-main .badge { margin-left: 4px; }
.entry-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Report */
.report-filters .report-dates { display: none; }
.report-filters:has(select[name="period"] option[value="custom"]:checked) .report-dates { display: inline-flex; }
.report-table th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: 0.95rem; font-weight: 600; color: var(--text); }
.report-table .report-subline th[scope="row"] { padding-left: 36px; font-weight: normal; color: var(--muted); }
.report-subline td { color: var(--muted); }
.report-table tfoot th, .report-table tfoot td { border-top: 2px solid var(--border); font-weight: 700; }

/* Typing hours into the week grid. The table scrolls sideways on its own, above the grid's buttons. */
.card.week-grid-card { overflow: visible; }  /* beats .table-wrap's */
.grid-scroll { overflow-x: auto; border-radius: var(--radius) var(--radius) 0 0; }
.week-grid td:has(.hours-input) { padding-left: 4px; padding-right: 4px; }
.hours-input {
  width: 4.2em; padding: 4px 6px; text-align: right; font-variant-numeric: tabular-nums;
  border-color: transparent; background: var(--bg);
}
.hours-input:hover { border-color: var(--border); }
.hours-input:focus { background: var(--surface); }
.week-grid td.has-error .hours-input { border-color: var(--danger); background: var(--error-bg); }
.cell-error { display: block; max-width: 7em; margin-top: 2px; margin-left: auto; font-size: 0.72rem; line-height: 1.2; color: var(--danger); white-space: normal; }
.cell-fixed { cursor: help; border-bottom: 1px dotted var(--muted); }
.grid-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 20px; border-top: 1px solid var(--border); }
.grid-add { flex-wrap: wrap; }
.grid-add select { max-width: 280px; }
.grid-dirty { display: none; color: var(--warning-text); font-weight: 600; }
.week-grid-card.is-dirty .grid-dirty { display: inline; }

/* Where the week's timesheet stands (not submitted, submitted, approved, returned) */
.week-status {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin-bottom: 16px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.week-status-text { margin: 0; flex: 1; min-width: 220px; }
.week-status.is-submitted { border-color: var(--primary); }
.week-status.is-approved { border-color: var(--success-text); background: var(--success-bg); }
.week-status.is-returned { border-color: var(--warning-border); background: var(--warning-bg); }
.return-week > summary { list-style: none; }
.return-week > summary::-webkit-details-marker { display: none; }
/* Opened, "Return…" takes a line of its own for the note (a popover would run off a phone's screen). */
.week-status .actions:has(.return-week[open]), .return-week[open] { flex-basis: 100%; }
.return-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.return-form input { flex: 1; min-width: 180px; }

.form-notice { padding: 10px 14px; border: 1px solid var(--warning-border); border-radius: var(--radius); background: var(--warning-bg); color: var(--warning-text); }
fieldset.form-grid { border: 0; padding: 0; margin: 0; min-width: 0; }
.badge.badge-billed { background: var(--success-bg); color: var(--success-text); }
.badge.badge-returned { background: var(--warning-bg); color: var(--warning-text); }
.unrated { margin-left: 2px; color: var(--warning-text); cursor: help; }
.table-card-heading { margin: 0; padding: 16px 20px 4px; }
.table-card-empty { margin: 0; padding: 8px 20px 20px; }

/* Log time form: "Non-billable" only means something for client time. */
.time-form:has(select[name="time-entity"] option[value=""]:checked) .field-non-billable { display: none; }
.field-non-billable { column-gap: 12px; }
.actions .push-right { margin-left: auto; }

/* Modal dialog (static/js/app.js) */
.modal {
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text);
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: var(--backdrop); }
.modal-card { padding: 20px 24px 24px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.modal-header h2 { margin: 0; font-size: 1.2rem; }
.modal-close { background: none; border: 0; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--text); }

/* Task form: two columns, the client/engagement/deadline block re-rendered when it changes */
.task-form { max-width: none; }
.form-grid, .task-links, .time-links { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.task-links noscript, .time-links noscript { grid-column: 1 / -1; }  /* the no-JS hint spans however many columns there are */
.task-page-form { max-width: 680px; }
@media (max-width: 560px) {
  .form-grid, .task-links, .time-links { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
}
.missing-steps { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.progress-cell { min-width: 160px; }
.checklist { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0 16px; }
.checklist legend { font-weight: 700; padding: 0 6px; }
.checklist-table th, .checklist-table td { padding: 6px 6px; }
.checklist-table input[type="text"] { width: 100%; min-width: 180px; }
.checklist-table .days input { width: 5rem; }
.checklist-table select { max-width: 220px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.checklist { min-width: 0; }  /* a fieldset otherwise grows to fit its table */
.checklist-rows { container: checklist / inline-size; overflow-x: auto; }
@media (min-width: 721px) {
  .sr-only-wide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
/* A narrow checklist (phones, small laptops) shows each step as a stack of labelled fields. */
@container checklist (max-width: 840px) {
  .checklist-table thead { display: none; }
  .checklist-table, .checklist-table tbody, .checklist-table tr, .checklist-table td { display: block; }
  .checklist-table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .checklist-table tbody tr:last-child { border-bottom: 0; }
  .checklist-table td, .card > .checklist-table td:first-child { padding: 4px 0; border: 0; text-align: left; }
  .checklist-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
  .checklist-table input[type="text"], .checklist-table select { width: 100%; max-width: none; min-width: 0; }
}

/* Workspace picker */
.workspace-list { list-style: none; margin: 16px 0 0; padding: 0; max-width: 640px; }
.workspace-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; padding: 16px 20px; }
.workspace-card.current { border-color: var(--primary); }
.workspace-name { font-weight: 600; font-size: 1.05rem; }
.workspace-info { flex: 1; min-width: 0; }
.workspace-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--border); padding: 3px; }

/* Firm logo */
.logo-preview { margin-bottom: 12px; }
.logo-preview img { max-width: 220px; max-height: 90px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; padding: 8px; background: #fff; }

/* Settings pages */
.settings-form { max-width: 680px; }
.settings-form.engagement-page { max-width: 960px; }
.engagement-page .form { max-width: none; }
.engagement-page .form > .field { max-width: 600px; }
.settings-form .card { scroll-margin-top: 16px; }
.item-list { list-style: none; margin: 0 0 8px; padding: 0; }
.item-list .item { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.item-list .item:last-child { border-bottom: 0; }
.item-title { font-weight: 600; }
.item-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.logo-grid .item { flex-direction: column; align-items: stretch; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.logo-grid .item:last-child { border-bottom: 1px solid var(--border); }
.logo-grid .item.is-default { border-color: var(--primary); }
.logo-grid .item-actions { justify-content: flex-start; }
.logo-thumb { width: 100%; height: 80px; object-fit: contain; background: #fff; border-radius: 6px; }

/* Settings: a menu panel beside the section being edited (a row of chips on smaller screens) */
.settings-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings-menu {
  position: sticky; top: 20px; display: flex; flex-direction: column; gap: 14px; padding: 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.settings-menu-group { display: flex; flex-direction: column; gap: 2px; }
.settings-menu-heading { padding: 4px 10px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.settings-menu a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--text); font-size: 0.93rem; }
.settings-menu a .icon { width: 16px; height: 16px; color: var(--muted); }
.settings-menu a:hover { background: var(--bg); text-decoration: none; }
.settings-menu a.active { background: var(--info-bg); color: var(--info-text); font-weight: 600; }
.settings-menu a.active .icon { color: var(--info-text); }
.settings-body { min-width: 0; max-width: 720px; }
.settings-body > h2 { font-size: 1.25rem; margin-bottom: 4px; }
.settings-body > .section-intro { margin: 0 0 16px; }
.settings-body .form { max-width: none; }  /* as wide as the list cards */
.card-heading { margin: 0 0 12px; font-size: 1rem; }
.item-with-icon { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.item-with-icon > .icon { margin-top: 3px; color: var(--muted); }
@media (max-width: 1099px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .settings-menu { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; padding: 0; border: 0; background: none; }
  .settings-menu-group { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .settings-menu-heading { display: none; }
  .settings-menu a { white-space: nowrap; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
  .settings-menu a.active { border-color: var(--primary); }
}

/* Sign-in and invite pages */
.auth-page { max-width: 420px; margin: 9vh auto 40px; padding: 0 16px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; font-size: 1.5rem; font-weight: 650; letter-spacing: -0.02em; }
.auth-brand img { border-radius: 9px; }
.auth-card { padding: 28px; box-shadow: var(--shadow-sm); }
.auth-card h1 { font-size: var(--text-xl); margin-bottom: 16px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 16px; font-size: var(--text-sm); color: var(--muted); }
.auth-links a { color: var(--muted); }
.auth-card .form { max-width: none; }
.btn-block { width: 100%; }
.card.notice { border-color: var(--primary); }
.invite-link { display: flex; gap: 8px; margin-top: 8px; }
.invite-link input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 0.85rem; }

/* --- 5. Components ------------------------------------------------------------------------------------ */

/* Page header: where you are (breadcrumb), the title, one line about it, then one main action and a menu
   for the rest. Every page starts with one. */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-header > div:first-child { min-width: 0; flex: 1 1 320px; }
.page-header h1 { overflow-wrap: anywhere; }
.page-header h1 .badge { vertical-align: middle; }
.page-header p { margin: 4px 0 0; }
.page-header > div:first-child > a.muted.small, .portal-page-header > div:first-child > a.muted.small {
  display: inline-block; margin-bottom: 4px; font-weight: 500;
}
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin: 0 0 4px; font-size: var(--text-sm); color: var(--muted); }
.breadcrumb a { color: var(--muted); font-weight: 500; }
.breadcrumb a:hover { color: var(--text); text-decoration: none; }
.breadcrumb .sep { color: var(--border-strong); }
.breadcrumb [aria-current] { color: var(--text-2); }
.page-subtitle { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 4px 0 0; color: var(--muted); }
.page-header .actions { flex-shrink: 0; }

/* The rest of a page's actions, behind a "more" button */
.more-menu .menu-panel { left: auto; right: 0; min-width: 210px; z-index: 30; }
.more-menu > summary { cursor: pointer; }
.more-menu > summary.btn { display: inline-flex; align-items: center; justify-content: center; padding-left: 9px; padding-right: 9px; }
.more-menu > summary .icon { margin: 0; width: 16px; height: 16px; }
.more-menu[open] > summary.btn { border-color: var(--border-strong); background: var(--surface-3); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.right { text-align: right; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 7px 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; color: var(--text); }
a.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat-value { font-size: var(--text-3xl); font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); }

/* Buttons: primary (one per page), secondary (the default), ghost, danger */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height);
  padding: 5px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: 500 var(--text-base)/1.4 var(--font);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:active { box-shadow: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-danger { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.btn-danger:hover { background: #a92a2a; border-color: #a92a2a; }
.btn-danger-outline { color: var(--danger); }
.btn-danger-outline:hover { border-color: var(--danger); background: var(--danger-bg); }
.btn-small { min-height: 28px; padding: 2px 10px; font-size: var(--text-sm); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn .icon { width: 15px; height: 15px; margin-right: 6px; }
.btn.icon-only .icon { margin-right: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

/* Tables */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
thead th { background: var(--surface-2); }
.card:not(.table-wrap) > table thead th, .card > .table-scroll > table thead th, .card > details > table thead th,
.card > details > .table-scroll > table thead th { background: none; }
tbody tr:last-child td { border-bottom: 0; }
.card > table th:first-child, .card > table td:first-child { padding-left: 0; }
.card > table th:last-child, .card > table td:last-child { padding-right: 0; }
.table-wrap table th:first-child, .table-wrap table td:first-child { padding-left: 20px; }
.table-wrap table th:last-child, .table-wrap table td:last-child { padding-right: 20px; }
.card > .table-scroll > table th:first-child, .card > .table-scroll > table td:first-child,
.card > details > .table-scroll > table th:first-child, .card > details > .table-scroll > table td:first-child { padding-left: 0; }
.card > .table-scroll > table th:last-child, .card > .table-scroll > table td:last-child,
.card > details > .table-scroll > table th:last-child, .card > details > .table-scroll > table td:last-child { padding-right: 0; }
@media (max-width: 720px) { .hide-sm { display: none; } }

/* The table component: <div class="card table-wrap data-table-box"><table class="data-table">.
   Sticky column names, a row that lights up under the pointer, its actions showing on hover or focus, columns
   that sort (links in the header), and a first column that stays put when a phone scrolls sideways.
   Density: "comfortable" by default, "compact" on <html data-density="compact"> (the Display menu). */
.data-table-box { position: relative; }
.data-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); box-shadow: inset 0 -1px 0 var(--border); border-bottom: 0; }
.data-table tbody tr:hover > td, .data-table tbody tr:focus-within > td { background: var(--surface-2); }
.data-table tbody tr.is-selected > td { background: var(--primary-soft); }
.data-table td { vertical-align: middle; }
.data-table .row-actions { text-align: right; white-space: nowrap; }
@media (hover: hover) and (min-width: 900px) {
  .data-table .row-actions > * { opacity: 0; transition: opacity 0.1s; }
  .data-table tr:hover .row-actions > *, .data-table tr:focus-within .row-actions > *, .data-table .row-actions > [open] { opacity: 1; }
}
.data-table .select-cell { width: 36px; padding-right: 0; }
.data-table .select-cell input { width: 16px; height: 16px; margin: 0; vertical-align: middle; accent-color: var(--primary); }
th.sortable { padding: 0; }
th.sortable > a { display: flex; align-items: center; gap: 4px; padding: 10px 14px; color: inherit; }
.table-wrap table th.sortable:first-child { padding-left: 0; }
.table-wrap table th.sortable:first-child > a { padding-left: 20px; }
th.sortable > a:hover { color: var(--text); text-decoration: none; }
th.sortable.num > a { justify-content: flex-end; }
th.sortable .sort-mark { width: 12px; height: 12px; opacity: 0.35; }
th.sortable[aria-sort] > a { color: var(--text); }
th.sortable[aria-sort] .sort-mark { opacity: 1; color: var(--primary); }
th.sortable[aria-sort="descending"] .sort-mark { transform: rotate(180deg); }
:root[data-density="compact"] th, :root[data-density="compact"] td { padding-top: 5px; padding-bottom: 5px; }
:root[data-density="compact"] th.sortable { padding-top: 0; padding-bottom: 0; }
:root[data-density="compact"] th.sortable > a { padding-top: 5px; padding-bottom: 5px; }
:root[data-density="compact"] .data-table .small, :root[data-density="compact"] .data-table .muted.small { display: none; }
@media (max-width: 720px) {
  .data-table th:first-child:not(.select-cell), .data-table td:first-child:not(.select-cell),
  .data-table .select-cell + th, .data-table .select-cell + td {
    position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border);
  }
  .data-table thead th:first-child, .data-table thead .select-cell + th { z-index: 3; background: var(--surface-2); }
  .data-table .select-cell { display: none; }  /* bulk actions are for a bigger screen */
}

/* What the ticked rows can do: a bar that shows once one is ticked (static/js/app.js) */
.bulk-bar {
  position: sticky; bottom: 16px; z-index: 20; display: none; align-items: center; gap: 8px 12px; flex-wrap: wrap;
  width: fit-content; max-width: 100%; margin: 12px auto 0; padding: 8px 10px 8px 16px;
  border-radius: var(--radius-lg); background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg);
}
.bulk-bar.is-active { display: flex; }
.bulk-bar .bulk-count { font-weight: 600; margin-right: 4px; }
.bulk-bar .btn { background: transparent; border-color: rgba(127, 137, 150, 0.5); color: inherit; box-shadow: none; }
.bulk-bar .btn:hover { background: rgba(127, 137, 150, 0.25); }
.bulk-bar select { min-height: 28px; padding: 2px 26px 2px 8px; font-size: var(--text-sm); }
.no-js .bulk-bar, .no-js .select-cell { display: none; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.badge-active { background: var(--success-bg); color: var(--success-text); }
.badge-prospect { background: var(--info-bg); color: var(--info-text); }
.badge-inactive { background: var(--surface-3); color: var(--muted); }
.badge-overdue { background: var(--danger-bg); color: var(--danger); }
.badge-soon { background: var(--warning-bg); color: var(--warning-text); }
.badge-client { background: var(--purple-bg); color: var(--purple-text); }
.badge-done { background: var(--success-bg); color: var(--success-text); }

.details { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 720px) { .details { grid-template-columns: 1fr; gap: 2px; } .details dd { margin-bottom: 10px; } }

/* Forms */
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input[type="search"] { flex: 1; min-width: 200px; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 6px 10px;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.switch), select { min-height: var(--control-height); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; min-height: 0; padding: 0; vertical-align: -3px; box-shadow: none; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; box-shadow: none; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
select {
  max-width: 100%;  /* long options (client names) can't widen the page */
  -webkit-appearance: none; appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237b8798' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
select[multiple] { background-image: none; padding-right: 10px; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }

.form { max-width: 640px; }
.form .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form .field input:not([type="checkbox"]):not([type="radio"]), .form .field select, .form .field textarea { width: 100%; }
/* Radio groups (rendered by Django as a fieldset) */
.field fieldset { border: 0; padding: 0; margin: 0; }
.field fieldset legend { font-weight: 600; font-size: var(--text-sm); padding: 0; margin-bottom: 4px; }
.field fieldset label { display: inline-flex; gap: 8px; align-items: center; font-weight: normal; font-size: var(--text-base); }
.field fieldset > div > div { margin: 3px 0; }
.field label { font-weight: 600; font-size: var(--text-sm); color: var(--text-2); }
.field .helptext { color: var(--muted); font-size: var(--text-sm); }
.field:has(input[type="checkbox"]) { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 8px; }

.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 100%; }
/* Inline forms use placeholders instead; help text would misalign the row. */
.inline-form .helptext { display: none; }

/* Entity form: the household fields only for an individual */
.form:has(select[name="entity_type"]) .field:not(.has-error):has([name="household_head"], [name="household_role"]) { display: none; }
.form:has(select[name="entity_type"] option[value="individual"]:checked) .field:has([name="household_head"], [name="household_role"]) { display: flex; }

/* Share register entry form: show From/To only for the types that use them */
.txn-form .field-from_party, .txn-form .field-to_party { display: none; }
.txn-form:has(select[name="transaction_type"] option[value="issue"]:checked) .field-to_party,
.txn-form:has(select[name="transaction_type"] option[value="transfer"]:checked) .field-from_party,
.txn-form:has(select[name="transaction_type"] option[value="transfer"]:checked) .field-to_party,
.txn-form:has(select[name="transaction_type"] option[value="redemption"]:checked) .field-from_party { display: flex; }
.txn-form input[type="number"] { width: 8rem; }

.section-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-header h2, .section-header .filters { margin: 0; }
.section-header .filters { align-items: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.tabular, time, .card-date, .deadline-day { font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
tr.future { opacity: 0.45; }
form.inline { display: inline; }
details.past { margin-top: 12px; }
details.past summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }

.warning { color: var(--warning-text); }

.errorlist { list-style: none; margin: 0 0 8px; padding: 0; color: var(--danger); font-size: var(--text-sm); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }

/* Messages: toasts in the corner, so they show wherever the page is scrolled; confirmations fade out. */
#messages { position: fixed; right: 20px; bottom: 20px; z-index: 60; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.message {
  padding: 10px 14px; border-radius: var(--radius); background: var(--success-bg); color: var(--success-text);
  border: 1px solid var(--success-border); box-shadow: var(--shadow-md); pointer-events: auto; font-weight: 500;
}
.message-success { animation: message-out 0.4s ease 6s forwards; }
.message-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.message-info { background: var(--surface); color: var(--text); border-color: var(--border); animation: message-out 0.4s ease 6s forwards; }
.message-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border-soft); }
@keyframes message-out { to { opacity: 0; visibility: hidden; } }
@media (max-width: 720px) { #messages { right: 16px; bottom: 16px; } }
@media (prefers-reduced-motion: reduce) { .message-success, .message-info { animation-duration: 0s; } }

/* htmx: what's being replaced dims while the request is on its way, and a bar runs along the top of the page */
.results { transition: opacity 150ms; }
.results.htmx-request, .htmx-request.results { opacity: 0.55; }
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
#loading-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 2px; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--primary) 40%, #8fb0ff 60%, transparent); background-size: 50% 100%;
  background-repeat: no-repeat;
}
.is-loading #loading-bar { opacity: 1; animation: loading-bar 1.1s linear infinite; }
@keyframes loading-bar { from { background-position: -50% 0; } to { background-position: 150% 0; } }
@media (prefers-reduced-motion: reduce) { .is-loading #loading-bar { animation: none; background: var(--primary); } }

/* A grey shape where content is on its way (tabs loading) */
.skeleton { display: block; border-radius: var(--radius-md); background: var(--surface-3); color: transparent; animation: skeleton 1.4s ease-in-out infinite; }
.skeleton-line { height: 12px; margin: 10px 0; }
.skeleton-line.is-short { width: 40%; }
@keyframes skeleton { 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Nothing here yet: what this is for, and the way to start */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 20px; text-align: center; color: var(--muted);
}
.empty > .icon { width: 32px; height: 32px; stroke-width: 1.5; color: var(--border-strong); margin-bottom: 4px; }
.empty h2, .empty h3 { margin: 0; font-size: var(--text-md); color: var(--text); }
.empty p { max-width: 460px; margin: 0; }
.empty .actions { margin-top: 10px; justify-content: center; }

/* Tooltips: [data-tip] on anything that takes focus or the pointer */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); z-index: 70; transform: translateX(-50%);
  width: max-content; max-width: 260px; padding: 5px 9px; border-radius: var(--radius-md); background: #111827; color: #fff;
  font: 500 var(--text-xs)/1.4 var(--font); text-transform: none; letter-spacing: 0; white-space: normal; text-align: center;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.12s 0.25s;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; visibility: visible; }
[data-tip][data-tip-side="right"]::after { left: calc(100% + 8px); bottom: auto; top: 50%; transform: translateY(-50%); }

.pagination { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.pagination .page-size { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.pagination .page-size select { min-height: 28px; padding: 2px 26px 2px 8px; font-size: var(--text-sm); }
.load-more { display: flex; justify-content: center; padding: 12px; }

/* Tabs: sections of one record, each with its own address */
.tabs {
  display: flex; gap: 2px; margin: 0 0 20px; padding: 0; border-bottom: 1px solid var(--border); overflow-x: auto;
  scrollbar-width: none; list-style: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 8px 12px; margin-bottom: -1px;
  border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; border-bottom-color: var(--border-strong); }
.tabs a.active, .tabs a[aria-current] { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
.tabs a:focus-visible { outline-offset: -2px; }
.tabs .count { font-size: var(--text-xs); }
.tabs .count.is-alert { background: var(--danger-bg); color: var(--danger); }
@media (max-width: 899px) { .tabs a { min-height: var(--touch-target); } }

/* Filters: a search box, a Filters button that opens the rest, what's in force as chips that come off,
   and the views someone saved. All of it is in the address, so a filtered list can be bookmarked and shared. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1 1 240px; min-width: 0; max-width: 420px; }
.toolbar .push-right { margin-left: auto; }
.search-field { position: relative; flex: 1 1 240px; min-width: 0; max-width: 420px; }
.search-field > .icon { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input[type="search"] { width: 100%; max-width: none; padding-left: 32px; }
.filter-menu .menu-panel {
  left: 0; right: auto; z-index: 30; width: min(340px, calc(100vw - 32px)); padding: 14px;
  display: grid; gap: 10px;
}
.filter-menu > summary { cursor: pointer; }
.filter-menu[open] > summary.btn { border-color: var(--primary); color: var(--link); }
.filter-menu .field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.filter-menu .field label, .filter-menu .field-label { font-size: var(--text-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.filter-menu select, .filter-menu input[type="text"], .filter-menu input[type="date"] { width: 100%; }
.filter-menu .check { white-space: normal; }
.filter-menu .actions { justify-content: space-between; margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--border); }
.filter-count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 6px; padding: 0 5px; border-radius: var(--radius-full);
  background: var(--primary); color: var(--on-primary); font-size: 0.6875rem; font-weight: 700;
}
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 1px 4px 1px 10px; border-radius: var(--radius-full);
  background: var(--primary-soft); color: var(--info-text); font-size: var(--text-sm); font-weight: 500;
}
.filter-chip a { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: inherit; }
.filter-chip a:hover { background: var(--info-border); text-decoration: none; }
.filter-chip a .icon { width: 12px; height: 12px; }
.filter-chips .clear-all { font-size: var(--text-sm); margin-left: 4px; }
.saved-views { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.saved-views .chip.is-current { border-color: var(--primary); color: var(--link); font-weight: 600; }
.saved-view-form { display: flex; gap: 6px; }
.saved-view-form input { min-width: 0; flex: 1; }

/* Print: just the page content */
@media print {
  .topbar, .sidebar, .skip-link, .nav-backdrop, #messages, #timer-bar, #loading-bar, .bulk-bar, .toolbar, .filter-chips,
  .saved-views, .pagination, .page-header .actions, .tabs, .row-actions, .select-cell, .no-print { display: none !important; }
  .layout { display: block; }
  .content { max-width: none; padding: 0; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card { border: 0; box-shadow: none; padding: 0; break-inside: avoid; }
  .data-table thead th { position: static; }
  a { color: inherit; text-decoration: none; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* Links that look like text, a label that isn't a <label> */
.plain-link { color: var(--text); }
.plain-link:hover { color: var(--link); }
.field-label { font-weight: 600; font-size: var(--text-sm); }
form.is-dirty .grid-dirty { display: inline; }  /* forms with data-unsaved-guard (static/js/app.js) */

/* --- Billing ------------------------------------------------------------------------------------ */
.billing-stats { margin-bottom: 16px; }
.billing-stats .stat-value { font-size: 1.6rem; }
.billing-notes {
  display: flex; flex-direction: column; gap: 4px; list-style: none; margin: 0 0 16px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 0.92rem;
}
.billing-source { display: flex; align-items: center; gap: 8px; margin: -8px 0 16px; color: var(--muted); font-size: 0.9rem; }
.billing-source .icon { width: 16px; height: 16px; }
h1 .badge { vertical-align: middle; font-size: 0.8rem; }
.payment-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.invoice-table td, .payment-table td { vertical-align: middle; }

/* Where an invoice stands (models.Invoice.state) */
.badge-inv-unpaid { background: var(--info-bg); color: var(--info-text); }
.badge-inv-partly_paid { background: var(--warning-bg); color: var(--warning-text); }
.badge-inv-overdue { background: var(--error-bg); color: var(--danger); }
.badge-inv-paid { background: var(--success-bg); color: var(--success-text); }
.badge-inv-void { text-decoration: line-through; }

/* Billed and received by month: two series in the reference palette's first two slots, checked with the
   dataviz palette validator against this app's light and dark card surfaces. */
.rev-card .is-billed { --series: var(--series-1); }
.rev-card .is-received { --series: var(--series-2); }
.rev-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; list-style: none; margin: 0; padding: 0; font-size: 0.88rem; }
.rev-legend li { display: inline-flex; align-items: center; gap: 6px; }
.rev-key { width: 10px; height: 10px; border-radius: 2px; background: var(--series); }
.rev-plot { position: relative; height: 240px; margin-top: 18px; }
.rev-grid { position: absolute; top: 0; right: 0; bottom: 26px; left: 52px; display: flex; flex-direction: column; justify-content: space-between; }
.rev-gridline { position: relative; border-top: 1px solid var(--chart-grid); }
.rev-gridline:last-child { border-top-color: var(--chart-base); }
.rev-tick {
  position: absolute; right: calc(100% + 8px); top: -0.55em; font-size: 0.72rem; line-height: 1; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.rev-months {
  position: absolute; top: 0; right: 0; bottom: 0; left: 52px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
  list-style: none; margin: 0; padding: 0;
}
.rev-month { position: relative; display: grid; grid-template-rows: minmax(0, 1fr) 26px; border-radius: 6px; outline: none; cursor: default; }
.rev-bars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; min-height: 0; border-radius: 6px 6px 0 0; }
.rev-bar { width: min(18px, 36%); border-radius: 4px 4px 0 0; background: var(--series); }
.rev-month-label { align-self: center; text-align: center; font-size: 0.75rem; color: var(--muted); }
.rev-month:hover .rev-bars, .rev-month:focus-visible .rev-bars { background: rgba(127, 137, 150, 0.12); }
.rev-month:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
.rev-tip {
  position: absolute; top: -6px; left: 50%; z-index: 5; display: none; flex-direction: column; gap: 3px; min-width: 170px;
  padding: 8px 10px; transform: translate(-50%, -100%); border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15); font-size: 0.82rem; white-space: nowrap; pointer-events: none;
}
.rev-month:hover .rev-tip, .rev-month:focus-visible .rev-tip { display: flex; }
.rev-month:nth-child(-n+2) .rev-tip { left: 0; transform: translate(0, -100%); }
.rev-month:nth-last-child(-n+2) .rev-tip { left: auto; right: 0; transform: translate(0, -100%); }
.rev-tip-title { font-weight: 600; color: var(--muted); }
.rev-tip strong { margin-right: 4px; color: var(--text); font-variant-numeric: tabular-nums; }
.rev-line { display: inline-block; width: 12px; height: 2px; margin-right: 6px; vertical-align: middle; background: var(--series); }
.rev-table { margin-top: 14px; }
.rev-table summary { cursor: pointer; color: var(--link); font-size: 0.9rem; }
.rev-table table { margin-top: 8px; }

/* An invoice as the client sees it (and prints) */
.invoice-doc { max-width: 820px; padding: 40px 44px; }
.inv-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.inv-firm { font-size: 0.9rem; line-height: 1.45; color: var(--muted); }
.inv-logo { display: block; max-width: 180px; max-height: 70px; margin-bottom: 10px; object-fit: contain; }
.inv-firm-name { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.inv-meta { margin-left: auto; text-align: right; }
.inv-title { margin-bottom: 8px; font-size: 1.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.inv-stamp {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border: 2px solid var(--danger); border-radius: 6px;
  color: var(--danger); font-size: 0.9rem; letter-spacing: 0.08em; vertical-align: middle;
}
.inv-meta dl { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 2px 14px; margin: 0; font-size: 0.92rem; }
.inv-meta dt { color: var(--muted); }
.inv-meta dd { margin: 0; font-weight: 600; text-align: right; }
.inv-to { margin-bottom: 24px; }
.inv-label { margin-bottom: 4px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.inv-client { font-weight: 700; }
.inv-lines { margin-bottom: 20px; font-variant-numeric: tabular-nums; }
.inv-lines th, .inv-lines td { padding: 9px 8px; }
.inv-lines thead th { border-bottom: 2px solid var(--text); color: var(--text); }
.inv-lines tfoot th, .inv-lines tfoot td { padding-top: 5px; padding-bottom: 5px; border-bottom: 0; }
.inv-lines tfoot th { text-align: right; text-transform: none; letter-spacing: 0; font-size: 0.95rem; font-weight: 500; color: var(--text); }
.inv-lines tfoot tr:first-child th, .inv-lines tfoot tr:first-child td { padding-top: 14px; }
.inv-lines .inv-total th, .inv-lines .inv-total td { border-top: 1px solid var(--text); font-weight: 700; }
.inv-lines .inv-balance th, .inv-lines .inv-balance td { font-weight: 700; }
.inv-notes { margin-bottom: 16px; }
.inv-footer { padding-top: 14px; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--muted); }
.invoice-extras { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 20px; max-width: 820px; }
@media (max-width: 900px) { .invoice-extras { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  .invoice-doc { padding: 22px 16px; }
  .inv-meta { margin-left: 0; text-align: left; }
  .inv-meta dl { justify-content: start; }
  .inv-meta dd { text-align: left; }
}

/* The invoice form: its fees as rows, totalled as they're typed (static/js/app.js) */
.invoice-form { max-width: 980px; }
.invoice-form-heading { margin: 8px 0 6px; font-size: 1rem; }
.invoice-lines { min-width: 640px; }
.invoice-lines th, .invoice-lines td { padding: 6px 6px; border-bottom: 0; }
.invoice-lines td:first-child input { width: 100%; min-width: 200px; }
.invoice-lines input[type="number"] { width: 8rem; text-align: right; }
.invoice-lines tfoot th, .invoice-lines tfoot td { padding-top: 4px; padding-bottom: 4px; }
.invoice-lines tfoot tr:first-child th, .invoice-lines tfoot tr:first-child td { padding-top: 10px; border-top: 2px solid var(--border); }
.invoice-lines tfoot tr:last-child { font-weight: 700; }
.invoice-line.has-error input { border-color: var(--danger); }
.invoice-lines .errorlist { margin: 2px 0 0; font-size: 0.8rem; }

@media print {
  .invoice-page-header, .invoice-extras, .billing-source { display: none !important; }
  .invoice-doc { max-width: none; margin: 0; padding: 0; border: 0; background: #fff; }
  .invoice-doc, .invoice-doc th, .invoice-doc td, .invoice-doc dt, .invoice-doc .inv-firm, .invoice-doc .inv-label, .invoice-doc .inv-footer { color: #000; }
}

/* Billing overview: last year's figure under the Billed and Received cards, the two breakdown cards side
   by side, the row for the chosen client type; the invoice form's service column. */
.stat-change { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.stat-delta.is-up { color: var(--success-text); font-weight: 600; }
.stat-delta.is-down { color: var(--danger); font-weight: 600; }
.report-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin-bottom: 16px; }
.report-pair > .card { margin-bottom: 0; }
.report-table tr.is-selected th, .report-table tr.is-selected td { background: var(--bg); }
.overview-pagination { padding: 8px 20px 16px; }
.invoice-line-service select { width: 8.5rem; min-width: 0; }

/* --- Client portal: the firm's pages ------------------------------------------------------------- */
/* The sidebar's count of documents that need the firm (new from clients, changes asked for) */
.nav-badge {
  margin-left: auto; min-width: 1.6em; padding: 0 6px; border-radius: 999px; background: var(--primary); color: #fff;
  font-size: 0.72rem; font-weight: 700; line-height: 1.6; text-align: center;
}
.sidebar-hidden .nav-badge { display: none; }

/* What needs attention: counts that filter the list */
.attention-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.attention-stat { margin-bottom: 0; padding: 14px 16px; border-top: 3px solid var(--border); }
.attention-stat .stat-value { font-size: 1.5rem; line-height: 1.2; }
.attention-stat .stat-label { font-size: 0.88rem; }
.attention-stat.is-waiting { border-top-color: var(--warning-border); }
.attention-stat.is-changes { border-top-color: var(--danger); }
.attention-stat.is-new { border-top-color: var(--primary); }
.attention-stat.is-zero .stat-value { color: var(--muted); }
.attention-stat.is-selected { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.attention-chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0 0 16px; padding: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: 0.88rem;
}
.chip:hover { text-decoration: none; border-color: var(--muted); }
.chip.is-waiting { border-color: var(--warning-border); }
.chip.is-changes { border-color: var(--danger); color: var(--danger); }
.chip.is-new { border-color: var(--primary); color: var(--link); }

/* Where a document stands */
.badge.badge-new, .badge.badge-portal, .badge.badge-progress { background: var(--info-bg); color: var(--info-text); }
.badge.badge-waiting { background: var(--warning-bg); color: var(--warning-text); }
.badge.badge-you { background: none; box-shadow: inset 0 0 0 1px var(--border); color: var(--text); }
.badge.badge-past-due { background: var(--error-bg); color: var(--danger); }
.badge.badge-approved { background: var(--success-bg); color: var(--success-text); }
.badge.badge-changes { background: var(--error-bg); color: var(--danger); }
.badge.badge-invited { background: var(--purple-bg); color: var(--purple-text); }
.badge .icon { width: 12px; height: 12px; margin-right: 3px; vertical-align: -1px; }
.vis { display: inline-flex; align-items: center; gap: 5px; font-size: 0.88rem; font-weight: 600; white-space: nowrap; }
.vis .icon { width: 15px; height: 15px; }
.vis-shared { color: var(--success-text); }
.vis-firm { color: var(--muted); }
.vis-client { color: var(--link); }
.vis-date { display: block; }

/* A file: its type as a coloured label, then its name */
.file-badge {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-width: 38px; height: 22px;
  padding: 0 5px; border-radius: 5px; background: #667085; color: #fff; font-size: 0.66rem; font-weight: 800;
  letter-spacing: 0.04em; line-height: 1;
}
.file-badge.file-pdf { background: #c8372d; }
.file-badge.file-sheet { background: #1e7e45; }
.file-badge.file-doc { background: #2b579a; }
.file-badge.file-image { background: #7c4ddb; }
.file-badge.file-mail { background: #a35f00; }

/* The firm's list of documents; narrow, each document becomes a small card */
.doc-list-box { container: doc-list / inline-size; }
.doc-table td { vertical-align: middle; }
.doc-table .badge { white-space: nowrap; }
.doc-main { min-width: 240px; }
.doc-title-line { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; }
.doc-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.doc-title:hover { color: var(--link); }
.doc-meta { margin-top: 3px; }
.doc-note, .doc-opened { display: flex; align-items: flex-start; gap: 6px; margin-top: 4px; }
.doc-note .icon, .doc-opened .icon { width: 14px; height: 14px; margin-top: 2px; flex-shrink: 0; color: var(--muted); }
.doc-note { color: var(--text); }
.doc-actions { text-align: right; white-space: nowrap; }
.btn-share { border-color: var(--success-text); color: var(--success-text); }
.btn-share:hover { border-color: var(--success-text); background: var(--success-bg); }
.doc-row.is-new td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
@container doc-list (max-width: 760px) {
  .doc-table thead { display: none; }
  .doc-table, .doc-table tbody { display: block; }
  .doc-table tr.doc-row {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 14px 20px; border-bottom: 1px solid var(--border);
  }
  .doc-table tbody tr.doc-row:last-child { border-bottom: 0; }
  .doc-list-box table.doc-table tr.doc-row > td { padding: 0; border: 0; min-width: 0; }
  .doc-table .doc-vis .vis-date { display: inline; margin-left: 6px; }
  .doc-table .doc-actions { text-align: left; margin-top: 4px; }
  .doc-table tr.doc-row.is-new { box-shadow: inset 3px 0 0 var(--primary); }
  .doc-table tr.doc-row.is-new td:first-child { box-shadow: none; }
  .card:not(.table-wrap) > .doc-list-box .doc-table tr.doc-row { padding-left: 0; padding-right: 0; }  /* the card pads it */
}
.card:not(.table-wrap) > .doc-list-box .doc-table th:first-child, .card:not(.table-wrap) > .doc-list-box .doc-table td:first-child { padding-left: 0; }
.card:not(.table-wrap) > .doc-list-box .doc-table th:last-child, .card:not(.table-wrap) > .doc-list-box .doc-table td:last-child { padding-right: 0; }
.doc-section .section-header h2 { display: flex; align-items: center; gap: 8px; }
.doc-section-empty .empty-engagement { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* A client's page: the portal section */
.portal-signin-line { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; }
.portal-signin-line .icon { margin-top: 3px; color: var(--muted); }
.recent-docs li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.recent-docs .doc-title-line { flex: 1 1 260px; min-width: 0; }

/* Who can sign in; copying invite links */
.access-table td { vertical-align: middle; }
.copy-field { display: flex; gap: 8px; align-items: center; margin: 6px 0 4px; max-width: 560px; }
.copy-field input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 0.82rem; }
.portal-link-card .item-with-icon { align-items: flex-start; }
.portal-link-card .item-with-icon > div { flex: 1; min-width: 0; }
.portal-closed-notice { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 16px; }
.portal-closed-notice .icon { margin-top: 2px; }

/* Uploading: a box to choose files or drop them on */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 112px; padding: 18px; border: 2px dashed var(--border); border-radius: 10px; background: var(--bg);
  color: var(--muted); text-align: center; cursor: pointer; font-weight: normal;
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--primary); color: var(--text); }
.dropzone.is-dragging { background: rgba(59, 106, 224, 0.08); }
.dropzone:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.dropzone .icon { width: 26px; height: 26px; color: var(--primary); }
.dropzone-text strong { color: var(--link); }
.dropzone-files { color: var(--text); font-size: 0.88rem; font-weight: 600; overflow-wrap: anywhere; }
.dropzone.has-files { border-style: solid; border-color: var(--primary); }
.dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.has-error .dropzone { border-color: var(--danger); }
.upload-form { max-width: none; }
.doc-links { margin-bottom: 4px; }
.visibility-field fieldset > div { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.upload-page { max-width: 720px; }

/* Yes/no settings: what it is and what it does, with a switch (portal/_toggle.html) */
.toggle-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 11px 0; }
.toggle-row + .toggle-row { border-top: 1px solid var(--border); }
.toggle-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; }
.toggle-label { font-weight: 600; font-size: 0.95rem; }
.toggle-help { color: var(--muted); font-size: 0.85rem; font-weight: normal; }
input.switch {
  -webkit-appearance: none; appearance: none; position: relative; flex-shrink: 0; width: 40px; height: 23px; margin: 1px 0 0;
  padding: 0; border: 0; border-radius: 999px; background: var(--control-off); cursor: pointer; transition: background 0.15s;
}
input.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s;
}
input.switch:checked { background: var(--primary); }
input.switch:checked::before { transform: translateX(17px); }
input.switch:focus { outline: none; }
input.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { input.switch, input.switch::before { transition: none; } }
.form .toggle-row { margin-bottom: 4px; }
.portal-settings .sub-fields { margin: 0 0 6px 18px; padding: 2px 0 2px 16px; }
.portal-settings .sub-fields .field { margin: 8px 0 4px; }
.portal-settings:has(#id_show_deadlines:not(:checked)) .sub-fields { opacity: 0.5; }

/* A document's page, the portal settings */
.client-note { margin: 8px 0 0; padding: 8px 12px; border-left: 3px solid var(--border); background: var(--bg); border-radius: 0 6px 6px 0; }
.compact-list li { padding: 4px 0; }
.approval-actions { margin-top: 8px; }
.sub-fields { margin: -6px 0 12px 26px; padding-left: 12px; border-left: 2px solid var(--border); }
.portal-settings .card { max-width: none; }
.portal-intro .steps { margin: 12px 0 16px; padding-left: 20px; }
.portal-intro .steps li { margin-bottom: 8px; }
.portal-intro .steps li::marker { color: var(--primary); font-weight: 700; }

/* Setting up services for many clients (engagements/bulk_views.py) */
.bulk-filters { margin-bottom: 12px; }
.bulk-problems { margin-bottom: 12px; }
.bulk-problems p { margin: 0; }
.bulk-clients summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; cursor: pointer; }
.bulk-clients summary .card-heading { display: inline; margin: 0; }
.bulk-clients .table-scroll { margin-top: 12px; }
.bulk-client-table { max-height: none; }
.bulk-preset-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.bulk-preset-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.bulk-preset-actions { display: flex; gap: 6px; }
.bulk-group { margin-top: 20px; }
.bulk-service { margin-bottom: 8px; padding: 12px 16px; }
.bulk-service-head { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: normal; }
.bulk-service-head input { flex: none; margin-top: 3px; }
.bulk-service-rule { display: block; margin-top: 2px; }
.bulk-service-fields { margin: 12px 0 0 26px; }
.bulk-service:not(:has(.bulk-service-toggle:checked)) .bulk-service-fields { display: none; }
.bulk-service:has(.bulk-service-toggle:checked) { border-color: var(--primary); }
.bulk-grid td, .bulk-grid th { white-space: nowrap; }
.bulk-grid th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.bulk-cell.is-add { font-weight: 600; color: var(--success-text); }
.bulk-grid tfoot th, .bulk-grid tfoot td { border-top: 2px solid var(--border); font-weight: 600; }
.bulk-bar-actions {
  position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 16px; padding: 12px 0; border-top: 1px solid var(--border); background: var(--bg);
}
.bulk-save { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.bulk-save input { min-width: 200px; }
@media (max-width: 640px) { .bulk-save { margin-left: 0; } .bulk-service-fields { margin-left: 0; } }

/* Request templates, and requests and invites for many clients at once (portal/template_views.py, bulk_views.py) */
.template-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.template-card { margin: 0; padding: 16px 20px; }
.template-card-head { display: grid; gap: 10px; }
.template-card-head p { margin: 2px 0 0; }
.template-card-head .actions { justify-content: flex-start; }
.template-name { margin: 0; font-size: 1.05rem; }
.template-items { margin-top: 8px; }
.template-items summary { cursor: pointer; color: var(--link); }
.template-items ol { margin: 8px 0 4px; padding-left: 22px; }
.template-items li { margin-bottom: 2px; }
.todo-template-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; }
.todo-template-pick label { font-weight: 600; }
.todo-template-pick select { width: auto; max-width: 100%; }
.bulk-request { max-width: none; margin-bottom: 16px; }
.template-choice { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-bottom: 8px; }
.template-choice .field { flex: 1 1 260px; margin-bottom: 0; }
.template-choice .btn { margin-bottom: 2px; }
.bulk-request .template-items { margin: 0 0 14px; }
.filed-under { align-self: end; margin: 0 0 12px; }
.bulk-clients > .card-heading { margin-bottom: 4px; }
.bulk-clients > p { margin: 0 0 8px; }
.invite-table .badge { margin-left: 4px; }
.invite-note { max-width: none; margin-top: 16px; }
.email-preview-box { margin: 6px 0 10px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.email-preview-box p { margin: 0 0 4px; }
.email-preview-text { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--text-sm); }

/* Importing clients and contacts (firmdata/import_views.py) */
.import-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
@media (max-width: 900px) { .import-layout { grid-template-columns: minmax(0, 1fr); } }
.import-layout .card { margin: 0; }
.import-tips { margin: 0 0 12px; padding-left: 18px; }
.import-tips li { margin-bottom: 4px; }
.import-columns select { width: 100%; min-width: 180px; max-width: 320px; }
.import-columns tbody th {
  color: var(--text); font-size: var(--text-sm); font-weight: 600; letter-spacing: normal; text-transform: none;
  white-space: normal;
}
.import-columns tbody th label { color: inherit; font-size: inherit; }
.import-columns .import-sample { overflow: hidden; max-width: 260px; text-overflow: ellipsis; white-space: nowrap; }
.import-columns tr.is-refused th, .import-columns tr.is-refused td { color: var(--muted); }
.import-columns .show-sm { display: none; }
@media (max-width: 640px) { .import-columns .show-sm { display: block; } }
.import-problems p { margin: 0; }
.import-problems { margin-bottom: 12px; }
.import-counts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.import-options { display: grid; gap: 6px; margin: 0 0 12px; }
.check-row { display: flex; align-items: flex-start; gap: 8px; font-size: var(--text-sm); }
.check-row input { flex: none; margin-top: 2px; }
.import-households .check-row { margin: 6px 0; }
.import-rows select { min-width: 150px; }
.import-rows .import-details { min-width: 240px; max-width: 420px; }
.import-rows .import-reason { margin-top: 4px; }
.import-warnings { margin: 4px 0 0; padding-left: 16px; color: var(--warning-text); }
.import-check:has(.import-only-notes:checked) .import-rows tbody tr:not(.has-notes) { display: none; }
.import-bar {
  position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding: 12px 0;
  border-top: 1px solid var(--border); background: var(--bg);
}
.import-numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 0 0 16px; }
.import-numbers div { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.import-numbers dt { color: var(--muted); font-size: var(--text-sm); }
.import-numbers dd { margin: 2px 0 0; font-size: 1.4rem; font-weight: 600; }
.import-next { margin: 0; padding-left: 18px; }

/* Password fields: the show/hide button inside the field, on the right (static/js/app.js) */
.password-field { position: relative; display: block; width: 100%; }
.password-field input { width: 100%; padding-right: 44px; }
.password-toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: inline-flex; align-items: center;
  justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--radius-md);
  background: none; color: var(--muted); cursor: pointer;
}
.password-toggle:hover { color: var(--text); }
.password-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.password-toggle .icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Settings, Portal address: the name on the app's domain, the firm's own domain and its DNS record */
.address-now .copy-field { max-width: 640px; }
.address-form { max-width: 560px; }
.address-input { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.address-input input { flex: 1 1 160px; min-width: 0; font-family: ui-monospace, monospace; }
.address-part { font-family: ui-monospace, monospace; font-size: var(--text-sm); }
.domain-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; }
.domain-name { font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.domain-problem { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; }
.domain-problem .icon { flex: none; margin-top: 2px; }
.dns-record {
  display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 6px 14px;
  margin: 8px 0 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2);
}
.dns-record dt { font-size: var(--text-sm); font-weight: 600; color: var(--text-2); }
.dns-record dd { min-width: 0; margin: 0; }
.dns-record .copy-field { max-width: none; margin: 0; }
@media (max-width: 560px) {
  .dns-record { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dns-record dd + dt { margin-top: 8px; }
}
.domain-optional { margin: 12px 0 4px; }
.domain-optional summary { cursor: pointer; color: var(--text-2); font-size: var(--text-sm); }

/* --- Client portal: what the client sees ------------------------------------------------------- */
body.portal-page { min-height: 100vh; display: flex; flex-direction: column; }
.portal-preview-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 20px; background: var(--warning-bg); color: var(--warning-text);
  font-size: 0.9rem; border-bottom: 1px solid var(--warning-border-soft);
}
.portal-preview-bar > span { flex: 1; min-width: 220px; }

.portal-header { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); }
.portal-bar { display: flex; align-items: center; gap: 16px; max-width: 1040px; margin: 0 auto; padding: 10px 20px; }
.portal-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.05rem; flex-shrink: 0; }
.portal-brand:hover { text-decoration: none; }
.portal-logo { display: block; max-height: 38px; max-width: 170px; object-fit: contain; }
.portal-client { flex: 1; min-width: 0; display: flex; }
.client-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 16px; border-left: 1px solid var(--border); }
.client-button {
  display: flex; align-items: center; gap: 10px; max-width: 100%; padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; color: var(--text);
}
.client-button:hover, .client-menu[open] > .client-button { border-color: var(--muted); }
.client-button-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.client-button-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.client-button-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-button .chevron { width: 16px; height: 16px; color: var(--muted); transition: transform 0.15s; }
.client-menu[open] .chevron { transform: rotate(180deg); }
.client-menu { min-width: 0; }
.client-menu .menu-panel { right: auto; min-width: 260px; max-width: calc(100vw - 32px); }
.account-button { display: block; border-radius: 50%; cursor: pointer; }
.account-button:focus-visible, .client-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.portal-page .avatar { background: var(--primary); }
.account-menu { flex-shrink: 0; }
.account-menu .menu-panel { left: auto; right: 0; min-width: 220px; }

.portal-nav { border-top: 1px solid var(--border); }
.portal-nav-inner { display: flex; gap: 22px; max-width: 1040px; margin: 0 auto; padding: 0 20px; overflow-x: auto; scrollbar-width: none; }
.portal-nav a {
  position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 11px 0 9px; border-bottom: 2px solid transparent;
  color: var(--muted); font-weight: 500; white-space: nowrap;
}
.portal-nav a .icon { width: 17px; height: 17px; }
.portal-nav a:hover { color: var(--text); text-decoration: none; }
.portal-nav a.active { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
.portal-nav a.active .icon { color: var(--primary); }
.portal-nav a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-count {
  min-width: 1.5em; padding: 0 6px; border-radius: 999px; background: var(--primary); color: #fff;
  font-size: 0.7rem; font-weight: 700; line-height: 1.6; text-align: center;
}

.portal-main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 24px 20px 40px; }
.portal-main:focus { outline: none; }
.portal-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.portal-page-header h1 { font-size: 1.55rem; }
.portal-page-header p { margin: 4px 0 0; }
.portal-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.portal-footer-inner { display: flex; flex-wrap: wrap; gap: 4px 18px; max-width: 1040px; margin: 0 auto; padding: 16px 20px; }
.portal-footer strong { color: var(--text); }

/* Overview */
.portal-welcome { display: flex; gap: 12px; align-items: flex-start; border-left: 3px solid var(--primary); }
.portal-welcome > .icon { color: var(--primary); margin-top: 2px; }
.portal-welcome p { margin: 0 0 8px; }
.portal-welcome p:last-child { margin-bottom: 0; }
.portal-glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.glance { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 14px 16px; color: var(--text); border-top: 3px solid var(--border); }
.glance:hover { text-decoration: none; border-color: var(--primary); }
.glance.is-new { border-top-color: var(--primary); }
.glance.is-alert { border-top-color: var(--warning-border); }
.glance-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.glance-label { color: var(--muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.portal-attention { border-color: var(--warning-border); }
.portal-attention h2, .portal-callout { display: flex; align-items: center; gap: 8px; }
.portal-attention h2 .icon { color: var(--warning-border); }
.portal-columns { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 0 20px; align-items: start; }
@media (max-width: 900px) { .portal-columns { grid-template-columns: minmax(0, 1fr); } }
.portal-narrow { max-width: 560px; }

/* Documents */
.portal-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.portal-filters input[type="search"] { flex: 1; min-width: 200px; }
.portal-callout { margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--warning-border); border-radius: var(--radius); background: var(--warning-bg); color: var(--warning-text); }
.portal-year-title { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; margin-bottom: 4px; }
.portal-section-title {
  margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.portal-year-title + .portal-section-title { border-top: 0; margin-top: 8px; padding-top: 0; }
.portal-doc-list { list-style: none; margin: 0; padding: 0; }
.portal-doc {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; padding: 12px 0;
  border-bottom: 1px solid var(--border); scroll-margin-top: 130px;
}
.portal-doc:last-child { border-bottom: 0; }
.portal-doc > .file-badge { margin-top: 1px; }
.portal-doc-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.portal-doc-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.portal-doc-title:hover { color: var(--link); }
.portal-doc-meta { margin-top: 2px; }
.portal-doc-main > p { margin: 4px 0 0; }
.portal-doc-message { display: flex; gap: 8px; margin: 8px 0 0; padding: 8px 12px; border-radius: 6px; background: var(--bg); font-size: 0.92rem; }
.portal-doc-message .icon { width: 15px; height: 15px; margin-top: 3px; color: var(--muted); }
.portal-doc-actions { display: flex; gap: 6px; }
.portal-received { display: flex; align-items: flex-start; gap: 6px; margin: 4px 0 0; color: var(--success-text); }
.portal-received .icon { width: 14px; height: 14px; margin-top: 3px; }
.approve-box {
  margin-top: 10px; padding: 10px 12px; border: 1px solid var(--warning-border); border-radius: var(--radius); background: var(--warning-bg-soft);
}
.approve-box > p { margin: 0 0 8px; }
.approve-box > p:last-child { margin: 8px 0 0; }
.approve-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.changes-box > summary { list-style: none; }
.changes-box > summary::-webkit-details-marker { display: none; }
.changes-box[open] { flex-basis: 100%; }
.changes-form { max-width: none; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.changes-form label { font-weight: 600; font-size: 0.9rem; }
.changes-form textarea { width: 100%; }
.is-compact .portal-doc { padding: 9px 0; }
.portal-empty { text-align: center; padding: 36px 20px; }
.portal-empty > .icon { width: 38px; height: 38px; color: var(--muted); stroke-width: 1.5; }
.portal-empty h2 { margin: 10px 0 6px; }
.portal-empty p { max-width: 460px; margin: 0 auto 12px; }

/* Deadlines */
.deadline-month-title {
  margin: 16px 0 4px; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.deadline-month-title:first-of-type { margin-top: 4px; }
.deadline-list, .done-list, .deadline-docs, .team-list, .firm-lines, .service-list, .people-list { list-style: none; margin: 0; padding: 0; }
.deadline { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.deadline:last-child { border-bottom: 0; }
.deadline-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; width: 50px; height: 52px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); line-height: 1.1;
}
.deadline-month { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--danger); }
.deadline-day { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.deadline.is-client .deadline-date { border-style: dashed; }
.deadline-main { flex: 1; min-width: 0; }
.deadline-title { font-weight: 600; overflow-wrap: anywhere; }
.deadline-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 3px; }
.deadline-docs { margin-top: 6px; }
.deadline-docs li { padding: 2px 0; }
.deadline-docs a { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.deadline-docs .icon { width: 14px; height: 14px; }
.is-compact .deadline-date { width: 44px; height: 46px; }
.is-compact .deadline-day { font-size: 1.1rem; }
.done-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.done-item:last-child { border-bottom: 0; }
.done-mark {
  display: inline-grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%;
  background: var(--success-bg); color: var(--success-text);
}
.done-mark .icon { width: 14px; height: 14px; }
.done-main { flex: 1; min-width: 0; }
.done-title { font-weight: 600; overflow-wrap: anywhere; }

/* Deadlines: calendar view */
.calendar-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.calendar-title { margin: 0; }
.tracker-nav .btn.is-disabled { opacity: 0.4; cursor: default; }
.calendar-grid { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.calendar-weekdays, .calendar-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekday {
  padding: 6px 4px; text-align: center; font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); background: var(--bg); border-bottom: 1px solid var(--border);
}
.calendar-week + .calendar-week { border-top: 1px solid var(--border); }
.calendar-day { min-height: 92px; padding: 6px; border-left: 1px solid var(--border); min-width: 0; }
.calendar-day:first-child { border-left: 0; }
.calendar-day.is-outside { background: var(--bg); }
.calendar-day.is-outside .calendar-day-number { color: var(--muted); opacity: 0.6; }
.calendar-day-number { font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.calendar-day.is-today .calendar-day-number span[aria-hidden] {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 12px;
  background: var(--primary); color: #fff;
}
.calendar-items { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.calendar-item {
  display: flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 4px; font-size: 0.78rem; line-height: 1.3;
  background: var(--primary); color: #fff; border: 1px solid transparent;
}
.calendar-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-item.is-client { background: transparent; color: var(--text); border: 1px dashed var(--primary); }
.calendar-item.is-past-due { border-color: var(--danger); color: var(--danger); }
.calendar-item.is-done { background: var(--success-bg); color: var(--success-text); }
.calendar-item-mark { display: inline-grid; flex-shrink: 0; }
.calendar-item-mark .icon { width: 11px; height: 11px; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; }
.calendar-key { display: inline-flex; align-items: center; gap: 6px; }
.calendar-key::before { content: ""; width: 12px; height: 12px; border-radius: 3px; border: 1px solid transparent; }
.calendar-key.is-firm::before { background: var(--primary); }
.calendar-key.is-client::before { border: 1px dashed var(--primary); }
.calendar-key.is-done::before { background: var(--success-bg); border-color: var(--success-text); }
@media (max-width: 560px) {  /* an agenda: only the days with something on them */
  .calendar-weekdays { display: none; }
  .calendar-week { grid-template-columns: 1fr; }
  .calendar-week + .calendar-week { border-top: 0; }
  .calendar-day { border-left: 0; border-top: 1px solid var(--border); min-height: 0; }
  .calendar-day.is-empty, .calendar-day.is-outside { display: none; }
  .calendar-week:first-child .calendar-day:first-of-type { border-top: 0; }
  .calendar-day-number { font-size: 0.8rem; }
  .calendar-day.is-today .calendar-day-number span[aria-hidden]::after { content: " · Today"; }
  .calendar-day.is-today .calendar-day-number span[aria-hidden] { min-width: 0; border-radius: 12px; padding: 0 8px; }
  .calendar-item { font-size: 0.85rem; padding: 4px 8px; }
  .calendar-item-title { white-space: normal; overflow-wrap: anywhere; }
}

/* Team, the firm's details, services, people */
.team-person { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.team-person:last-child { border-bottom: 0; }
.team-person .avatar { width: 36px; height: 36px; font-size: 0.8rem; }
.team-person-text { min-width: 0; }
.team-name { font-weight: 600; }
.team-reach { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 2px; }
.team-reach a, .firm-lines li { display: inline-flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.team-reach .icon { width: 14px; height: 14px; }
.firm-lines li { display: flex; align-items: flex-start; padding: 5px 0; }
.firm-lines .icon { width: 16px; height: 16px; margin-top: 3px; color: var(--muted); flex-shrink: 0; }
.firm-card .btn-block { margin-top: 12px; text-align: center; }
.service-list li, .people-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.service-list li:last-child, .people-list li:last-child { border-bottom: 0; }
.service-name, .people-name { font-weight: 600; }

/* Invoices */
.portal-invoices td { vertical-align: middle; }
.portal-invoices .badge { margin-left: 6px; }
.show-sm { display: none; }

/* Sign-in pages */
.portal-auth-brand { display: flex; justify-content: center; margin-bottom: 20px; }
.portal-auth-logo { display: block; max-height: 64px; max-width: 240px; object-fit: contain; }
.portal-auth .auth-card h1 { margin-bottom: 8px; }

/* Phones: the sections move to a bar at the bottom of the screen, in reach of a thumb */
@media (max-width: 720px) {
  .portal-header { position: static; }
  .portal-bar { gap: 10px; padding: 10px 16px; }
  .portal-logo { max-height: 32px; max-width: 120px; }
  .portal-brand .portal-firm { display: none; }
  .client-name { padding-left: 10px; font-size: 0.95rem; }
  .portal-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; border-top: 1px solid var(--border);
    background: var(--surface); box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  }
  .portal-nav-inner { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; padding: 0 4px env(safe-area-inset-bottom); }
  .portal-nav a {
    flex-direction: column; gap: 2px; padding: 8px 2px 7px; border-bottom: 0; border-top: 2px solid transparent;
    font-size: 0.7rem; font-weight: 500;
  }
  .portal-nav a .icon { width: 21px; height: 21px; }
  .portal-nav a.active { border-top-color: var(--primary); color: var(--link); }
  .portal-nav .nav-count { position: absolute; top: 4px; left: calc(50% + 6px); }
  .portal-main { padding: 18px 16px 96px; }
  .portal-footer-inner { padding-bottom: 84px; }
  .portal-page-header h1 { font-size: 1.35rem; }
  .portal-doc { grid-template-columns: auto minmax(0, 1fr); }
  .portal-glance { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .glance { padding: 12px 14px; }
  .glance-value { font-size: 1.2rem; }
  .portal-doc-actions { grid-column: 2; }
  .show-sm { display: block; }
  .portal-preview-bar { padding: 8px 16px; }
  .portal-page #messages { bottom: 84px; }  /* above the bar */
}

@media print {
  .portal-header, .portal-nav, .portal-footer, .portal-preview-bar { display: none !important; }
  .portal-main { max-width: none; padding: 0; }
}

/* --- Client portal: to-dos ------------------------------------------------------------------------ */
/* How much is done */
.todo-progress { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.todo-progress progress { width: 90px; height: 8px; accent-color: var(--success-text); }
.todo-summary-progress .todo-progress progress { width: 220px; height: 10px; }
.todo-summary-progress .todo-progress .small { font-size: 0.95rem; font-weight: 600; }
.todo-summary p { margin: 8px 0 0; }

/* The firm's lists of to-dos */
.todo-table td { vertical-align: middle; }
.todo-title { font-weight: 600; color: var(--text); }
.todo-title:hover { color: var(--link); }
.todo-status .badge { margin: 2px 4px 2px 0; white-space: nowrap; }
.todo-table tr.has-new td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.card > .table-scroll > .todo-table tr.has-new td:first-child { padding-left: 10px; }  /* off the new-answers bar */
.attention-stat.is-todo-new { border-top-color: var(--primary); }
.attention-stat.is-todo-overdue { border-top-color: var(--danger); }
.attention-stat.is-todo-waiting { border-top-color: var(--warning-border); }
.chip.is-todo-new { border-color: var(--primary); color: var(--link); }
.chip.is-todo-overdue { border-color: var(--danger); color: var(--danger); }

/* Making a to-do: one row per item */
.todo-form { max-width: 980px; }
.todo-editor { min-width: 0; margin: 8px 0 16px; padding: 12px 16px 4px; border: 1px solid var(--border); border-radius: var(--radius); }
.todo-editor legend { padding: 0 6px; font-weight: 700; }
.todo-editor > p { margin: 0 0 10px; }
.todo-rows { container: todo-rows / inline-size; }
.todo-row {
  display: grid; grid-template-columns: 150px minmax(0, 1.4fr) minmax(0, 1fr) 128px 64px; gap: 8px; align-items: start;
  padding: 6px 0; border-bottom: 1px dashed var(--border);
}
.todo-row > div { min-width: 0; }
.todo-row input[type="text"], .todo-row select { width: 100%; }
.todo-row-head { padding-top: 0; border-bottom: 1px solid var(--border); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.todo-row-remove { padding-top: 7px; text-align: right; }
.todo-row .todo-row-format { visibility: hidden; }
.todo-row:has(select[name$="-kind"] option[value="information"]:checked) .todo-row-format { visibility: visible; }
.todo-row-errors { grid-column: 1 / -1; }
.todo-row.has-error input[type="text"]:invalid, .todo-row.has-error .errorlist + input { border-color: var(--danger); }
.todo-row .errorlist { margin: 4px 0 0; font-size: 0.8rem; }
.todo-editor-more { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 10px 0 8px; }
@container todo-rows (max-width: 700px) {
  .todo-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 10px 0; }
  .todo-row-head { display: none; }
  .todo-row-label, .todo-row-details { grid-column: 1 / -1; }
  .todo-row .todo-row-format { display: none; }
  .todo-row:has(select[name$="-kind"] option[value="information"]:checked) .todo-row-format { display: block; }
  .todo-row-remove { text-align: left; padding-top: 0; }
}

/* A to-do on the firm's side: each item with what the client gave */
.review-list, .todo-items, .todo-files, .review-files, .todo-overview { list-style: none; margin: 0; padding: 0; }
.review-item { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 6px 12px; padding: 14px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 20px; }
.review-item:last-child { border-bottom: 0; }
.review-item.is-new { box-shadow: inset 3px 0 0 var(--primary); padding-left: 10px; margin-left: -10px; }
.review-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.review-label { font-weight: 600; overflow-wrap: anywhere; }
.review-response { margin-top: 8px; padding: 8px 12px; border-radius: 6px; background: var(--bg); }
.review-files li { padding: 3px 0; }
.review-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; justify-content: flex-end; }
.send-back > summary { list-style: none; }
.send-back > summary::-webkit-details-marker { display: none; }
.send-back-form { max-width: none; width: min(340px, 80vw); margin-top: 8px; }
.send-back-form .field { margin-bottom: 8px; }
.send-back-form textarea { width: 100%; }
.todo-returned-note { display: flex; align-items: flex-start; gap: 6px; margin-top: 6px; color: var(--warning-text); }
.todo-returned-note .icon { width: 14px; height: 14px; margin-top: 3px; flex-shrink: 0; }
@media (max-width: 720px) {
  .review-item { grid-template-columns: 26px minmax(0, 1fr); }
  .review-actions { grid-column: 2; justify-content: flex-start; }
}

/* Where an item stands: an empty circle to do, a green tick done, a cross when it's not needed */
.todo-check {
  display: inline-grid; place-items: center; width: 24px; height: 24px; flex-shrink: 0; margin-top: 1px;
  border: 2px solid var(--control-off); border-radius: 50%; color: #fff;
}
.todo-check .icon { width: 13px; height: 13px; stroke-width: 3; }
.is-done > .todo-check { border-color: var(--success-text); background: var(--success-text); color: var(--surface); }
.is-not_needed > .todo-check { border-color: var(--border); color: var(--muted); }
.is-not_needed .todo-item-label, .is-not_needed .review-label { color: var(--muted); text-decoration: line-through; }
.todo-kind { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.todo-kind .icon { width: 13px; height: 13px; }
.todo-answer { overflow-wrap: anywhere; }

/* The client's to-dos */
.todo-card { scroll-margin-top: 130px; }
.todo-card.is-overdue { border-color: var(--danger); }
.todo-card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 20px; }
.todo-card-title { min-width: 0; flex: 1 1 280px; }
.todo-card-title h2 { margin: 0 0 6px; font-size: 1.15rem; }
.todo-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.todo-card > .portal-doc-message { margin-top: 12px; }
.todo-items { margin-top: 8px; }
.todo-item { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); scroll-margin-top: 130px; }
.todo-item-main { flex: 1; min-width: 0; }
.todo-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.todo-item-label { font-weight: 600; overflow-wrap: anywhere; }
.todo-item-details { margin: 2px 0 0; }
.todo-returned {
  display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 0; padding: 8px 12px; border-radius: 6px;
  background: var(--warning-bg); color: var(--warning-text);
}
.todo-returned .icon { width: 15px; height: 15px; margin-top: 2px; flex-shrink: 0; }
.todo-response { max-width: 620px; margin-top: 10px; }
.todo-response .field { margin-bottom: 10px; }
.todo-response textarea { width: 100%; }
.todo-response input[type="date"], .todo-response input[type="number"] { max-width: 240px; }
.todo-response fieldset > div { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.todo-response .actions { margin-top: 2px; }
.dropzone.dropzone-compact { flex-direction: row; flex-wrap: wrap; min-height: 64px; padding: 12px 14px; gap: 4px 10px; }
.dropzone-compact .icon { width: 20px; height: 20px; }
.dropzone-compact .dropzone-files { flex-basis: 100%; }
.dropzone-compact .dropzone-files:empty { display: none; }
.todo-given { margin-top: 8px; padding: 8px 12px; border-radius: 6px; background: var(--bg); }
.todo-given .todo-answer { margin-bottom: 2px; }
.todo-given.is-earlier { background: none; border: 1px dashed var(--border); }
.todo-files li { padding: 3px 0; }
.todo-files a { display: inline-flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.todo-change { margin-top: 6px; }
.todo-attach { margin: -2px 0 10px; }
.todo-attach > summary { display: inline-flex; align-items: center; gap: 6px; list-style: none; color: var(--link); }
.todo-attach > summary::-webkit-details-marker { display: none; }
.todo-attach > summary .icon { width: 14px; height: 14px; }
.todo-attach[open] > summary { margin-bottom: 8px; }
.todo-change > summary { display: inline-block; list-style: none; }
.todo-change > summary::-webkit-details-marker { display: none; }
.todo-change > summary.link-action { color: var(--link); }
.done-todo > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 0; list-style: none; cursor: pointer; border-top: 1px solid var(--border); }
.done-todo > summary::-webkit-details-marker { display: none; }
.done-todo:first-of-type > summary { border-top: 0; }
.done-todo-title { font-weight: 600; }
.done-todo[open] > summary .done-todo-title { color: var(--link); }

/* The overview: the to-dos still open */
.todo-overview li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 16px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.todo-overview li:first-child { border-top: 0; }
.todo-overview-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.todo-overview-title:hover { color: var(--link); }
@media (max-width: 720px) {
  .todo-overview li { grid-template-columns: minmax(0, 1fr) auto; }
  .todo-overview li .todo-progress { grid-column: 1; grid-row: 2; }
  .todo-overview li .btn { grid-column: 2; grid-row: 1 / 3; }
  .todo-progress progress { width: 70px; }
}

/* --- Emails ---------------------------------------------------------------------------------------------- */
/* "Email the client about it" only means something once the document is shared */
.form:has(.visibility-field input[value="firm"]:checked) .shared-only { display: none; }

/* Shared documents, or items sent back, that the client hasn't been emailed about yet */
.email-pending { border-color: var(--info-border); }
.email-pending-head { display: flex; align-items: flex-start; gap: 12px; }
.email-pending-head h2 { margin: 0 0 2px; font-size: 1.05rem; }
.email-pending-head p { margin: 0; }
.email-pending-icon {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%;
  background: var(--info-bg); color: var(--info-text);
}
.email-pending-icon .icon { width: 17px; height: 17px; }
.email-pending-list { margin: 10px 0 6px 46px; padding: 0; list-style: none; }
.email-pending-list li { padding: 2px 0; overflow-wrap: anywhere; }
.email-pending-form { margin-left: 46px; }
.email-pending-form .actions { margin-top: 8px; }
.email-note > summary { display: inline-block; list-style: none; color: var(--link); }
.email-note > summary::-webkit-details-marker { display: none; }
.email-note textarea { display: block; width: 100%; max-width: 620px; margin-top: 6px; }
@media (max-width: 720px) { .email-pending-list, .email-pending-form { margin-left: 0; } }

/* How emails go out (settings, the email log) */
.email-setup-notice, .email-failed-notice { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 16px; }
.email-setup-notice .icon, .email-failed-notice .icon { margin-top: 2px; flex-shrink: 0; }
.email-setup-notice code { font-size: 0.85em; }
.reminder-fields { min-width: 0; margin: 4px 0 12px; padding: 0; border: 0; }
.reminder-fields legend { margin-bottom: 6px; padding: 0; }
.reminder-fields .field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; align-items: end; }
.reminder-fields p { margin: 0; }

/* The email log */
.email-table td { vertical-align: top; }
.email-table tr.is-failed td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.email-to, .email-subject { overflow-wrap: anywhere; }
.email-subject a { color: var(--text); }
.email-subject a:hover { color: var(--link); }
.email-error { color: var(--danger); overflow-wrap: anywhere; }
.email-error.small, .email-table .email-error { max-width: 320px; margin-top: 4px; }

/* A to-do's emails: sending it with an email, when the next reminder goes, what was sent */
.todo-send-form { display: inline-flex; align-items: center; gap: 10px; }
.todo-form-emails { margin: 4px 0 8px; }
.todo-reminders { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 12px; color: var(--muted); }
.todo-reminders > .icon { width: 14px; height: 14px; flex-shrink: 0; }
.todo-reminders form { display: inline; }
.email-history { margin: 0; padding: 0; list-style: none; }
.email-history li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.email-history li:last-child { border-bottom: 0; }
.email-history-when { min-width: 110px; }
.invite-email-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }

/* --- Reminders ------------------------------------------------------------------------------------------- */
/* A client's reminders, on its portal page */
.reminders-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.reminders-summary p { margin: 0; }
.reminders-setup { margin-top: 12px; }
.reminders-setup > summary { display: inline-flex; list-style: none; }
.reminders-setup > summary::-webkit-details-marker { display: none; }
.reminders-setup[open] > summary { margin-bottom: 14px; }
.reminders-form { max-width: 780px; }
.reminders-form fieldset { min-width: 0; margin: 0 0 14px; padding: 0; border: 0; }
.reminders-form legend { margin-bottom: 6px; padding: 0; }
.reminders-form .field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 16px; align-items: end; }
.recipients-field label { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-weight: 400; overflow-wrap: anywhere; }
.recipients-field input[type="checkbox"] { flex-shrink: 0; }
.reminders-past { margin-top: 10px; }
.reminders-past > summary { display: inline-block; list-style: none; color: var(--link); }
.reminders-past > summary::-webkit-details-marker { display: none; }
.reminders-past[open] > summary { margin-bottom: 8px; }
.reminders-clients { margin-top: 14px; }
.reminder-summary p { margin: 2px 0 0; }

/* Lists of reminders */
.reminder-table td { vertical-align: top; }
.reminder-table tr.needs-amount td:first-child { box-shadow: inset 3px 0 0 var(--warning-border); }
.reminder-about a { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.reminder-about a:hover { color: var(--link); }
.reminder-table tr.is-skipped .reminder-about a { color: var(--muted); text-decoration: line-through; }
.reminder-about .icon { width: 12px; height: 12px; margin-right: 3px; color: var(--success-text); vertical-align: -1px; }
.attention-stat.is-reminder-soon { border-top-color: var(--primary); }
.attention-stat.is-reminder-amount { border-top-color: var(--warning-border); }

/* One reminder: the form, and what they'll read */
.reminder-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .reminder-layout { grid-template-columns: minmax(0, 1fr); } }
.reminder-form textarea, .template-grid textarea { width: 100%; font-family: inherit; }
.reminder-form .form-grid { align-items: end; }
.fields-help { margin: -4px 0 12px; }
.fields-help > summary { display: inline-block; list-style: none; color: var(--link); }
.fields-help > summary::-webkit-details-marker { display: none; }
.fields-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 8px 0; font-size: 0.85rem; }
.fields-list dt, .fields-list dd { margin: 0; }
.fields-list dd { color: var(--muted); }
.reminder-preview h2 { margin: 0 0 4px; font-size: 1rem; }
.preview-subject { margin: 12px 0 8px; font-weight: 700; overflow-wrap: anywhere; }
.preview-body { padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); overflow-wrap: anywhere; }
.preview-body p { margin: 0 0 10px; }
.preview-body p:last-child { margin-bottom: 0; }
.preview-facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 10px 0 0; padding: 10px 14px; border-radius: 6px; background: var(--bg); }
.preview-facts dt { color: var(--muted); }
.preview-facts dd { margin: 0; font-weight: 600; }

/* The templates (settings) */
.template-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 900px) { .template-grid { grid-template-columns: minmax(0, 1fr); } }
.template-preview { align-self: start; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 6px; background: var(--bg); font-size: 0.9rem; overflow-wrap: anywhere; }
.template-preview p { margin: 0 0 8px; }
.template-preview p:last-child { margin-bottom: 0; }
.template-fields code { white-space: nowrap; }

/* Two-factor sign-in: setup steps, the QR code, recovery codes */
.setup-steps { padding-left: 20px; margin: 16px 0; display: grid; gap: 12px; }
.qr { margin: 12px 0; padding: 8px; background: #fff; border-radius: 8px; display: block; width: fit-content; line-height: 0; }
.qr svg { width: 232px; height: 232px; display: block; }
.secret-key { margin-top: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95rem; letter-spacing: 0.04em; color: var(--text); word-break: break-all; }
.recovery-codes { list-style: none; padding: 16px; margin: 16px 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.recovery-codes code { font-size: 1.05rem; letter-spacing: 0.06em; }
@media print { .auth-brand, .actions, .messages { display: none; } }

/* --- Today ------------------------------------------------------------------------------------------------ */
.today-glance { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.glance-tile {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs);
}
.glance-tile:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.glance-number { font-size: var(--text-2xl); font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.glance-name { color: var(--muted); font-size: var(--text-sm); }
.glance-tile.is-overdue .glance-number { color: var(--danger); }
.glance-tile.is-new .glance-number { color: var(--link); }
.today-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.today-card.is-overdue { border-top: 3px solid var(--danger); }
.today-card .section-header h2 { display: flex; align-items: center; gap: 8px; }
.today-links { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.today-more { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
.count.is-alert { background: var(--danger-bg); color: var(--danger); }
@media (max-width: 1100px) { .today-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .today-glance { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

/* Deadlines and tasks in one list */
.work-rows { list-style: none; margin: 0; padding: 0; }
.work-row {
  display: grid; grid-template-columns: 108px minmax(0, 1fr) auto; gap: 4px 14px; align-items: start; padding: 10px 0;
  border-top: 1px solid var(--border);
}
.work-row:first-child { border-top: 0; padding-top: 2px; }
.work-row:last-child { padding-bottom: 2px; }
.work-when { display: flex; flex-direction: column; line-height: 1.35; white-space: nowrap; }
.work-date { font-weight: 600; font-variant-numeric: tabular-nums; }
.work-line { display: flex; align-items: center; gap: 8px; }
.work-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.work-title:hover { color: var(--link); }
.work-for a { color: var(--muted); }
.work-for a:hover { color: var(--link); }
.work-tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; align-items: center; padding-top: 1px; }
@media (max-width: 560px) {
  .work-row { grid-template-columns: 96px minmax(0, 1fr); }
  .work-tags { grid-column: 2; justify-content: flex-start; }
}

/* A number and what it counts, each a link to the list behind it */
.fact-list { list-style: none; margin: 0; padding: 0; }
.fact-list li + li { border-top: 1px solid var(--border); }
.fact-list a { display: flex; align-items: baseline; gap: 8px; padding: 8px 0; color: var(--text-2); }
.fact-list li:first-child a { padding-top: 0; }
.fact-list a:hover { color: var(--link); text-decoration: none; }
.fact-number { min-width: 1.8em; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fact-number.is-alert { color: var(--danger); }
.fact-number.is-new { color: var(--link); }
.fact-list + .plain-list { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }
.activity-list { list-style: none; margin: 12px 0 0; padding: 14px 0 0; border-top: 1px solid var(--border); display: grid; gap: 12px; }
.activity-list li { display: flex; gap: 10px; min-width: 0; }
.activity-list li > div { min-width: 0; overflow-wrap: anywhere; }
.activity-icon {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%;
  background: var(--primary-soft); color: var(--info-text);
}
.activity-icon .icon { width: 14px; height: 14px; }
.activity-list a { color: var(--text); }
.activity-list a strong { font-weight: 600; }
.empty.is-quiet { flex-direction: row; justify-content: center; gap: 8px; padding: 18px 12px; }
.empty.is-quiet > .icon { width: 18px; height: 18px; margin: 0; color: var(--success); }

/* Getting started on Today (hello/started.py): a new firm's first steps, a bar that fills as they're done */
.getting-started { margin-bottom: 20px; }
.getting-started .section-header { align-items: flex-start; flex-wrap: nowrap; margin-bottom: 0; }
.getting-started .section-header p { margin: 2px 0 0; }
.start-progress { display: flex; gap: 4px; margin: 14px 0 4px; }
.start-progress span { flex: 1; height: 6px; border-radius: 3px; background: var(--border); }
.start-progress .is-done { background: var(--success); }
.start-steps { list-style: none; margin: 8px 0 0; padding: 0; }
.start-step { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 6px 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--border); }
.start-step:first-child { border-top: 0; }
.start-step.is-done { padding: 8px 0; }
.start-text p { margin: 2px 0 0; max-width: 60ch; }
.start-title { font-weight: 600; color: var(--text); }
.start-step.is-done .start-title { font-weight: 500; color: var(--muted); }
.start-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.start-actions a:not(.btn) { font-size: var(--text-sm); }
@media (max-width: 640px) {
  .start-step { grid-template-columns: 24px minmax(0, 1fr); }
  .start-actions { grid-column: 2; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
}

/* A sample firm (hello/demo.py): a banner on every page, and the offers to make one */
.sample-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--info-border); border-radius: var(--radius); background: var(--info-bg); color: var(--text); }
.sample-banner > .icon { flex: none; color: var(--info-text); }
.sample-banner p { flex: 1 1 320px; margin: 0; font-size: var(--text-sm); }
.sample-banner-actions { display: flex; flex-wrap: wrap; gap: 6px; }
/* Firmdesk's notice (ops/notices.py): planned maintenance, or a problem being worked on */
.service-notice { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--info-border); border-radius: var(--radius); background: var(--info-bg); color: var(--text); }
.service-notice > .icon { flex: none; margin-top: 2px; color: var(--info-text); }
.service-notice p { margin: 0; font-size: var(--text-sm); }
.service-notice.is-problem { border-color: var(--warning-border-soft); background: var(--warning-bg); }
.service-notice.is-problem > .icon { color: var(--warning-text); }
.sample-offer { margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--border); }
.sample-offer p { margin: 0 0 8px; }
.start-sample { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.start-sample .link-button { margin: 0 2px; }
.start-call { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.start-call > .icon { flex-shrink: 0; color: var(--muted); }
.start-call > span { flex: 1 1 14rem; }

/* From signing up to the firm's first day: where someone is (workspaces/views.py, ONBOARDING) */
.onboarding-steps { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 0 0 18px; padding: 0; font-size: var(--text-sm); color: var(--muted); }
.onboarding-steps li { display: inline-flex; align-items: center; gap: 6px; }
.onboarding-dot { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border-strong); font-size: 0.72rem; font-weight: 600; line-height: 1; }
.onboarding-dot .icon { width: 12px; height: 12px; stroke-width: 3; }
.onboarding-steps .is-done .onboarding-dot { border-color: var(--success-text); background: var(--success-text); color: var(--surface); }
.onboarding-steps .is-current { color: var(--text); font-weight: 600; }
.onboarding-steps .is-current .onboarding-dot { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.firm-setup #id_team_size { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.signed-in-as { margin: 16px 0 0; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; }
.link-button:hover { text-decoration: underline; }
@media (max-width: 899px), (pointer: coarse) {
  .link-button { min-height: var(--touch-target); }
}

/* --- Settings: data; deleting ---------------------------------------------------------------------------- */
.danger-zone { border-color: var(--danger-border); }
.danger-zone .card-heading { color: var(--danger); }
.deletion-banner {
  display: flex; align-items: flex-start; gap: 10px; margin: 0 0 20px; padding: 10px 14px; border: 1px solid var(--danger-border);
  border-radius: var(--radius); background: var(--danger-bg); color: var(--text);
}
.deletion-banner .icon { margin-top: 2px; color: var(--danger); }
.export-table td { vertical-align: middle; }
.fact-list.is-plain li { display: flex; align-items: baseline; gap: 8px; padding: 7px 0; }

/* --- Plan and billing (the plans app): the banner, the plans to choose from, the trial's countdown ----------------- */
.plan-banner {
  display: flex; align-items: flex-start; gap: 10px; margin: 0 0 20px; padding: 10px 14px; border: 1px solid var(--warning-border);
  border-radius: var(--radius); background: var(--warning-bg); color: var(--text);
}
.plan-banner .icon { margin-top: 2px; color: var(--warning-text); }
.plan-banner.is-info { border-color: var(--info-border); background: var(--info-bg); }
.plan-banner.is-info .icon { color: var(--info-text); }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; list-style: none; margin: 12px 0 0; padding: 0; }
.plan-card { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 16px 18px; }
.plan-card h3 { margin: 0; font-size: var(--text-md); }
.plan-card p { margin: 0; }
.plan-price { font-size: var(--text-xl); font-weight: 600; }
.plan-card form { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.trial-countdown {
  margin: auto 0 8px; padding: 8px 10px; border: 1px solid var(--sidebar-border); border-radius: var(--radius);
  color: var(--sidebar-text); font-size: var(--text-sm);
}
.trial-countdown a { color: inherit; font-weight: 600; }
.trial-countdown + .help-menu { margin-top: 0; }
.sidebar-hidden .trial-countdown { display: none; }

/* --- Settings: the activity log ---------------------------------------------------------------------------- */
.settings-body.is-wide { max-width: none; }
.settings-body .section-header .section-intro { margin: 0; }
.activity-filters select { max-width: 200px; }
.activity-filters .activity-dates { display: none; gap: 8px; }
.activity-filters:has(select[name="period"] option[value="custom"]:checked) .activity-dates { display: inline-flex; }
.activity-table td { vertical-align: top; }
.activity-table tr.is-alert td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.activity-what { overflow-wrap: anywhere; min-width: 220px; }

/* --- The policies (legal/): pages anyone can read ------------------------------------------------------------ */
body.legal-page { background: var(--surface); }
.legal-header { position: sticky; top: 0; z-index: 30; border-bottom: 1px solid var(--border); background: var(--surface); }
.legal-bar { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; max-width: 960px; margin: 0 auto; padding: 10px 20px; }
.legal-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 650; font-size: 1.05rem; letter-spacing: -0.015em; }
.legal-brand:hover { text-decoration: none; }
.legal-brand img { border-radius: 7px; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 2px 4px; flex: 1; }
.legal-nav a { padding: 6px 10px; border-radius: var(--radius-md); color: var(--muted); font-weight: 500; }
.legal-nav a:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.legal-nav a.active { color: var(--text); background: var(--surface-3); font-weight: 600; }
.legal-main { max-width: 960px; margin: 0 auto; padding: 36px 20px 64px; }
.legal-main:focus { outline: none; }
.legal-text { max-width: 720px; font-size: var(--text-md); line-height: 1.65; }
.legal-text h1 { font-size: var(--text-3xl); margin-bottom: 12px; }
.legal-text h2 { margin: 36px 0 10px; font-size: var(--text-xl); scroll-margin-top: 72px; }
.legal-text p { margin: 0 0 14px; }
.legal-text ul { margin: 0 0 16px; padding-left: 22px; }
.legal-text li { margin-bottom: 7px; }
.legal-lead { font-size: var(--text-lg); color: var(--text-2); }
.legal-summary { margin: 24px 0 8px; padding: 18px 22px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.legal-summary h2 { margin: 0 0 10px; font-size: var(--text-md); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.legal-table { margin: 4px 0 18px; font-size: var(--text-base); line-height: 1.5; }
.legal-table th, .legal-table td { padding: 10px 12px 10px 0; vertical-align: top; }
.legal-table thead th { background: none; }
.legal-table tbody th { text-transform: none; letter-spacing: 0; font-size: inherit; color: var(--text); white-space: nowrap; }
.legal-text .table-scroll { max-width: 100%; }
.legal-text .legal-table { min-width: 560px; }
.legal-footer { max-width: 720px; margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: var(--text-sm); }
.legal-footer p { margin: 0 0 6px; }
/* What's new (/changelog/): on the policies' layout */
.changelog-entry h3 { margin: 22px 0 2px; font-size: var(--text-lg); }
.legal-text .changelog-date { margin-bottom: 8px; color: var(--muted); font-size: var(--text-sm); }
.portal-footer-legal { margin-left: auto; }
.portal-footer-legal a { color: var(--muted); }
@media (max-width: 720px) {
  .legal-header { position: static; }
  .legal-main { padding: 24px 16px 48px; }
  .legal-text h1 { font-size: var(--text-2xl); }
  .portal-footer-legal { margin-left: 0; }
}
@media print { .legal-header { display: none; } .legal-main { padding: 0; } }

/* A contact whose emails bounced */
.email-stopped { color: var(--text); }
.email-stopped p { margin: 0 0 10px; }

/* --- A client's record: header, facts, tabs, the overview's two columns ---------------------------------------- */
.record-header { align-items: flex-start; margin-bottom: 14px; }
.record-title { display: flex; align-items: flex-start; gap: 14px; }
.record-mark {
  display: grid; place-items: center; width: 46px; height: 46px; flex-shrink: 0; margin-top: 2px; border-radius: var(--radius-lg);
  background: var(--primary-soft); color: var(--info-text); font-weight: 700; font-size: var(--text-md); letter-spacing: 0.02em;
}
.record-mark.is-individual { border-radius: 50%; background: var(--purple-bg); color: var(--purple-text); }
.record-mark.is-trust, .record-mark.is-non_profit { background: var(--success-bg); color: var(--success-text); }
.record-mark.is-partnership, .record-mark.is-sole_prop { background: var(--warning-bg); color: var(--warning-text); }
.record-header .page-subtitle { gap: 4px 12px; }
.record-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; margin: 0 0 18px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-xs);
}
.record-facts > div { padding: 10px 16px; border-right: 1px solid var(--border); min-width: 0; }
.record-facts > div:last-child { border-right: 0; }
.record-facts dt { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.record-facts dd { margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-facts .who-chip:hover { text-decoration: none; background: var(--border-strong); }
.record-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.rail-card { padding: 16px 18px; margin-bottom: 16px; }
.rail-card .section-header { margin-bottom: 8px; }
.rail-card h2 { font-size: var(--text-md); }
.rail-list, .rail-people, .attention-list, .timeline { list-style: none; margin: 0; padding: 0; }
.rail-list li { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.rail-list li:first-child, .rail-people li:first-child { border-top: 0; padding-top: 0; }
.rail-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; width: 42px; height: 44px;
  border: 1px solid var(--border); border-radius: var(--radius-md); line-height: 1.1;
}
.rail-date.is-overdue { border-color: var(--danger-border); background: var(--danger-bg); }
.rail-month { font-size: 0.625rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--danger); }
.rail-day { font-size: var(--text-lg); font-weight: 650; font-variant-numeric: tabular-nums; }
.rail-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.rail-text a { color: var(--text); font-weight: 500; }
.rail-text a:hover { color: var(--link); }
.rail-people li { padding: 8px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.rail-people li > a { font-weight: 500; }
.rail-notes { margin: 0; overflow-wrap: anywhere; }
.attention-card { border-left: 3px solid var(--warning); }
.attention-list li + li { border-top: 1px solid var(--border); }
.attention-list a { display: flex; align-items: center; gap: 12px; padding: 9px 0; color: var(--text); }
.attention-list a:hover { text-decoration: none; color: var(--link); }
.attention-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; }
.attention-icon .icon { width: 15px; height: 15px; }
.attention-icon.is-danger { background: var(--danger-bg); color: var(--danger); }
.attention-icon.is-warning { background: var(--warning-bg); color: var(--warning-text); }
.attention-icon.is-info { background: var(--info-bg); color: var(--info-text); }
.household-table td { vertical-align: middle; }
.household-table tr.is-selected td { background: var(--surface-2); }
.card > .table-scroll > .household-table tr.is-selected td:first-child { padding-left: 10px; box-shadow: inset 3px 0 0 var(--primary); }
.timeline li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; padding: 9px 0; border-top: 1px solid var(--border); }
.timeline li:first-child { border-top: 0; padding-top: 0; }
.timeline-when, .timeline-what { display: flex; flex-direction: column; line-height: 1.4; }
.timeline-when time { font-weight: 600; font-variant-numeric: tabular-nums; }
.timeline-what { overflow-wrap: anywhere; }
@media (max-width: 1100px) { .record-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  .record-facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .record-facts > div { border-right: 0; border-bottom: 1px solid var(--border); }
  .record-facts > div:nth-child(odd) { border-right: 1px solid var(--border); }
  .record-facts > div:nth-last-child(-n+2) { border-bottom: 0; }
  .record-mark { width: 40px; height: 40px; }
  .timeline li { grid-template-columns: 76px minmax(0, 1fr); }
}

/* --- Adding a service to a client: the cards to choose from, the form and what it will add ------------------------ */
.service-group { margin-bottom: 28px; }
.service-group > h2 { margin-bottom: 10px; font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.service-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; list-style: none; margin: 0; padding: 0; }
.service-card { display: flex; flex-direction: column; justify-content: space-between; gap: 12px; margin: 0; padding: 16px 18px; }
.service-card h3 { margin: 0 0 4px; font-size: var(--text-md); }
.service-card p { margin: 0; }
.service-card-action { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.service-card:not(.is-unavailable):not(.is-added):hover { border-color: var(--primary); }
.service-card.is-added { background: var(--surface-2); }
.service-card.is-unavailable { background: none; box-shadow: none; border-style: dashed; }
.service-card.is-unavailable h3 { color: var(--muted); }
.engagement-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.engagement-form { max-width: none; }
.engagement-form > .field { max-width: 620px; }
.engagement-side { position: sticky; top: 20px; }
.preview-card h2 { font-size: var(--text-md); }
.preview-summary { margin: 0 0 10px; }
.preview-list { list-style: none; margin: 0; padding: 0; }
.preview-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.preview-list .rail-text { flex: 1; }
.preview-list .tags { flex-shrink: 0; }
#deadline-preview.htmx-request { opacity: 0.55; }
@media (max-width: 1100px) {
  .engagement-layout { grid-template-columns: minmax(0, 1fr); }
  .engagement-side { position: static; }
}

/* --- Search everywhere (Ctrl+K) ---------------------------------------------------------------------------- */
.search-dialog {
  width: min(640px, calc(100vw - 24px)); max-height: min(560px, calc(100vh - 80px)); margin: 10vh auto auto; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.search-dialog[open] { display: flex; flex-direction: column; }
.search-dialog::backdrop { background: var(--backdrop); }
.search-dialog form { display: flex; flex-direction: column; min-height: 0; margin: 0; }
.search-input { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.search-input .icon { width: 18px; height: 18px; color: var(--muted); }
.search-input input {
  flex: 1; min-width: 0; min-height: 0; padding: 4px 0; border: 0; background: none; font-size: var(--text-lg); box-shadow: none;
}
.search-input input:focus { box-shadow: none; }
.search-input input::-webkit-search-cancel-button { display: none; }
.search-esc, .search-hints kbd {
  padding: 1px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  font: 500 0.6875rem/1.5 var(--font); color: var(--muted);
}
.search-results { overflow-y: auto; padding: 6px 8px 8px; min-height: 80px; }
.search-group h3 { margin: 10px 8px 4px; font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.search-group ul { list-style: none; margin: 0; padding: 0; }
.search-hit { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 6px 8px; border-radius: var(--radius-md); color: var(--text); }
.search-hit:hover { text-decoration: none; background: var(--surface-3); }
.search-hit[aria-selected="true"] { background: var(--primary-soft); text-decoration: none; }
.search-hit:focus-visible { outline-offset: -2px; }
.search-hit-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; border-radius: var(--radius-md); background: var(--surface-3); color: var(--muted); }
.search-hit[aria-selected="true"] .search-hit-icon { background: var(--surface); color: var(--info-text); }
.search-hit-icon .icon { width: 15px; height: 15px; }
.search-hit-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.35; }
.search-hit-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hit-detail { font-size: var(--text-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-more { display: block; margin: 2px 8px 6px 48px; font-size: var(--text-sm); }
.search-empty { margin: 0; padding: 24px 16px; text-align: center; }
.search-hints { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 8px 16px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: var(--text-xs); color: var(--muted); }
.search-hints kbd { margin-right: 3px; }
.search-page-results { padding: 8px 12px 12px; }
.search-page-results .search-results, .search-page-results { max-width: 760px; }
.no-js .search-button kbd { display: none; }
@media (max-width: 720px) {
  .search-dialog { margin-top: 12px; max-height: calc(100vh - 24px); }
  .search-hints { display: none; }
  .search-hit { min-height: var(--touch-target); }
}

/* --- Lists: the toolbar's pieces, saved views, rows per page --------------------------------------------------- */
.list-region { position: relative; }
.list-region.htmx-request > .card, .list-region.htmx-request > .board { opacity: 0.55; transition: opacity 150ms; }
.toolbar .segmented { flex-shrink: 0; }
.toolbar .check { white-space: nowrap; }
.toolbar-note { color: var(--muted); font-size: var(--text-sm); }
.saved-views .chip { gap: 6px; }
.saved-views .chip .icon { width: 13px; height: 13px; color: var(--muted); }
.saved-views form.chip { margin: 0; padding-right: 4px; }
.saved-views .chip.is-current .icon { color: var(--primary); }
.chip-remove {
  display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: inherit; cursor: pointer;
}
.chip-remove:hover { background: var(--surface-3); }
.chip-remove .icon { width: 12px; height: 12px; }
.save-view-menu .menu-panel { width: min(300px, calc(100vw - 32px)); }
.save-view-menu p { margin: 0; }
.save-view-menu > summary .icon { width: 13px; height: 13px; margin-right: 4px; }
.page-size-choice { min-width: 28px; padding: 2px 6px; border-radius: var(--radius-sm); text-align: center; font-size: var(--text-sm); color: var(--muted); }
.page-size-choice:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.page-size-choice.is-current { background: var(--surface-3); color: var(--text); font-weight: 600; }
.row-actions .btn-small { padding-left: 8px; padding-right: 8px; }
.row-actions .btn.icon-only { padding-left: 6px; padding-right: 6px; }
.data-table td.primary-cell a { font-weight: 500; }
.data-table .group-row th { position: static; background: var(--surface-2); text-transform: none; letter-spacing: 0; font-size: var(--text-sm); color: var(--text); }
.bulk-bar .field-inline { display: inline-flex; align-items: center; gap: 6px; }
.bulk-bar select { background-color: var(--surface); color: var(--text); }
@media (max-width: 720px) {
  .toolbar .search-field, .toolbar input[type="search"] { flex-basis: 100%; max-width: none; }
  .pagination .page-size { margin-left: 0; }
}
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-small { width: 24px; height: 24px; font-size: 0.625rem; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.avatar-stack .muted { margin-left: 6px; }
.data-table tr:hover .avatar-small { box-shadow: 0 0 0 2px var(--surface-2); }

/* --- Deadlines: tighter cards, the board by client -------------------------------------------------------------- */
.tracker-toolbar { gap: 8px 12px; }
.tracker-toolbar .segmented a { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; }
.tracker-toolbar .segmented .icon { width: 14px; height: 14px; }
.tracker-nav .icon { width: 14px; height: 14px; }
.board { gap: 10px; }
.column-header { position: sticky; top: 0; z-index: 1; padding: 8px 10px; border-radius: var(--radius) var(--radius) 0 0; background: var(--surface); }
.column-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.column-title a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.column-items { padding: 6px; gap: 6px; }
.deadline-card { padding: 7px 9px 8px; font-size: var(--text-sm); line-height: 1.4; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-date { font-size: var(--text-xs); }
.card-done { flex-shrink: 0; line-height: 1; }
.deadline-card .card-entity { margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deadline-card .card-title { display: block; margin: 1px 0 5px; }
.deadline-card .card-badges { margin-bottom: 0; align-items: center; }
.deadline-card .card-badges .who { margin-left: auto; }
.deadline-card .task-progress { margin: 6px 0 0; }
.deadline-card .card-for { margin: -3px 0 5px; }
.deadline-card.client-handled { background: none; border-style: dashed; border-left-style: solid; }
.client-handled .card-title, .client-handled .card-entity { color: var(--muted); }
.board.by-client { grid-auto-columns: minmax(230px, 280px); }
.board-column.overdue .column-sub { color: var(--danger); font-weight: 600; }
.tracker-table .row-actions .btn .icon { margin-right: 4px; }
.btn-secondary { background: var(--surface); }
.card-moved { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* My work: what's always in sight (open or completed, how far ahead) beside the Filters button */
.work-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.work-filters .search-field { flex: 1 1 220px; max-width: 320px; }
/* A round tick marks something done; a square box selects a row */
.tick { border-radius: 50%; }
.data-table .tick-cell { width: 30px; padding-right: 0; }
.sr-only-head th { padding-top: 6px; padding-bottom: 6px; }

/* --- Fingers: on a phone or a tablet, everything to tap is 44 px or more ------------------------------------------ */
@media (max-width: 899px), (pointer: coarse) {
  :root { --control-height: 44px; }
  .btn-small, .chip, .filter-chip, .segmented a, .segmented label, .tabs a, .link-action,
  .page-size-choice, .check, .search-more, .breadcrumb a { min-height: var(--touch-target); }
  .btn.icon-only, .more-menu > summary.btn, .page-size-choice { min-width: var(--touch-target); }
  .segmented a, .segmented label, .link-action, .chip, .page-size-choice, .breadcrumb a, .search-more {
    display: inline-flex; align-items: center; justify-content: center;
  }
  .filter-chip a, .chip-remove { width: 36px; height: 44px; }
  .select-cell input, .check input { width: 20px; height: 20px; }
  /* A small mark takes the taps around it */
  .tick, .timer-toggle { position: relative; }
  .tick::after { content: ""; position: absolute; inset: -13px; }
  .timer-toggle::after { content: ""; position: absolute; inset: -9px; }
  .page-header .actions { flex-shrink: 1; min-width: 0; max-width: 100%; }
  .toolbar .segmented { max-width: 100%; overflow-x: auto; }
}

/* Counts read on their grey, in a chosen segment too */
.count { color: var(--text-2); }
.segmented .active .count, .segmented label:has(input:checked) .count { background: rgba(0, 0, 0, 0.28); color: #fff; }
.search-button kbd { color: var(--sidebar-text); }

/* A box that scrolls sideways holds what's positioned inside it: a label for screen readers in a wide table
   would widen the page otherwise. */
.table-wrap, .table-scroll, .doc-list-box, .board, .tabs, .segmented { position: relative; }

@media (max-width: 899px), (pointer: coarse) {
  .field:has(> input[type="checkbox"]) > label, .field fieldset label, .toggle-text { min-height: var(--touch-target); }
  .field:has(> input[type="checkbox"]) > label, .field fieldset label { display: inline-flex; align-items: center; }
  .toggle-text { justify-content: center; }
  .filter-chip a, .chip-remove { width: var(--touch-target); }
  .segmented a, .segmented label, .btn-small { min-width: var(--touch-target); }
  details:not(.menu) > summary { padding-block: 11px; }
  input[type="file"] { min-height: var(--touch-target); }
}
@media (max-width: 720px) {
  .check { white-space: normal; }
  .inv-lines { font-size: var(--text-sm); }
  .inv-lines th, .inv-lines td { padding-left: 6px; padding-right: 6px; }
  .invoice-doc { overflow-x: auto; }
}

/* --- The client portal's overview: a box to send documents, then four blocks -------------------------------------- */
.portal-send { padding: 14px; }
.dropzone-big { min-height: 148px; gap: 6px; border-radius: var(--radius-lg); }
.dropzone-big .icon { width: 34px; height: 34px; }
.dropzone-big .dropzone-text { font-size: var(--text-lg); }
.dropzone-big .dropzone-text strong { font-weight: 650; }
.portal-send-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 12px; }
.camera-button { position: relative; overflow: hidden; }
.camera-button input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.camera-button.has-files { border-color: var(--primary); color: var(--link); }
/* A camera is a phone's or a tablet's: a computer chooses files or drops them */
@media (hover: hover) and (pointer: fine) { .camera-button { display: none; } }
@media (hover: none), (pointer: coarse) { .drop-hint { display: none; } }
/* "Send" shows once something is chosen (always without JavaScript) */
.js .portal-send:not(:has(.has-files)) .send-button { display: none; }
.portal-blocks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.portal-block { margin: 0; min-width: 0; }
.portal-block h2 { display: flex; align-items: center; gap: 8px; }
.portal-block h2 .icon { width: 18px; height: 18px; color: var(--muted); }
.portal-block.is-waiting { border-color: var(--warning-border); }
.portal-block.is-waiting h2 .icon { color: var(--warning-border); }
.portal-block.is-late h2 .icon { color: var(--danger); }
.portal-block .empty.is-quiet { justify-content: flex-start; padding: 10px 0 4px; text-align: left; }
.portal-block .count.is-new { background: var(--info-bg); color: var(--info-text); }
.todo-overview + .portal-approvals { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.portal-approvals h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: var(--text-base); }
.portal-approvals h3 .icon { width: 16px; height: 16px; color: var(--warning-border); }
.portal-owing { margin: 0 0 8px; }
.portal-owing-value { font-size: var(--text-2xl); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.portal-invoice-list { list-style: none; margin: 0; padding: 0; }
.portal-invoice-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.portal-invoice-list li .num { margin-left: auto; }
@media (max-width: 860px) { .portal-blocks { grid-template-columns: minmax(0, 1fr); gap: 16px; } }
@media (max-width: 720px) {
  .dropzone-big { min-height: 120px; }
  .portal-send-actions .btn { flex: 1 1 140px; min-height: 48px; }
}

/* The portal settings: the accent colour, typed or picked */
.colour-row { display: flex; align-items: center; gap: 10px; }
.colour-row input[type="text"] { width: 9rem; font-family: var(--font-mono); }
.colour-picker { width: 44px; height: var(--control-height); padding: 2px; cursor: pointer; }
.no-js .colour-picker { display: none; }

/* --- On paper: the deadline list, a client's summary ------------------------------------------------------------- */
.print-note { margin: 0 0 10pt; font-size: 9pt; color: #444; }
@media print {
  @page { margin: 14mm 12mm; }
  .list-region > form, .more-menu, .card-done, .tick, .timer-toggle, .search-dialog, .deletion-banner,
  .load-more, .empty .actions, .section-header .btn, .card-actions, .link-action, .attention-stats { display: none !important; }
  .page-header { margin-bottom: 8pt; }
  .page-header h1 { font-size: 16pt; }
  .page-subtitle, .muted { color: #444 !important; }
  .badge, .count { border: 0.5pt solid #888; background: none !important; color: #000 !important; }
  .overdue-text { color: #000 !important; font-weight: 700; text-decoration: underline; }
  table { font-size: 9.5pt; }
  th, td { padding: 4pt 6pt; border-bottom: 0.5pt solid #bbb; }
  thead th, .data-table thead th { background: none !important; box-shadow: none; border-bottom: 1pt solid #000; color: #000; }
  thead { display: table-header-group; }  /* the column names on every page */
  tr { break-inside: avoid; }
  .table-wrap, .table-scroll, .data-table-box { overflow: visible !important; }
  .hide-sm { display: table-cell !important; }
  .group-row th { background: none !important; border-bottom: 1pt solid #000; padding-top: 10pt; font-size: 10.5pt; }
  .client-handled, tr.future { opacity: 1; }

  /* The board becomes a list: a heading a column, a line a deadline */
  .board { display: block; overflow: visible; }
  .board-column { border: 0; margin: 0 0 10pt; background: none; break-inside: auto; }
  .column-header { position: static; padding: 0 0 2pt; border-bottom: 1pt solid #000; background: none; }
  .column-items { display: block; padding: 0; }
  .column-empty { display: none; }
  .deadline-card { display: grid; grid-template-columns: 34mm 52mm 1fr; gap: 0 8pt; align-items: baseline; padding: 3pt 0;
    border: 0; border-bottom: 0.5pt solid #bbb; border-radius: 0; background: none; font-size: 9.5pt; break-inside: avoid; }
  .deadline-card .card-top { display: block; }
  .deadline-card .card-entity, .deadline-card .card-title { margin: 0; white-space: normal; }
  .deadline-card .card-badges, .deadline-card .task-progress, .deadline-card .card-moved, .deadline-card .card-for { grid-column: 3; margin: 0; }
  .next-task { display: none; }

  /* A client's summary: its facts, then each section under the other */
  .record-facts { border: 0.5pt solid #bbb; }
  .record-grid { display: block !important; }
  .record-mark { border: 0.5pt solid #888; background: none !important; color: #000 !important; }
  .rail-card, .record-body .card { margin-bottom: 10pt; padding: 0; }
  .rail-date { border: 0.5pt solid #888; background: none !important; }
  h2 { font-size: 11.5pt; margin: 8pt 0 4pt; }
  .who-chip, .avatar { border: 0.5pt solid #888; background: none !important; color: #000 !important; }
}

/* Bars of a chart: their height as a class (billing_tags.bar_height), since the security policy allows no style
   attributes. */
.h-0 { height: 0%; } .h-1 { height: 1%; } .h-2 { height: 2%; } .h-3 { height: 3%; } .h-4 { height: 4%; } .h-5 { height: 5%; } .h-6 { height: 6%; } .h-7 { height: 7%; } .h-8 { height: 8%; } .h-9 { height: 9%; }
.h-10 { height: 10%; } .h-11 { height: 11%; } .h-12 { height: 12%; } .h-13 { height: 13%; } .h-14 { height: 14%; } .h-15 { height: 15%; } .h-16 { height: 16%; } .h-17 { height: 17%; } .h-18 { height: 18%; } .h-19 { height: 19%; }
.h-20 { height: 20%; } .h-21 { height: 21%; } .h-22 { height: 22%; } .h-23 { height: 23%; } .h-24 { height: 24%; } .h-25 { height: 25%; } .h-26 { height: 26%; } .h-27 { height: 27%; } .h-28 { height: 28%; } .h-29 { height: 29%; }
.h-30 { height: 30%; } .h-31 { height: 31%; } .h-32 { height: 32%; } .h-33 { height: 33%; } .h-34 { height: 34%; } .h-35 { height: 35%; } .h-36 { height: 36%; } .h-37 { height: 37%; } .h-38 { height: 38%; } .h-39 { height: 39%; }
.h-40 { height: 40%; } .h-41 { height: 41%; } .h-42 { height: 42%; } .h-43 { height: 43%; } .h-44 { height: 44%; } .h-45 { height: 45%; } .h-46 { height: 46%; } .h-47 { height: 47%; } .h-48 { height: 48%; } .h-49 { height: 49%; }
.h-50 { height: 50%; } .h-51 { height: 51%; } .h-52 { height: 52%; } .h-53 { height: 53%; } .h-54 { height: 54%; } .h-55 { height: 55%; } .h-56 { height: 56%; } .h-57 { height: 57%; } .h-58 { height: 58%; } .h-59 { height: 59%; }
.h-60 { height: 60%; } .h-61 { height: 61%; } .h-62 { height: 62%; } .h-63 { height: 63%; } .h-64 { height: 64%; } .h-65 { height: 65%; } .h-66 { height: 66%; } .h-67 { height: 67%; } .h-68 { height: 68%; } .h-69 { height: 69%; }
.h-70 { height: 70%; } .h-71 { height: 71%; } .h-72 { height: 72%; } .h-73 { height: 73%; } .h-74 { height: 74%; } .h-75 { height: 75%; } .h-76 { height: 76%; } .h-77 { height: 77%; } .h-78 { height: 78%; } .h-79 { height: 79%; }
.h-80 { height: 80%; } .h-81 { height: 81%; } .h-82 { height: 82%; } .h-83 { height: 83%; } .h-84 { height: 84%; } .h-85 { height: 85%; } .h-86 { height: 86%; } .h-87 { height: 87%; } .h-88 { height: 88%; } .h-89 { height: 89%; }
.h-90 { height: 90%; } .h-91 { height: 91%; } .h-92 { height: 92%; } .h-93 { height: 93%; } .h-94 { height: 94%; } .h-95 { height: 95%; } .h-96 { height: 96%; } .h-97 { height: 97%; } .h-98 { height: 98%; } .h-99 { height: 99%; }
.h-100 { height: 100%; }

.code-resend { margin-top: 14px; }
@media (max-width: 899px), (pointer: coarse) {
  details:not(.menu) > summary { min-height: var(--touch-target); box-sizing: border-box; padding-block: 11px; }
}

/* The onboarding funnel (/ops/, superusers only) */
.ops-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.ops-stats > .card { margin-bottom: 0; }
.ops-stats .stat-value { font-size: 1.6rem; }
.table-card-intro { margin: 0; padding: 0 20px 8px; }
.ops-table tr.is-quiet th, .ops-table tr.is-quiet td { color: var(--muted); }
.ops-done { display: inline-flex; align-items: center; gap: 4px; color: var(--success-text); font-weight: 600; }
.ops-done .icon { width: 14px; height: 14px; }
.ops-table thead th { white-space: normal; vertical-align: bottom; min-width: 5.5rem; }
.ops-firms tbody th { white-space: normal; min-width: 12rem; overflow-wrap: break-word; }
.ops-how { margin-bottom: 16px; }
.ops-how ol { margin: 0 0 8px; padding-left: 20px; }
.ops-how p { margin: 0; }
.ops-files .ops-file { min-width: 18rem; }
.ops-files .ops-file strong { overflow-wrap: anywhere; }
.ops-note { margin: 4px 0 0; white-space: normal; overflow-wrap: anywhere; }
.ops-files .copy-field { margin-top: 6px; }
.ops-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
/* Service health (/ops/health/) */
.ops-flags ul, .ops-elsewhere { margin: 0; padding-left: 0; list-style: none; }
.ops-flags li, .ops-elsewhere li { margin: 0 0 8px; }
.ops-all-well { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; color: var(--success-text); font-weight: 600; }
.ops-health-table tbody th { width: 30%; min-width: 9rem; white-space: normal; text-transform: none; letter-spacing: 0; font-size: inherit; color: var(--text); }
.ops-health-table td { white-space: normal; overflow-wrap: anywhere; }
.ops-health-table td.right { width: 1%; white-space: nowrap; }
/* The notice (/ops/notice/) */
.ops-notice { margin: 0 0 16px; }
.ops-notice .service-notice { margin-bottom: 6px; }
.ops-notice-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.ops-notice-meta p { margin: 0; }
.ops-past-notices { margin: 0; padding-left: 20px; }
.ops-past-notices li { margin: 0 0 6px; }
/* The what's new email (/ops/news/) */
.ops-month { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.ops-month select { width: auto; }
.ops-failed { margin: 0 0 12px; padding-left: 20px; overflow-wrap: anywhere; }
.ops-news-entry { max-width: 640px; }
.ops-news-entry h3 { margin: 16px 0 4px; font-size: var(--text-md); }
.ops-news-entry p { margin: 0 0 8px; }
.sent-files .primary-cell { overflow-wrap: anywhere; }

/* A page's first-visit tip (hello/tips.py), until it's closed */
.tip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--info-border); border-radius: var(--radius); background: var(--info-bg); color: var(--text); }
.tip > .icon { flex: none; color: var(--info-text); }
.tip-text { flex: 1 1 320px; margin: 0; font-size: var(--text-sm); }
.tip form { margin: 0; }

/* Who can do what, beside a new team member's form */
.member-roles h3 { margin: 14px 0 4px; font-size: var(--text-base); }
.member-roles dl { margin: 0; }
.member-roles dt { margin-top: 8px; font-weight: 600; font-size: var(--text-sm); }
.member-roles dd { margin: 2px 0 0; color: var(--muted); font-size: var(--text-sm); }
.member-roles p { margin: 0 0 8px; }
.member-roles p:last-child { margin: 14px 0 0; }

/* My work, for someone new */
.whats-next { margin: 8px auto 0; padding-left: 18px; max-width: 460px; text-align: left; }
.whats-next li { margin: 4px 0; }

/* The portal's welcome, on a client's first visit */
.portal-tour { border-color: var(--primary); }
.portal-tour-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.portal-tour-head h2 { margin: 0; font-size: var(--text-md); }
.portal-tour-head form { margin: 0; flex: none; }
.portal-tour-steps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.portal-tour-steps li { display: flex; gap: 10px; align-items: flex-start; }
.portal-tour-steps .icon { flex: none; margin-top: 2px; color: var(--primary); }

/* The portal's header on a phone: a finger's width to tap the client switcher and the account menu */
@media (max-width: 899px), (pointer: coarse) {
  .client-button { min-height: var(--touch-target); box-sizing: border-box; }
  .account-button { display: grid; place-items: center; min-width: var(--touch-target); min-height: var(--touch-target); }
}

/* /ops/pilots/: its many columns' headings may wrap (ops/templates/ops/pilot.html). */
.pilot-weeks th { white-space: normal; }
