/* === Task Board === */

/* Brand-derived custom properties (--accent, --accent-hover, --accent-alpha,
   --border-focus, --accent-secondary, --font-display) are injected by the
   server into <style id="brand-vars"> from this instance's branding row — see
   backend/shell.py. The values below are fallbacks so the stylesheet still
   renders standalone. */

:root {
    /* Tells the UA to render native controls dark: the date pickers in the
       Reports filter bar were white boxes in a dark UI because nothing had
       ever declared this. Paired with the light override below, so both
       themes get native controls that match. */
    color-scheme: dark;

    --on-accent: #ffffff;
    --border-hover: #363a48;
    --accent-secondary: #8b5cf6;
    --accent-alpha: rgba(91, 138, 240, 0.15);
    --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #222632;
    --bg-input: #141720;
    --border: #2a2e3a;
    --border-focus: #5b8af0;
    --text: #e4e6eb;
    /* Three tiers, all at or above AA on --bg-card. --text-dim was #5c6070 =
       2.69:1 and carried real text (hints, empty states, "No active tasks");
       lifting it to 4.52 pushed it into --text-muted's old 5.25, so muted moved
       up too and the ladder is 13.5 / 6.5 / 4.5. */
    --text-muted: #9da1b1;
    --text-dim: #7f8496;
    --accent: #5b8af0;
    --accent-hover: #4a77dd;
    /* The accent as a fill behind --on-accent text. The accent itself is
       5.07:1 as text on the cards but only 3.31:1 behind white, and no one
       value passes both, so fills darken it until white reaches 4.5
       (branding.accent_fill; injected per instance by shell.py). */
    --accent-fill: #366fed;
    --accent-fill-hover: #2f61d0;

    --priority-low: #4aa86a;
    --priority-medium: #d4a843;
    --priority-high: #e07840;
    --priority-urgent: #e25454;   /* was #e04545 = 4.09:1, just under AA */

    --status-not-started: #5c6070;
    --status-in-progress: #5b8af0;
    --status-on-hold: #d4a843;
    --status-pending-customer: #3bb3b0;
    --status-completed: #4aa86a;
    --status-cancelled: #8b8fa3;
    /* Badge text. A badge paints its colour on a translucent tint of that
       colour over the card, which moves the background toward the text; the
       status and priority tokens were measured against the card alone. Eleven
       badge and theme pairs measured under 4.5:1 that way (2026-09-24,
       tests/test_badge_contrast.py). These are only for badge text: the
       shared tokens also fill buttons with white text on them, which a
       lighter urgent would have broken. Each is the same hue moved the least
       that reaches AA. */
    --badge-in-progress: #6a95f1;
    --badge-on-hold: var(--status-on-hold);
    --badge-completed: var(--status-completed);
    --badge-cancelled: #9296a9;
    --badge-low: var(--priority-low);
    --badge-medium: var(--priority-medium);
    --badge-high: #e38653;
    --badge-urgent: #e87676;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --transition: 150ms ease;
    --error-text: #f0a0a0;
    --success-text: #8fd4a0;

    /* === Semantic aliases ===
       One name per meaning, pointing at values already in use. Before these,
       "destructive" was spelled four ways across the stylesheet (an undefined
       --danger, a literal #e74c3c, --priority-urgent and --error-text) and
       nothing could be restyled at the root. Use these for meaning; use a
       priority or status token only when you mean that literal priority or
       status. (Do not write an asterisk-slash glob in a CSS comment: it closes
       the comment and invalidates the next declaration. That is how --success
       shipped dead for the ten minutes before this line was measured.) */
    --success: var(--priority-low);
    --warning: var(--priority-medium);
    --danger: var(--priority-urgent);
    --info: var(--accent);
    --private: var(--accent-secondary);

    /* === Colour channels, for tints ===
       CSS cannot add an alpha to a hex custom property without color-mix(),
       which is not safe to assume on shop-floor tablets, so tints are built as
       rgba(var(--x-rgb), a). --accent-rgb and --accent-secondary-rgb are
       overridden by the injected brand block; the values here are fallbacks.
       Alpha convention: .15 tint, .2 strong tint, .4 border. */
    --accent-rgb: 91,138,240;
    --accent-secondary-rgb: 139,92,246;
    --private-rgb: var(--accent-secondary-rgb);
    --success-rgb: 74,168,106;
    --warning-rgb: 212,168,67;
    --danger-rgb: 226,84,84;
    --high-rgb: 224,120,64;
    --border-rgb: 42,46,58;
    --not-started-rgb: 92,96,112;
    --pending-customer-rgb: 59,179,176;
    --cancelled-rgb: 139,143,163;

    /* === Pill scale ===
       Three steps, which is what the badge/pill family already used: five
       classes agreed exactly on 10px/1px 7px and five more on 11px/2px 8px.
       The values were just never named, so "how a tag looks" had to be changed
       in three places and nothing kept the family a family. */
    --pill-xs-size: 10px;
    --pill-xs-pad: 1px 7px;
    --pill-sm-size: 11px;
    --pill-sm-pad: 2px 8px;
    --pill-md-size: 12px;
    --pill-md-pad: 3px 10px;

    /* Every pill in the family wants a capsule. The six radii in use (4, 9,
       10, 12, 20 and 999px) were six attempts to say that at six different
       heights: .tag-pill's 12px at 24px tall and the count badges' 9px at 18px
       tall are each exactly half the height. 999px says it once and stays
       right whatever the pill grows to. --radius-chip is the one deliberate
       exception, the squarer recurrence marker. */
    --radius-pill: 999px;
    --radius-chip: 4px;

    /* === Type scale ===
       The de facto set, previously 136 literal px values. */
    --text-xs: 11px;
    --text-sm: 12px;
    --text-base: 13px;
    --text-md: 14px;
    --text-lg: 18px;

    /* === Z-index ladder ===
       Replaces 8 ad-hoc values in which .summary-popup and .status-popup tied
       .modal-overlay at 200 and won on DOM order alone. Toast sits top: a
       message nobody can see is worse than one that overlaps a dialog.
       Values 1-5 inside components (gantt internals, modal footer) are local
       stacking and deliberately stay literal. */
    --z-sticky: 100;
    --z-bar: 150;
    --z-modal: 200;
    --z-popup: 250;
    --z-progress: 275;
    --z-lightbox: 300;
    --z-dialog: 400;
    --z-toast: 500;
    --z-login: 1000;
}

[data-theme="light"] {
    color-scheme: light;

    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f1f5;
    --bg-input: #f8f9fb;
    --border: #d8dbe3;
    --border-focus: #4a77dd;
    /* Was a hardcoded #363a48 everywhere, so hover jumped to dark slate on a
       light surface. */
    --border-hover: #c3c8d4;
    --text: #1a1d27;
    --text-muted: #5c6070;
    --text-dim: #71758e;   /* was #8b8fa3 = 3.20:1 on white */
    --accent: #4a77dd;
    --accent-hover: #3a65c8;
    --accent-fill: #4271dc;
    --accent-fill-hover: #3a63c1;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --error-text: #c0392b;
    --success-text: #27864a;
    --bg-card-secondary: #f5f6fa;

    /* The light theme overrode surfaces and text but never these, so every
       priority and status colour kept its dark-theme value on a white card:
       amber measured 2.21:1 and green 2.96:1. Each value below is the same hue
       taken down to >= 4.5:1 on #ffffff. The dark theme keeps the brighter
       originals, which already pass on #1a1d27. */
    --priority-low: #3a8554;
    --priority-medium: #947122;
    --priority-high: #c0581f;
    --priority-urgent: #cc3333;

    --status-not-started: #5c6070;
    --status-in-progress: #366fed;
    --status-on-hold: #947122;
    /* Teal, clear of On Hold's amber and the purple that means private.
       5.07:1 on its own badge tint over white, 4.71:1 over the stat cards. */
    --status-pending-customer: #0c6b68;
    --status-completed: #3a8554;
    --status-cancelled: #70758e;
    --badge-in-progress: #3063d3;
    --badge-on-hold: #82631e;
    --badge-completed: #33754a;
    --badge-cancelled: #63677d;
    --badge-low: #33754a;
    --badge-medium: #82631e;
    --badge-high: #a14a1a;
    --badge-urgent: #b42d2d;

    --success-rgb: 58,133,84;
    --warning-rgb: 148,113,34;
    --danger-rgb: 204,51,51;
    --high-rgb: 192,88,31;
    --border-rgb: 216,219,227;
    --not-started-rgb: 92,96,112;
    --pending-customer-rgb: 12,107,104;
    --cancelled-rgb: 112,117,142;
}

/* Light theme: de-emphasize stats and activity so task list is focal point */
[data-theme="light"] .stat-card {
    background: var(--bg-card-secondary);
    border-color: #e4e6ed;
}
[data-theme="light"] .stat-card .stat-value { font-size: 24px; }
[data-theme="light"] .stat-card .stat-label { font-size: 11px; }

[data-theme="light"] .activity-feed-panel {
    background: var(--bg-card-secondary);
    border-color: #e4e6ed;
}

[data-theme="light"] .task-row,
[data-theme="light"] .task-card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { overflow-x: hidden; }
button, a, input, select, label, .task-row, .nav-tab, .status-badge { touch-action: manipulation; }
.task-card { touch-action: pan-y; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =================== LOGIN =================== */
.login-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-login);
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    margin: 16px;
}
.login-header {
    text-align: center;
    margin-bottom: 24px;
}
.login-header h1 { font-family: var(--font-display); font-size: 22px; margin: 12px 0 4px; }
.login-header h2 { font-family: var(--font-display); font-size: 20px; margin: 0 0 4px; }
.login-header p { color: var(--text-muted); font-size: 14px; margin: 0; }
.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 12px;
}
.login-error {
    background: var(--priority-urgent);
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    margin-top: 12px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    animation: shake 0.3s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}
.login-message {
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 12px;
    font-size: 14px;
    text-align: center;
    background: var(--accent-fill);
    color: var(--on-accent);
}
.login-forgot {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
}
/* The public demo's "Try as" panel (auth.js renderDemoPanel). */
.demo-panel {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.demo-panel h2 {
    font-family: var(--font-display);
    font-size: 16px;
    margin: 0 0 10px;
    text-align: center;
}
.demo-personas {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
button.demo-persona {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    min-height: 44px;
    padding: 8px 14px;
    background: rgba(var(--accent-rgb), .1);
    border: 1px solid rgba(var(--accent-rgb), .4);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
}
button.demo-persona:hover { border-color: var(--accent); }
.demo-persona-name { font-weight: 700; }
.demo-persona-role { color: var(--text-muted); font-size: 12px; }
.demo-note {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
.user-display-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
}

/* --- Error banner ---
   Fixed + high z-index so it's visible above an open modal (z-index: 200) —
   toasts appended to .main-content render underneath the modal backdrop otherwise. */
/* One shape, two skins. These were two blocks of ~15 identical declarations
   differing only in hue, so any change to the toast's position, width, radius
   or shadow had to be made twice, and twice drifted. Class names unchanged;
   showError/showSuccess still pass them straight through. */
.error-banner,
.success-banner {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 600px;
    z-index: var(--z-toast);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: var(--text-md);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    animation: slideDownCentered 200ms ease;
}

.error-banner button,
.success-banner button {
    background: none;
    border: none;
    color: inherit;
    font-size: var(--text-lg);
    cursor: pointer;
    padding: 0 4px;
    margin-left: 12px;
}

.error-banner {
    background: rgba(var(--danger-rgb),0.15);
    border: 1px solid rgba(var(--danger-rgb),0.4);
    color: var(--error-text);
}

.success-banner {
    background: rgba(var(--success-rgb), 0.15);
    border: 1px solid rgba(var(--success-rgb), 0.4);
    color: var(--success-text);
}




@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Same slide as slideDown, but preserves the horizontal centering transform
   on .error-banner/.success-banner (position: fixed; left: 50%) throughout —
   using slideDown directly would drop translateX(-50%) during the animation. */
@keyframes slideDownCentered {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Layout --- */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.app-logo {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo .logo-img {
    height: 36px;
    width: auto;
    border-radius: 6px;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    height: 100%;
    align-items: stretch;
}

.nav-tab {
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
    white-space: nowrap;
}

.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* --- Stats Cards --- */
/* Fixed column counts that divide the eight cards evenly: 8 across on a
   desktop, 4 by 2 on a tablet, 2 by 4 on a phone (the 768px block). auto-fit
   put 7 on a 1280px row and left the eighth alone underneath. */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
@media (min-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(8, 1fr); }
    .stats-grid .stat-card { padding: 14px 16px; }
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background var(--transition), border-color var(--transition);
}

/* The dashboard's cards are <button>s (each applies a filter); the Reports
   page renders the same class as plain divs, so the reset is scoped to the
   clickable variant rather than to `.stat-card`. It names only properties
   `.stat-card` itself is silent about, so it cannot decide them from here. */
.stat-card.clickable {
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
}

.stat-card.clickable:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-card.overdue .stat-value { color: var(--priority-urgent); }
.stat-card.due-today .stat-value { color: var(--priority-high); }
.stat-card.in-progress .stat-value { color: var(--status-in-progress); }
.stat-card.completed .stat-value { color: var(--status-completed); }
.stat-card.pending-customer .stat-value { color: var(--status-pending-customer); }

/* --- Toolbar --- */
.toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.toolbar-always-visible {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Desktop: filter/sort/views bar is shown inline by default (the toggle
   button below is hidden). Mobile overrides this back to collapsed — see
   the max-width:768px block. */
.toolbar-collapsible {
    display: flex;
}
/* No `.toolbar-collapsible.open` rule at desktop scope: it was identical to
   the base rule once the toggle stopped painting here (see below). The
   mobile block still has one, and that one does work. */

.task-create-collapsible {
    display: none;
}
.task-create-collapsible.open {
    display: block;
}

/* Desktop renders #toolbar-collapsible already expanded, so this button has
   nothing to toggle there and must not paint.

   It is scoped to .toolbar-always-visible purely to out-specify `.btn`, which
   sets `display: inline-flex` at the same (0,1,0) specificity and is written
   *later* in this file. A bare `.filter-toggle-btn { display: none }` lost that
   tie and the button showed on desktop, where clicking it did nothing at all:
   toggleFilterBar() flips `.open`, whose desktop rule sets the same
   `display: flex` the base rule already had. Source order in this stylesheet is
   load-bearing in enough places already; this one should not join them. */
.toolbar-always-visible .filter-toggle-btn { display: none; }
/* The Archived button's box icon is for the phone layout, where the toggles
   show only their icons; on a wider screen its word is enough. */
.tb-icon-phone { display: none; }

.filter-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-pill);
    background: var(--accent-fill);
    color: var(--on-accent);
    font-size: var(--pill-xs-size);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.toolbar-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.view-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
#view-save-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}
#view-save-name {
    min-width: 140px;
}

.toolbar select,
.toolbar input[type="text"] {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 8px 12px;
    font-size: 13px;
    transition: border-color var(--transition);
    min-width: 0;
}

.toolbar select:focus,
.toolbar input:focus {
    border-color: var(--border-focus);
}

.search-input {
    width: 180px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all var(--transition);
    white-space: nowrap;
    /* An unknown or misspelled variant must still read as a button. Without
       these, .btn-secondary (which had no rule at all until 2026-08-29)
       rendered with no surface and whatever colour it inherited. */
    background: transparent;
    color: var(--text);
}

.btn-primary {
    background: var(--accent-fill);
    color: var(--on-accent);
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-fill-hover); }

/* .btn-accent was a byte-identical copy of .btn-primary, added because the
   login button shipped with a class that had no rule. Its six call sites now
   say .btn-primary and the duplicate is gone. */

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text); }

