/* Shared application shell: reset, type, header, buttons, forms, badges, tables, gauge, modal.
 *
 * Loaded on every page after tokens.css and before the page's own stylesheet. Everything here was
 * previously copy-pasted across dashboard.css / portal.css / review_queue.css, where it had already
 * begun to drift (.section-title was 13px on one page and 12px on another; .status-badge existed in
 * three places; two pages never defined the reapproval and denied variants at all, so those badges
 * rendered with no background). One definition, three consumers.
 *
 * The signature element is .gauge — see that section. */

/* ── Reset ───────────────────────────────────────────────────────────────────────────────────── */

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

html {
    -webkit-text-size-adjust: 100%;
    /* Root size for the whole rem-based type scale (tokens.css). One knob: at 112.5% the 14px body
       reads at ~16px and every heading/label scales with it. Nudge here to resize the app globally. */
    font-size: 112.5%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--ink-900);
    background-color: var(--surface-sunken);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh; /* iOS: 100vh includes the address bar, so the page overflows */
    display: flex;
    flex-direction: column;
}

img,
svg {
    display: block;
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

/* ── Focus ───────────────────────────────────────────────────────────────────────────────────
 * Nine `outline: none` rules used to strip focus with nothing put back. Keyboard users had no way
 * to see where they were — in an app whose whole purpose is a compliance audit trail. */

:focus-visible {
    outline: var(--focus-width) solid var(--focus-ring);
    outline-offset: var(--focus-offset);
    border-radius: 1px;
}

.on-dark :focus-visible {
    outline-color: var(--focus-ring-dark);
}

/* ── Typography ──────────────────────────────────────────────────────────────────────────────── */

h1,
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--leading-tight);
    letter-spacing: 0.02em;
}

/* A section heading, marked by a short gold tick. The tick is the same mark the gauge puts at a
   baseline — a notch on a scale — so the brand colour appears as ornament rather than as text it is
   too pale to be. */
.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--ink-900);
    margin-bottom: var(--space-4);
}

.section-title::before {
    content: "";
    flex: none;
    width: 2px;
    height: 12px;
    background: var(--brand-gold);
}

.label {
    display: block;
    font-size: var(--text-2xs);
    font-weight: 500;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--ink-600);
    margin-bottom: var(--space-2);
}

.muted {
    color: var(--ink-600);
}

.num {
    font-variant-numeric: tabular-nums;
}

/* Token-spacing / type utilities — the sanctioned way to apply a token where a static inline style
   would otherwise creep in (FI-93). The gauge's runtime custom property stays the one inline style. */
.mt-1 { margin-top: var(--space-1); }
.mt-4 { margin-top: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.text-xs { font-size: var(--text-xs); }

/* ── Header ──────────────────────────────────────────────────────────────────────────────────── */

.app-header {
    background-color: var(--surface-ink);
    padding: var(--space-3) var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.app-header__brand h1 {
    color: var(--brand-gold);
    font-size: var(--text-lg);
    letter-spacing: 0.12em;
}

.app-header__subtitle {
    display: block;
    font-size: var(--text-2xs);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--ink-400);
}

.app-header__right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.app-header__meta {
    font-size: var(--text-xs);
    color: var(--ink-400);
}

/* ── Primary navigation (on the dark header) ─────────────────────────────────────────────────────
 * Cross-page links read as navigation, not buttons: plain text, muted until hovered, with the
 * current page underlined in gold. This is the one place gold carries meaning on the header. */

.app-nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-wrap: wrap;
}

.app-nav__link {
    padding: var(--space-2) var(--space-3);
    border-bottom: 2px solid transparent;
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    color: var(--ink-400);
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.app-nav__link:hover {
    color: var(--ink-on-dark);
}

.app-nav__link[aria-current="page"] {
    color: var(--brand-gold);
    border-bottom-color: var(--brand-gold);
}

/* ── Account menu ────────────────────────────────────────────────────────────────────────────────
 * Identity + the account actions (profile, log out) behind one avatar trigger. The menu is a
 * light-surface popover anchored to the trigger; ui.js toggles it and handles outside-click / Esc. */

.account {
    position: relative;
}

.account__trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--ink-400);
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.account__trigger:hover,
.account__trigger[aria-expanded="true"] {
    border-color: var(--brand-gold);
    color: var(--ink-on-dark);
}

