/* Phone first: the navigation sits at the bottom, and wider screens move it into the header. */
:root {
    --rw-touch-target: 48px;
    --rw-nav-height: 56px;
}

/* Bootstrap's light value is nearly black, so an error would read as ordinary text.
   "only" stops a browser's darken-websites setting from recolouring a page someone chose to have light. */
[data-bs-theme="light"] {
    --bs-danger-text-emphasis: #b02a37;
    color-scheme: only light;
}

main {
    padding-top: 1rem;
    padding-bottom: 1rem;
    overflow-wrap: anywhere;
}

.btn,
.form-control,
.form-select {
    min-height: var(--rw-touch-target);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Bootstrap's outline-light and outline-dark each suit only one page colour, so this one follows the theme. */
.rw-btn-outline {
    --bs-btn-color: var(--bs-emphasis-color);
    --bs-btn-border-color: var(--bs-emphasis-color);
    --bs-btn-hover-color: var(--bs-body-bg);
    --bs-btn-hover-bg: var(--bs-emphasis-color);
    --bs-btn-hover-border-color: var(--bs-emphasis-color);
    --bs-btn-focus-shadow-rgb: var(--bs-emphasis-color-rgb);
    --bs-btn-active-color: var(--bs-body-bg);
    --bs-btn-active-bg: var(--bs-emphasis-color);
    --bs-btn-active-border-color: var(--bs-emphasis-color);
}

/* The page you are on: dimmed as Bootstrap dims a disabled button, with no href and no hover, so it is never
   mistaken for the button under the pointer. Not bold, as a wider button would move the others along. */
.rw-btn-outline[aria-current="page"] {
    opacity: var(--bs-btn-disabled-opacity);
    pointer-events: none;
}

/* A two-way switch: the chosen half is tinted, not filled, so it does not glare in a dark car (batch QA L9). */
.rw-toggle {
    --bs-btn-color: var(--bs-body-color);
    --bs-btn-border-color: var(--bs-gray-600);
    --bs-btn-hover-color: var(--bs-body-color);
    --bs-btn-hover-bg: var(--bs-tertiary-bg);
    --bs-btn-hover-border-color: var(--bs-gray-600);
    --bs-btn-active-color: var(--bs-primary-text-emphasis);
    --bs-btn-active-bg: var(--bs-primary-bg-subtle);
    --bs-btn-active-border-color: var(--bs-primary);
}

.btn-check:checked + .rw-toggle {
    font-weight: 600;
}

/* A labelled group of fields, so a patroller finds one without reading every label. */
.rw-group {
    margin-bottom: 1rem;
    padding: 0.75rem 0.75rem 0.25rem;
    background-color: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
}

.rw-group-title {
    float: none;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bs-primary-text-emphasis);
}

/* What the car carries, read at a glance: green for carried, grey for not, and the word says which. */
.rw-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rw-chip {
    padding: 0.25rem 0.625rem;
    color: var(--bs-secondary-color);
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-pill);
}

.rw-chip-on {
    color: var(--bs-success-text-emphasis);
    background-color: var(--bs-success-bg-subtle);
    border-color: var(--bs-success-border-subtle);
    font-weight: 600;
}

/* Where a log on stands, coloured by state from Bootstrap's variables so both themes keep their contrast. */
.rw-state {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid;
    border-left-width: 0.5rem;
    border-radius: var(--bs-border-radius-lg);
}

.rw-state h1 {
    margin-bottom: 0.25rem;
}

.rw-state-success { color: var(--bs-success-text-emphasis); background-color: var(--bs-success-bg-subtle); border-color: var(--bs-success-border-subtle); }
.rw-state-warning { color: var(--bs-warning-text-emphasis); background-color: var(--bs-warning-bg-subtle); border-color: var(--bs-warning-border-subtle); }
.rw-state-danger { color: var(--bs-danger-text-emphasis); background-color: var(--bs-danger-bg-subtle); border-color: var(--bs-danger-border-subtle); }
.rw-state-secondary { color: var(--bs-body-color); background-color: var(--bs-secondary-bg-subtle); border-color: var(--bs-secondary-border-subtle); }

/* Comms' number in a sentence (PBI 435), in the sentence's own colour, on one line. Its 48 px target reaches over the lines
   above and below, as .rw-icon-button's does, so the sentence keeps even spacing (QA L2); positioned, so the overlap takes taps. */
.rw-comms-phone {
    position: relative;
    display: inline-block;
    padding-block: calc((var(--rw-touch-target) - 1.5em) / 2);
    margin-block: calc((1.5em - var(--rw-touch-target)) / 2);
    color: inherit;
    font-weight: 700;
    white-space: nowrap;
}

/* Bootstrap's own border colour nearly vanishes on the dark page, and is too faint to find a field by. */
.form-control,
.form-select {
    border-color: var(--bs-gray-600);
}

/* The same for a tick box or a switch, which on the light page all but vanished. */
.form-check-input {
    border-color: var(--bs-gray-600);
}

