/*
 * Page theme shared by list, view and form pages.
 * Ported from the EHS app's ISO pages (EHSApp incidents/static/incidents/css/spcc.css)
 * with the `spcc-` prefix renamed to `nw-`. Tokens live on :root so the base layout
 * (navbar, sidebar) shares them; page content opts in to the components via `.nw`.
 */
:root {
    --nw-ink: #1f2933;
    --nw-muted: #616e7c;
    --nw-faint: #66727f; /* labels: >=4.5:1 on white and the page background */
    --nw-line: #e3e8ee;
    --nw-canvas: #f3f5f8;
    --nw-page: #fbfbfb;
    --nw-surface: #fff;
    --nw-surface-sunken: #f8fafc;
    --nw-surface-hover: #fafbfc;
    --nw-ink-strong: #0b1220;
    --nw-chrome: #1f2933;
    --nw-chrome-line: rgba(255, 255, 255, .08);
    --nw-focus: 0 0 0 .2rem rgba(240, 168, 48, .45);
    --nw-accent: #f0a830;
    --nw-accent-ink: #8a4f00;
    --nw-ok: #17703d;
    --nw-ok-bg: #dcf3e5;
    --nw-warn: #a15c00;
    --nw-warn-bg: #fff1d6;
    --nw-bad: #b42318;
    --nw-bad-bg: #fde8e7;
    --nw-due: #475467;
    --nw-due-bg: #eef1f5;
    --nw-progress: #1d4ed8;
    --nw-progress-bg: #eef4ff;
    --nw-radius: 10px;
    --nw-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

.nw {
    color: var(--nw-ink);
    padding-bottom: 2rem;
}

/* Browser surfaces themed from the palette */
::selection { background: rgba(240, 168, 48, .35); color: var(--nw-ink-strong); }
.nw .btn:focus-visible, .nw .form-control:focus, .nw .form-select:focus, .nw .form-check-input:focus { border-color: var(--nw-accent); box-shadow: var(--nw-focus); }
.nw a:focus-visible, .nw summary:focus-visible { outline: 2px solid var(--nw-accent); outline-offset: 2px; border-radius: 4px; }
.nw-table, .nw-facts .v, .nw-kv .v { font-variant-numeric: tabular-nums; }
.nw .form-control::placeholder { color: var(--nw-muted); }
.nw .form-control[readonly] { background-color: var(--nw-surface-sunken); }
.nw .v a { color: var(--nw-accent-ink); font-weight: 600; text-underline-offset: 3px; }
/* Row action (Remove) lines up with the inputs, below their labels, not with help text */
@media (min-width: 768px) { .nw-row-action { padding-top: 2rem; } }

/* Required-field marker (django-bootstrap5 required_css_class) */
/* Required-field marker; the empty alt text keeps screen readers from announcing "star" (the input's
   required attribute already conveys it). Older browsers ignore the second declaration. */
.nw .required > .form-label::after { content: " *"; content: " *" / ""; color: var(--nw-bad); }

/* Page header */
.nw-header { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.5rem; }
.nw-crumbs { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .85rem; color: var(--nw-muted); margin-bottom: .35rem; }
.nw-crumbs a { color: var(--nw-accent-ink); text-decoration: none; font-weight: 600; }
.nw-crumbs a:hover { text-decoration: underline; text-underline-offset: 3px; }
.nw-crumbs [aria-hidden] { color: var(--nw-faint); }
.nw-title { font-size: 1.65rem; font-weight: 700; margin: 0; line-height: 1.2; letter-spacing: -.01em; }
.nw-subtitle { color: var(--nw-muted); margin: .25rem 0 0; }
.nw-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.nw .btn { border-radius: 8px; font-weight: 500; }
.nw .btn-accent { background: var(--nw-ink); border-color: var(--nw-ink); color: #fff; }
.nw .btn-accent:hover, .nw .btn-accent:focus { background: var(--nw-ink-strong); border-color: var(--nw-ink-strong); color: #fff; }
.nw .btn-accent .bi { color: var(--nw-accent); }
.nw .btn-quiet { background: var(--nw-surface); border: 1px solid var(--nw-line); color: var(--nw-ink); }
.nw .btn-quiet:hover { background: var(--nw-canvas); color: var(--nw-ink); }
.nw .btn-quiet-danger { background: var(--nw-surface); border: 1px solid var(--nw-line); color: var(--nw-bad); }
.nw .btn-quiet-danger:hover { background: var(--nw-bad-bg); border-color: var(--nw-bad-bg); color: var(--nw-bad); }

/* Cards */
.nw-card { background: var(--nw-surface); border: 1px solid var(--nw-line); border-radius: var(--nw-radius); box-shadow: var(--nw-shadow); }
.nw-card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--nw-line); }
.nw-card-head h2 { font-size: .95rem; font-weight: 600; margin: 0; }
.nw-card-body { padding: 1.1rem; }
.nw-section-label { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--nw-muted); margin: 0 0 .6rem; }
.nw-section-label:not(:first-child) { margin-top: 1.25rem; }