.account__name {
    max-width: 16ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: var(--tracking-caps-tight);
    text-transform: uppercase;
}

.account__caret {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform var(--dur) var(--ease);
}

.account__trigger[aria-expanded="true"] .account__caret {
    transform: rotate(180deg);
}

.account__menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    z-index: 40;
    min-width: 240px;
    padding: var(--space-2);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-pop);
}

.account__id {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2) var(--space-3) var(--space-3);
    margin-bottom: var(--space-2);
    border-bottom: 1px solid var(--line);
}

.account__id-name {
    font-weight: 600;
    color: var(--ink-900);
}

.account__id-role {
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: var(--tracking-caps-tight);
    text-transform: uppercase;
    color: var(--brand-gold-deep);
}

.account__id-contact {
    font-size: var(--text-xs);
    color: var(--ink-600);
    word-break: break-word;
}

.account__logout {
    margin: 0;
}

.account__item {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font: inherit;
    font-size: var(--text-sm);
    text-align: left;
    text-decoration: none;
    color: var(--ink-900);
    cursor: pointer;
}

.account__item:hover {
    background: var(--surface-tint);
}

.account__item--danger {
    color: var(--danger-fg);
}

/* ── Buttons ─────────────────────────────────────────────────────────────────────────────────
 * Previously every button inverted to gold-on-black on hover — and gold was also the active state,
 * so hovering an inactive tab made it look selected. Hover now darkens; active is a filled state. */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 40px;
    padding: 0 var(--space-5);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
        color var(--dur) var(--ease);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.45;
}

.btn--sm {
    min-height: 32px;
    padding: 0 var(--space-3);
}

.btn--block {
    width: 100%;
}

/* Primary — the brand's one high-contrast pairing, gold on near-black at 8.7:1. */
.btn--primary {
    background-color: var(--brand-black);
    color: var(--brand-gold);
}

.btn--primary:not(:disabled):hover {
    background-color: #23262d;
}

.btn--secondary {
    background-color: transparent;
    border-color: var(--line-strong);
    color: var(--ink-900);
}

.btn--secondary:not(:disabled):hover {
    border-color: var(--ink-900);
    background-color: var(--surface-tint);
}

.btn--ghost {
    background: transparent;
    color: var(--ink-600);
    min-height: 32px;
    padding: 0 var(--space-2);
}

.btn--ghost:not(:disabled):hover {
    color: var(--ink-900);
    background-color: var(--surface-tint);
}

.btn--approve {
    background-color: var(--ok-edge);
    color: var(--ink-on-dark);
}

.btn--approve:not(:disabled):hover {
    background-color: #1b5e20;
}

.btn--deny {
    background-color: var(--danger-edge);
    color: var(--ink-on-dark);
}

.btn--deny:not(:disabled):hover {
    background-color: #7f0000;
}

.btn--danger-outline {
    background: transparent;
    border-color: var(--danger-edge);
    color: var(--danger-fg);
}

.btn--danger-outline:not(:disabled):hover {
    background-color: var(--danger-edge);
    color: var(--ink-on-dark);
}

/* Icon-only button (the assistant's mic and its voice toggle). Square, no text padding — its
   accessible name comes from aria-label, so never render one of these without one. */
.btn--icon {
    width: 40px;
    padding: 0;
}

.btn--icon svg {
    width: 20px;
    height: 20px;
}

.btn--ghost.btn--icon {
    width: 32px;
}

.btn--ghost.btn--icon svg {
    width: 18px;
    height: 18px;
}


/* ── Forms ───────────────────────────────────────────────────────────────────────────────────── */

.field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    position: relative;
    min-width: 0;
}

.field > label {
    font-size: var(--text-2xs);
    font-weight: 500;
    letter-spacing: var(--tracking-caps-tight);
    text-transform: uppercase;
    color: var(--ink-600);
}

.field__hint {
    font-size: var(--text-2xs);
    color: var(--ink-600);
}

.input,
.textarea,
.select {
    width: 100%;
    padding: var(--space-2) var(--space-1);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--line-strong);
    font-size: var(--text-base);
    color: var(--ink-900);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--ink-400);
}

/* A field the current role may read but not change (H-9's metric fields for a project manager).
   Readonly rather than hidden or disabled: the value is still worth seeing, and a readonly input
   keeps its place in the tab order and stays announced, which a disabled one does not. */