/* Secondary: a real filled-neutral action, one step down from primary and one
   step up from the tertiary ghost. Its five call sites (the two settings digest
   buttons, both file-visibility Cancels, "Everyone Can See") shipped against
   this name while it had no rule at all. */
.btn-secondary {
    background: var(--bg-card-hover);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-input); border-color: var(--border-hover); }

.btn-danger {
    background: transparent;
    color: var(--priority-urgent);
    border-color: var(--priority-urgent);
}
.btn-danger:hover { background: var(--priority-urgent); color: white; }

.btn-subtask-add {
    color: var(--priority-high);
}
.btn-subtask-add:hover { background: rgba(var(--high-rgb), 0.15); color: var(--priority-high); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.spacer { flex: 1; }

/* --- Task-row controls that are buttons ---
   Every control in a task row is a real <button>, so the row is operable from
   the keyboard: the title (which opens the task, the app's central action),
   the status badge, the tag pills and the three subtask pills. They were
   `<span onclick>` inside a `<div onclick>`, which Tab can never reach. That
   was Top 10 #1 of the 2026-08-29 design review and the largest accessibility
   gap in the product. WCAG 2.1.1.

   Each one has to look exactly like the span it replaced, so the UA's button
   chrome comes off here. The split below is not tidiness. Qualifying a
   selector with its element raises specificity to (0,1,1), so `button.x` here
   out-specifies `.x` no matter how far below it that rule sits, and source
   order cannot save it: a first cut of this flattened the "+ Sub" pill's
   outline and drained the tint out of every tag pill, both of which looked
   perfect in the source. So each rule names only the controls whose own class
   rule is silent on that property. Adding a property here means checking the
   same thing; tests/test_keyboard_targets.py enforces it.

   `.task-title` is also a plain div in the staff panel and `.status-badge` is
   a button in the detail summary strip, where `.summary-edit` supplies its own
   border; scoping by element and by the `-interactive` class keeps both out of
   this. */
button.task-title,
button.status-badge-interactive,
button.tag-pill-display,
button.subtask-toggle-pill,
button.done-toggle-pill,
button.subtask-add-pill,
button.focus-pill {
    font-family: inherit;
    line-height: inherit;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
}

/* Not the three subtask pills: their outline is the affordance. */
button.task-title,
button.status-badge-interactive,
button.tag-pill-display {
    border: 0;
}

/* Not the tag pill: its accent tint is how it reads as a tag. */
button.task-title,
button.status-badge-interactive {
    background: none;
}

/* The title replaced a block-level div rather than a pill, and is the only one
   whose own rule sets neither padding nor cursor. */
button.task-title {
    display: block;
    width: 100%;
    padding: 0;
    text-align: left;
    cursor: pointer;
}

/* --- Task List --- */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-group-header {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;   /* was 0.05em; same idiom, three units across the file */
    color: var(--text-muted);
    padding: 16px 4px 6px;
}

.task-group-header:first-child {
    padding-top: 0;
}

.task-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: grid;
    /* No arrow column outside Reorder mode: the arrows are display:none there
       (see .order-arrows), and a grid slot kept for them was 28px of empty
       gutter on every row. The reorder rule below puts the column back. */
    grid-template-columns: auto 10px 1fr;
    gap: 12px;
    align-items: center;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.task-row:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.task-row.overdue {
    border-left: 3px solid var(--priority-urgent);
}

/* === Urgency system: priority × due-date proximity === */
.task-row.urgency-critical,
.task-card.urgency-critical {
    border-left: 4px solid var(--priority-urgent);
    background: linear-gradient(90deg, rgba(var(--danger-rgb), 0.1) 0%, transparent 40%);
}
.task-row.urgency-high,
.task-card.urgency-high {
    border-left: 3px solid var(--priority-high);
    background: linear-gradient(90deg, rgba(var(--high-rgb), 0.07) 0%, transparent 30%);
}
.task-row.urgency-elevated,
.task-card.urgency-elevated {
    border-left: 3px solid var(--priority-medium);
    background: linear-gradient(90deg, rgba(var(--warning-rgb), 0.05) 0%, transparent 25%);
}
.task-row.urgency-watch,
.task-card.urgency-watch {
    border-left: 2px solid rgba(var(--warning-rgb), 0.4);
}

/* Critical items get a pulsing countdown pill */
.urgency-critical .countdown-pill {
    animation: urgency-pulse 2s ease-in-out infinite;
}
@keyframes urgency-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--danger-rgb), 0.4); }
    50% { box-shadow: 0 0 8px 2px rgba(var(--danger-rgb), 0.3); }
}

/* Compact (list) view */
.task-row.compact {
    grid-template-columns: auto 10px 1fr auto;
    padding: 8px 14px;
    gap: 8px;
}
/* The arrows are the rows' first child, so without their column every cell
   would shift one slot left; with it, they need it back. The compact rule has
   to be named on its own or the plain one outranks it. */
.task-list.sort-custom-active .task-row {
    grid-template-columns: 28px auto 10px 1fr;
}
.task-list.sort-custom-active .task-row.compact {
    grid-template-columns: 28px auto 10px 1fr auto;
}

.task-row.compact .task-title {
    font-size: 14px;
}

.compact-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    font-size: 12px;
}

.compact-meta .meta-sep {
    white-space: nowrap;
    font-size: 11px;
    color: var(--text-muted);
}

.task-row-line1 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.task-row-line1 .task-title {
    flex: 1;
    min-width: 0;
}

/* Where the priority dot was (2026-10-14): how pressing the due date is.
   Empty and quiet unless the task is due within three days. */
.due-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border);
}
.due-dot.soon { background: var(--warning); border-color: var(--warning); }
.due-dot.today { width: 12px; height: 12px; background: var(--priority-high); border-color: var(--priority-high); }
.due-dot.overdue { width: 12px; height: 12px; background: var(--danger); border-color: var(--danger); box-shadow: 0 0 6px rgba(var(--danger-rgb), 0.6); }

.order-arrows {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 28px;
    user-select: none;
}
/* display, not visibility: a hidden-but-present pair of 44px buttons held
   about 99px of every mobile card's second line empty, which is what pushed
   the pills sideways on some cards and not others. */
.task-list:not(.sort-custom-active) .order-arrows {
    display: none;
}
.order-arrow-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 20px;
    padding: 0;
    background: none;
    border: none;
    line-height: 1;
    font-size: 10px;
    color: var(--text-dim);
    cursor: pointer;
}
.order-arrow-btn:hover:not(:disabled) {
    color: var(--text);
}
.order-arrow-btn:disabled {
    opacity: 0.25;
    cursor: default;
}
/* Mobile task cards are the shop-floor-tablet layout (the whole reason
   arrows replaced drag), so these hit the project's documented 44px
   minimum touch target — the desktop .task-row layout is mouse-driven
   and stays compact. */
.task-card-line2 .order-arrows {
    flex-direction: row;
    width: auto;
    gap: 4px;
}
.task-card-line2 .order-arrow-btn {
    width: 44px;
    height: 44px;
    font-size: 14px;
}

.task-info {
    min-width: 0;
}

.task-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    margin-top: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.task-meta .meta-sep { white-space: nowrap; }

/* Last-modified time on a task row. Non-interactive, so it is deliberately
   absent from the 44px hit-area selector lists in the mobile media query. */
.meta-updated { white-space: nowrap; color: var(--text-muted); opacity: 0.75; }

.task-excerpt {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.countdown-pill {
    font-size: var(--pill-xs-size);
    font-weight: 600;
    padding: var(--pill-xs-pad);
    border-radius: var(--radius-pill);
    white-space: nowrap;
}
.countdown-ok { background: rgba(var(--success-rgb), 0.15); color: var(--priority-low); }
.countdown-soon { background: rgba(var(--warning-rgb), 0.15); color: var(--priority-medium); }
.countdown-tomorrow { background: rgba(var(--danger-rgb), 0.15); color: var(--priority-urgent); }
.countdown-today { background: rgba(var(--danger-rgb), 0.2); color: var(--priority-urgent); font-weight: 700; }
.countdown-overdue { background: rgba(var(--danger-rgb), 0.2); color: var(--priority-urgent); font-weight: 700; }
.countdown-none { background: var(--bg-input); color: var(--text-dim); }

.task-assignees {
    display: flex;
    gap: 4px;
}

.avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-fill);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.status-badge {
    padding: var(--pill-xs-pad);
    border-radius: var(--radius-pill);
    font-size: var(--pill-xs-size);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* Marks the status badges that open the quick-change popup (task list rows)
   as distinct from the plain read-only status badges used elsewhere, e.g.
   in the dependency list — those aren't clickable and shouldn't look it. */
.status-badge-interactive { cursor: pointer; }
.status-badge-interactive::after {
    content: '\25BE';
    margin-left: 3px;
    opacity: 0.6;
    font-size: 9px;
}

.status-badge.not-started { background: rgba(var(--not-started-rgb),0.2); color: var(--text-muted); }
.status-badge.in-progress { background: rgba(var(--accent-rgb),0.15); color: var(--badge-in-progress); }
.status-badge.on-hold { background: rgba(var(--warning-rgb),0.15); color: var(--badge-on-hold); }
.status-badge.pending-customer { background: rgba(var(--pending-customer-rgb),0.15); color: var(--status-pending-customer); }
.status-badge.completed { background: rgba(var(--success-rgb),0.15); color: var(--badge-completed); }
.status-badge.cancelled { background: rgba(var(--cancelled-rgb),0.15); color: var(--badge-cancelled); }

.due-date {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.due-date.overdue { color: var(--priority-urgent); font-weight: 600; }

.recurrence-badge {
    display: inline-block;
    padding: var(--pill-xs-pad);
    border-radius: var(--radius-chip);
    font-size: var(--pill-xs-size);
    font-weight: 600;
    text-transform: capitalize;
    background: rgba(var(--private-rgb),0.15);
    color: var(--accent-secondary);
}

/* --- Tags --- */
.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--accent);
    padding: var(--pill-md-pad);
    border-radius: var(--radius-pill);
    font-size: var(--pill-md-size);
    font-weight: 500;
}

.tag-pill button {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.7;
}

.tag-pill button:hover { opacity: 1; }

.tag-pill-display {
    display: inline-block;
    background: rgba(var(--accent-rgb), 0.12);
    color: var(--accent);
    padding: var(--pill-xs-pad);
    border-radius: var(--radius-pill);
    font-size: var(--pill-xs-size);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.tag-pill-display:hover {
    background: rgba(var(--accent-rgb), 0.25);
}

.tag-pill-editable {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(var(--accent-rgb), 0.12);
    color: var(--accent);
    padding: 2px 6px 2px 8px;
    border-radius: var(--radius-pill);
    font-size: var(--pill-sm-size);
    font-weight: 600;
    white-space: nowrap;
}


/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.6);
    z-index: var(--z-modal);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-x: hidden;
    overflow-y: auto;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    box-shadow: var(--shadow);
    overflow-x: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Confirm dialog — stacks above the main modal, centered, compact. */
.confirm-overlay {
    z-index: var(--z-dialog);
    align-items: center;
}

.confirm-modal {
    max-width: 420px;
    padding: 24px;
}

.confirm-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 10px;
    color: var(--text);
}

.confirm-message {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-muted);
    white-space: pre-line;
    margin-bottom: 20px;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* The footer row of a form inside the shared modal. Same shape as
   .confirm-actions above; its two call sites (change password, admin reset
   password) shipped against this name with no rule behind it. */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
}