/* Pills & badges */
.nw-pill { display: inline-flex; align-items: center; gap: .35em; padding: .2rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.nw-pill-ok { background: var(--nw-ok-bg); color: var(--nw-ok); }
.nw-pill-issues { background: var(--nw-warn-bg); color: var(--nw-warn); }
.nw-pill-overdue { background: var(--nw-bad-bg); color: var(--nw-bad); }
.nw-pill-due { background: var(--nw-due-bg); color: var(--nw-due); }
.nw-pill-progress { background: var(--nw-progress-bg); color: var(--nw-progress); }
.nw-pill-lg { font-size: .88rem; padding: .35rem .85rem; }
.nw-badge { display: inline-block; padding: .15rem .55rem; border-radius: 6px; font-size: .75rem; font-weight: 600; letter-spacing: .02em; border: 1px solid; color: var(--nw-due); border-color: var(--nw-line); background: var(--nw-canvas); }

/* Inline status select on the requests table, tinted like the status pills */
.nw-status-select { width: auto; min-width: 8.5rem; font-size: .82rem; font-weight: 600; border-radius: 999px; padding: .2rem 2rem .2rem .75rem; border-color: transparent; }
.nw-status-due { background-color: var(--nw-due-bg); color: var(--nw-due); }
.nw-status-progress { background-color: var(--nw-progress-bg); color: var(--nw-progress); }
.nw-status-ok { background-color: var(--nw-ok-bg); color: var(--nw-ok); }
.nw-status-overdue { background-color: var(--nw-bad-bg); color: var(--nw-bad); }

/* Filters */
.nw-filters summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; padding: .85rem 1.1rem; font-weight: 600; }
.nw-filters summary::-webkit-details-marker { display: none; }
.nw-filters summary .chev { margin-left: auto; transition: transform .15s ease; color: var(--nw-muted); }
.nw-filters[open] summary .chev { transform: rotate(180deg); }
.nw-filters[open] summary { border-bottom: 1px solid var(--nw-line); }
.nw-filter-count { background: var(--nw-accent); color: var(--nw-ink-strong); border-radius: 999px; font-size: .72rem; padding: .05rem .5rem; font-weight: 700; }
.nw-filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .9rem 1rem; }
.nw-filter-grid label { font-size: .78rem; font-weight: 600; color: var(--nw-muted); margin-bottom: .25rem; display: block; }
.nw-filter-grid .range { display: flex; gap: .4rem; }
.nw-filter-grid .range input { min-width: 0; }
.nw-filter-grid .wide { grid-column: span 2; }
@media (max-width: 575.98px) { .nw-filter-grid .wide { grid-column: auto; } }
.nw-filter-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* Register table */
.nw-table-wrap { overflow-x: auto; }
.nw-table { font-size: .9rem; }
.nw-table thead th { background: var(--nw-surface-sunken); color: var(--nw-muted); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border-bottom: 1px solid var(--nw-line); white-space: nowrap; padding: .7rem .9rem; }
.nw-table thead th a { color: inherit; text-decoration: none; }
.nw-table thead th a:hover { color: var(--nw-ink); }
.nw-table td { padding: .7rem .9rem; border-color: var(--nw-line); }
.nw-table tbody tr:hover { background: var(--nw-surface-hover); }
.nw-table .nw-col-nowrap { white-space: nowrap; }
.nw-table .nw-col-wide { min-width: 11rem; }
.nw-table-actions td:last-child { white-space: nowrap; text-align: right; }
.nw .table-container .pagination { margin: 1rem 0 .25rem; }