.input[readonly],
.textarea[readonly] {
    color: var(--ink-600);
    border-bottom-style: dashed;
    cursor: default;
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-bottom-color: var(--ink-900);
    box-shadow: inset 0 -1px 0 var(--ink-900);
}

.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
    outline: var(--focus-width) solid var(--focus-ring);
    outline-offset: var(--focus-offset);
}

.input[aria-invalid="true"] {
    border-bottom-color: var(--danger-edge);
    box-shadow: inset 0 -1px 0 var(--danger-edge);
}

/* A select needs a full box — a bare underline gives no hint that it opens. */
.select {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    background-color: var(--surface);
    cursor: pointer;
}

.textarea {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    min-height: 88px;
    resize: vertical;
}

.required {
    color: var(--brand-gold-deep);
    font-weight: 600;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
}

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

/* A checkable list — one bordered row per option. Shared by the role editor's permission
   checklist (admin) and the director-assignment picker (company page); the trailing slot holds
   whatever each page needs there (a permission key chip, an "inactive" note). */
.check-list {
    display: grid;
    gap: var(--space-1);
}

.check-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.check-row:hover {
    background: var(--surface-tint);
}

.check-row input:disabled {
    cursor: not-allowed;
}

.check-row__label {
    font-size: var(--text-sm);
    color: var(--ink-900);
}

.check-row__note {
    font-size: var(--text-2xs);
    color: var(--ink-600);
}

/* ── Surfaces ────────────────────────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.card--padded {
    padding: var(--space-6);
}

/* An inset block, marked with the same gold notch as .section-title. */
.inset {
    background: var(--surface-tint);
    border-left: 2px solid var(--brand-gold);
    padding: var(--space-4);
}

/* ── Badges ──────────────────────────────────────────────────────────────────────────────────
 * The dot is redundant with the text label on purpose: colour is never the only carrier, and
 * caution-yellow against warning-orange is exactly the pair that converges under deuteranopia. */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: var(--tracking-caps-tight);
    text-transform: uppercase;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.badge--approved {
    color: var(--ok-fg);
    background: var(--ok-bg);
}

.badge--pending {
    color: var(--info-fg);
    background: var(--info-bg);
}

.badge--reapproval {
    color: var(--caution-fg);
    background: var(--caution-bg);
}

.badge--warning {
    color: var(--warn-fg);
    background: var(--warn-bg);
}

.badge--denied {
    color: var(--danger-fg);
    background: var(--danger-bg);
}

.badge--neutral {
    color: var(--ink-600);
    background: var(--surface-sunken);
}

/* ── Role + state chips ──────────────────────────────────────────────────────────────────────
 * Shared by the admin panel and the profile page (FI-138: these lived only in admin.css, so on
 * /profile the role chip and Active pill rendered as bare unstyled text). A role gets a NEUTRAL
 * chip, deliberately not the semantic status badge — a role isn't a safety outcome, and reusing the
 * approval colours would muddy that language. */
.role-chip {
    display: inline-block;
    padding: 2px var(--space-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: var(--tracking-caps-tight);
    text-transform: uppercase;
    color: var(--ink-900);
    white-space: nowrap;
}

.role-chip--admin {
    border-color: var(--ink-900);
    background: var(--ink-900);
    color: var(--ink-on-dark);
}

.state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-xs);
}

.state::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ink-400);
}

.state--active {
    color: var(--ok-fg);
}

.state--active::before {
    background: var(--ok-edge);
}

.state--inactive {
    color: var(--ink-600);
}

/* COI expiry status text — inline "· expired" / "· N days left". Shared by the dashboard register
   and the company detail page (FI-69: these lived only in the index sheet, so the colour silently
   vanished on /company; a two-page component belongs here). */
.coi-expired {
    color: var(--danger-fg);
    font-weight: 600;
}

.coi-warning {
    color: var(--warn-fg);
    font-weight: 600;
}

/* ── Avatar ──────────────────────────────────────────────────────────────────────────────────
 * Initials, not photos — derived from the name, so it costs nothing and can't be mis-set. Shared by
 * the profile page and the admin User Card. */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface-ink);
    color: var(--brand-gold);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-lg);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.avatar--lg {
    width: 64px;
    height: 64px;
    font-size: var(--text-2xl);
}

