/* ==========================================================================
   Tempo Design System — single source of truth for the whole ERP.
   Consume tokens by name; never hard-code a raw hex or px into a screen.
   Loaded by every layout (ERP, Sprint, Auth) so all screens inherit changes.
   ========================================================================== */

/* Self-hosted IBM Plex (OFL-licensed, see public/fonts/LICENSE.txt) — no
   third-party font CDN request, so no visitor IP is sent to a third party. */
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-400.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-500.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-600.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-700.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/ibm-plex-mono-400.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/ibm-plex-mono-500.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/ibm-plex-mono-600.woff2') format('woff2');
}

:root {
    /* Accent — the one themeable brand color. Layouts inject the configured
       value after this file loads; this is only the fallback default. */
    --accent: #4b48e6;
    --accent-hover: #3d3ad0;
    --accent-tint: color-mix(in srgb, var(--accent) 12%, transparent);
    --accent-ring: color-mix(in srgb, var(--accent) 35%, transparent);
    /* accent-2 is used ONLY where accent is rendered as small/body TEXT on a
       surface (links, active-nav labels) rather than a solid button fill —
       identical to --accent in light mode; dark mode lightens it via
       color-mix so any configured accent stays readable as text on a dark
       surface without needing a second hardcoded brand color. */
    --accent-2: var(--accent);

    /* Neutrals — carry ~95% of the interface. */
    --app-bg: #f4f5f7;
    --surface: #ffffff;
    --sunken: #f0f1f4;
    --column-bg: #f0f1f4; /* alias kept for Sprint board columns */
    --border: #e6e8eb;
    --divider: #eef0f2;
    --text: #101828;
    /* text-2 is darkened slightly from #667085 so it also passes WCAG AA
       (4.5:1) against the --sunken/--column-bg family, not just white — see
       issue #71. */
    --text-2: #636d81;
    /* text-3 is darkened from the original #98a2b3 (~2.6:1 on white, WCAG AA
       fail) to meet the 4.5:1 AA minimum against BOTH white and the darker
       --sunken/--column-bg family (the harder case) — see issue #71. */
    --text-3: #666d78;

    /* Semantic — status (always paired with a text label). Colors darkened
       from their original, lower-contrast values to meet WCAG AA (4.5:1)
       against each status's own -bg token — see issue #71. */
    --s-backlog: #666d78;    --s-backlog-bg: #f1f2f4;
    --s-todo: #626c80;       --s-todo-bg: #eef0f3;
    --s-inprogress: #536d9d; --s-inprogress-bg: #eef3fc;
    --s-inreview: #81693e;   --s-inreview-bg: #f9f2e4;
    --s-done: #4a765f;       --s-done-bg: #eaf5ef;

    /* Semantic — priority. */
    --p-urgent: #9b6666;
    --p-high: #dcae78;
    --p-medium: #cbb877;
    --p-low: #98a2b3;

    /* Semantic — feedback. Darkened from their original values (see the
       status block above) to meet WCAG AA against their -bg pairing;
       --danger is additionally dark enough for white text on a solid
       --danger fill (.btn-danger) at 4.5:1+ — see issue #71. */
    --success: #4a765f;  --success-bg: #eaf5ef;  --success-text: #3f7a5c;
    --danger: #9b6666;   --danger-bg: #fbecec;   --danger-text: #a05656;
    --warning: #81693e;  --warning-bg: #f9f2e4;
    --info: #536d9d;     --info-bg: #eef3fc;
    /* danger-solid is the fixed button-fill color for .btn-danger (white
       text on top) — kept separate from --danger (which remaps lighter for
       dark-mode TEXT/badge use) so the button never gets light-on-light. */
    --danger-solid: #9b6666;

    /* Sprint task-type glyph colors (task/bug/story icons). */
    --type-task: #4f7fd6;
    --type-bug: #d64545;
    --type-story: #3f9c6d;

    /* Control surfaces & borders — shaded independently from the base
       neutrals above so buttons/fields can change without touching them. */
    --surface-alt: #f2f3f5;
    --surface-alt-hover: #e7e9ed;
    --field-border: #e0e3e8;
    --field-bg: #f7f8fa;
    --chip-border: #e9ebee;
    --scrollbar-thumb: #d0d3d9;
    --btn-danger-hover: #8c5c5c;
    --on-color: #fff; /* text placed on top of a solid accent/status fill */

    /* Radius scale. */
    --r-chip: 4px;
    --r-button: 6px;
    --r-card: 8px;
    --r-panel: 10px;
    --r-modal: 12px;

    /* Elevation — borders separate; shadows lift on interaction / overlays. */
    --e-rest: 0 1px 1px rgba(16, 24, 40, 0.03);
    --e-hover: 0 2px 8px rgba(16, 24, 40, 0.09);
    --e-popover: 0 3px 10px rgba(16, 24, 40, 0.09);
    --e-modal: 0 24px 60px rgba(16, 24, 40, 0.28);

    /* Motion — fast and functional. */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --dur: 0.14s;

    /* Type. */
    --sans: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* --- Dark theme (issue #73) — a second token set, not a redesign. Toggled
   via [data-theme="dark"] on <html> (see public/js/theme-toggle.js); the
   inline script in each layout's <head> sets it before first paint (no
   FOUC), defaulting to prefers-color-scheme when no saved preference
   exists. Every value below was measured to keep 4.5:1 AA against its
   actual pairing (see docs/accessibility.md). --danger-solid/--btn-danger-
   hover are NOT overridden here on purpose — they're the fixed button-fill
   color that already works with white text in either theme. */
:root[data-theme="dark"] {
    --accent-2: color-mix(in srgb, var(--accent) 65%, white 35%);
    --accent-tint: color-mix(in srgb, var(--accent) 18%, transparent);
    --accent-ring: color-mix(in srgb, var(--accent) 45%, transparent);

    --app-bg: #14161a;
    --surface: #1c1f26;
    --sunken: #22252c;
    --column-bg: #22252c;
    --border: #2c2f37;
    --divider: #262931;
    --text: #e6e8ec;
    --text-2: #9099ad;
    --text-3: #868e9d;

    --s-backlog: #9aa3b5;    --s-backlog-bg: color-mix(in srgb, #9aa3b5 20%, var(--surface));
    --s-todo: #b7becc;       --s-todo-bg: color-mix(in srgb, #b7becc 20%, var(--surface));
    --s-inprogress: #8fabe0; --s-inprogress-bg: color-mix(in srgb, #8fabe0 20%, var(--surface));
    --s-inreview: #d6b06e;   --s-inreview-bg: color-mix(in srgb, #d6b06e 20%, var(--surface));
    --s-done: #7fc9a0;       --s-done-bg: color-mix(in srgb, #7fc9a0 20%, var(--surface));

    --p-urgent: #e08b8b;
    --p-high: #e0b183;
    --p-medium: #d6c98d;
    --p-low: #9aa3b5;

    --success: #7fc9a0;  --success-bg: color-mix(in srgb, #7fc9a0 20%, var(--surface));  --success-text: #7fc9a0;
    --danger: #e08b8b;   --danger-bg: color-mix(in srgb, #e08b8b 20%, var(--surface));   --danger-text: #e08b8b;
    --warning: #d6b06e;  --warning-bg: color-mix(in srgb, #d6b06e 20%, var(--surface));
    --info: #8fabe0;     --info-bg: color-mix(in srgb, #8fabe0 20%, var(--surface));

    --type-task: #8fabe0;
    --type-bug: #e08b8b;
    --type-story: #7fc9a0;

    --surface-alt: #262a32;
    --surface-alt-hover: #2e323b;
    --field-border: #363a44;
    --field-bg: #20232a;
    --chip-border: #363a44;
    --scrollbar-thumb: #3a3e48;

    --e-rest: 0 1px 1px rgba(0, 0, 0, 0.3);
    --e-hover: 0 2px 8px rgba(0, 0, 0, 0.45);
    --e-popover: 0 3px 10px rgba(0, 0, 0, 0.45);
    --e-modal: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* --- Base reset & typography ---------------------------------------------- */
* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--app-bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

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

::selection { background: var(--accent-tint); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 5px; border: 2px solid var(--app-bg); }
::-webkit-scrollbar-track { background: transparent; }

.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }

/* --- Screen-reader-only utility (visually hidden, still announced) -------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Focus-visible (keyboard navigation, WCAG 2.4.7) ----------------------
   Applies only when the browser determines keyboard focus is likely (not on
   mouse/pointer clicks), so it never adds visual noise on click-driven UIs. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-chip);
}
/* Inputs/selects already show a sufficient focus ring via box-shadow. */
.field:focus-visible,
.select:focus-visible,
.auth-card input:focus-visible {
    outline: none;
}

/* --- Reduced motion (WCAG 2.3.3) ------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 15px;
    border: none;
    border-radius: var(--r-button);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    background: var(--accent);
    transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary { color: var(--text-2); background: var(--surface-alt); }
.btn-secondary:hover { background: var(--surface-alt-hover); }

.btn-ghost { color: var(--text-2); background: transparent; font-weight: 500; }
.btn-ghost:hover { background: var(--sunken); color: var(--text); }

.btn-danger { color: var(--on-color); background: var(--danger-solid); }
.btn-danger:hover { background: var(--btn-danger-hover); }

.btn-disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.theme-toggle {
    border: none;
    background: var(--surface-alt);
    color: var(--text-2);
    width: 34px;
    height: 34px;
    border-radius: var(--r-button);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex: none;
}
.theme-toggle:hover { background: var(--surface-alt-hover); }

/* --- Notification bell + panel (issue #57) --------------------------------- */
.notif-bell { position: relative; flex: none; }
.notif-bell__button { position: relative; }
.notif-bell__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger-solid);
    color: var(--on-color);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}