/* Detail facts */
.nw-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.nw-facts > div { padding: .9rem 1.1rem; border-right: 1px solid var(--nw-line); }
.nw-facts > div:last-child { border-right: 0; }
.nw-facts .k { font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--nw-faint); margin-bottom: .2rem; }
.nw-facts .v { font-weight: 600; }
@media (max-width: 767.98px) { .nw-facts > div { border-right: 0; border-bottom: 1px solid var(--nw-line); } }

/* Label/value grid inside cards */
.nw-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .85rem 1.25rem; }
.nw-kv .k { font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--nw-faint); margin-bottom: .15rem; }
.nw-kv .v { overflow-wrap: anywhere; }
.nw-kv .full { grid-column: 1 / -1; }

.nw-tabs { border-bottom: 1px solid var(--nw-line); gap: .25rem; }
.nw-tabs .nav-link { background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--nw-muted); font-weight: 600; border-radius: 0; padding: .6rem .9rem; }
.nw-tabs .nav-link.active { color: var(--nw-ink); border-bottom-color: var(--nw-accent); background: transparent; }

/* Sticky action bar */
.nw-actionbar { position: sticky; bottom: 0; z-index: 20; margin-top: 1.25rem; background: rgba(255, 255, 255, .94); backdrop-filter: saturate(160%) blur(6px); border: 1px solid var(--nw-line); border-radius: var(--nw-radius); box-shadow: 0 -4px 20px -6px rgba(16,24,40,.18); padding: .7rem 1rem; display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.nw-actionbar .status { display: flex; align-items: center; gap: .6rem; margin-right: auto; font-size: .9rem; }
.nw-actionbar .status .hint { color: var(--nw-muted); }
@media (max-width: 575.98px) {
    .nw-actionbar { flex-wrap: nowrap; padding: .5rem .6rem; gap: .4rem; margin-left: -.25rem; margin-right: -.25rem; }
    .nw-actionbar .btn { padding: .35rem .65rem; }
}

/* Prose, numbered steps, repeated sub-rows */
.nw-prose { white-space: normal; }
.nw-prose p:last-child { margin-bottom: 0; }
.nw-docs .row { --bs-gutter-x: .75rem; }
.nw-step { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: 999px; background: var(--nw-ink); color: var(--nw-accent); font-size: .78rem; font-weight: 700; margin-right: .4rem; }
.nw-subrow { border-top: 1px solid var(--nw-line); padding-top: .85rem; margin-bottom: .5rem; }
.nw-subrow:first-of-type { border-top: 0; padding-top: 0; }

/* Document tiles */
.nw-doc { height: 100%; display: flex; flex-direction: column; gap: .5rem; }
.nw-doc-thumb { width: 100%; height: 160px; object-fit: contain; border: 1px solid var(--nw-line); border-radius: 6px; background: var(--nw-canvas); }
.nw-doc-placeholder { width: 100%; height: 160px; border: 1px solid var(--nw-line); border-radius: 6px; background: var(--nw-canvas); color: var(--nw-faint); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }
.nw-doc-name { font-size: .85rem; overflow-wrap: anywhere; }
.nw-doc-actions { margin-top: auto; display: flex; gap: .4rem; }

/* Login */
.nw-login { max-width: 420px; margin: 3rem auto; }

/* Notes list */
.nw-notes { list-style: none; margin: 0; }
.nw-notes li { padding: .65rem 0; border-top: 1px solid var(--nw-line); }
.nw-notes li:first-child { border-top: 0; padding-top: 0; }
.nw-note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .8rem; color: var(--nw-muted); margin-bottom: .2rem; }
.nw-note-meta:empty { display: none; }

/* Base layout chrome (navbar + sidebar) on the shared tokens */
body { background-color: var(--nw-page); }
.nw-chrome { background-color: var(--nw-chrome); }
#main-navbar .navbar-toggler { border-color: var(--nw-chrome-line); }
#main-navbar .navbar-toggler:focus { box-shadow: var(--nw-focus); }