/* Header account trigger — small enough to sit on the toolbar without crowding the nav. */
.avatar--sm {
    width: 28px;
    height: 28px;
    font-size: var(--text-xs);
}

/* ── Tabs ────────────────────────────────────────────────────────────────────────────────────────
 * Underline tabs for switching panels within a page (the dashboard's Lookup/Add/Overview, the admin
 * panel's Users/Invitations/Activity). Shared here so both pages read identically; each page keeps
 * its own tablist container (the divider and any right-side controls are page layout). The active
 * tab is carried by BOTH the gold underline AND aria-selected — colour is never the only signal. */

.tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: var(--space-3) var(--space-4);
    font: inherit;
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--ink-600);
    cursor: pointer;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.tab:hover {
    color: var(--ink-900);
}

.tab[aria-selected="true"] {
    color: var(--ink-900);
    border-bottom-color: var(--brand-gold);
}

.tab__count {
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--surface-sunken);
    font-size: var(--text-2xs);
    font-variant-numeric: tabular-nums;
    color: var(--ink-900);
}

/* ── Tables ──────────────────────────────────────────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    padding: var(--space-3);
    background: var(--surface);
    border-bottom: 1px solid var(--line-strong);
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--ink-600);
    white-space: nowrap;
}

.table td {
    padding: var(--space-3);
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table tbody tr:hover td {
    background-color: var(--surface-tint);
}

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* A row's primary cell doubles as the control that opens it — as a real button, not a styled
   <strong> with a click handler and 2.4:1 gold text. */
.link-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--ink-900);
    text-align: left;
    text-decoration: underline;
    text-decoration-color: var(--brand-gold);
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
    cursor: pointer;
}

.link-btn:hover {
    color: var(--brand-gold-deep);
}

/* ── Gauge — the signature element ───────────────────────────────────────────────────────────
 * Every routing decision this app makes is a threshold comparison: EMR against 1.0, TRIR and DART
 * against their BLS industry averages. The number alone hides that. "0.85" means little; "0.85,
 * 15% below baseline" is the whole answer.
 *
 * The track is a scale, the notch is the baseline, the bar runs from the notch to the value and is
 * coloured by which side it lands on. Two custom properties are set from JS:
 *
 *     --gauge-fill-start   left edge of the bar, as a percentage
 *     --gauge-fill-width   its width, as a percentage
 *
 * plus data-side="below|above" to pick the colour and the direction it grows from. The graphic is
 * aria-hidden; the adjacent text carries the meaning. */

.gauge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

/* No overflow:hidden — the baseline notch is meant to overhang the track, the way a tick overhangs
   a scale. The fill's position is clamped in JS, so nothing escapes that shouldn't.
   The track uses --line rather than the page background: against a white card the latter is 1.1:1
   and the scale simply disappears, leaving the fill floating in space. */
.gauge__track {
    position: relative;
    flex: none;
    width: 120px;
    height: 8px;
    background: var(--line);
    border-radius: 1px;
}

.gauge__fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--gauge-fill-start, 50%);
    width: var(--gauge-fill-width, 0%);
    background: var(--ink-400);
    animation: gauge-grow 240ms var(--ease) both;
}

.gauge[data-side="below"] .gauge__fill {
    background: var(--ok-edge);
    transform-origin: right center;
}

.gauge[data-side="above"] .gauge__fill {
    background: var(--warn-edge);
    transform-origin: left center;
}

.gauge[data-side="danger"] .gauge__fill {
    background: var(--danger-edge);
    transform-origin: left center;
}

/* The baseline notch. Sits at the midpoint: the value's position is normalised against it, so the
   midpoint is always "industry average" regardless of the units. The halo separates it from the
   fill it abuts — without it the notch reads as a dark cap on the bar rather than a line the bar
   is measured against. */
.gauge__baseline {
    position: absolute;
    top: -3px;
    bottom: -3px;
    left: 50%;
    width: 2px;
    margin-left: -1px;
    background: var(--ink-900);
    box-shadow: 0 0 0 1px var(--surface);
}

/* On a tinted panel — or a hovered table row — the halo has to match what's behind it, not the card. */
.inset .gauge__baseline,
.metrics .gauge__baseline,
.review__grid .gauge__baseline,
.table tbody tr:hover .gauge__baseline {
    box-shadow: 0 0 0 1px var(--surface-tint);
}

.gauge__readout {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    min-width: 0;
}