.modal-header > div:first-child {
    min-width: 0;
    flex: 1;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* The task modal's header used to stack, because five action buttons left a
   long title wrapping into a squeezed second line. Those five are one menu
   now, so the title shares the row again and the header is 60px on a phone
   rather than 160. `.modal-header-stacked` went with them. */
.detail-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Destructive, and the only item here that is. It reads as an ordinary line
   in a list otherwise, which is the wrong weight for delete. */
.header-menu-list button.menu-item-danger { color: var(--danger); }
.header-menu-list button.menu-item-danger:hover {
    background: rgba(var(--danger-rgb), 0.15);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 24px; overflow-x: hidden; }

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.form-group input:not([type="checkbox"]),
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
}

.form-group input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.form-group.checkbox-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.form-group.checkbox-row label {
    margin-bottom: 0;
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
}

.visibility-segmented {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-input);
}
.visibility-segmented .segment {
    position: relative;
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border-right: 1px solid var(--border);
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 0;
    transition: background var(--transition), color var(--transition);
}
.visibility-segmented .segment:last-child {
    border-right: none;
}
.visibility-segmented .segment:hover {
    background: var(--bg-card-hover);
}
.visibility-segmented .segment:has(input:checked) {
    background: var(--accent-fill);
    color: var(--on-accent);
}
.visibility-segmented .segment:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
.visibility-segmented .segment input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    margin-left: 26px;
}

.form-group input:not([type="checkbox"]):focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--border-focus);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.date-time-row {
    display: flex;
    gap: 8px;
}
.date-time-row input[type="date"] {
    flex: 1;
}
.date-time-row input[type="time"] {
    flex: 0 0 130px;
}

.form-group select[multiple] {
    min-height: 100px;
}

/* --- Multi-select picker (Assignees, Dependencies) --- */
.picker {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.picker-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 6px 0 6px;
}
.picker-selected:empty { display: none; }
.picker-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: var(--accent-alpha);
    border: 1px solid var(--accent);
    color: var(--text);
    border-radius: var(--radius-pill);
    padding: 2px 4px 2px 10px;
    font-size: var(--pill-md-size);
    line-height: 1.4;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.picker-pill button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
    min-height: 0;
}
/* The second selector is for pickers inside a form: `.form-group input:not(...)`
   is (0,2,1) and out-specified the plain class, so its width: 100% plus these
   6px margins ran the box past the picker's right edge, visibly clipped on a
   phone, and its padding and background replaced these. */
.picker-search,
.form-group input.picker-search:not([type="checkbox"]) {
    margin: 6px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    width: calc(100% - 12px);
}
.picker-search:focus { border-color: var(--border-focus); }
.picker-list {
    max-height: 180px;
    overflow-y: auto;
    padding: 0 6px 6px 6px;
    -webkit-overflow-scrolling: touch;
}
.picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
    user-select: none;
    min-height: 36px;
}
.picker-row:hover { background: var(--bg-card-hover); }
.picker-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
}
.picker-empty {
    padding: 12px;
    color: var(--text-dim);
    font-size: 13px;
    text-align: center;
}

.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* --- Large Modal (Help) --- */
.modal-large { max-width: 820px; }

.help-content h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.help-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.help-section:last-child { border-bottom: none; margin-bottom: 0; }
.help-section ul { margin: 6px 0 0; padding-left: 20px; }
.help-section li { margin-bottom: 6px; line-height: 1.5; }
.help-section p { margin: 0 0 8px; line-height: 1.5; }
.help-badge {
    display: inline-block;
    font-size: var(--pill-sm-size);
    font-weight: 600;
    background: var(--accent-fill);
    color: var(--on-accent);
    padding: var(--pill-sm-pad);
    border-radius: var(--radius-pill);
    vertical-align: middle;
}
.help-version {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: normal;
}
.help-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.help-section-header h3 {
    margin: 0;
}
.help-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}
.help-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}
.help-item {
    background: var(--bg-card-secondary, var(--bg-card));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
}
.help-item strong {
    display: block;
    font-size: 13px;
    margin-bottom: 2px;
    color: var(--accent);
}
.help-item span {
    color: var(--text-dim);
}
.help-callout-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}
.help-callout {
    padding: 8px 12px;
    background: var(--bg-card-secondary, var(--bg-card));
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 13px;
    line-height: 1.5;
}
.help-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-dim);
}
@media (max-width: 768px) {
    .help-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Detail Tabs --- */
.detail-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.detail-tab-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 12px 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition);
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-tab-btn:hover { color: var(--text); }

.detail-tab-btn.active {
    color: var(--accent);
}

.detail-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

.detail-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    font-size: var(--pill-sm-size);
    font-weight: 700;
    background: var(--border);
    color: var(--text-muted);
    line-height: 1;
}

.detail-tab-btn.active .detail-tab-badge {
    background: var(--accent-fill);
    color: var(--on-accent);
}

.detail-tab-pane {
    display: none;
}

.detail-tab-pane.active {
    display: block;
}

.detail-description-box {
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px 18px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg-input);
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    min-height: 60px;
}

.detail-notes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-note-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    background: var(--bg-input);
}

.detail-note-item .note-meta {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.note-edit-btn {
    padding: 0 2px;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: 11px;
    line-height: inherit;
    color: var(--text-muted);
    margin-left: 6px;
    cursor: pointer;
}
.note-edit-btn:hover { color: var(--accent); text-decoration: underline; }
.detail-note-item .note-content {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

/* --- Task Detail Panel --- */
.detail-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* At-a-glance summary strip at the top of the Task tab: the fields you
   most want on open (status / due / who), without a switch to Details. */
/* Shrinks to its three controls rather than stretching the modal's width and
   leaving half of itself empty. max-width keeps it inside the modal, and the
   wrap still stacks it on a phone. */
.detail-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 28px;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: fit-content;
    max-width: 100%;
}



/* The three strip controls. They are <button>s so they are keyboard reachable
   and announce as actionable, but they must not look like form buttons: the
   status one keeps its status-badge colours, the other two read as text until
   hovered. */
.summary-edit {
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    background: none;
    text-align: left;
    padding: 2px 6px;
    margin: -2px -6px;
    border-radius: calc(var(--radius) - 2px);
}

.summary-edit-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.summary-edit:hover,
.summary-edit:focus-visible {
    border-color: var(--border);
    background: var(--bg-card-hover);
}

.summary-edit.is-empty {
    color: var(--text-muted);
    font-weight: 400;
}

/* Empty-description affordance: reads as an invitation rather than a dash, and
   fills the box so it is hard to miss and easy to hit on a tablet. */
.detail-description-add {
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0;
    text-align: left;
    width: 100%;
    min-height: 44px;
}

.detail-description-add:hover,
.detail-description-add:focus-visible {
    color: var(--text);
}

.detail-description-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
}

/* Popover for the due-date and assignee editors. */
.summary-popup {
    position: fixed;
    z-index: var(--z-modal);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    padding: 10px;
    min-width: 240px;
    max-width: min(320px, calc(100vw - 16px));
    animation: fadeIn 100ms ease;
}

.summary-popup-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
}

.summary-popup-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.summary-popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* The parent picker holds full task titles, so it needs more room than the
   date input and must not push the popup past the viewport. */
.summary-popup select.summary-popup-input {
    max-width: 100%;
}

/* Task inbound email address, with copy — forward/CC mail here to file it. */
.task-email-block {
    padding-top: 12px;
    margin-top: 6px;
    border-top: 1px solid var(--border);
}

.task-email-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 4px 0 8px;
    line-height: 1.5;
}

.task-email-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.task-email-addr {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 13px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    color: var(--text);
    overflow-wrap: anywhere;
}

.detail-section {
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}

.detail-section:last-child { border-bottom: none; }

/* The upload progress panel. Fixed to the page, not inside the task window,
   so rebuilding the window cannot remove it. Above the modal (which fills a
   phone) and below the lightbox and dialogs, so it never covers a receipt
   dialog's Save button. */
.upload-panel {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: min(420px, calc(100% - 32px));
    z-index: var(--z-progress);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text);
}
@media (max-width: 768px) {
    /* Clear the bottom nav when no dialog covers it, as the bulk bar does. */
    body:not(.dialog-open) .upload-panel { bottom: calc(72px + env(safe-area-inset-bottom)); }
}
.upload-panel-bar {
    height: 6px;
    margin-top: 8px;
    border-radius: var(--radius-pill);
    background: rgba(var(--border-rgb), 0.6);
    overflow: hidden;
}
.upload-panel-fill {
    height: 100%;
    background: var(--accent-fill);
}
.upload-panel-failed { margin-top: 4px; }
.upload-panel-line + .upload-panel-bar + .upload-panel-failed { margin-top: 12px; }
.upload-panel-failed strong { color: var(--danger); }
.upload-panel-why { color: var(--text-muted); margin-top: 4px; overflow-wrap: anywhere; }
.upload-panel-actions { display: flex; gap: 8px; margin-top: 10px; }

.receipt-save-error:not(:empty) {
    color: var(--danger);
    font-size: 13px;
    margin: 8px 0 0;
}

/* The former Notifications tab, folded under Activity as a disclosure. */
.detail-notifications {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
.detail-notifications > summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    min-height: 44px;
    display: flex;
    align-items: center;
}
.detail-notifications[open] > summary { margin-bottom: 8px; }

.detail-section h3 {
    font-family: var(--font-display);
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
}

.detail-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.detail-field .field-label {
    font-size: 13px;
    color: var(--text-muted);
}

.detail-field .field-value {
    font-size: 13px;
    font-weight: 500;
}


/* Comments */


.comment-form {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 8px;
}

.comment-form textarea,
.comment-form input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    padding: 8px 12px;
    font-size: 13px;
}

.comment-form textarea:focus,
.comment-form input:focus { border-color: var(--border-focus); }

/* Reminders */
.reminder-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.reminder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 8px 12px;
}

.reminder-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.reminder-who {
    font-weight: 600;
    color: var(--accent);
}

.reminder-when {
    color: var(--text-muted);
    font-size: 12px;
}

.reminder-sent {
    font-size: 11px;
    font-weight: 600;
    color: var(--priority-low);
    background: rgba(var(--success-rgb),0.15);
    padding: 2px 8px;
    border-radius: 4px;
}

.reminder-pending {
    font-size: 11px;
    font-weight: 600;
    color: var(--priority-medium);
    background: rgba(var(--warning-rgb),0.15);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Activity log */
.activity-list {
    max-height: 200px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    font-size: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(var(--border-rgb),0.5);
}

.activity-item:last-child { border-bottom: none; }
.activity-time { color: var(--text-dim); white-space: nowrap; }
.activity-detail { color: var(--text); }

/* --- Calendar --- */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.calendar-header h2 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
}

/* Six children in one nowrap flex row collide below ~420px: the month title
   ran into the Prev/Next buttons and "Hide completed" truncated to a bare
   checkbox. Let the row wrap and give the title its own full-width line. */