.nav-badge {
    margin-left: auto;
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger-solid);
    color: var(--on-color);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}
.notif-panel {
    position: absolute;
    top: 42px;
    right: 0;
    width: 340px;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-panel);
    box-shadow: var(--e-popover);
    z-index: 100;
    overflow: hidden;
}
.notif-panel[hidden] { display: none; }
.notif-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.notif-panel__mark-all {
    border: none;
    background: none;
    color: var(--accent-2);
    font-size: 12px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
}
.notif-panel__mark-all:hover { text-decoration: underline; }
.notif-panel__list { overflow-y: auto; }
.notif-panel__empty { padding: 20px 14px; margin: 0; color: var(--text-3); font-size: 13px; text-align: center; }
.notif-item {
    display: block;
    padding: 12px 14px;
    border-bottom: 1px solid var(--divider);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--sunken); }
.notif-item.is-unread { position: relative; padding-left: 22px; font-weight: 600; }
.notif-item.is-unread::before {
    content: "";
    position: absolute;
    left: 14px;
    top: 18px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}
.notif-item__time { display: block; margin-top: 2px; color: var(--text-3); font-size: 11px; font-weight: 400; }

/* --- Explainability drill-down links (issue #63) ---------------------------
   A consistent affordance for a figure that decomposes into ledger entries —
   deliberately distinct from `.cell-link` (which navigates to a referenced
   RECORD, e.g. an invoice) so users learn the difference: a dotted underline
   means "this number is a sum, click to see what it's made of". */
