:root {
    /* Surfaces */
    --canvas: #f4f6f8;
    --surface: #ffffff;
    --surface-alt: #f9fafb;
    --surface-hover: #f3f4f6;

    /* Borders */
    --border: #d1d5db;
    --border-divider: #e5e7eb;
    --border-strong: #9ca3af;

    /* Text */
    --text: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;

    /* Brand */
    --accent: #1f2933;
    --accent-hover: #111827;
    --nellis-red: #700007;
    --nellis-red-hover: #5a0006;
    --nellis-red-soft: rgba(112,0,7,0.08);

    /* Status */
    --status-fill: #16a34a;
    --status-fill-bg: #dcfce7;
    --status-fill-text: #14532d;
    --status-warn: #d97706;
    --status-warn-bg: #fef3c7;
    --status-warn-text: #78350f;
    --status-error: #dc2626;
    --status-error-bg: #fee2e2;
    --status-error-text: #7f1d1d;
    --status-neutral: #6b7280;
    --status-neutral-bg: #f3f4f6;
    --status-neutral-text: #374151;

    /* Effects */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-card-hover: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-focus: 0 0 0 3px rgba(112, 0, 7, 0.15);

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-full: 999px;

    /* Layout — cumulative offsets for sticky positioning */
    --header-height: 60px;
    --sticky-bar-height: 116px;
    --employee-header-height: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI",
                 system-ui, sans-serif;
    background: var(--canvas);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* -------- Top header bar -------- */
.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-divider);
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm);
}
.header-title {
    font-size: 16px; font-weight: 600;
    letter-spacing: -0.01em;
}
.header-user { font-size: 13px; color: var(--text-muted); }

/* -------- Sidebar + content layout -------- */
.layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: calc(100vh - var(--header-height));
}
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border-divider);
    padding: 24px 14px;
    display: flex; flex-direction: column; gap: 2px;
    /* Pinned below the global header; sidebar stays put when content scrolls. */
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    align-self: start;
    overflow-y: auto;
}
.sidebar-section {
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 14px 12px 6px;
}
.sidebar-item {
    display: block;
    padding: 9px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.sidebar-item.active {
    background: var(--nellis-red-soft);
    color: var(--nellis-red);
    font-weight: 600;
}
.content {
    padding: 28px;
    max-width: 1280px;
}
.page-title {
    font-size: 22px; font-weight: 600;
    letter-spacing: -0.015em;
    margin: 0 0 24px;
    color: var(--text);
}

/* -------- Cards -------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border-divider);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
    transition: box-shadow 0.2s ease;
}
.card h2 {
    font-size: 15px; font-weight: 600;
    margin: 0 0 16px;
    letter-spacing: -0.01em;
    color: var(--text);
}
.card h3 {
    font-size: 14px; font-weight: 600;
    margin: 0;
    color: var(--text);
}

/* Section header sits between cards to group them under a heading. */
.section-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 32px 4px 12px;
}

/* Two-column form layout — collapses to one column on narrow screens. */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px 18px;
}

/* Collapsible row (used by Live coaching team mode). Adds a chevron that
   rotates on open + a subtle background shift so the AM can scan which
   row they're currently looking at. Scoped via .details-row so generic
   <details> elements elsewhere (install instructions, fallback panels)
   keep their default browser styling. */
.details-row {
    transition: background 0.15s ease;
}
.details-row > summary {
    cursor: pointer;
    list-style: none;
    position: relative;
    padding-right: 32px;  /* room for the chevron at the right edge */
    border-radius: var(--radius-md);
    transition: background 0.15s ease;
}
.details-row > summary::-webkit-details-marker { display: none; }
.details-row > summary::after {
    content: "▸";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    transition: transform 0.15s ease;
}
.details-row > summary:hover {
    background: var(--surface-hover);
}
.details-row[open] {
    background: var(--surface-alt);
}
.details-row[open] > summary::after {
    transform: translateY(-50%) rotate(90deg);
}
/* Status-coloured KPI snippets, used by the Live coaching row headers
   and the matching KPI pills in the expanded view. Green = on or above
   target; red = needs check-in. */