@media (max-width: 560px) {
    .calendar-header,
    .gantt-header {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .calendar-header h2,
    .gantt-header h2 {
        order: -1;
        flex-basis: 100%;
        text-align: center;
        font-size: 18px;
    }
}

.toggle-label {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}


.calendar-grid {
    display: grid;
    /* minmax(0, 1fr), not bare 1fr: an implicit 1fr track's minimum is
       "auto" (min-content), so a long, unwrapped task title in one day
       forces that whole column — and the grid's own box — wider than the
       page, pushing later days off-screen with no way back (the app shell
       disables horizontal page scroll everywhere else on purpose). Clamping
       the minimum to 0 makes columns always divide the available width
       evenly regardless of content, and .calendar-task's existing
       overflow/ellipsis rules take over for long titles instead. */
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.calendar-day-header {
    background: var(--bg-card);
    padding: 10px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-cell {
    background: var(--bg-card);
    min-height: 110px;
    padding: 8px;
    position: relative;
    cursor: pointer;
    transition: background var(--transition);
}

.calendar-cell:hover { background: var(--bg-card-hover); }

.calendar-cell.other-month { opacity: 0.35; }
.calendar-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }

.calendar-date {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.calendar-cell.today .calendar-date { color: var(--accent); }

/* A <button>: on the calendar it is the only way to open a task. Buttons
   shrink-wrap, so it needs an explicit block box to keep filling the day
   cell. Its background comes from the due-date rules below. */
.calendar-task {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-weight: 500;
    display: block;
    width: 100%;
    background: none;
    border: 0;
    font-family: inherit;
    line-height: inherit;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
}

.calendar-task { background: rgba(var(--accent-rgb),0.15); color: var(--text); }
.calendar-task.due-soon { background: rgba(var(--warning-rgb),0.2); }
.calendar-task.due-today { background: rgba(var(--high-rgb),0.25); }
.calendar-task.due-overdue { background: rgba(var(--danger-rgb),0.25); }

/* A button since 2026-09-29: it was a div, so the tasks it counted could not
   be reached from the calendar at all. Tapping it lists the whole day. */
.calendar-more {
    font-size: 11px;
    color: var(--text-dim);
    padding: 2px 0;
    font-family: inherit;
    line-height: inherit;
    background: none;
    border: 0;
    cursor: pointer;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
}
.calendar-more:hover { color: var(--text); text-decoration: underline; }

/* --- Gantt View --- */
.gantt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.gantt-header h2 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
}

.gantt-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}

.gantt-chart-inner {
    position: relative;
    min-width: 900px;
    /* The label column's width, in one place: the rows' grid and the today
       line's position (views.js) both read it. The line used to hardcode 200px
       while phones drew a 140px column, so it sat up to 60px late there.
       260px since v2.79.0: at 200 most job names were cut to a few words. */
    --gantt-label-w: 260px;
}

.gantt-row {
    display: grid;
    grid-template-columns: var(--gantt-label-w) 1fr;
    border-bottom: 1px solid var(--border);
}

.gantt-row:last-child { border-bottom: none; }

.gantt-header-row {
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 2;
}

/* A task's label is a <button>; the header row's label keeps the same class
   and stays a div, which is why the button reset lives in this rule rather
   than in a `button.gantt-label` one. As with .activity-feed-item, the sides
   are zeroed individually so the column rule's border-right survives. */
.gantt-label {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-right: 1px solid var(--border);
    border-top: 0;
    border-bottom: 0;
    border-left: 0;
    background: none;
    font-family: inherit;
    line-height: inherit;
    text-align: left;
    transition: background var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.gantt-label:hover { background: var(--bg-card-hover); }
.gantt-label .subtask-icon,
.gantt-label .due-dot { flex-shrink: 0; }
.gantt-label-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-job-row .gantt-label { font-weight: 700; }
.gantt-job-row { border-top: 1px solid var(--border); }

.gantt-span { display: inline-flex; gap: 4px; }
.gantt-span-btn.active { background: rgba(var(--accent-rgb), .15); color: var(--accent); border-color: rgba(var(--accent-rgb), .4); }

/* Three months: about ninety day columns, so only Mondays and today are
   numbered, and a band of month names sits above them. */
.gantt-chart-inner.gantt-wide { min-width: 1100px; }
.gantt-wide .gantt-date-header { padding: 6px 0; font-size: 10px; min-height: 26px; }
.gantt-wide .gantt-date-header:not(.week-start):not(.month-start) { border-left-color: transparent; }
.gantt-date-header.month-start { border-left: 2px solid var(--border); }
.gantt-month-row { background: var(--bg-card); }
.gantt-month-band { padding: 0; }
.gantt-month-name {
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border-left: 2px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-label-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: default;
}

.gantt-label-header:hover { background: transparent; }

.gantt-bar-area {
    display: grid;
    align-items: center;
    padding: 4px 0;
    position: relative;
}

.gantt-date-header {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 2px;
    line-height: 1.3;
    border-left: 1px solid rgba(var(--border-rgb),0.3);
}

.gantt-date-header.today {
    color: var(--accent);
    background: rgba(var(--accent-rgb),0.08);
}

.gantt-date-header.weekend {
    color: var(--text-dim);
}

.gantt-bar {
    height: 28px;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    margin: 0 2px;
    transition: filter var(--transition);
}

.gantt-bar:hover { filter: brightness(1.2); }

.gantt-bar.not-started { background: rgba(var(--not-started-rgb),0.4); }
.gantt-bar.in-progress { background: rgba(var(--accent-rgb),0.4); }
.gantt-bar.on-hold { background: rgba(var(--warning-rgb),0.4); }
.gantt-bar.pending-customer { background: rgba(var(--pending-customer-rgb),0.4); }
.gantt-bar.completed { background: rgba(var(--success-rgb),0.4); }
.gantt-bar.cancelled { background: rgba(var(--cancelled-rgb),0.3); }

/* A task with one date is a dot centred in its day, whatever the column
   width: stretching it across the column drew an oval. */
.gantt-bar.single-day {
    width: 12px;
    min-width: 12px;
    height: 12px;
    margin: 0;
    justify-self: center;
    border-radius: 50%;
}

.gantt-bar.single-day.not-started { background: var(--status-not-started); }
.gantt-bar.single-day.in-progress { background: var(--status-in-progress); }
.gantt-bar.single-day.on-hold { background: var(--status-on-hold); }
.gantt-bar.single-day.pending-customer { background: var(--status-pending-customer); }
.gantt-bar.single-day.completed { background: var(--status-completed); }
.gantt-bar.single-day.cancelled { background: var(--status-cancelled); }

.gantt-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: 4px;
    pointer-events: none;
}

.gantt-bar.not-started .gantt-bar-fill { background: var(--status-not-started); }
.gantt-bar.in-progress .gantt-bar-fill { background: var(--status-in-progress); }
.gantt-bar.on-hold .gantt-bar-fill { background: var(--status-on-hold); }
.gantt-bar.pending-customer .gantt-bar-fill { background: var(--status-pending-customer); }
.gantt-bar.completed .gantt-bar-fill { background: var(--status-completed); }
.gantt-bar.cancelled .gantt-bar-fill { background: var(--status-cancelled); }

.gantt-bar-text {
    position: relative;
    z-index: 1;
    font-size: 11px;
    font-weight: 500;
    color: white;
    padding: 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--priority-urgent);
    z-index: 3;
    pointer-events: none;
    opacity: 0.7;
}

/* --- Subtask timeline, in the task window (subtask-timeline.js) --- */
.subtask-timeline { margin-top: 18px; }
.subtask-timeline h3 { margin: 0 0 8px; }
.stl-body {
    --stl-label-w: 200px;
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 0;
}
.stl-row {
    display: grid;
    grid-template-columns: var(--stl-label-w) minmax(0, 1fr);
    align-items: center;
    min-height: 30px;
}
.stl-label {
    display: block;
    min-width: 0;
    padding: 0 10px 0 calc(10px + var(--depth, 0) * 12px);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.3;
    color: var(--text);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: none;
    border: 0;
    cursor: pointer;
}
.stl-label .due-dot { display: inline-block; flex-shrink: 0; margin-right: 6px; vertical-align: middle; }
span.stl-label { cursor: default; }
.stl-parent .stl-label { font-weight: 600; }
.stl-track { position: relative; height: 30px; margin-right: 10px; }
.stl-bar {
    position: absolute;
    top: 7px;
    height: 16px;
    min-width: 6px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}
.stl-parent .stl-bar { cursor: default; }
.stl-bar.point { width: 12px; height: 12px; top: 9px; border-radius: 50%; }
.stl-bar.not-started { background: rgba(var(--not-started-rgb),0.4); }
.stl-bar.in-progress { background: rgba(var(--accent-rgb),0.4); }
.stl-bar.on-hold { background: rgba(var(--warning-rgb),0.4); }
.stl-bar.pending-customer { background: rgba(var(--pending-customer-rgb),0.4); }
.stl-bar.completed { background: rgba(var(--success-rgb),0.4); }
.stl-bar.cancelled { background: rgba(var(--cancelled-rgb),0.3); }
.stl-bar.point.not-started, .stl-bar.not-started .stl-fill { background: var(--status-not-started); }
.stl-bar.point.in-progress, .stl-bar.in-progress .stl-fill { background: var(--status-in-progress); }
.stl-bar.point.on-hold, .stl-bar.on-hold .stl-fill { background: var(--status-on-hold); }
.stl-bar.point.pending-customer, .stl-bar.pending-customer .stl-fill { background: var(--status-pending-customer); }
.stl-bar.point.completed, .stl-bar.completed .stl-fill { background: var(--status-completed); }
.stl-bar.point.cancelled, .stl-bar.cancelled .stl-fill { background: var(--status-cancelled); }
.stl-fill { position: absolute; left: 0; top: 0; height: 100%; pointer-events: none; }
.stl-axis, .stl-axis .stl-track { min-height: 22px; height: 22px; }
.stl-mark {
    position: absolute;
    top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    transform: translateX(-50%);
}
.stl-mark.start { transform: none; }
.stl-mark.end { transform: translateX(-100%); }
.stl-mark.today { color: var(--danger); font-weight: 600; }
.stl-today {
    position: absolute;
    top: 26px;
    bottom: 4px;
    left: calc(var(--stl-label-w) + (100% - var(--stl-label-w) - 10px) * var(--today-f, 0));
    width: 2px;
    background: var(--danger);
    opacity: 0.6;
    pointer-events: none;
}
.stl-undated { font-size: 13px; color: var(--text-muted); margin: 6px 0 0; }
@media (max-width: 768px) {
    .stl-body { --stl-label-w: 110px; }
    .stl-row, .stl-track { min-height: 44px; height: 44px; }
    .stl-axis, .stl-axis .stl-track { min-height: 22px; height: 22px; }
    .stl-label { min-height: 44px; }
    .stl-bar { top: 14px; }
    .stl-bar.point { top: 16px; }
}

/* --- Staff View --- */
.staff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.staff-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.staff-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Wraps: four buttons are wider than a 320px card, and without it Archive
   ran off the card's edge, clipped by its overflow: hidden. */
.staff-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: auto;
    max-width: 100%;
}

.staff-card-header .avatar {
    width: 40px;
    height: 40px;
    font-size: 15px;
}

.staff-name { font-weight: 700; font-size: 15px; }
.staff-role { font-size: 12px; color: var(--text-muted); }

.staff-task-list {
    padding: 12px 20px;
    max-height: 250px;
    overflow-y: auto;
}

.staff-task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 0;
    border-top: 0;
    border-right: 0;
    border-left: 0;
    border-bottom: 1px solid rgba(var(--border-rgb),0.5);
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: 13px;
    line-height: inherit;
    text-align: left;
    cursor: pointer;
}

.staff-task-item:last-child { border-bottom: none; }
.staff-task-item:hover .task-title { color: var(--accent); }

.staff-task-item .task-title {
    font-size: 13px;
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color var(--transition);
}

.staff-task-count {
    padding: 8px 20px;
    font-size: 12px;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
}

/* --- Completion bar --- */
.completion-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.completion-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }
.empty-state-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

/* --- View containers --- */
.view { display: none; }
.view.active { display: block; }

/* Settings modal */
.settings-section h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.settings-section .checkbox-row {
    margin-bottom: 6px;
}

/* --- Responsive --- */
/* An iPhone SE (320px): at the phone rule's 46% the status box left search
   about 100px. One more class than that rule, so source order cannot matter. */
@media (max-width: 360px) {
    .toolbar .toolbar-always-visible .toolbar-filter-status { max-width: 40%; }
}
/* Between the bottom bar (768px and under) and a window wide enough for the
   logo, the user controls and every tab on one line, the tabs ran off the
   right edge with no way to scroll to them: at 820px Team and Reports could
   not be reached at all. They take a row of their own here instead. The
   header is sticky and nothing is positioned from its 60px height, so a
   taller header only pushes the page down. */
@media (min-width: 769px) and (max-width: 1199px) {
    .app-header {
        height: auto;
        min-height: 60px;
        flex-wrap: wrap;
        padding-top: 8px;
    }
    .nav-tabs {
        flex-basis: 100%;
        height: auto;
    }
    .nav-tab { min-height: 44px; padding: 0 16px; }
}
/* Last resort for a product name long enough to crowd the tabs even at full
   width: they scroll rather than disappear. */