.drill {
    color: inherit;
    text-decoration: underline dotted;
    text-decoration-color: var(--text-3);
    text-underline-offset: 3px;
    cursor: pointer;
}
.drill:hover { color: var(--accent-2); text-decoration-color: var(--accent-2); }

/* --- Internal messaging (issue #77) — a simple chat-bubble thread --------- */
.message-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 6px;
}
.message-row { display: flex; }
.message-row--mine { justify-content: flex-end; }
.message-bubble {
    max-width: 70%;
    background: var(--sunken);
    border-radius: var(--r-panel);
    padding: 10px 14px;
}
.message-row--mine .message-bubble { background: var(--accent-tint); }
.message-bubble__meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 11px;
    color: var(--text-3);
    margin-bottom: 4px;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.message-bubble__body { font-size: 13.5px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.message-bubble__attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--accent);
    text-decoration: underline;
}
.message-bubble__status {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 4px;
    text-align: right;
}



/* --- Pagination ------------------------------------------------------------ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}
.pagination__summary { color: var(--text-2); font-size: 13px; }
.pagination__links { display: flex; gap: 10px; }

/* --- Line-item rows (dynamic add/remove, JS-enhanced) ---------------------
   .js-only elements are hidden by default and unhidden by public/js/line-items.js,
   so the form degrades to plain fixed rows without JS. --------------------- */