/* Marked by width as well as colour, so an invalid field does not rest on colour alone. */
.form-control.input-validation-error {
    border-width: 2px;
    border-color: var(--bs-danger-text-emphasis);
}

.rw-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--rw-nav-height);
    padding: env(safe-area-inset-top) 0.75rem 0;
    background: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

.rw-brand {
    font-weight: 600;
}

.rw-header > .rw-theme-switch,
.rw-account {
    margin-left: auto;
}

/* Twice the header's gap from the switch, as a stray tap on Sign out costs a retyped password. */
.rw-sign-out {
    margin-left: 0.75rem;
}

/* Who is signed in (PBI 457): a disc with the initials, tinted rather than filled so it does not glare in a dark car. */
.rw-account {
    position: relative;
}

.rw-account-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--rw-touch-target);
    height: var(--rw-touch-target);
    font-weight: 600;
    color: var(--bs-primary-text-emphasis);
    background-color: var(--bs-primary-bg-subtle);
    border: 1px solid var(--bs-primary-border-subtle);
    border-radius: 50%;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.rw-account-icon::-webkit-details-marker {
    display: none;
}

/* The whole disc carries the name on hover, but the layer below does not. */
.rw-account-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* Open is marked by a ring as well as colour. */
.rw-account[open] > .rw-account-icon {
    box-shadow: 0 0 0 2px var(--bs-primary);
}

/* A clear layer over the page while open, part of the disc: a tap anywhere outside the menu closes it and does
   nothing else. iOS Safari sends no click to the page for a tap on plain text, so a script could not see it. */
.rw-account[open] > .rw-account-icon::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1044;
    cursor: default;
}

/* Over the page, so opening it moves nothing under a finger; above the bottom bar and the report's leave panel. */
.rw-account-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: max-content;
    min-width: 13rem;
    max-width: calc(100vw - 1.5rem);
    padding: 0.75rem;
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.3);
}

.rw-account-name {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.rw-account-menu .btn {
    width: 100%;
}

/* 32 px below the theme switch, past a line, as a stray tap on Sign out costs a retyped password (PBI 398, Q1-R1). */
.rw-account-sign-out {
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--bs-border-color);
}

/* A phone keeps :hover after a tap, and this button stays on screen, so it would sit filled in and glare.
   Some Samsung phones wrongly report that they can hover, so a coarse pointer counts too. */
@media (hover: none), (pointer: coarse) {
    .rw-theme-switch {
        --bs-btn-hover-color: var(--bs-btn-color);
        --bs-btn-hover-bg: transparent;
        --bs-btn-hover-border-color: var(--bs-btn-border-color);
    }
}

/* Each word in the switch names the theme it leads to, so the one for the theme already showing is hidden. */
[data-bs-theme="dark"] .rw-theme-switch [data-rw-theme="dark"],
[data-bs-theme="light"] .rw-theme-switch [data-rw-theme="light"] {
    display: none;
}

.rw-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bs-tertiary-bg);
    border-top: 1px solid var(--bs-border-color);
}

.rw-nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--rw-nav-height);
    color: var(--bs-body-color);
    text-decoration: none;
}

/* Marked by a bar as well as colour, as in the light theme this blue is close to the other links' black. */
.rw-nav-link[aria-current="page"] {
    color: var(--bs-primary-text-emphasis);
    font-weight: 600;
    box-shadow: inset 0 3px 0 currentColor;
    cursor: default;
    user-select: none;
}

.rw-with-nav main {
    padding-bottom: calc(var(--rw-nav-height) + env(safe-area-inset-bottom) + 1rem);
}

/* A table squeezed under "anywhere" would break a name part-way through a word. */
.rw-roster-table,
.rw-admin-table {
    overflow-wrap: normal;
}

.rw-roster-today {
    --bs-table-bg-state: var(--bs-primary-bg-subtle);
}

/* Spans wrap between the parts, so a long call sign and an Event Number still fit a phone. */
.rw-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 0.4rem;
    min-height: var(--rw-touch-target);
    padding: 0.25rem 0.75rem;
    text-decoration: none;
    border-bottom: 1px solid var(--bs-border-color);
}

.rw-status-word {
    text-transform: uppercase;
}

/* The line counting entries not sent yet (PBI 500): its longest words, unseen, share one cell with the real ones, so a
   shorter count never shrinks it and moves the page. */
.rw-unsent {
    display: grid;
}

.rw-unsent > * {
    grid-area: 1 / 1;
}

.rw-unsent-space {
    visibility: hidden;
}

/* A card for the user's own live log on wears its strip's colours, framed in the strip's text colour, so it cannot be missed. */
.rw-card-live {
    --bs-card-border-width: 2px;
    --bs-card-border-color: currentColor;
}

/* A solid blue "Today" on that card would catch the eye before the strip's colour, so it takes the card's own. */
.rw-badge-live {
    color: inherit;
    border: 1px solid currentColor;
}

/* A switch on the log on screen is pressed one-handed in a moving car, so it and its words are a touch target tall. Only
   they answer, not the whole line: the line took a hurried second tap where Equipment's Edit had been (owner, Bug 489). */