.kpi-good { color: var(--status-fill, #2d7a2d); font-weight: 600; }
.kpi-bad  { color: var(--status-error, #c33333); font-weight: 600; }

.details-row[open] > summary {
    border-bottom: 1px solid var(--border-divider);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 8px;
    padding-bottom: 10px;
}

/* Tab navigation — used on /coaching/ to switch between Live, Open, Reports. */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-divider);
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.tab {
    padding: 10px 18px;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab-active {
    color: var(--text);
    border-bottom-color: var(--nellis-red);
}

/* Filter row used by gap-analysis / coaching / paylocity-journal home pages.
   Reflows from N columns down to 1 as the viewport narrows. The submit
   button lives on its own row below so it never strands itself on a
   half-empty line when the grid wraps. */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px 16px;
    align-items: end;
}
.filter-shortcuts {
    margin-top: 14px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-submit {
    margin-top: 24px;
}
/* Date pair — start/end on the same row, on its own line below the main
   filter dropdowns. Capped width so two dates don't stretch to fill the
   card; collapses to two natural columns on narrow viewports. */
.filter-date-pair {
    margin-top: 14px;
    display: grid;
    grid-template-columns: minmax(150px, 240px) minmax(150px, 240px);
    gap: 12px;
    align-items: end;
}

/* Inline callout / tip block — softer than .err, more prominent than .info. */
.callout {
    margin-top: 14px;
    padding: 10px 14px;
    background: #fff8e6;
    border: 1px solid #f0c674;
    border-radius: var(--radius-md);
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-secondary);
}
.callout a { color: var(--nellis-red); }

/* -------- Forms -------- */
label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}
label input, label select, input[type="text"], input[type="number"],
input[type="date"], input[type="email"], input[type="password"], select {
    display: block;
    width: 100%;
    padding: 9px 12px;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
label input:hover, label select:hover, input:not([type="radio"]):not([type="checkbox"]):hover, select:hover {
    border-color: var(--border-strong);
}
label input:focus, label select:focus, input:focus, select:focus {
    outline: none;
    border-color: var(--nellis-red);
    box-shadow: var(--shadow-focus);
}
/* Radio + checkbox: inline by nature; reset the block-level rule above. */
label input[type="radio"],
label input[type="checkbox"] {
    display: inline-block;
    width: auto;
    padding: 0;
    margin: 0 8px 0 0;
    border: none;
    vertical-align: middle;
    cursor: pointer;
    accent-color: var(--nellis-red);
}
label.inline {
    display: inline-block;
    margin: 0 20px 0 0;
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
}

/* -------- Buttons -------- */
button {
    padding: 9px 18px;
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease, transform 0.05s ease;
}
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
button.primary {
    background: var(--nellis-red);
    border-color: var(--nellis-red);
}
button.primary:hover {
    background: var(--nellis-red-hover);
    border-color: var(--nellis-red-hover);
}

/* -------- Status banners -------- */
.info {
    padding: 10px 14px;
    background: var(--status-fill-bg);
    color: var(--status-fill-text);
    border: 1px solid var(--status-fill);
    border-radius: var(--radius-md);
    margin-top: 12px;
    font-size: 13px;
}
.err {
    padding: 10px 14px;
    background: var(--status-error-bg);
    color: var(--status-error-text);
    border: 1px solid var(--status-error);
    border-radius: var(--radius-md);
    margin-top: 12px;
    font-size: 13px;
}

/* -------- Tables -------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table th, table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-divider);
    text-align: left;
    vertical-align: top;
}
table thead th {
    background: var(--surface-alt);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-divider);
}
table tbody tr { transition: background 0.1s ease; }
table tbody tr:hover { background: var(--surface-hover); }
table a { color: var(--nellis-red); text-decoration: none; font-weight: 500; }
table a:hover { text-decoration: underline; }

/* -------- Pills (legacy — kept for HR breakdown chips, etc.) -------- */
.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.pill-fill     { background: var(--status-fill-bg);    color: var(--status-fill-text); }
.pill-dontfill { background: var(--status-warn-bg);    color: var(--status-warn-text); }
.pill-manual   { background: var(--status-neutral-bg); color: var(--status-neutral-text); }

.matched-via {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 6px;
    font-weight: 500;
}

/* -------- Sticky filter bar on run-detail pages -------- */
.sticky-bar {
    position: sticky;
    top: var(--header-height);
    z-index: 50;
    background: var(--canvas);
    border-bottom: 1px solid var(--border-divider);
    padding: 14px 0;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.sticky-bar-left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sticky-bar-right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.kpi-pill {
    background: var(--surface);
    border: 1px solid var(--border-divider);
    border-radius: var(--radius-md);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}
.kpi-pill-fill     { border-color: var(--status-fill); color: var(--status-fill-text); }
.kpi-pill-dontfill { border-color: var(--status-warn); color: var(--status-warn-text); }
.kpi-pill-manual   { border-color: var(--border-strong); color: var(--text-secondary); }

/* -------- Filter chips -------- */
.filter-btn {
    display: inline-block;
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.filter-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
}
.filter-btn-active {
    background: var(--nellis-red);
    color: white;
    border-color: var(--nellis-red);
}
.filter-btn-active:hover {
    background: var(--nellis-red-hover);
    color: white;
    border-color: var(--nellis-red-hover);
}

/* -------- Sortable column indicators -------- */
thead th[data-sortable] { cursor: pointer; user-select: none; }
thead th[data-sortable]:hover { background: var(--surface-hover); color: var(--text); }
.sort-indicator {
    font-size: 10px;
    margin-left: 4px;
    color: var(--text-muted);
}

/* -------- Verdict labels (replaces .pill on verdict cells) -------- */
.v {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.v-mir    { color: var(--status-fill); }
.v-ol     { color: var(--status-warn); }
.v-review { color: var(--text-muted); }

.verdict-legend {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding: 8px 12px;
    background: var(--surface-alt);
    border-radius: var(--radius-md);
}

/* -------- Per-employee header (sticky below filter bar) -------- */
.employee-header {
    position: sticky;
    top: var(--sticky-bar-height);
    z-index: 40;
    background: var(--surface);
    padding: 14px 16px;
    margin: -24px -24px 16px;
    border-bottom: 1px solid var(--border-divider);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* -------- Sticky table headers (gap-analysis run detail) -------- */
.gap-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}
.gap-table thead {
    position: sticky;
    top: calc(var(--sticky-bar-height) + var(--employee-header-height));
    z-index: 30;
}
.gap-table thead th {
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border-divider);
    padding: 10px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}
.gap-table td {
    border-bottom: 1px solid var(--border-divider);
    padding: 9px 10px;
}

/* -------- Fill button (write-back to LaborIQ) -------- */
.fill-btn {
    padding: 7px 22px;
    min-width: 80px;
    font-size: 13px;
    font-weight: 600;
    background: var(--nellis-red);
    color: white;
    border: 1px solid var(--nellis-red);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s ease;
}
.fill-btn:hover { background: var(--nellis-red-hover); border-color: var(--nellis-red-hover); }

/* -------- Quick-range shortcut buttons -------- */
.range-shortcut {
    padding: 6px 14px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.range-shortcut:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
}
.range-shortcut-active {
    background: var(--nellis-red);
    color: white;
    border-color: var(--nellis-red);
}
.range-shortcut-active:hover {
    background: var(--nellis-red-hover);
    color: white;
    border-color: var(--nellis-red-hover);
}

/* -------- Outcome labels for help_request resolution -------- */
.outcome-original  { color: var(--status-fill); font-weight: 600; }
.outcome-other     { color: var(--status-warn); font-weight: 600; }
.outcome-notfound  { color: var(--status-error); font-weight: 600; }
.outcome-cancelled { color: var(--text-muted); }
.outcome-pending   { color: var(--text-muted); }

/* -------- Details element (expandable HR view) -------- */
details {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--surface-alt);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-divider);
}
details > summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 2px 0;
    user-select: none;
}
details > summary:hover { color: var(--text); }
details[open] > summary { margin-bottom: 12px; }

/* -------- Links -------- */
a { color: var(--nellis-red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -------- Code blocks -------- */
code {
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", monospace;
    font-size: 12px;
    background: var(--surface-alt);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-divider);
    color: var(--text-secondary);
}
pre {
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", monospace;
    font-size: 12px;
    background: var(--surface-alt);
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-divider);
    overflow-x: auto;
}
pre code {
    background: none; border: none; padding: 0;
}

/* Rendered-markdown content on the /help page. Gives headings, lists, code
   readable spacing inside a .card without affecting app chrome. */
.help-doc h1 { font-size: 20px; font-weight: 600; margin: 0 0 16px; }
.help-doc h2 { font-size: 16px; font-weight: 600; margin: 24px 0 10px; }
.help-doc h3 { font-size: 14px; font-weight: 600; margin: 18px 0 6px; }
.help-doc p,
.help-doc li { font-size: 14px; line-height: 1.6; color: var(--text); }
.help-doc ul,
.help-doc ol { margin: 8px 0 8px 22px; }
.help-doc li { margin: 4px 0; }
.help-doc code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    background: var(--surface-alt);
    padding: 1px 5px;
    border-radius: var(--radius-sm, 4px);
}
.help-doc a { color: var(--nellis-red); }
.help-doc h2:first-child,
.help-doc h1:first-child { margin-top: 0; }