.js-only { display: none; }
.line-items tfoot td { padding-top: 12px; border-top: 1px solid var(--border); font-weight: 700; }
.row-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--r-button);
    background: transparent;
    color: var(--text-3);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.row-remove:hover { background: var(--sunken); color: var(--danger); }

/* --- Inputs --------------------------------------------------------------- */
.field,
.select {
    height: 36px;
    border: 1px solid var(--field-border);
    border-radius: var(--r-button);
    padding: 0 12px;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--text);
    background: var(--field-bg);
    outline: none;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field:focus,
.select:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-tint);
}
.select { background: var(--surface); cursor: pointer; }

/* --- Badges / pills / chips ----------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: 20px;
}
.badge-backlog { color: var(--s-backlog); background: var(--s-backlog-bg); }
.badge-todo { color: var(--s-todo); background: var(--s-todo-bg); }
.badge-inprogress { color: var(--s-inprogress); background: var(--s-inprogress-bg); }
.badge-inreview { color: var(--s-inreview); background: var(--s-inreview-bg); }
.badge-done { color: var(--s-done); background: var(--s-done-bg); }
.badge-success { color: var(--success); background: var(--success-bg); }
.badge-danger { color: var(--danger-text); background: var(--danger-bg); }
.badge-warning { color: var(--warning); background: var(--warning-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }

.chip {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--text-2);
    background: var(--surface-alt);
    border: 1px solid var(--chip-border);
    padding: 1px 6px;
    border-radius: var(--r-chip);
}

/* --- Scan-driven receiving/picking (issue #129) --------------------------- */
.scan-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.scan-bar input[data-scan-input] {
    max-width: 320px;
}
.scan-status {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}
.scan-status--waiting { color: var(--text-2); }
.scan-status--success { color: var(--success); }
.scan-status--error { color: var(--danger-text); }
.scan-status--done { color: var(--success); font-weight: 600; }
tr.scan-row--current { background: var(--accent-tint); }
tr.scan-row--done td { color: var(--text-3); }
tr.scan-row--error { background: var(--danger-bg); }
.qr-code svg { display: block; }

/* --- Tooltips --------------------------------------------------------------
   Two forms, both dismissible on Escape without moving focus (see
   public/js/tooltip.js, which toggles [data-tooltip-suppressed] — WCAG
   2.1.4/1.4.13) and shown on both hover AND keyboard focus so mouse and
   keyboard users get the same information:

   1. `[data-tooltip="…"]` — a lightweight CSS-only bubble for a control that
      ALREADY has its own accessible name (an icon-only button's
      `aria-label`, a `role="img"` glyph's `aria-label`). Purely a *visual*
      affordance for sighted users; add it to the interactive/labelled
      element itself, never to a bare decorative span.
   2. `.tooltip-info` (+ `<x-tooltip>` Blade component) — a small "info"
      button for supplementary explanation that has no other on-screen
      representation (e.g. what a metric counts, why a threshold applies).
      Its text lives in a real DOM node (`.tooltip-bubble`) wired via
      `aria-describedby`, so screen readers announce it on focus regardless
      of visual hover state.

   Default placement is above the trigger; add `data-tooltip-pos="bottom"`
   for controls near the top edge of the viewport (e.g. the top bar) where
   an upward tooltip would clip. `data-tooltip-wrap` allows a longer,
   left-aligned, wrapped bubble instead of the default single-line one. */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%) translateY(2px);
    background: var(--text);
    color: var(--surface);
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
    padding: 5px 9px;
    border-radius: var(--r-chip);
    box-shadow: var(--e-popover);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
    z-index: 300;
}
[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--text);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) var(--ease);
    z-index: 300;
    pointer-events: none;
}
[data-tooltip][data-tooltip-pos="bottom"]::after {
    bottom: auto; top: calc(100% + 7px); transform: translateX(-50%) translateY(-2px);
}
[data-tooltip][data-tooltip-pos="bottom"]::before {
    bottom: auto; top: calc(100% + 3px);
    border-top-color: transparent; border-bottom-color: var(--text);
}
[data-tooltip][data-tooltip-wrap]::after {
    white-space: normal; width: max-content; max-width: 220px; text-align: left;
}
[data-tooltip]:hover::after, [data-tooltip]:hover::before,
[data-tooltip]:focus-visible::after, [data-tooltip]:focus-visible::before {
    opacity: 1;
    visibility: visible;
}
[data-tooltip]:not([data-tooltip-pos="bottom"]):hover::after,
[data-tooltip]:not([data-tooltip-pos="bottom"]):focus-visible::after {
    transform: translateX(-50%) translateY(0);
}
[data-tooltip][data-tooltip-pos="bottom"]:hover::after,
[data-tooltip][data-tooltip-pos="bottom"]:focus-visible::after {
    transform: translateX(-50%) translateY(0);
}
[data-tooltip][data-tooltip-suppressed]::after,
[data-tooltip][data-tooltip-suppressed]::before {
    opacity: 0 !important;
    visibility: hidden !important;
}