[data-rw-log-on] .form-check {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    min-height: var(--rw-touch-target);
    margin-bottom: 0;
}

[data-rw-log-on] .form-check-label {
    flex: 0 1 auto;
    padding-block: 0.75rem;
}

/* The sign-in page's eye at the end of the password field (PBI 465): a square touch target, the icon in its middle. */
.rw-show-password {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--rw-touch-target);
}

/* A phone keeps :hover after a tap, which would leave the eye filled whatever it shows (QA L1): hover only with a mouse. */
@media not ((hover: hover) and (pointer: fine)) {
    .rw-show-password {
        --bs-btn-hover-color: var(--bs-btn-color);
        --bs-btn-hover-bg: transparent;
        --bs-btn-hover-border-color: var(--bs-btn-border-color);
    }
}

/* Edge's own eye in a password field, hidden once ours shows (show-password.js), so one eye does the job. */
.rw-has-eye::-ms-reveal {
    display: none;
}

/* A link inside a sentence, kept on one line and as tall as a touch target. */
.rw-inline-target {
    display: inline-block;
    min-height: var(--rw-touch-target);
    line-height: var(--rw-touch-target);
}

/* The app's icons: inline SVG, one partial each (Shared/_Icon<Name>.cshtml), outlines on a 24 unit grid in the colour of
   the text around them, sized with it. No icon library (PBI 460). */
.rw-icon {
    width: 1.25em;
    height: 1.25em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* An icon alone as a button, such as the pencil beside a shift report's finish (PBI 460). Its 48 px target reaches over the
   lines above and below instead of heightening its own, so a table keeps its spacing; positioned, so the overlap takes taps. */
.rw-icon-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--rw-touch-target);
    height: var(--rw-touch-target);
    margin-block: calc((1.5em - var(--rw-touch-target)) / 2);
    padding: 0;
    vertical-align: middle;
    color: var(--bs-link-color);
    background: none;
    border: 0;
}

/* With a mouse only: a phone keeps :hover after a tap. */
@media (hover: hover) and (pointer: fine) {
    .rw-icon-button:hover {
        color: var(--bs-link-hover-color);
    }
}

/* A folded section's heading is a whole touch target, not just its words. */
.rw-disclosure {
    padding-block: 0.75rem;
    cursor: pointer;
}

/* The log on screen's field headings are bold, so each field is found by its name (owner, PBI 449). */
[data-rw-log-on] .form-label {
    font-weight: 700;
}

/* A field still needed is marked by width as well as colour, as the server's own error class is elsewhere. */
[data-rw-log-on] .form-control.is-invalid,
[data-rw-log-on] .form-select.is-invalid {
    border-width: 2px;
}

/* A half-row list has no room for the error icon, which cut "Select a zone" short. The border and note stay (PBI 432). */
[data-rw-log-on] .rw-field-pair .form-select.is-invalid:not([multiple]) {
    --bs-form-select-bg-icon: none;
    padding-right: 2.25rem;
}

/* One line kept under each required field, so a note appearing never moves the page under a press (PBI 450). */
.rw-field-note {
    min-height: 1.25rem;
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

/* A method's fields open below its button. Chrome would hold a field further down still and scroll the buttons off the
   top, so nothing in the form anchors the scroll (QA of 474, M1). */
[data-rw-log-on] {
    overflow-anchor: none;
}

/* "Still needed" keeps its line when empty: scrolled to the bottom, its going moved the button down (PBI 450). */
[data-rw-log-on] [data-rw-missing] {
    min-height: 1.5em;
}

/* The suggested finish: noticed, never the error style (PBI 450). */
.form-control.rw-attention:not(.is-invalid) {
    border-width: 2px;
    border-color: var(--rw-attention);
}

/* Amber that reads as amber: Bootstrap's emphasis shade in the dark, as before; on white, where that shade read as
   brown, a deeper amber, the border at 3.5:1 and the note at 4.8:1 (final QA, L1). */
[data-bs-theme="dark"] {
    --rw-attention: var(--bs-warning-text-emphasis);
}

[data-bs-theme="light"] {
    --rw-attention: #b38000;
}

[data-bs-theme="light"] [data-rw-log-on] [data-rw-note] {
    --bs-warning-text-emphasis: #946c00;
}

/* The patroller's name decides the width of the select, so the two columns stay equal. */
.rw-field-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.75rem;
}

/* The whole strip opens the log on, so the report's link sits beside it and not inside it. */
.rw-status-row {
    display: flex;
}

.rw-status-row .rw-status {
    flex: 1;
    min-width: 0;
}

.rw-status-report {
    display: flex;
    align-items: center;
    padding-inline: 0.75rem;
    font-weight: 600;
    border-bottom: 1px solid var(--bs-border-color);
    border-left: 1px solid var(--bs-border-color);
}

/* So the browser stops scrolling with Save, a vehicle check's note, an entry's editor or its lock line clear of the fixed
   bottom bar (PBI 492, QA M1 and O2-R4). Only where the bar is: the tablet and wide screens have none (O1-R5). */