.gauge__value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: var(--text-base);
}

.gauge__delta {
    font-size: var(--text-xs);
    color: var(--ink-600);
    white-space: nowrap;
}

.gauge[data-side="below"] .gauge__value {
    color: var(--ok-fg);
}

.gauge[data-side="above"] .gauge__value {
    color: var(--warn-fg);
}

.gauge[data-side="danger"] .gauge__value {
    color: var(--danger-fg);
}

/* Table-cell variant: short track, number only. */
.gauge--compact {
    gap: var(--space-2);
}

.gauge--compact .gauge__track {
    width: 68px;
    height: 7px;
}

.gauge--compact .gauge__value {
    font-size: var(--text-sm);
}

/* Hidden from sight in a dense table, but kept for screen readers: in the compact variant the only
   visual cue for which side of the baseline a value fell on is the colour of the number, and colour
   must never be the sole carrier. */
.gauge--compact .gauge__delta {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Review-panel variant: full width, scale end-labels. */
.gauge--wide {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-2) var(--space-4);
    align-items: center;
    width: 100%;
}

.gauge--wide .gauge__track {
    width: 100%;
    height: 10px;
}

/* The number the value is judged against, printed rather than implied. Quieter than the value and
   louder than the delta: a reader checks the comparison here, then reads how far off it was. */
.gauge__against {
    font-size: var(--text-xs);
    color: var(--ink-900);
    white-space: nowrap;
}

/* Hidden with the delta in a table cell — the row has no width for either, and the compact
   variant's job is the number plus its side of the line. */
.gauge--compact .gauge__against {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Headline variant (analytics): the comparison IS the content of its card, not an annotation in a
   row, so the track carries real weight and the readout wraps onto its own line beneath it. */
.gauge--lg {
    display: grid;
    gap: var(--space-2);
    width: 100%;
}

.gauge--lg .gauge__track {
    width: 100%;
    height: 14px;
    border-radius: 2px;
}

.gauge--lg .gauge__baseline {
    top: -4px;
    bottom: -4px;
    width: 3px;
    margin-left: -1.5px;
}

.gauge--lg .gauge__readout {
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
}

.gauge--lg .gauge__value {
    font-size: var(--text-xl);
}

.gauge--lg .gauge__against {
    font-size: var(--text-sm);
}

@keyframes gauge-grow {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

/* ── Modal ───────────────────────────────────────────────────────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(13, 15, 18, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal__card {
    background: var(--surface);
    width: 680px;
    max-width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-modal);
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    background: var(--surface-ink);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    flex: none;
}

.modal__title {
    color: var(--brand-gold);
    font-family: var(--font-display);
    font-size: var(--text-xl);
    letter-spacing: 0.06em;
}

.modal__close {
    background: transparent;
    border: none;
    color: var(--ink-400);
    font-size: var(--text-xl);
    line-height: 1;
    padding: var(--space-1);
    cursor: pointer;
}

.modal__close:hover {
    color: var(--brand-gold);
}

.modal__body {
    padding: var(--space-6);
    overflow-y: auto;
    flex: 1;
}

.modal__footer {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--line);
    flex: none;
}

/* Destructive actions sit apart from the confirming one — DELETE used to be adjacent to SAVE. */
.modal__footer .btn--danger-outline {
    margin-right: auto;
}

/* ── Feedback ────────────────────────────────────────────────────────────────────────────────── */

.alert {
    padding: var(--space-3) var(--space-4);
    border-left: 3px solid;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: var(--text-sm);
}

.alert--error {
    background: var(--danger-bg);
    border-color: var(--danger-edge);
    color: var(--danger-fg);
}

.alert--success {
    background: var(--ok-bg);
    border-color: var(--ok-edge);
    color: var(--ok-fg);
}

.alert--info {
    background: var(--info-bg);
    border-color: var(--info-edge);
    color: var(--info-fg);
}

.alert--caution {
    background: var(--caution-bg);
    border-color: var(--caution-edge);
    color: var(--caution-fg);
}

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-12) var(--space-6);
    text-align: center;
    color: var(--ink-600);
    font-size: var(--text-sm);
}

.empty__mark {
    width: 32px;
    height: 2px;
    background: var(--brand-gold);
}