.tooltip-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    flex: none;
    margin-left: 5px;
    border: none;
    border-radius: 50%;
    padding: 0;
    background: var(--surface-alt);
    color: var(--text-3);
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    cursor: help;
    position: relative;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tooltip-info:hover, .tooltip-info:focus-visible { background: var(--accent-tint); color: var(--accent-2); }
.tooltip-info::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--text);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) var(--ease);
    z-index: 300;
    pointer-events: none;
}
.tooltip-bubble {
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%) translateY(2px);
    width: max-content;
    max-width: 240px;
    background: var(--text);
    color: var(--surface);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    text-align: left;
    padding: 8px 10px;
    border-radius: var(--r-chip);
    box-shadow: var(--e-popover);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
    z-index: 300;
}
.tooltip-info[data-tooltip-pos="bottom"] .tooltip-bubble {
    bottom: auto; top: calc(100% + 7px); transform: translateX(-50%) translateY(-2px);
}
.tooltip-info[data-tooltip-pos="bottom"]::before {
    bottom: auto; top: calc(100% + 3px);
    border-top-color: transparent; border-bottom-color: var(--text);
}
.tooltip-info:hover .tooltip-bubble, .tooltip-info:hover::before,
.tooltip-info:focus-visible .tooltip-bubble, .tooltip-info:focus-visible::before {
    opacity: 1;
    visibility: visible;
}
.tooltip-info:not([data-tooltip-pos="bottom"]):hover .tooltip-bubble,
.tooltip-info:not([data-tooltip-pos="bottom"]):focus-visible .tooltip-bubble {
    transform: translateX(-50%) translateY(0);
}
.tooltip-info[data-tooltip-pos="bottom"]:hover .tooltip-bubble,
.tooltip-info[data-tooltip-pos="bottom"]:focus-visible .tooltip-bubble {
    transform: translateX(-50%) translateY(0);
}
.tooltip-info[data-tooltip-suppressed] .tooltip-bubble,
.tooltip-info[data-tooltip-suppressed]::before {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* --- Alerts --------------------------------------------------------------- */
.alert {
    border-radius: var(--r-panel);
    padding: 12px 16px;
    font-size: 13.5px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
}
.alert-success { background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 30%, #fff); color: var(--success-text); }
.alert-danger { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 30%, #fff); color: var(--danger-text); }
.alert-warning { background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 30%, #fff); color: var(--warning); }
.alert-info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 30%, #fff); color: var(--info); }
.alert-list { margin: 8px 0 0; padding-left: 20px; }
/* A link inside an alert must inherit the alert's own already-contrast-
   verified text color -- the generic .cell-link accent color is only
   verified against the app's normal surface/sunken backgrounds, not an
   alert's own tinted background (issue #141 caught this in dark theme). */
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }

/* --- Confirm modal (replaces window.confirm() on destructive actions;
   see public/js/confirm-modal.js) ------------------------------------------ */
.confirm-scrim {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.confirm-scrim[hidden] { display: none; }
.confirm-modal {
    background: var(--surface);
    border-radius: var(--r-modal);
    box-shadow: var(--e-modal);
    width: 380px;
    max-width: calc(100% - 32px);
    padding: 22px;
}
.confirm-modal__message { margin: 0 0 20px; font-size: 13.5px; line-height: 1.5; color: var(--text); }
.confirm-modal__actions { display: flex; justify-content: flex-end; gap: 10px; }

/* --- Shared shell primitives (sidebar/topbar avatar, back-link, actions) --- */
.avatar,
.avatar-sm,
.avatar-xs {
    border-radius: 50%;
    color: var(--on-color);
    background: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex: none;
}
.avatar { width: 30px; height: 30px; font-size: 11px; }
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-xs { width: 18px; height: 18px; font-size: 9px; }

/* --- Page chrome & form layout utilities ----------------------------------
   Shared across ERP/Sprint/Auth screens so views never need inline style. */
.page-actions { display: flex; justify-content: flex-end; margin-bottom: 16px; gap: 10px; }
.page-actions.justify-start { justify-content: flex-start; }
.page-actions.justify-between { justify-content: space-between; }
.inline-actions { display: flex; gap: 10px; align-items: center; }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row + .form-row,
.form-row + .checkbox-row { margin-top: 14px; }
.form-col { flex: 1; min-width: 200px; }
.form-col-lg { flex: 2; min-width: 240px; }
.form-col-narrow { flex: none; min-width: 160px; }
.form-col-max { flex: none; width: 100%; max-width: 360px; }
.field-full,
.select-full { width: 100%; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row label { margin: 0; }
.scroll-list-sm { max-height: 320px; overflow-y: auto; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.gap-24 { gap: 24px; }

/* --- Read-only Kanban-style pipeline board (issue #259 opportunities) -----
   Deliberately separate from public/css/sprint.css's board/column/card
   classes (sprint-only components, see AGENTS.md) -- ERP pages only load
   tempo.css, so this is a small, non-draggable equivalent for grouping
   records by a fixed status/stage into columns. */
.pipeline-board { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; }
.pipeline-column { flex: 1 1 0; min-width: 220px; background: var(--sunken); border-radius: var(--r-panel); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.pipeline-column__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 6px; }
.pipeline-column__title { font-family: var(--mono); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); }
.pipeline-column__count { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.pipeline-column__body { display: flex; flex-direction: column; gap: 8px; min-height: 24px; }
.pipeline-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-panel); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.pipeline-card__title { font-size: 13px; font-weight: 600; }
.pipeline-card__meta { font-size: 12px; color: var(--text-2); }

.kpis-3, .kpis.kpis-3 { grid-template-columns: repeat(3, 1fr); }
.kpis-5, .kpis.kpis-5 { grid-template-columns: repeat(5, 1fr); }
.kpis-6, .kpis.kpis-6 { grid-template-columns: repeat(6, 1fr); }
.kpis-7, .kpis.kpis-7 { grid-template-columns: repeat(7, 1fr); }
.kpis-8, .kpis.kpis-8 { grid-template-columns: repeat(8, 1fr); }
.kpis-10, .kpis.kpis-10 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 0 12px; }
.kpi-status { font-size: 18px; margin-top: 12px; }
.empty-cell { color: var(--text-3); padding: 18px 10px; }
.text-capitalize { text-transform: capitalize; }
.text-muted { color: var(--text-2); }
.text-faint { color: var(--text-3); }
.text-danger { color: var(--danger-text); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.mt-md { margin-top: 14px; }
.mt-lg { margin-top: 22px; }

/* --- Setup wizard (issue #141) ---------------------------------------- */
.setup-template-card {
    border: 1px solid var(--border);
    border-radius: var(--r-panel);
    background: var(--sunken);
    padding: 16px;
    margin-top: 14px;
}

.col-110 { width: 110px; } .col-120 { width: 120px; } .col-150 { width: 150px; }
.col-14 { width: 14%; } .col-16 { width: 16%; } .col-18 { width: 18%; }
.col-34 { width: 34%; } .col-38 { width: 38%; }

/* --- Auth screens (login / forgot-password / reset-password) -------------- */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-modal);
    padding: 28px; box-shadow: var(--e-modal); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth-brand__mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--on-color);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.auth-brand__name { font-weight: 700; font-size: 18px; }
.auth-sub { color: var(--text-2); font-size: 13px; margin: 4px 0 22px; }
.auth-card label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin: 14px 0 6px; }
.auth-card input[type=email],
.auth-card input[type=password] { width: 100%; height: 40px; padding: 0 12px;
    border: 1px solid var(--field-border); border-radius: var(--r-button); font-size: 14px; background: var(--field-bg);
    color: var(--text); outline: none; font-family: var(--sans); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.auth-card input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-tint); }
.auth-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.auth-row.justify-between { justify-content: space-between; }
.auth-row label { margin: 0; }
.auth-forgot-link { font-size: 13px; color: var(--accent-2); }
.auth-card button[type=submit] { width: 100%; height: 42px; margin-top: 20px; border: none; border-radius: var(--r-button);
    background: var(--accent); color: var(--on-color); font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background var(--dur) var(--ease); }
.auth-card button[type=submit]:hover { background: var(--accent-hover); }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; font-size: 12px; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.04em; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-oauth-btn { display: block; width: 100%; height: 42px; line-height: 42px; text-align: center; border-radius: var(--r-button);
    border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600;
    text-decoration: none; transition: background var(--dur) var(--ease); }
.auth-oauth-btn:hover { background: var(--surface-alt); }
.auth-hint { margin-top: 18px; font-size: 12px; color: var(--text-2); text-align: center; }
.auth-hint code { font-family: var(--mono); color: var(--text); background: var(--sunken); padding: 1px 5px; border-radius: var(--r-chip); }
.auth-hint a { color: var(--accent-2); }
.auth-hint a:hover { text-decoration: underline; }

/* --- Custom HTTP error pages (404/403/405/419/500/503 — issue #107) -------
   Reuses .auth-card's centered-card shell; adds a large muted status code
   and a two-button recovery row. Never renders request headers/cookies/
   stack traces — that's the whole point (Laravel only uses these views
   when app.debug is false; when true it shows its own debug view instead,
   which is the scenario this page exists to never be a substitute for). */
.error-card { width: 420px; text-align: center; }
.error-code { font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
    color: var(--text-3); margin-bottom: 10px; }
.error-title { font-size: 20px; margin: 0 0 6px; }
.error-actions { display: flex; gap: 10px; margin-top: 22px; }
.error-actions .btn { flex: 1; }

/* --- Responsive shell: off-canvas sidebar + touch targets (issue #62) ------
   Shared building blocks used by both erp/layout.blade.php and
   sprint/layout.blade.php, which each define the actual `.app`/`.sidebar`/
   `.topbar`/`.content` grid rules (existing per-layout convention) and add
   their own `@media (max-width: 900px)` block that flips the sidebar to this
   fixed/off-canvas mode. Hidden by default; each layout's media query sets
   `display: inline-flex` on `.sidebar-toggle` to reveal it below 900px. */
.sidebar-toggle {
    display: none;
    border: none;
    background: var(--surface-alt);
    color: var(--text-2);
    width: 34px;
    height: 34px;
    border-radius: var(--r-button);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex: none;
}
.sidebar-toggle:hover { background: var(--surface-alt-hover); }

.sidebar-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, 0.45);
    z-index: 190;
}
.sidebar-scrim.is-open { display: block; }

/* Touch-friendly hit areas (≥44px) once a mouse/trackpad-sized pointer isn't
   guaranteed — tablet is the priority target, phone secondary. */
@media (max-width: 900px) {
    .btn, .theme-toggle, .sidebar-toggle, .notif-bell__button {
        min-height: 44px;
    }
    .btn { padding: 0 18px; }
    .field, .select {
        min-height: 44px;
    }
    .nav a {
        min-height: 44px;
    }

    /* Dense tables (ledger, aging, item/vendor lists, …) keep their natural
       column widths — rather than reformatting every list view into cards,
       the table itself becomes its own horizontal-scroll container so a wide
       table never forces the surrounding page to scroll sideways. */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}