@media (max-width: 767.98px) {
    .rw-with-nav [data-rw-save-area],
    .rw-with-nav [data-rw-check-answer],
    .rw-with-nav .rw-editor,
    .rw-with-nav [data-rw-editor-locked] {
        scroll-margin-bottom: calc(var(--rw-nav-height) + env(safe-area-inset-bottom) + 0.5rem);
    }
}

/* "Back to the entry" brings the box to the top with its label still showing above it (PBI 437). */
[data-rw-entry-text] {
    scroll-margin-top: 2.5rem;
}

.rw-category-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.5rem;
}

/* Four to a row where the form itself has room for four whole words, so the seven take two rows (owner, 2026-11-13).
   Measured on the form, not the screen: a 900 to 991 px landscape tablet gives the form only about 300 px. */
.rw-category-box {
    container-type: inline-size;
}

/* What a refused Save still needs (PBI 495): the categories outlined in the form's own red, the words box as wide. */
.rw-category-box.rw-invalid {
    border-radius: var(--bs-border-radius);
    outline: 2px solid var(--bs-form-invalid-border-color);
    outline-offset: 0.25rem;
}

[data-rw-entry-form] .form-control.is-invalid,
.rw-editor .form-control.is-invalid {
    border-width: 2px;
}

@container (min-width: 26rem) {
    .rw-category-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.rw-entry-text {
    white-space: pre-wrap;
}

/* The finished report laid out as onPatrol's (PBI 446): the Event Number in a banner, and labels shaded in their column.
   Bootstrap's subtle tones keep both themes readable. */
.rw-report-banner {
    background-color: var(--bs-info-bg-subtle);
    border: 1px solid var(--bs-info-border-subtle);
    border-radius: var(--bs-border-radius);
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
}

.rw-report-header th {
    width: 8.5rem;
    background-color: var(--bs-secondary-bg);
    font-weight: 600;
}

/* An entry's box in onPatrol's fills: blue for "No activity", peach for the rest. The peach is Bootstrap's orange over the
   page's own background, so it darkens with the dark theme; a browser without color-mix gets the warning tone instead. */
.rw-report-entry th {
    width: 8.5rem;
    font-weight: 600;
}

/* On a phone the labels take only their longest word, so the notes keep most of the width (Q1-L1). Without
   `normal`, main's "anywhere" lets a label shrink to one letter a line (R1). */
@media (max-width: 575.98px) {
    .rw-report-header th,
    .rw-report-entry th {
        width: 1%;
        overflow-wrap: normal;
    }
}

.rw-report-entry-quiet {
    --bs-table-bg: var(--bs-info-bg-subtle);
}

.rw-report-entry-event {
    --bs-table-bg: var(--bs-warning-bg-subtle);
}

@supports (background-color: color-mix(in srgb, red, blue)) {
    .rw-report-entry-event {
        --bs-table-bg: color-mix(in srgb, var(--bs-orange) 22%, var(--bs-body-bg));
    }
}

/* A 10-minute position line: set apart from the entries' cards, so it does not read as one. */
.rw-position {
    border-left: 3px solid var(--bs-border-color);
    padding-left: 0.75rem;
}

.rw-track-map {
    height: 260px;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

@media (min-width: 768px) {
    .rw-track-map {
        height: 400px;
    }
}

/* On the report page the map sits beside the shift's card, or under it on the tablet, and must leave the entries in view. */
.rw-report-map .rw-track-map {
    height: 240px;
}

/* The map's line: a full-width 48 px target that also carries the recording notice, so the two take one line, not three.
   The report card's "Shift details" line looks the same, so both read as the same kind of box (PBI 479). */
.rw-track-summary,
.rw-fold-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 48px;
    cursor: pointer;
    list-style: none;
}

.rw-track-summary::-webkit-details-marker,
.rw-fold-summary::-webkit-details-marker {
    display: none;
}

.rw-track-summary::before,
.rw-fold-summary::before {
    content: "\25B8";
}

.rw-track-details[open] > .rw-track-summary::before,
.rw-shift-details[open] > .rw-fold-summary::before {
    content: "\25BE";
}

.rw-track-title,
.rw-fold-title {
    flex: none;
    font-weight: 600;
}

.rw-track-notice {
    font-size: 0.8125rem;
    line-height: 1.25;
    color: var(--bs-secondary-color);
    margin: 0;
}

.rw-track-details[open] > .rw-track-summary {
    margin-bottom: 0.25rem;
}

.rw-track-follow {
    min-height: 48px;
}

/* Zoom buttons a thumb can hit (48 px). One class more than Leaflet's own rule, as leaflet.css loads after this file. */
.rw-track .rw-track-map .leaflet-bar a {
    width: 48px;
    height: 48px;
    line-height: 48px;
    font-size: 1.5rem;
}

/* Popups, zoom buttons and the attribution follow the theme, so nothing on the map glares white in a dark car. */
[data-bs-theme="dark"] .rw-track-map .leaflet-popup-content-wrapper,
[data-bs-theme="dark"] .rw-track-map .leaflet-popup-tip,
[data-bs-theme="dark"] .rw-track .rw-track-map .leaflet-bar a,
[data-bs-theme="dark"] .rw-track .rw-track-map .leaflet-control-attribution {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .rw-track .rw-track-map .leaflet-control-attribution a {
    color: var(--bs-link-color);
}

/* A bright map dazzles a driver at night: the tiles are darkened in the dark theme, the track and dots are not. */
[data-bs-theme="dark"] .rw-track-map .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9);
}