@media (min-width: 769px) {
    .nav-tabs { min-width: 0; overflow-x: auto; scrollbar-width: thin; }
}
@media (max-width: 768px) {
    .app-header {
        padding: 8px 12px;
        height: auto;
        flex-wrap: wrap;
        gap: 4px;
    }
    .app-logo { font-size: 15px; gap: 8px; }
    .app-logo .logo-img { height: 28px; }
    .user-info {
        gap: 4px;
        flex-wrap: nowrap;
        justify-content: flex-end;
        /* No `overflow: hidden` here. It existed to contain a row of five
           header buttons, which is now one menu button, and it clipped the
           menu's absolutely-positioned dropdown to the header strip. */
    }
    .user-info .user-display-name { font-size: 13px; }
    .user-info .btn-sm { min-height: 32px; padding: 4px 8px; font-size: 12px; }
    .nav-tab { padding: 0 12px; font-size: 13px; }
    .nav-tab .tab-text { display: none; }
    .nav-tab .tab-icon { display: inline; }
    .main-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 10px; }
    .stat-card .stat-value { font-size: 20px; }
    .stat-card .stat-label { font-size: 9px; }
    .toolbar { gap: 6px; }
    .toolbar-always-visible { gap: 6px; }
    /* Two rows instead of four (2026-09-29): search, status and filters,
       then My Tasks and the four view toggles as icons. Ordered with CSS so
       the DOM, and every test that walks it, stays as it is; the spacer is
       the line break. New Task leaves the toolbar for a floating button. */
    .toolbar-always-visible .search-input { order: 1; flex: 1 1 0; }
    .toolbar-always-visible .toolbar-filter-status { order: 2; flex: 0 1 auto; max-width: 46%; }
    .toolbar-always-visible .filter-toggle-btn { order: 3; width: 44px; padding: 0; justify-content: center; }
    .toolbar-always-visible .spacer { display: block; order: 4; flex-basis: 100%; height: 0; margin-top: -6px; }
    .toolbar-always-visible .my-tasks-toggle { order: 5; }
    .toolbar-always-visible .tb-toggle { order: 6; width: 44px; padding: 0; justify-content: center; font-size: 16px; }
    .tb-icon-phone { display: inline; }
    /* Hidden from sight, not from screen readers: it is the button's name. */
    .tb-toggle .tb-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    /* (0,2,1), so it out-specifies `.btn` and the toolbar's 44px
       `.toolbar-always-visible .btn` rule (0,2,0), both written later. */
    .toolbar-always-visible button.new-task-btn {
        position: fixed;
        right: 16px;
        bottom: calc(72px + env(safe-area-inset-bottom));
        width: 56px;
        height: 56px;
        min-height: 56px;
        padding: 0;
        border-radius: 50%;
        font-size: 28px;
        line-height: 1;
        justify-content: center;
        z-index: var(--z-bar);
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    }
    .new-task-btn .new-task-label { display: none; }
    /* The bulk bar takes the same corner while tasks are selected. */
    body.bulk-selecting .toolbar-always-visible button.new-task-btn { display: none; }
    /* So the last card's checkbox is never under the floating button. */
    #view-dashboard { padding-bottom: 72px; }

    /* Mobile: collapse the filter bar behind the toggle again to save space. */
    /* Matching specificity to the desktop rule above, for the same reason. */
    .toolbar-always-visible .filter-toggle-btn { display: inline-flex; }
    .toolbar-collapsible { display: none; flex-direction: column; gap: 8px; }
    .toolbar-collapsible.open { display: flex; }
    .toolbar-collapsible .toolbar-group { flex-direction: column; width: 100%; }
    .toolbar-collapsible .toolbar-group select { width: 100%; }

    /* Give search its own full-width row so the labelled toolbar buttons
       wrap cleanly below it instead of squeezing the search box. */
    .search-input { width: auto; min-width: 0; }

    .task-row {
        grid-template-columns: auto 10px 1fr;
        gap: 10px;
        padding: 12px 14px;
    }

    .form-row { grid-template-columns: 1fr; }
    .date-time-row { flex-direction: column; }
    .date-time-row input[type="time"] { flex: 1; }
    .calendar-cell { min-height: 80px; padding: 4px; }
    .calendar-task { font-size: 10px; }
    .staff-grid { grid-template-columns: 1fr; }
    .gantt-chart-inner { --gantt-label-w: 140px; }
    .gantt-label { width: var(--gantt-label-w); min-width: var(--gantt-label-w); font-size: 12px; padding: 8px; }

    /* Bottom navigation */
    .nav-tabs {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: var(--z-sticky);
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        border-bottom: none;
        height: auto;
        display: flex;
        justify-content: space-around;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom);
        gap: 0;
    }

    .nav-tab {
        flex: 1;
        flex-direction: column;
        gap: 2px;
        border-bottom: none;
        border-top: 2px solid transparent;
        height: 56px;
    }

    .nav-tab.active { border-bottom-color: transparent; border-top-color: var(--accent); }
    .nav-tab .tab-text { display: block; font-size: 10px; }
    .nav-tab .tab-icon { font-size: 20px; }

    .main-content { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
    .bulk-action-bar { bottom: calc(72px + env(safe-area-inset-bottom)); }

    /* Larger touch targets (44px minimum) */
    .btn { min-height: 44px; padding: 8px 14px; }
    .btn-sm { min-height: 36px; padding: 6px 10px; }
    .status-badge { padding: var(--pill-xs-pad); font-size: var(--pill-xs-size); }
    .nav-tab { min-width: 44px; min-height: 44px; justify-content: center; }
    .avatar { width: 32px; height: 32px; font-size: 13px; }
    .task-checkbox-cell { min-width: 44px; min-height: 44px; }
    .task-checkbox-cell input[type="checkbox"] { width: 22px; height: 22px; }
    /* The pin marker keeps its 26px face and its 44px ::after tap area; only the
       controls around it need growing for gloved fingers on a tablet. */
    .pin-add-btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
    .pin-legend-action { min-height: 44px; padding: 6px 12px; font-size: 12px; }
    .pin-legend-item { flex-wrap: wrap; }
    .modal-overlay { padding: 0; align-items: stretch; }
    /* Not the confirm box: a two-line question stretched to 100vh sat at the
       top of an empty screen. Both halves are needed, since the overlay's
       `align-items: stretch` alone makes a child full height. */
    .modal:not(.confirm-modal) {
        max-width: 100%;
        border-radius: 0;
        min-height: 100vh;
        max-height: none;
    }
    .confirm-overlay { align-items: flex-start; padding: 24px 16px; }
    .confirm-modal { width: 100%; border-radius: var(--radius); }
    .modal-large { max-width: 100%; }
    .modal-close { font-size: 28px; padding: 8px; }
    .modal-header {
        padding: 12px 16px;
        flex-direction: column;
        align-items: stretch;
        position: relative;
        padding-right: 48px;
    }
    .modal-header h2 { font-size: 18px; }
    .modal-header > div:last-child {
        justify-content: flex-end;
        flex-wrap: wrap;
    }
    .modal-header .modal-close {
        position: absolute;
        top: 8px;
        right: 8px;
    }

    /* Task detail header: the actions ride in the corner beside the close
       button rather than taking a 44px band of their own below the title.
       `display: contents` lets each child position itself, so the close keeps
       the rule above and the menu sits to its left. The trigger drops its
       label here and keeps its accessible name, which is what buys the room:
       a labelled button would need 110px of reserved padding on a 390px
       screen and the title would pay for it. */
    .modal-header-detail { padding-right: 100px; }
    .modal-header-detail .detail-header-actions { display: contents; }
    .modal-header-detail .header-menu {
        position: absolute;
        top: 8px;
        right: 52px;
    }
    .modal-header-detail .detail-actions-label { display: none; }
    .modal-body { padding: 16px; }
    .modal-footer {
        padding: 12px 16px;
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        z-index: 5;
    }
    .detail-tabs { padding: 0 8px; }
    /* Only while there is more to the right (watchTabOverflow): scrolled to
       the end, the fade sat over the last tab's label. */
    .detail-tabs.can-scroll-right {
        mask-image: linear-gradient(to right, black calc(100% - 24px), transparent);
        -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent);
    }
    .detail-tab-btn { padding: 10px 10px; font-size: 12px; }

    /* Stack label above value so long values stop colliding */
    .detail-field {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        padding: 8px 0;
    }
    .detail-field .field-label { font-size: 11px; }
    .detail-field .field-value { font-size: 14px; }

    /* --- Touch targets ---
       The project's minimum is 44px, but the task list controls predate the
       rule: measured at 390px the status badge was 18px, the pills 23px and the
       tag pill 17px. Expand the HIT AREA with a transparent ::after rather than
       inflating the control, the same trick .pin-marker uses, because a 44px
       status chip would dominate the card row it sits in. Expansion is vertical
       only: these sit in horizontal rows, and growing them sideways would let
       neighbouring controls steal each other's taps.

       Checkboxes are excluded on purpose. They are replaced elements and do not
       render ::after reliably, and the list ones are already wrapped in a
       .task-checkbox-cell label that measures a true 44x44. */
    .status-badge-interactive,
    .subtask-add-pill,
    .focus-pill,
    .subtask-toggle-pill,
    .done-toggle-pill,
    .tag-pill-display {
        position: relative;
    }

    .status-badge-interactive::after,
    .subtask-add-pill::after,
    .focus-pill::after,
    .subtask-toggle-pill::after,
    .done-toggle-pill::after,
    .tag-pill-display::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        height: 44px;
    }

    /* Ticking off a subtask is a common action and this was 22px. The label is
       a real element, so it can simply be sized. */
    .subtask-list .subtask-check {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Buttons and the search field were 33 to 36px. These are real boxes with
       room around them, so they grow rather than getting a hidden overlay. */
    .toolbar .btn,
    .toolbar-always-visible .btn,
    .toolbar-always-visible select,
    .modal-header .btn,
    .modal-footer .btn,
    .comment-form .btn,
    .subtask-item .btn,
    .search-input {
        min-height: 44px;
    }

    /* Opens the subtask, and was 19px of bare text. */
    .subtask-title-link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    /* With the pills' hit areas grown to 44px, an 8px row gap left adjacent
       wrapped rows overlapping by 3px, so a tap in that band would reach the
       control on the row above or below rather than the one under the finger.
       The gap has to be at least the difference between the row pitch and 44.
       Measured: the tallest item in a wrapped row is 28px, so 16px of gap puts
       the row pitch at exactly 44 and the zones sit adjacent rather than
       overlapping. Adjacent is fine and unavoidable in a dense list; overlapping
       is not, because the control that paints last silently wins the tap.

       Qualified with .task-card on purpose: the base `.task-card-line2 { gap:
       8px }` rule sits LATER in this file, and a media query adds no
       specificity, so an unqualified selector here loses to it and silently
       does nothing. */
    .task-card .task-card-line2 { row-gap: 16px; }
    /* The bulk checkbox is absolute in the card's top-right corner with a
       44px hit area that reaches down into this line, where the reorder
       arrows and the + Sub pill wrap to. Up to 527 square px of a tap meant
       for "move down" selected the task instead. The line leaves that column
       free; qualified with .task-card for the same reason as the rule above. */
    .task-card .task-card-line2 { padding-right: 44px; }

    /* The four views the 44px sweep never measured (Calendar, Timeline,
       Reports, the team view): their .btn-sm controls were 36px, and the
       staff panel's task rows 37px. The task modal keeps its own audited
       rules; this is scoped to the views so it cannot reach them. */
    #view-calendar .btn-sm,
    #view-gantt .btn-sm,
    #view-reports .btn-sm,
    #view-staff .btn-sm { min-height: 44px; }
    .staff-task-item { min-height: 44px; }

    /* The strip's controls are the primary way status and dates get changed on
       a shop tablet, so they take the project's 44px minimum hit area. The
       strip stays shrink-to-content here too: forcing it full width put a 92px
       empty tail back on a 390px screen, which is the defect this was meant to
       remove. It wraps on its own when the content genuinely needs two rows. */
    .detail-summary { gap: 10px 14px; padding: 10px 14px; }

    /* The two text controls take the 44px minimum directly: they paint no
       background, so the height is spacing rather than bulk. The status badge
       does paint one, and a 44px-tall tint slab around 11px of text is what
       made this strip read as fat on a phone, so it keeps its own size and
       grows its HIT AREA with a transparent ::after instead. Same trick, and
       same reason, as the task list's badges further up this file.

       The expansion is vertical only and the strip's rows are at least 44px
       apart, so the ::after cannot reach into the row below and steal a tap
       meant for the control there. */
    .summary-edit-value {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .summary-edit.status-badge { position: relative; }
    .summary-edit.status-badge::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        height: 44px;
    }

    /* Reminder form: stack staff picker above the When dropdown */
    .reminder-form-row {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Larger picker rows for thumb taps */
    .picker-list { max-height: 220px; }
    .picker-row { min-height: 44px; padding: 10px 8px; }
    .picker-row input[type="checkbox"] { width: 22px; height: 22px; }
    .picker-search { padding: 10px 12px; font-size: 15px; }

    /* Subtask rows in the detail modal: title wraps, meta drops to its own line */
    /* One row per subtask: tick, title, delete. The title wraps in its own
       column instead of pushing anything onto a second line, so a five-item
       list is readable in one screen rather than one item per thumb-scroll.

       This replaced a two-column grid that put the delete button on its own
       row under the title and vertically centred the tick across both. With
       delete inflated to a full 44x44 red button by the touch-target pass, one
       subtask stood 140px tall to show one line of text, and the tick no longer
       lined up with the title it belonged to. */
    .subtask-list .subtask-item {
        display: grid;
        grid-template-columns: auto 1fr auto;
        column-gap: 12px;
        row-gap: 2px;
        align-items: center;
        padding: 6px 10px;
    }
    .subtask-list .subtask-check {
        grid-column: 1;
        grid-row: 1;
    }
    .subtask-list .subtask-check input[type="checkbox"] { width: 22px; height: 22px; }
    /* min-width: 0 on both column-2 children is load-bearing, not tidying. A
       `1fr` track resolves to minmax(auto, 1fr), and `auto` means min-content,
       so a single child that refuses to wrap sets the floor for the whole
       column. A subtask with five people on it made .subtask-assignees 332px
       of unwrappable text, which took the row to 448px, which took the modal
       past a 390px screen and clipped the notes, the blocked-by list and every
       other section mid-word. Nothing scrolled, because the modal hides
       overflow, so the only symptom was text running off the right edge. */
    .subtask-list .subtask-title-link {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: anywhere;
        line-height: 1.35;
        font-size: 14px;
        padding: 4px 0;
    }
    /* Assignees, when there are any, tuck under the title rather than
       competing with it for the same line on a 390px screen. */
    .subtask-list .subtask-meta {
        grid-column: 2;
        grid-row: 2;
        min-width: 0;
        justify-content: flex-start;
    }
    /* Wrap rather than run off the screen. A whole crew on one subtask is two
       lines here; keeping it to one line is what caused the overflow. */
    .subtask-list .subtask-assignees {
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .subtask-list .subtask-delete {
        grid-column: 3;
        grid-row: 1;
    }
    .subtask-done-toggle,
    .subtask-add-btn {
        min-height: 44px;
        padding: 4px 12px;
    }

    /* The edit form keeps its flex row, but the row has to be at least as tall
       as the hit area it contains. At its natural 41px each delete zone
       overhung its neighbours by 3px, and the one painted last silently wins a
       tap meant for the row above. */
    #edit-subtask-list .subtask-item {
        padding: 6px 10px;
        min-height: 44px;
    }
    /* The visible × stays 28px so it does not read as the row's main action,
       and grows an invisible 44x44 hit area the way .pin-marker does. 8px of
       overhang into a 12px column gap leaves 4px of clear space, so this zone
       sits beside the title's rather than on top of it.

       Not scoped to .subtask-list: the edit form renders the same row outside
       it, and a 28px delete with no expanded hit area there would quietly drop
       below the 44px minimum this whole block exists to enforce. */
    .subtask-delete::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 44px;
        height: 44px;
        transform: translate(-50%, -50%);
    }

    /* Bigger × on tag pills so gloved fingers can hit them */
    .tag-pill button,
    .tag-pill-editable button {
        min-width: 28px;
        min-height: 28px;
        padding: 4px 8px !important;
        font-size: 18px !important;
        line-height: 1 !important;
    }

}

@media (max-width: 480px) {
    .nav-tabs { gap: 0; }
}

/* --- Photos --- */
.photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

/* Tile plus its caption. The tile itself is a fixed square with overflow
   hidden and four overlay controls on it, so the date needs its own row
   underneath rather than a slot inside. */
.photo-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
    /* Pinned, not merely sized: a flex item's min-width is auto, so a caption
       wider than the tile would otherwise stretch the cell and knock every
       tile beside it out of the grid. */
    flex: 0 0 100px;
    width: 100px;
    min-width: 0;
    max-width: 100px;
}