/* ── Uploaded documents + preview ────────────────────────────────────────────────────────────
 * The file list and its in-page preview frame, rendered by ui.js renderDocuments on both the
 * review queue and the company page (FI-166 — these were two identical copies, .doc-file and
 * .doc-row, one per page stylesheet). The frame is the browser's own PDF/image viewer: no
 * library, no build step. The server marks inline responses same-origin-frameable
 * (Config.CSP_FRAMEABLE_DOC) — without that, X-Frame-Options: DENY blocks even our own frame. */

.doc-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--line);
}

.doc-file:last-child {
    border-bottom: none;
}

.doc-file__name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink-900);
}

.doc-file__actions {
    display: flex;
    gap: var(--space-2);
}

.doc-preview {
    margin-top: var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.doc-preview__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-tint);
    border-bottom: 1px solid var(--line);
}

.doc-preview__title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink-900);
}

.doc-preview__frame {
    display: block;
    width: 100%;
    height: 70vh;
    min-height: 320px;
    border: 0;
    background: var(--surface-sunken);
}

/* The same preview as a dialog (the company page — see ui.js previewIn). It reuses the .modal
   shell wholesale; only the card width and the flush body are specific to holding a document. */
/* Near-full-bleed: a document is read, not glanced at, so the dialog takes the screen it needs. */
.doc-modal {
    padding: var(--space-3);
}

.doc-modal .modal__card {
    width: 1440px;
    max-height: 96vh;
}

.doc-modal .modal__body {
    padding: 0;
    overflow: hidden;
}

.doc-modal .doc-preview__frame {
    height: 86vh;  /* + the header, inside the card's 96vh ceiling */
}

@media (max-width: 640px) {
    .doc-preview__frame,
    .doc-modal .doc-preview__frame {
        height: 55vh;
    }
}

/* ── Trusted contractor (3.8) ────────────────────────────────────────────────────────────────
   Shared by the review queue and the company page (ui.js renderTrustedControl), so the component
   carries layout only — a page adds its own framing (see review_queue.css, where it is a standalone
   callout rather than a card's contents). */

.trusted__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.trusted__body {
    min-width: 0;
}

.trusted__label {
    font-size: var(--text-2xs);
    font-weight: 500;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--ink-600);
    margin-bottom: var(--space-1);
}

.trusted__status {
    font-size: var(--text-sm);
    font-weight: 600;
}

.trusted__status--on {
    color: var(--ok-fg);
}

.trusted__status--off {
    color: var(--ink-600);
}

.trusted__info {
    margin-top: var(--space-3);
    max-width: 62ch;
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--ink-600);
}

/* A <details> toggle rather than a scripted popover: the disclosure, its keyboard handling and
   its screen-reader state are all native, and the copy stays in the DOM for find-in-page. */
.trusted__info > summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--ink-900);
    border-radius: var(--radius-sm);
}

.trusted__info > p {
    margin-top: var(--space-2);
}

.trusted__info > ul {
    margin-top: var(--space-2);
    padding-left: var(--space-5);
    list-style: disc;
}

/* ── Toast ───────────────────────────────────────────────────────────────────────────────────
 * A transient status message pinned to the corner, coloured by the .alert modifier it carries.
 * Shared: any page can drop `.toast .alert .alert--success|error` onto <body>. */

.toast {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 1200;
    max-width: 420px;
    box-shadow: var(--shadow-pop);
    animation: toast-in var(--dur) var(--ease);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@media (max-width: 640px) {
    .toast {
        left: var(--space-4);
        max-width: none;
    }
}

/* ── Utilities ───────────────────────────────────────────────────────────────────────────────── */

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Off-screen until tabbed to — the first stop for a keyboard user, who otherwise has to walk the
   whole header nav on every page load. */
.skip-link {
    position: absolute;
    left: var(--space-2);
    top: -100%;
    z-index: 1100;
    padding: var(--space-2) var(--space-4);
    background: var(--surface);
    color: var(--ink-900);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-pop);
}

.skip-link:focus {
    top: 0;
}

/* ── Motion ──────────────────────────────────────────────────────────────────────────────────── */

@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;
    }
}

/* ── Small screens ───────────────────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .app-header {
        padding: var(--space-3) var(--space-4);
    }

    .app-header__meta {
        display: none;
    }

    .modal__footer {
        flex-wrap: wrap;
    }

    .modal__footer .btn--danger-outline {
        margin-right: 0;
        order: 3;
        width: 100%;
    }
}