[data-bs-theme="dark"] .rw-track-map {
    background: #1d1f21;
}

/* The waiting line inside the tablet's open map while it has nothing to show, so the map keeps its space (track-map.js). */
.rw-track-waiting {
    position: absolute;
    inset: 0;
    z-index: 450;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    font-family: var(--bs-body-font-family);
    font-size: 0.875rem;
    text-align: center;
    color: var(--bs-secondary-color);
    pointer-events: none;
}

/* Held down to talk, so the browser must not select the word or open its long-press menu under the thumb.
   pan-y lets a swipe that starts here still scroll the page, and the browser then tells the script. */
.rw-record {
    width: 100%;
    min-height: 6rem;
    font-size: 1.5rem;
    font-weight: 600;
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Marked by shape and word as well as colour. Every state is set, as a held button is also :active and :hover. */
.rw-record[aria-pressed="true"] {
    --bs-btn-color: var(--bs-danger-text-emphasis);
    --bs-btn-bg: var(--bs-body-bg);
    --bs-btn-border-color: var(--bs-danger-text-emphasis);
    --bs-btn-hover-color: var(--bs-danger-text-emphasis);
    --bs-btn-hover-bg: var(--bs-body-bg);
    --bs-btn-hover-border-color: var(--bs-danger-text-emphasis);
    --bs-btn-active-color: var(--bs-danger-text-emphasis);
    --bs-btn-active-bg: var(--bs-body-bg);
    --bs-btn-active-border-color: var(--bs-danger-text-emphasis);
    border-width: 0.4rem;
}

/* The message and the words so far take turns in one space kept for two lines, so the box below does not jump. */
.rw-record-lines {
    min-height: 3em;
    margin-block: 0.5rem;
}

/* In italics, with the newest words kept, so they read as what was heard and not as part of the notice. */
.rw-record-heard {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    max-height: 3em;
    overflow: hidden;
    font-style: italic;
}

/* Wide enough for "Not entered" at 360 px, so a blank figure never reads as a cut-off word. */
.rw-hours-input {
    min-width: 8.5rem;
}

/* One line kept free, so the page does not move under a thumb when the location arrives. Every location line fits one
   line from 320 px; "Change it if…" is a line of its own, kept while hidden (PBI 473). */
.rw-location-note {
    min-height: 1.5em;
}

/* The line, then Change location and Undo, above Save, which comes last (PBI 473). */
.rw-location {
    margin-bottom: 0.75rem;
}

.rw-place-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.rw-place-row [data-rw-place-move] {
    min-height: 48px;
}

.rw-place-undo {
    flex: none;
    min-height: 48px;
    padding-inline: 0.5rem;
}

/* The entry's place (PBI 473): the shift's map large over the page, a fixed pin at its centre, while the place is moved. */
.rw-place-frame {
    position: relative;
}

/* Over the bottom bar (1030), the leave panel (1040) and the account menu (1045); under the tablet's dimming cover (2000).
   Nothing behind it takes a touch, and a swipe on the dimmed edge does not scroll the page. */
.rw-place-overlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgb(0 0 0 / 60%);
    overscroll-behavior: contain;
    touch-action: none;
}

/* While the large map is open the page under it does not scroll (entry-place.js). */
html.rw-place-open {
    overflow: hidden;
}

.rw-place-dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 960px;
    max-height: 100%;
    padding: 0.75rem;
    background: var(--bs-body-bg);
    border-radius: var(--bs-border-radius-lg);
}

/* Leaves room for the title and the buttons on a phone turned sideways and under Safari's bars (O2-R1). */
.rw-place-big {
    height: min(70vh, 620px, calc(100vh - 9.5rem));
    height: min(70dvh, 620px, calc(100dvh - 9.5rem));
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.rw-place-overlay-buttons {
    display: flex;
    gap: 0.5rem;
}

.rw-place-overlay-buttons .btn {
    flex: 1 1 0;
    min-height: 48px;
}

/* The entry's pin: fixed at the large map's centre, and on the shift's map where the entry will go (track-map.js). A red
   ring with a white edge, so the route and the entries' dots under it stay in sight, and it does not read as an entry. */
.rw-place-pin,
.rw-entry-pin {
    box-sizing: border-box;
    width: 24px;
    height: 24px;
    border: 4px solid #dc3545;
    border-radius: 50%;
    background: transparent;
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px rgba(0, 0, 0, 0.6), inset 0 0 0 1px #ffffff;
    pointer-events: none;
}

.rw-place-pin {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 500;
    margin: -12px 0 0 -12px;
}

/* One class more than leaflet.css's .leaflet-touch rule, which loads later in the page (O5). */
.rw-place-overlay .rw-place-big .leaflet-bar a {
    width: 48px;
    height: 48px;
    line-height: 48px;
    font-size: 1.5rem;
}

[data-bs-theme="dark"] .rw-place-big .leaflet-bar a,
[data-bs-theme="dark"] .rw-place-big .leaflet-control-attribution {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .rw-place-big .leaflet-control-attribution a {
    color: var(--bs-link-color);
}

/* Darkened at night like the report's own map; the route and the pin are not. */
[data-bs-theme="dark"] .rw-place-big .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9);
}