/* The optional title a person typed. Sits above the date on image tiles;
   document tiles show it in place of the filename inside the thumb itself. */
.photo-cell-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    line-height: 1.3;
    width: 100%;
    /* A title is free text and may well be one long unbroken token. */
    overflow-wrap: anywhere;
    /* Two lines, then ellipsis: a 100px column cannot show much, and letting a
       long title grow unbounded would misalign every tile beside it. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.photo-cell-caption {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.photo-cell-date {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Quiet until the tile is hovered or the control is focused, so a grid of
   photos does not read as a grid of buttons. Always visible on touch, where
   there is no hover to reveal it. */
.photo-title-btn {
    background: none;
    border: 0;
    padding: 0 2px;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 11px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.photo-cell:hover .photo-title-btn,
.photo-title-btn:focus-visible {
    opacity: 1;
}

.photo-title-btn:hover {
    color: var(--accent);
}

@media (hover: none) {
    .photo-title-btn {
        opacity: 1;
        /* The project's 44px touch minimum, without pushing the caption row
           taller: the padding overflows the flex line rather than growing it. */
        padding: 12px 10px;
        margin: -12px 0;
    }
}

.photo-thumb {
    width: 100px;
    height: 100px;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color var(--transition);
}

.photo-thumb:hover { border-color: var(--accent); }

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
/* The image's click target, a button so it is reachable by keyboard. It is
   the thumbnail's whole face; the lock, export and delete buttons sit on top. */
.photo-thumb-open {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: inherit;
    line-height: 0;
    cursor: pointer;
}

.photo-thumb-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.photo-thumb:hover .photo-thumb-delete { opacity: 1; }
.photo-thumb-delete:hover { background: var(--priority-urgent); }

.photo-thumb-save {
    position: absolute;
    top: 4px;
    right: 30px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}
.photo-thumb:hover .photo-thumb-save,
.file-thumb:hover .photo-thumb-save { opacity: 1; }
.photo-thumb-save:hover { background: var(--accent); }

.file-thumb {
    width: 100px;
    height: 100px;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    gap: 4px;
    padding: 0;
}
/* The file's click target, a button; lock and delete stay siblings, since a
   button may not contain a button. */
.file-thumb-open {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 100%;
    padding: 8px;
    border: 0;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: 11px;
    line-height: 1.3;
    cursor: pointer;
}
.file-thumb:hover { border-color: var(--accent); }
.file-thumb-icon { font-size: 28px; line-height: 1; }
.file-thumb-name {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.file-thumb:hover .photo-thumb-delete { opacity: 1; }

/* A touch screen has no hover, so the tile's buttons are always shown there,
   and larger on a phone. This sits after the base rules on purpose: the same
   declarations used to live in the phone block far above them, where the
   base rules, coming later at equal weight, overrode every one. Save and
   delete were invisible on a phone until the tile was tapped, and a tap
   opens the file. */
/* And for a keyboard: a focused button that stays invisible is no button. */
.photo-thumb-delete:focus-visible,
.photo-thumb-save:focus-visible { opacity: 1; }
@media (max-width: 768px), (hover: none) {
    .photo-thumb-delete,
    .photo-thumb-save { opacity: 1; }
}
@media (max-width: 768px) {
    /* 30px, not 32: a 100px tile also carries the 24px padlock on its left. */
    .photo-thumb-delete { width: 30px; height: 30px; font-size: 16px; }
    .photo-thumb-save { width: 30px; height: 30px; font-size: 14px; right: 36px; }
    /* The always-shown buttons sit along the top; the icon moves below them. */
    .file-thumb-open { justify-content: flex-start; padding-top: 38px; }
}

.photo-visibility-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    line-height: 1;
}
.photo-visibility-btn.restricted { background: rgba(var(--private-rgb), 0.7); }
.photo-visibility-indicator {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 13px;
    line-height: 1;
    background: rgba(var(--private-rgb), 0.7);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.restricted-file { outline: 2px solid rgba(var(--private-rgb), 0.5); outline-offset: -2px; }

.file-visibility-prompt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: rgba(var(--private-rgb), 0.12);
    border: 1px solid rgba(var(--private-rgb), 0.3);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text);
}
.file-visibility-prompt span { flex: 1; }

.photo-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition);
}

.photo-upload-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: var(--z-lightbox);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 52px 16px 16px;
    cursor: pointer;
    overflow-y: auto;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
    cursor: default;
}

/* Shrink-wraps the rendered image so pin offsets, which are percentages, are
   measured against the photo and not against the letterboxed overlay. */
.lightbox-stage {
    position: relative;
    line-height: 0;
    max-width: min(92vw, 1100px);
    flex: 0 0 auto;
}

/* Previous and next sit between the photo and its details. */
.lightbox-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #fff;
    cursor: default;
    flex: 0 0 auto;
}
.lightbox-nav-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-family: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
.lightbox-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,0.25); }
.lightbox-nav-btn:disabled { opacity: 0.35; cursor: default; }
.lightbox-count { font-size: 13px; min-width: 64px; text-align: center; }

.lightbox-overlay .lightbox-img {
    max-width: 100%;
    max-height: 60vh;
    display: block;
    cursor: default;
}

.lightbox-stage.placing .lightbox-img { cursor: crosshair; }

.pin-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.pin-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--accent-fill);
    color: var(--on-accent);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Extends the tap target to the 44px minimum without growing the visible
   circle, which would swamp the photo it is pointing at. */
.pin-marker::after {
    content: '';
    position: absolute;
    inset: -9px;
    border-radius: 50%;
}

.lightbox-panel {
    width: min(92vw, 1100px);
    max-height: 28vh;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    cursor: default;
    flex: 0 0 auto;
}

/* On a phone the photo gives some height to its details and to the previous
   and next row: 46vh + 34vh + the row and padding fill a 667px screen. After
   the base rules on purpose; above them (where 52vh and 34vh used to sit)
   the base 60vh and 28vh, coming later at equal weight, won. */
@media (max-width: 768px) {
    .lightbox-overlay .lightbox-img { max-height: 46vh; }
    .lightbox-panel { max-height: 34vh; }
}

.lightbox-dates {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 8px;
}

.lightbox-taken {
    color: var(--text);
}

.lightbox-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 1px;
}

.lightbox-filename {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 5px;
    word-break: break-all;
}

.lightbox-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.pin-add-btn {
    background: var(--accent-fill);
    color: var(--on-accent);
    border: none;
    border-radius: var(--radius);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 36px;
}

.pin-add-btn.active { background: var(--danger); }
.pin-add-btn[hidden] { display: none; }

.pin-hint { font-size: 12px; color: var(--text-dim); }

.pin-legend {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pin-legend-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 4px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.pin-legend-item.focused { background: var(--accent-alpha); border-radius: var(--radius); }

.pin-legend-num {
    flex: 0 0 auto;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-fill);
    color: var(--on-accent);
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pin-legend-text { flex: 1 1 auto; word-break: break-word; }
.pin-legend-author { flex: 0 0 auto; font-size: 11px; color: var(--text-dim); }

.pin-legend-action {
    flex: 0 0 auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 11px;
    padding: 3px 8px;
    cursor: pointer;
}

.pin-legend-action:hover { border-color: var(--accent); color: var(--accent); }
.pin-legend-action.danger:hover { border-color: var(--danger); color: var(--danger); }

.pin-legend-empty { font-size: 12px; color: var(--text-dim); padding: 4px; }

.photo-pin-badge {
    position: absolute;
    left: 4px;
    bottom: 4px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: var(--pill-sm-size);
    font-weight: 600;
    border-radius: var(--radius-pill);
    padding: 1px 6px;
    pointer-events: none;
}

.prompt-input {
    width: 100%;
    margin: 10px 0 4px;
    padding: 8px 10px;
    background: var(--bg-input, var(--bg-card-secondary));
    color: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 14px;
    resize: vertical;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
}

/* Loading spinner */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 48px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Task Checkbox --- */
.task-checkbox-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.task-checkbox-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* --- Mobile Task Card --- */
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    position: relative;
    transition: background var(--transition), border-color var(--transition);
    overflow: hidden;
}

.task-card.compact {
    padding: 6px 10px;
    gap: 2px;
}

.task-card.compact .task-checkbox-cell {
    top: 4px;
    right: 6px;
}

.task-card.compact .task-card-line1 {
    padding-right: 28px;
    gap: 6px;
}

.task-card.compact .task-card-line1 .task-title {
    font-size: 14px;
    line-height: 1.2;
}

.task-card.compact .task-card-line1 .due-dot { margin-top: 4px; }

.task-card.compact .task-card-line2 {
    gap: 6px;
    font-size: 11px;
}

.task-card:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.task-card.overdue { border-left: 3px solid var(--priority-urgent); }

.task-card .task-checkbox-cell {
    position: absolute;
    top: 12px;
    right: 12px;
    /* Above the title, which is lifted over the pills' tap areas: on a
       compact card the two overlap by about 12px of the cell's padding. */
    z-index: 2;
}

.task-card-line1 {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding-right: 40px;
}

.task-card-line1 .due-dot { margin-top: 6px; }

.task-card-line1 .task-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
    /* Above the line below. Its pills grow a 44px invisible tap area (see
       Touch targets), which reached half way up a compact card's title, so
       tapping the middle of the title expanded the subtasks instead of
       opening the task. Where the two overlap, the title wins; the card is
       its own stacking context, so this lifts it over nothing else. */
    position: relative;
    z-index: 1;
}

.task-card { isolation: isolate; }

.task-card-line2 {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    align-items: center;
}

/* --- Dependency Badge --- */
.dep-badge {
    font-size: 12px;
    margin-left: 6px;
    opacity: 0.7;
    vertical-align: middle;
}

/* --- Subtasks Collapse Pill (whole subtask list) & Done Subtasks Collapse Pill (nested) --- */
.subtask-toggle-pill,
.done-toggle-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: var(--pill-sm-pad);
    font-size: var(--pill-sm-size);
    font-weight: 600;
    color: var(--text-secondary, var(--text-muted));
    background: var(--bg-card-secondary, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-pill);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease;
}
.subtask-toggle-pill:hover,
.done-toggle-pill:hover {
    color: var(--text);
    background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}
/* Brighter than the done-toggle-pill it's paired with — it's the primary
   "there's more here" signal now that subtasks are hidden by default. */
.subtask-toggle-pill {
    color: var(--accent);
    border-color: var(--accent);
}
.subtask-toggle-pill:hover {
    color: var(--accent-hover);
    border-color: var(--accent-hover);
}
@media (max-width: 768px) {
    .subtask-toggle-pill,
    .done-toggle-pill {
        font-size: var(--pill-xs-size);
        padding: 3px 8px;   /* roomier than --pill-xs-pad on purpose; see min-height */
        min-height: 22px;
    }
}

/* --- Add Subtask Pill (dashboard row quick action) --- */
.subtask-add-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: var(--pill-sm-pad);
    font-size: var(--pill-sm-size);
    font-weight: 600;
    color: var(--text-secondary, var(--text-muted));
    background: var(--bg-card-secondary, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-pill);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease;
}
.subtask-add-pill:hover {
    color: var(--text);
    background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}
@media (max-width: 768px) {
    .subtask-add-pill {
        font-size: var(--pill-xs-size);
        padding: 3px 8px;   /* roomier than --pill-xs-pad on purpose; see min-height */
        min-height: 22px;
    }
}

/* --- Focus Pill (narrow the list to one task and its subtree) --- */
/* Every property mirrors .subtask-add-pill above, including the fallback in
   var(--bg-card-secondary, ...): that token is only defined inside the
   [data-theme="light"] block, so a bare var() here paints nothing in dark
   mode and looks perfectly correct in the source. */
.focus-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: var(--pill-sm-pad);
    font-size: var(--pill-sm-size);
    font-weight: 600;
    color: var(--text-secondary, var(--text-muted));
    background: var(--bg-card-secondary, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-pill);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease;
}
.focus-pill:hover {
    color: var(--text);
    background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}
/* The one row that is the focus root. Accent-tinted like the subtask toggle,
   because it is the same kind of signal: this row is why you are here. */
.focus-pill.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.15);
}
.focus-pill.active:hover {
    color: var(--accent-hover);
    border-color: var(--accent-hover);
}
@media (max-width: 768px) {
    .focus-pill {
        font-size: var(--pill-xs-size);
        padding: 3px 8px;
        min-height: 22px;
    }
}

/* The "Filtered by" line: phones only, where those filters are out of sight
   behind the filters button. On a wider screen the selects are in view. */
.filter-summary-bar { display: none; }
@media (max-width: 768px) {
    .filter-summary-bar {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        padding: 6px 12px;
        margin-bottom: 10px;
        border: 1px dashed rgba(var(--accent-rgb), 0.4);
        border-radius: var(--radius);
        font-size: 13px;
    }
    .filter-summary-label { color: var(--text-muted); font-weight: 600; }
    .filter-summary-list { flex: 1 1 140px; min-width: 0; color: var(--text); overflow-wrap: anywhere; }
    .filter-summary-clear { min-height: 44px; flex-shrink: 0; }
}

/* --- Focus Bar (first child of #task-list while focused), and the stat-card
   filter bar, which says the same kind of thing about a stat card --- */
.focus-bar,
.stat-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 12px;
    margin-bottom: 10px;
    background: rgba(var(--accent-rgb), 0.15);
    border: 1px solid rgba(var(--accent-rgb), 0.4);
    border-radius: var(--radius);
}
.focus-bar-icon {
    color: var(--accent);
    font-size: 13px;
    line-height: 1;
}
.focus-bar-label,
.stat-filter-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary, var(--text-muted));
}
.focus-bar-title,
.stat-filter-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    /* The title can be long and the bar must never widen the list: html and
       body carry overflow-x: hidden app-wide, so an unclamped title here
       pushes the Show all button off screen with no way to reach it. */
    flex: 1 1 160px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.focus-bar-clear,
.stat-filter-clear {
    flex-shrink: 0;
}
@media (max-width: 768px) {
    /* This one sits in the dashboard list, which the 44px sweep covered. */
    .focus-bar-clear,
    .stat-filter-clear {
        min-height: 44px;
    }
}

.private-icon { font-size: 12px; opacity: 0.7; flex-shrink: 0; }
.private-indicator {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    background: var(--accent-secondary);
    color: var(--on-accent);
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
    vertical-align: middle;
}
.badge-private {
    background: var(--priority-medium);
    color: var(--bg);
    font-size: var(--pill-sm-size);
    padding: var(--pill-sm-pad);
    border-radius: var(--radius-pill);
    font-weight: 600;
    vertical-align: middle;
}

/* --- Bulk Action Bar --- */
.bulk-action-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: var(--z-bar);
    animation: slideUp 200ms ease;
}

.bulk-action-bar select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
}

.bulk-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Activity Feed --- */
.activity-feed-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-top: 20px;
    overflow: hidden;
}

/* The heading wraps the button rather than the other way round: a <button>
   may not contain an <h3>, and this is the shape a disclosure widget wants
   anyway. The h3 keeps the panel in the document outline; the button is the
   part that is operable and carries aria-expanded. */
.activity-feed-header {
    margin: 0;
    font: inherit;
}

.activity-feed-header-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 20px;
    cursor: pointer;
    transition: background var(--transition);
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    line-height: inherit;
    color: var(--text);
    text-align: left;
    background: none;
    border: 0;
    -webkit-appearance: none;
    appearance: none;
}

.activity-feed-header-btn:hover {
    background: var(--bg-card-hover);
}

/* Explicit weight: the arrow now sits inside the header button, which is
   bold, where it used to sit beside the heading and inherit the panel's. */
.activity-feed-toggle {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
}

.activity-feed-body {
    border-top: 1px solid var(--border);
    max-height: 400px;
    overflow-y: auto;
}

/* A <button>, so the audit trail it expands is reachable by Tab. `display:
   flex` is block-level, so it already fills the panel and needs no width.
   The three border sides are zeroed individually and never with the `border`
   shorthand, which would also flatten the border-bottom this rule sets. */
.activity-feed-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(var(--border-rgb),0.5);
    border-top: 0;
    border-right: 0;
    border-left: 0;
    width: 100%;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.activity-feed-item:last-child { border-bottom: none; }
.activity-feed-item:hover { background: var(--bg-card-hover); }

.activity-feed-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.activity-feed-content {
    flex: 1;
    min-width: 0;
}

.activity-feed-task {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-feed-detail {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-feed-meta {
    flex-shrink: 0;
    text-align: right;
}

.activity-feed-actor {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    display: block;
}

.activity-feed-time {
    font-size: 11px;
    color: var(--text-dim);
    display: block;
}

.activity-feed-task-group { border-bottom: 1px solid rgba(var(--border-rgb),0.5); }
.activity-feed-task-group:last-child { border-bottom: none; }
.activity-feed-task-group .activity-feed-item { border-bottom: none; }

.activity-feed-expand-icon {
    font-size: 10px;
    transition: transform var(--transition);
}

.audit-trail {
    padding: 0 20px 12px 56px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.audit-trail-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.audit-trail-icon {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    font-size: 12px;
}

.audit-trail-detail {
    flex: 1;
    color: var(--text);
}

.audit-trail-meta {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
}

/* --- Dependency List (Task Detail) --- */
.dependency-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dependency-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 8px 12px;
}

.dependency-title {
    flex: 1;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: 13px;
    line-height: inherit;
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dependency-title:hover {
    text-decoration: underline;
}

/* --- Subtasks --- */
.subtask-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.subtask-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 8px 12px;
}

.subtask-check {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.subtask-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--accent);
}

.subtask-title-link {
    flex: 1;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: 13px;
    line-height: inherit;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--accent);
    cursor: pointer;
}

.subtask-title-link:hover {
    text-decoration: underline;
}

.subtask-title-link.completed {
    text-decoration: line-through;
    color: var(--text-dim);
}

.subtask-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* The toggle shares the heading's line, so it reads as part of the count it
   qualifies ("3/5 done    Show 3 done"). A flex row rather than a float: a
   floated button pushed the hint paragraph into wrapping around it. */
.subtask-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

/* The 10px gap under the heading moves to the row, or the button's height
   drags the hint further down than every other section's. */
.subtask-section-head h3 {
    margin: 0;
}

/* On a phone the pair drops below the heading as one row, rather than
   stacking and squeezing it. */
.subtask-section-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.subtask-done-toggle,
.subtask-add-btn {
    flex: 0 0 auto;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    color: var(--text-muted);
    padding: 4px 10px;
}

.subtask-done-toggle:hover,
.subtask-done-toggle:focus-visible,
.subtask-add-btn:hover,
.subtask-add-btn:focus-visible {
    color: var(--text);
    border-color: var(--border-focus, var(--accent));
}

/* Delete sits in its own slot rather than inside .subtask-meta, so a subtask
   with no assignees has nothing on the second line and the row stays one line
   tall. It reads as a quiet × until touched: a filled red button repeated down
   a list of five reads as the primary action on each row, which it is not. */
.subtask-delete {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) - 2px);
    background: none;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    position: relative;
}

.subtask-delete:hover,
.subtask-delete:focus-visible {
    color: var(--priority-urgent);
    border-color: var(--priority-urgent);
}

.subtask-assignees {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.subtask-indent {
    --depth: 1;
    margin-left: calc(var(--depth) * 28px);
    border-left: 2px solid var(--border);
    opacity: 0.9;
    position: relative;
}

.subtask-indent::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 10px;
    height: 50%;
    border-bottom: 2px solid var(--border);
}

.subtask-icon {
    color: var(--text-muted);
    font-size: 14px;
}

.task-done {
    opacity: 0.55;
}
.task-done .task-title {
    text-decoration: line-through;
    text-decoration-color: var(--text-muted);
    color: var(--text-muted);
}

.calendar-subtask {
    opacity: 0.8;
    font-size: 11px;
}

.gantt-subtask-label {
    padding-left: calc(12px + var(--depth, 1) * 14px);
    font-size: 12px;
}

.subtask-parent-link {
    border: 0;
    font-family: inherit;
    font-size: 12px;
    line-height: inherit;
    color: var(--accent);
    cursor: pointer;
    margin-bottom: 2px;
}

.subtask-parent-link:hover {
    text-decoration: underline;
}

/* The three always-visible toolbar toggles. "Active" means, respectively: My
   Tasks is filtering, stats are shown, Custom Order is on. Three byte-identical
   rules before this. */
/* .tb-toggle covers Stats, Compact, Archived and Reorder (2026-09-29). Archived
   and Compact had no rule here, and Archived's text swap was its only sign of
   being on; with the label fixed and the phone showing an icon, this is it. */
.my-tasks-toggle.active,
.tb-toggle.active,
#library-reorder-btn.active {
    background: var(--accent-fill);
    color: var(--on-accent);
    border-color: var(--accent);
}

/* --- Push Notification Prompt --- */
.push-prompt {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(var(--accent-rgb),0.12);
    border: 1px solid rgba(var(--accent-rgb),0.3);
    color: var(--text);
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    animation: slideDown 200ms ease;
}

.push-prompt span { flex: 1; }

/* --- Offline Banner --- */
.offline-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--warning-rgb),0.15);
    border: 1px solid rgba(var(--warning-rgb),0.3);
    color: var(--status-on-hold);
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    animation: slideDown 200ms ease;
}

/* --- Status Popup (tap-to-change in task list) --- */
.status-popup {
    position: fixed;
    z-index: var(--z-modal);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    min-width: 150px;
    padding: 4px;
    animation: fadeIn 100ms ease;
}

.status-popup-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    border-radius: calc(var(--radius) - 2px);
}

.status-popup-option:hover { background: var(--bg-card-hover); }
.status-popup-option.active { color: var(--accent); font-weight: 600; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Camera Button --- */
.camera-btn { position: relative; cursor: pointer; }
.camera-btn input[type="file"] { display: none; }

/* --- Swipe Gestures --- */
.task-card { position: relative; }


/* --- Pull to Refresh --- */


/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Notification audit log */
.notification-log-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
}

.notification-log-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: var(--text-sm);
    background: var(--bg-card);
}

.notification-log-row.notif-sent { border-left: 3px solid var(--success); }
.notification-log-row.notif-failed { border-left: 3px solid var(--danger); }
.notification-log-row.notif-pending { border-left: 3px solid var(--warning); }

.notif-channel { font-size: var(--text-md); flex: 0 0 24px; text-align: center; }
.notif-recipient { flex: 1; font-weight: 500; }
.notif-event { flex: 0 0 auto; color: var(--text-muted); font-size: var(--text-xs); }
.notif-status { flex: 0 0 24px; text-align: center; font-size: var(--text-md); }
.notif-time { flex: 0 0 auto; color: var(--text-muted); font-size: var(--text-xs); }

@media (max-width: 768px) {
    .notification-log-row {
        flex-wrap: wrap;
        gap: 4px;
    }
    .notif-event, .notif-time {
        font-size: var(--text-xs);
    }
}

/* ============== Reports view ============== */

.reports-header { margin-bottom: 24px; }

.reports-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 12px;
    background: var(--bg-card-secondary, var(--bg-card));
    border-radius: 8px;
    margin-top: 12px;
}
.reports-filter-bar label { font-size: 13px; color: var(--text-dim); display: flex; gap: 6px; align-items: center; }
.reports-filter-bar input[type="date"],
.reports-filter-bar select { padding: 4px 8px; }

.reports-section {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}
.reports-section h3 { margin: 0 0 12px; font-size: 16px; }

.reports-section-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-dim);
}
.reports-section-controls label { display: flex; gap: 4px; align-items: center; }

.reports-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.reports-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.reports-table th,
.reports-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
}
.reports-table th { color: var(--text-dim); font-weight: 600; font-size: 12px; }
.reports-table a { color: var(--text); text-decoration: none; }
.reports-table a:hover { text-decoration: underline; }
/* Qualifies a cell's value on its own line, e.g. a Last activity date that was
   rolled up from a subtask. Without it a task In Progress for months reads
   "last activity yesterday" with nothing to say why. */
.reports-cell-note {
    display: block;
    color: var(--text-dim);
    font-size: 11px;
}

.reports-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.reports-chart-card {
    background: var(--bg-card-secondary, rgba(255,255,255,0.02));
    padding: 12px;
    border-radius: 6px;
}
.reports-chart-card h4 { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); }

@media (max-width: 768px) {
    .reports-charts { grid-template-columns: 1fr; }
    .reports-section { overflow-x: auto; }
    .reports-table { min-width: 600px; }
}

/* ===== Reference library ===== */
.library-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    margin-bottom: 10px;
    font-size: 14px;
}
.library-crumb {
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    background: none;
    border: 0;
    color: var(--accent);
    padding: 6px 4px;
    min-height: 44px;
    cursor: pointer;
    border-radius: var(--radius);
}
.library-crumb:hover { text-decoration: underline; }
.library-crumb-current {
    color: var(--text);
    font-weight: 600;
    padding: 6px 4px;
}
.library-crumb-sep { color: var(--text-dim); padding: 0 2px; }

.library-list { display: flex; flex-direction: column; gap: 6px; }
.library-row {
    display: flex;
    align-items: stretch;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.library-row-open {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 8px 12px;
    text-align: left;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
    background: none;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    min-width: 0;
}
.library-row-open:hover { background: var(--bg-card-hover); }
.library-row-icon { font-size: 22px; flex-shrink: 0; width: 28px; text-align: center; }
.library-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.library-row-title { font-weight: 600; overflow-wrap: anywhere; }
.library-row-sub { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.library-row-chevron { color: var(--text-dim); font-size: 22px; flex-shrink: 0; }
.library-row-menu { align-self: center; margin-right: 6px; min-width: 44px; min-height: 44px; font-size: 18px; }
.library-row-retired .library-row-title { color: var(--text-muted); }
/* Reorder mode's arrows: side by side, each a 44px target, since arranging
   is done on the same tablets that rejected drag. */
.library-order { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.library-order-btn {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0;
    background: none; border: none; border-radius: var(--radius);
    font-family: inherit; font-size: 14px; line-height: 1;
    color: var(--text-muted); cursor: pointer;
}
.library-order-btn:hover:not(:disabled) { color: var(--text); background: var(--bg-card-hover); }
.library-order-btn:disabled { opacity: 0.25; cursor: default; }
/* On a phone the label would push + Document onto a row of its own; the
   glyph stays, and aria-label keeps the name. */
@media (max-width: 480px) {
    .library-reorder-label { display: none; }
    #library-reorder-btn { min-width: 44px; padding-left: 10px; padding-right: 10px; }
}
.library-retired-badge {
    display: inline-block;
    font-size: var(--pill-xs-size);
    padding: var(--pill-xs-pad);
    border-radius: var(--radius-pill);
    background: rgba(var(--warning-rgb), .15);
    color: var(--warning);
    font-weight: 600;
    vertical-align: middle;
}
.library-picker-list { max-height: 45vh; overflow-y: auto; margin-bottom: 12px; }
.library-actions { display: flex; flex-direction: column; gap: 8px; }
.library-actions .btn { min-height: 44px; justify-content: flex-start; }

.assign-me-btn { align-self: flex-start; margin-bottom: 8px; }

.reference-list { display: flex; flex-wrap: wrap; gap: 6px; }
.reference-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.3;
    padding: 8px 12px;
    min-height: 44px;
    border-radius: var(--radius);
    border: 1px solid rgba(var(--accent-rgb), .4);
    background: rgba(var(--accent-rgb), .15);
    color: var(--accent);
    cursor: pointer;
    text-align: left;
}
.reference-pill:hover { background: rgba(var(--accent-rgb), .2); }
.reference-pill-retired { border-style: dashed; color: var(--text-muted); }
.library-batch { display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow-y: auto; margin-bottom: 8px; }
.library-batch-head { font-size: 13px; color: var(--text-muted); margin: 0 0 4px; }
.library-batch-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.library-batch-row.failed { border-color: var(--danger); }
.library-batch-row.done { opacity: .6; }
.library-batch-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.library-batch-main input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
}
.library-batch-name { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-batch-error { font-size: 12px; color: var(--danger); }
.library-batch-status { font-size: 12px; color: var(--accent); }
.library-batch-ok { color: var(--success); font-size: 18px; padding: 8px 12px; }
.library-batch-drop { min-width: 44px; min-height: 44px; }
.reference-pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }
.reference-pick-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    min-height: 44px;
    border-radius: var(--radius);
    cursor: pointer;
}
.reference-pick-row:hover { background: var(--bg-card-hover); }
.reference-pick-row input { width: 18px; height: 18px; flex-shrink: 0; }
.reference-pick-folder {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    text-align: left;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
    background: none;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
}
.reference-pick-folder:hover { background: var(--bg-card-hover); }
.reference-pick-folder .library-row-main { flex: 1; min-width: 0; }
.reference-pick-crumbs { margin: 0 0 8px; }
.reference-pick-heading { font-size: 12px; color: var(--text-muted); margin: 10px 10px 2px; text-transform: uppercase; letter-spacing: .5px; }
.reference-pick-count { margin-right: auto; font-size: 13px; color: var(--text-muted); align-self: center; }