[data-bs-theme="dark"] .rw-place-big {
    background: #1d1f21;
}

/* Check a vehicle (PBI 441): under Record, one large field, Check beside Close, and the answer under them. */
.rw-vehicle-check {
    margin-bottom: 1rem;
}

.rw-vehicle-check-panel {
    margin-top: 0.75rem;
}

.rw-vehicle-check-plate {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.rw-vehicle-check-buttons {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.5rem;
    margin-block: 0.5rem;
}

/* STOLEN and the plate read at a glance; the two instructions stand apart from the facts above them. */
.rw-stolen-word {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.rw-stolen-plate {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.2;
}

.rw-stolen-orders {
    margin-top: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
}

/* The status page's shift with Report on its right (PBI 497): the text takes the room, and Report drops under it when
   both do not fit, as with very large text, so the page never scrolls sideways (layout QA L2). */
.rw-shift-lead {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0 1rem;
}

.rw-shift-lead > :first-child {
    flex: 1 1 0;
    min-width: min-content;
}

/* Never split, not even at 150 % text on a 360 px phone: normal wrap, not the page's "anywhere", and a size that shrinks
   only when large text would not fit the width (497 layout QA M1). */
.rw-event-number {
    font-size: min(2rem, 12vw);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow-wrap: normal;
}

/* A car's tablet is read at arm's length in a moving car and pressed with a thumb, so everything is larger. */
.rw-tablet-screen {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.rw-tablet-top {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.rw-tablet-call-sign,
.rw-tablet-clock {
    font-size: 2.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* With no connection the last time received would read as the time now. */
.rw-tablet-is-offline .rw-tablet-clock {
    visibility: hidden;
}

.rw-tablet-locked {
    margin-block: 3rem;
    font-size: 1.75rem;
    text-align: center;
}

.rw-tablet-status {
    font-size: 1.25rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.rw-tablet-shift {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1.5rem;
    margin: 0;
    font-size: 1.5rem;
}

.rw-tablet-shift dt {
    font-size: 1rem;
    font-weight: 400;
    color: var(--bs-secondary-color);
}

.rw-tablet-shift dd {
    margin: 0;
    font-weight: 600;
}

.rw-tablet-note {
    margin: 0;
    font-size: 1.25rem;
}

/* A shift's welcome on the tablet (PBI 494): its day and times sent to Comms lead, as large as the call sign's line. */
.rw-tablet-welcome-shift {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
}

/* Two shifts in the car (PBI 491): their times, as large as the shift's details. The earlier one's line carries its
   button; each later one waits under it, smaller and grey, so the two read differently at a glance (PBI 495). */
.rw-tablet-current-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.rw-tablet-current-first {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.rw-tablet-current-next {
    margin: 0.75rem 0 0;
    font-size: 1.25rem;
    color: var(--bs-secondary-color);
}

/* Two notes on the screen, such as last night's shift and a new crew's log on, read as two (QA L3). */
.rw-tablet-note + .rw-tablet-note {
    margin-top: 0.5rem;
}

.rw-tablet-log-off {
    align-self: flex-start;
    min-width: 14rem;
    min-height: 4rem;
    font-size: 1.5rem;
}

/* Over the foot of the screen, so the shift does not move under a thumb as the signal comes and goes. */
.rw-tablet-offline {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    left: 1rem;
    z-index: 1500;
    margin: 0;
    font-size: 1.25rem;
}

.rw-tablet-dim {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgb(0 0 0 / 70%);
}

/* The report on the car's tablet: larger, and in landscape the form beside the entries, so nothing scrolls away mid-entry. */
.rw-tablet-report {
    font-size: 1.15rem;
}

.rw-tablet-report-log-off {
    min-width: 12rem;
    min-height: 3.5rem;
    font-size: 1.25rem;
}

.rw-tablet-report-state {
    margin-bottom: 0.5rem;
}

.rw-tablet-report-state .rw-tablet-note {
    margin: 0.5rem 0 0;
}

/* In landscape the form fills the left half from the very top; the strip, the title, the shift's card and the entries
   stack on the right. So the box and Save stay in view. The last row grows to fit the form. */
@media (min-width: 900px) and (orientation: landscape) {
    .rw-tablet-report {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-rows: auto auto auto 1fr;
        column-gap: 1.5rem;
        align-items: start;
    }

    .rw-tablet-report .rw-report-body {
        display: contents;
    }

    .rw-tablet-report .rw-report-panel {
        grid-row: 1 / span 4;
        grid-column: 1;
    }

    .rw-tablet-report > .rw-tablet-report-state {
        grid-row: 1;
        grid-column: 2;
    }

    /* The left half is plainly the form; its heading's line goes to Save. It still names the section for a screen reader. */
    .rw-tablet-report .rw-report-panel > h2 {
        display: none;
    }

    .rw-tablet-report > .rw-report-title {
        grid-row: 2;
        grid-column: 2;
    }

    /* The card's map slot would otherwise ask for 22rem beside it, wider than half a small tablet. The map sits under the
       card, folded until opened (PBI 505), and short when open, so an entry stays in view under it. */
    .rw-tablet-report .rw-report-top {
        grid-row: 3;
        grid-column: 2;
        grid-template-columns: minmax(0, 1fr);
    }

    .rw-tablet-report .rw-report-map .rw-track-map {
        height: 160px;
    }

    .rw-tablet-report .rw-report-entries {
        grid-row: 4;
        grid-column: 2;
    }
}

/* A tone is one colour family, for a category or a state, from Bootstrap's own colours for each theme. */
.rw-tone-primary {
    --rw-tone-bg: var(--bs-primary-bg-subtle);
    --rw-tone-text: var(--bs-primary-text-emphasis);
    --rw-tone-border: var(--bs-primary-border-subtle);
    --rw-tone-mark: var(--bs-primary);
}

.rw-tone-info {
    --rw-tone-bg: var(--bs-info-bg-subtle);
    --rw-tone-text: var(--bs-info-text-emphasis);
    --rw-tone-border: var(--bs-info-border-subtle);
    --rw-tone-mark: var(--bs-info);
}

.rw-tone-success {
    --rw-tone-bg: var(--bs-success-bg-subtle);
    --rw-tone-text: var(--bs-success-text-emphasis);
    --rw-tone-border: var(--bs-success-border-subtle);
    --rw-tone-mark: var(--bs-success);
}

.rw-tone-warning {
    --rw-tone-bg: var(--bs-warning-bg-subtle);
    --rw-tone-text: var(--bs-warning-text-emphasis);
    --rw-tone-border: var(--bs-warning-border-subtle);
    --rw-tone-mark: var(--bs-warning);
}

.rw-tone-danger {
    --rw-tone-bg: var(--bs-danger-bg-subtle);
    --rw-tone-text: var(--bs-danger-text-emphasis);
    --rw-tone-border: var(--bs-danger-border-subtle);
    --rw-tone-mark: var(--bs-danger);
}

.rw-tone-secondary {
    --rw-tone-bg: var(--bs-secondary-bg-subtle);
    --rw-tone-text: var(--bs-secondary-text-emphasis);
    --rw-tone-border: var(--bs-secondary-border-subtle);
    --rw-tone-mark: var(--bs-secondary);
}

/* Bootstrap has no purple family, so these are its own tints and shades of --bs-purple, worked out as for the others. */
.rw-tone-purple {
    --rw-tone-bg: #e2d9f3;
    --rw-tone-text: #2c1a4d;
    --rw-tone-border: #c5b3e6;
    --rw-tone-mark: var(--bs-purple);
}

[data-bs-theme="dark"] .rw-tone-purple {
    --rw-tone-bg: #160d27;
    --rw-tone-text: #a98eda;
    --rw-tone-border: #432874;
}

/* On a dark page the full colours are dim, and the light text colour keeps the hue. */
[data-bs-theme="dark"] [class*="rw-tone-"] {
    --rw-tone-mark: var(--rw-tone-text);
}

/* A word in its tone's colours: an entry's category, or the shift's state beside the title. */
.rw-tag {
    display: inline-block;
    padding: 0.15em 0.6em;
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    color: var(--rw-tone-text, inherit);
    background: var(--rw-tone-bg, transparent);
    border: 1px solid var(--rw-tone-border, transparent);
    border-radius: var(--bs-border-radius-pill);
}

/* The shift's state shares colours with some categories, so it is square, bold and outlined: never read as a category. */
.rw-state {
    padding: 0.25em 0.7em;
    font-weight: 700;
    border: 2px solid currentColor;
    border-radius: var(--bs-border-radius-sm);
}

/* The report: the title and the state, then the shift's card, then the form and the list, each its own part. */
.rw-report-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.rw-report-top {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* The map's place beside the shift's card on a wide screen (PBI 422). Empty, it takes no space. */
.rw-report-map:empty {
    display: none;
}

@media (min-width: 900px) {
    .rw-report-top {
        grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
    }
}

.rw-report-head {
    padding: 0.75rem 1rem;
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
}

.rw-report-call-sign {
    margin-bottom: 0.5rem;
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1.2;
}

/* Small capitals over each value, so the eye finds a part by its label without reading the values. */
.rw-label,
.rw-report-facts dt {
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}

.rw-report-facts {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.75rem 1rem;
    margin: 0;
}

.rw-report-facts dd {
    margin: 0;
    font-weight: 600;
    color: var(--bs-emphasis-color);
}

.rw-report-wide {
    grid-column: 1 / -1;
}

.rw-report-event-number {
    font-size: 1.35em;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* The Event Number with Finish report on its right (PBI 495); the button's row of its own, with large text, is held by
   finish.js when someone else's press hides it. The facts are a block, not the card's grid, so the number's width counts:
   it never breaks (normal wrap, not the page's "anywhere") and is never drawn under the button (QA H1, R1). An admin's
   "Manual Event Number" has its own line under the number and may wrap, so it never runs under the button (R2). */
.rw-report-lead {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.rw-report-lead > .rw-report-facts {
    display: block;
    flex: 1 1 0;
    min-width: min-content;
    overflow-wrap: normal;
}

.rw-report-lead .badge {
    display: table;
    margin-top: 0.25rem;
    white-space: normal;
}

.rw-finish-open {
    flex-shrink: 0;
}

/* The odometer is one line at the foot of the card; a box opens only when a reading is asked for. */
/* flow-root keeps an asked box's top margin inside, so the space held for a partner's change is all it takes (479 O3-R2). */
.rw-odometer {
    display: flow-root;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--bs-border-color);
}

.rw-shift-details[open] > .rw-fold-summary {
    margin-bottom: 0.25rem;
}

/* With "Shift details" shut, the odometer keeps only what is asked: a box waiting for a reading, or a note. Its line stays
   while a reading this person may add is missing (data-rw-line-kept), or after a redraw until the next shut (-held, PBI 479). */
.rw-shift-details:not([open]) ~ .rw-odometer:not([data-rw-line-kept="1"], [data-rw-line-held]) {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.rw-shift-details:not([open]) ~ .rw-odometer:not([data-rw-line-kept="1"], [data-rw-line-held]) > .rw-label,
.rw-shift-details:not([open]) ~ .rw-odometer:not([data-rw-line-kept="1"], [data-rw-line-held]) > [data-rw-odometer-row] {
    display: none !important;
}

.rw-odometer-line {
    color: var(--bs-secondary-color);
}

.rw-odometer-line strong {
    color: var(--bs-emphasis-color);
}

/* Finish report's panel, or the finished note, keeps a gap under the Event Number's line (PBI 495). On the first child, so
   a part with nothing to show adds no gap (owner, 2026-11-13). flow-root keeps its children's margins inside it, so its
   height is all the space it takes when kept for a partner's change. */
.rw-finish {
    display: flow-root;
}

.rw-finish > :first-child {
    margin-top: 0.75rem;
}

/* A gap above "Shift details", so a low tap on the last button does not open it (QA L5). */
.rw-finish-panel,
.rw-finish [data-rw-finish-continue-open] {
    margin-bottom: 0.75rem;
}

.rw-report-panel {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
}

/* Each entry is marked down its left edge in its category's colour, so a glance down the list shows what kind it is. */
.rw-entry {
    border-left: 0.4rem solid var(--rw-tone-mark);
}

.rw-entry-time {
    font-size: 1.1em;
    font-variant-numeric: tabular-nums;
}

/* An entry edited where it stands (PBI 492): the card is ringed, and the editor stands in for its words, lines and buttons. */
.rw-entry-editing {
    box-shadow: 0 0 0 2px var(--bs-primary);
}

.rw-entry-editing [data-rw-entry-view],
.rw-entry-editing [data-rw-entry-tag] {
    display: none;
}

.rw-editor {
    margin-top: 0.5rem;
}

.rw-editor-category {
    min-height: 48px;
    padding-left: 1rem;
}

.rw-editor-move {
    min-height: 48px;
}

/* The same colour inside each category button, so the choice matches how its entry is marked. Drawn over, as a
   pressed or hovered button resets its border. */
.rw-category {
    position: relative;
    overflow: hidden;
}

/* Narrow at four to a row: a two-word name takes two tight lines and the button still keeps the 48 px floor. */
.rw-category-grid .rw-category {
    padding-block: 0.25rem;
    line-height: 1.15;
}

.rw-category::before {
    position: absolute;
    inset-block: 0;
    left: 0;
    width: 0.4rem;
    content: "";
    background: var(--rw-tone-mark);
}

/* Asked before a tap leaves the report with words in the box (PBI 437): over the page, above a phone's bottom bar. */
.rw-leave {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    box-shadow: 0 -0.25rem 1rem rgba(0, 0, 0, 0.3);
}

.rw-leave-inner {
    max-width: 36rem;
    margin-inline: auto;
}

@media (max-width: 767.98px) {
    .rw-with-nav .rw-leave {
        bottom: calc(var(--rw-nav-height) + env(safe-area-inset-bottom));
        padding-bottom: 0.75rem;
    }
}

@media (min-width: 768px) {
    .rw-nav {
        position: static;
        display: flex;
        padding-bottom: 0;
        background: none;
        border-top: 0;
    }

    .rw-nav-link {
        padding-inline: 1rem;
    }

    .rw-with-nav main {
        padding-bottom: 1rem;
    }
}