@media (max-width: 768px) {
    #view-library .search-input { width: 100%; order: 3; }
}

/* The reader and editor for a written document. One overlay, layered like
   the lightbox (it sits above the task modal), never the shared modal. */
.document-reader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: var(--z-lightbox);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
    overflow-y: auto;
}
.document-reader {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 64px);
}
.document-reader-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
}
.document-reader-heading { flex: 1; min-width: 0; }
.document-reader-title { margin: 0; font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.document-reader-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; overflow-wrap: anywhere; }
.document-reader-close {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    margin: -8px -8px 0 0;
    border: 0;
    background: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius);
}
.document-reader-close:hover { color: var(--text); background: var(--bg-card-hover); }
.document-reader-body {
    padding: 16px 20px;
    overflow-y: auto;
    font-size: 15px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.document-reader-body h2 { font-size: 19px; font-weight: 700; margin: 18px 0 8px; }
.document-reader-body h3 { font-size: 16px; font-weight: 700; margin: 16px 0 6px; }
.document-reader-body h2:first-child, .document-reader-body h3:first-child { margin-top: 0; }
.document-reader-body p { margin: 0 0 12px; white-space: pre-wrap; }
.document-reader-body ul, .document-reader-body ol { margin: 0 0 12px; padding-left: 28px; }
.document-reader-body li { margin: 4px 0; padding-left: 4px; }
.document-reader-body li::marker { color: var(--text-muted); }
.document-reader-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.document-reader-actions .btn { min-height: 44px; }
.document-editor-form { padding: 16px 20px; overflow-y: auto; }
.document-editor-form .form-hint code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    padding: 0 3px;
    border-radius: 3px;
    background: var(--bg-input);
}
/* .form-group textarea (0,1,1) sets min-height 80px and out-specifies a
   bare class, so the editor's box is named through its form. */
.document-editor-form .library-editor {
    width: 100%;
    min-height: 40vh;
    resize: vertical;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
}
.library-add-choice { display: flex; gap: 6px; margin-bottom: 14px; }
.library-add-choice-btn {
    flex: 1;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
}
.library-add-choice-btn.active {
    border-color: rgba(var(--accent-rgb), .4);
    background: rgba(var(--accent-rgb), .15);
    color: var(--accent);
}
@media (max-width: 768px) {
    .document-reader-overlay { padding: 0; }
    .document-reader { max-width: none; max-height: none; min-height: 100%; border: 0; border-radius: 0; }
    .document-reader-body, .document-editor-form { padding: 14px 16px; }
    .document-reader-actions { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}


/* === Receipt payment fields (2026-09-24) === */
.receipt-oop {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 12px;
    font-size: 13px;
}
.receipt-oop-flag {
    display: block;
    font-size: var(--pill-xs-size);
    font-weight: 600;
    color: var(--text-muted);
}

/* === Task owner (2026-09-24) ===
   The one assignee chased when a task is overdue. Ringed in the task window's
   summary strip, where assignees are initials; the full name and "(owner)"
   are in the control's title and aria-label. */
.owner-mark {
    border-radius: var(--radius-pill);
    box-shadow: 0 0 0 1.5px var(--accent);
    padding: 0 3px;
}
.owner-choice {
    margin-top: 8px;
}
.owner-choice label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--text-muted);
}
.owner-choice select {
    width: 100%;
}

/* === Focus visibility ===
   There was no global focus ring, and five base rules stripped the UA outline
   without replacing it, leaving only a 1px border-colour change. Those
   `outline: none` declarations are gone; this is the one replacement. Last in
   the file so nothing later un-sets it. WCAG 2.4.7. */

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

/* === Reduced motion ===
   The urgency countdown pill animates `infinite` (the urgent priority dot
   and badge did too, until priority left the board on 2026-10-14). WCAG 2.3.3.
   Deliberately targeted rather than a blanket `* { animation: none }`, which
   would also stop the loading spinner. */
@media (prefers-reduced-motion: reduce) {
    .urgency-critical .countdown-pill {
        animation: none;
    }
}

/* === File visibility dialog ===
   Was inline cssText on a `.modal-box` element that had no rule in this file.
   Now one dialog shared by both entry points, on the .confirm-modal shell. */
.file-visibility-list {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
}

.file-visibility-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    min-height: 32px;
}

/* === Reports thresholds ===
   These three were bare `<input type="number">` with an inline width, so they
   rendered as white UA boxes in the dark UI, the only unstyled fields left. */
.threshold-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.threshold-input {
    width: 64px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 6px 8px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color var(--transition);
}

.threshold-input:focus { border-color: var(--border-focus); }

/* The two date fields in the Reports filter bar are the same defect as the
   thresholds above: bare native inputs in a themed UI. */
.reports-filter-bar input[type="date"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 6px 8px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color var(--transition);
}

.reports-filter-bar input[type="date"]:focus { border-color: var(--border-focus); }

/* Scroll lock while any dialog is open. Without it the page behind an open
   modal scrolls under the user's fingers on a tablet, and a screen reader can
   wander into content the dialog is supposed to be covering. Set and cleared
   by registerDialog/unregisterDialog, which stack, so nested dialogs (lightbox
   over task modal over prompt) only release it once the last one closes. */
body.dialog-open {
    overflow: hidden;
}

/* Empty result inside a Reports table: keeps the table's shape rather than
   leaving a header over nothing, which reads as a failed query. */
.reports-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 18px 8px;
    font-size: var(--text-base);
}

/* === Header menu ===
   Replaces five separate header buttons. Two of them (Help, Password) were
   .hide-mobile, so on a phone Help was reachable only through the settings
   modal: an undiscoverable path to the feature that auto-opens for new users
   precisely because they would not find it. */
.header-menu {
    position: relative;
    display: inline-flex;
}

.header-menu-list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: var(--z-popup);
    min-width: 180px;
    display: flex;
    flex-direction: column;
    padding: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.header-menu-list[hidden] { display: none; }

.header-menu-list button {
    background: none;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: var(--text-base);
    text-align: left;
    padding: 10px 12px;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    white-space: nowrap;
    /* The shop-floor tablet minimum; these are the only route to Help there. */
    min-height: 44px;
}

.header-menu-list button:hover { background: var(--bg-card-hover); }

/* Two Apply buttons exist on the Reports page: the filter bar's, which scopes
   every section, and the Stuck Tasks thresholds, which do not. Naming the
   scope is cheaper than making them look alike and hoping. */
.section-scope-note {
    font-size: var(--text-sm);
    color: var(--text-dim);
}

/* === Receipts ===
   A purchase logged against a task. The row is one button (thumbnail, vendor,
   note, who and when, amount) so the whole thing opens the image, with the
   edit and delete controls as separate buttons beside it rather than nested
   inside, which is not valid button content. */

/* .photo-upload-btn has only ever dressed labels, so it answers font-size and
   nothing else. On a real button the UA supplies the rest through its `font`
   shorthand (a different typeface and line-height: normal) and the control
   silently loses three to five pixels of height with nothing in the diff to
   show it. Answer all three here. */
.receipt-add-btn {
    margin-bottom: 14px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
}

.receipt-total-bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: rgba(var(--accent-rgb), 0.15);
    border: 1px solid rgba(var(--border-rgb), 0.4);
}

.receipt-total-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.receipt-total-amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* Worded modestly on purpose. This figure is filtered by what the person
   reading it is allowed to see, so two people can legitimately read different
   subtotals on the same parent task. "Total spend" would be a claim the
   number cannot support. */
.receipt-subtotal {
    margin-top: 6px;
    font-size: var(--text-sm);
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.receipt-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.receipt-row {
    display: flex;
    align-items: stretch;
    gap: 4px;
}

.receipt-open {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 8px 10px;
    min-height: 44px;
    /* --bg-input, not --bg-card-secondary: that token is defined only inside
       the light-theme block, so an unscoped rule using it paints nothing at
       all in dark mode. */
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: var(--text-sm);
    line-height: 1.4;
}

.receipt-open:hover {
    background: var(--bg-card-hover);
}

.receipt-thumb {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--bg-card-hover);
}

.receipt-thumb-file {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.receipt-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.receipt-vendor {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.receipt-note,
.receipt-meta {
    font-size: var(--text-sm);
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* tabular-nums so a column of amounts lines up on the decimal point. It is
   the one genuinely new typographic need this feature brings. */
.receipt-amount {
    flex: 0 0 auto;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.receipt-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.receipt-action {
    width: 32px;
    flex: 1;
    min-height: 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
}

.receipt-action:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.receipt-action-danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.receipt-save-all { margin-left: 8px; }
.save-files-progress { font-variant-numeric: tabular-nums; }

/* The capture dialog. */
.receipt-form .form-group {
    margin-bottom: 12px;
}

/* Echoes the parsed amount back before Save is reachable. Without it, a
   misread total is only discovered by whoever reconciles the job. */
.receipt-money-echo {
    margin: -6px 0 12px;
    min-height: 16px;
    font-size: var(--text-sm);
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.receipt-money-bad {
    color: var(--warning);
}

.receipt-file-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.receipt-file-row input[type="file"] {
    display: none;
}

.receipt-file-preview {
    margin-top: 8px;
    min-height: 16px;
    font-size: var(--text-sm);
    color: var(--text-dim);
    overflow-wrap: anywhere;
}

.receipt-photo-notes { white-space: pre-line; font-size: 13px; color: var(--text-muted); background: var(--bg-card-secondary, var(--bg-card)); border-radius: var(--radius); padding: 8px 10px; margin: 0 0 10px; text-align: left; overflow-wrap: anywhere; }

@media (max-width: 768px) {
    /* Shop-floor tablets, where the 44px minimum is not negotiable. Stacked
       beside the row the two controls could only reach 36px each, and the
       transparent ::after trick used elsewhere does not rescue this one: two
       targets 4px apart would overlap, and the upper one would silently
       swallow taps meant for the lower. So on a phone the actions wrap onto
       their own line and get the full 44 in both directions. */
    .receipt-row {
        flex-wrap: wrap;
    }
    .receipt-open {
        flex: 1 1 100%;
        min-height: 56px;
    }
    .receipt-actions {
        flex-direction: row;
        margin-left: auto;
    }
    .receipt-action {
        flex: 0 0 auto;
        width: 44px;
        min-height: 44px;
    }
    .receipt-save-all {
        min-height: 44px;
    }
}

/* === Customers (2026-10-14) ===
   One card per customer tag, the board's starting point. A <button>, so it
   answers family, size and line-height itself (the UA font shorthand). */
.customer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 10px;
}
.customer-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    min-height: 44px;
    padding: 12px 14px;
    text-align: left;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}
.customer-card:hover { background: var(--bg-card-hover); }
.customer-card.has-today { border-left-color: var(--priority-high); }
.customer-card.has-overdue { border-left-color: var(--danger); }
.customer-name { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.customer-counts { font-size: 13px; color: var(--text-muted); }
.customer-overdue { color: var(--danger); font-weight: 600; }
.customer-today { color: var(--priority-high); font-weight: 600; }
.customer-next { font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }
.customer-next.overdue { color: var(--danger); }
.customer-choices {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
}
.customer-choice { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 6px; cursor: pointer; }
.customer-choice input { width: 20px; height: 20px; }

/* Live updates (2026-10-14): the open task window changed under someone who
   is typing in it, so it says so instead of rebuilding. */
.live-stale {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 16px 8px;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--text);
    background: rgba(var(--accent-rgb), 0.15);
    border: 1px solid rgba(var(--accent-rgb), 0.4);
    border-radius: var(--radius);
}

/* A help video in a Help window card (showHelp), the card's full width. */
.help-video {
    display: block;
    width: 100%;
    margin-top: 8px;
    border-radius: var(--radius);
    background: #000;
}
