/*
 * Stage 8b: the shell's look for the ordinary pages (Import Carriages, Carriage Facilities, Carriage Tracker, the
 * Carriage Audit Tracker and Auditors; more pages join in 8c and 8d). Everything is under .pg, so a page only changes
 * when its view adds the wrapper. Same language as the Change Log (css/changeRequestPages.css): a plain navy title,
 * a short line under it, light filter panels, white cards and navy table headings. The page scripts' ids and classes
 * are unchanged; this file only styles them.
 */
.pg {
    --pg-navy: var(--shell-navy, var(--brand-navy));
    --pg-navy-deep: var(--brand-navy-deep);
    --pg-accent: var(--shell-accent, var(--brand-yellow));
    --pg-ink: #1d1b3f;
    --pg-muted: #5f5d86;
    --pg-line: #dcdbea;
    --pg-soft: #f5f5fb;
    --pg-good: #146c43;
    --pg-good-bg: #d9f5e6;
    --pg-bad: #b02a37;
    --pg-bad-bg: #fbe1e4;
    color: var(--pg-ink);
    padding: 4px 4px 32px;
}

    .pg div,
    .pg p,
    .pg ol,
    .pg ul {
        line-height: 1.45;
    }

/* ---- Heading ---------------------------------------------------------------- */

.pg__head {
    margin-bottom: 16px;
}

/* styles.css gives every #mainContent h1 a navy bar (with !important) and h2s their own colour. */
#mainContent .pg .pg__title,
.pg .pg__title {
    margin: 0 0 4px;
    padding: 0;
    background: none !important;
    color: var(--pg-navy);
    font-size: 2rem;
    font-weight: 400;
    line-height: 1.2;
}

.pg__lede {
    margin: 0;
    color: var(--pg-muted);
}

.pg__muted {
    color: var(--pg-muted);
}

/* ---- Panels and cards ---------------------------------------------------------- */

.pg-panel {
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--pg-line);
    border-radius: 12px;
    background: var(--pg-soft);
}

.pg-card {
    margin-bottom: 16px;
    border: 1px solid var(--pg-line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

.pg-card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--pg-line);
}

    #mainContent .pg .pg-card__head h2,
    .pg .pg-card__head h2 {
        margin: 0;
        padding: 0;
        background: none !important;
        color: var(--pg-navy);
        font-size: 1.1rem;
        font-weight: 700;
    }

.pg-card__body {
    padding: 16px 18px;
}

.pg-label {
    display: block;
    margin-bottom: 6px;
    color: var(--pg-ink);
    font-size: 0.9rem;
    font-weight: 700;
}

/* ---- Buttons ------------------------------------------------------------------ */

.pg .pg-btn,
.pg .pg-btn.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 18px;
    border: 1px solid var(--pg-navy);
    border-radius: 10px;
    background: var(--pg-navy);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

    .pg .pg-btn:hover {
        background: var(--pg-navy-deep);
        color: #fff;
    }

    .pg .pg-btn:focus-visible {
        outline: 3px solid var(--pg-accent);
        outline-offset: 2px;
    }

    .pg .pg-btn:disabled {
        opacity: 0.6;
    }

.pg .pg-btn--ghost,
.pg .pg-btn--ghost.btn {
    border-color: var(--pg-line);
    background: #fff;
    color: var(--pg-navy);
}

    .pg .pg-btn--ghost:hover {
        border-color: var(--pg-navy);
        background: var(--pg-soft);
        color: var(--pg-navy);
    }

/* ---- Messages ----------------------------------------------------------------- */

.pg-note {
    display: block;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--pg-soft);
    color: var(--pg-ink);
}

    .pg-note:empty,
    .pg-note:has(> span:empty:only-child) {
        display: none;
    }

/* ---- Tables ------------------------------------------------------------------- */

.pg-table-wrap {
    border: 1px solid var(--pg-line);
    border-radius: 12px;
    overflow-x: auto;
    background: #fff;
}

.pg table.pg-table,
.pg .pg-tables table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    color: var(--pg-ink);
}

    .pg table.pg-table thead th,
    .pg .pg-tables table thead th {
        padding: 12px 14px;
        border: 0;
        background: var(--pg-navy);
        color: #fff;
        font-size: 0.95rem;
        font-weight: 700;
        white-space: nowrap;
    }

    .pg table.pg-table tbody td,
    .pg .pg-tables table tbody td {
        padding: 12px 14px;
        border: 0;
        border-top: 1px solid var(--pg-line);
        background: #fff;
        font-size: 1rem;
        vertical-align: middle;
    }

    .pg table.pg-table tbody tr:hover td,
    .pg .pg-tables table tbody tr:hover td {
        background: var(--pg-soft);
    }

/* ---- Tiles (carriage numbers) ------------------------------------------------- */

.pg .pg-tiles ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pg .pg-tiles li.txtCarriage {
    display: block;
    width: auto;
    margin: 0;
    padding: 0;
    border: 1px solid var(--pg-line);
    border-radius: 10px;
    background: #fff;
    text-align: center;
}

    .pg .pg-tiles li.txtCarriage a {
        display: block;
        padding: 12px 6px;
        border: 0;
        border-radius: 10px;
        color: var(--pg-navy);
        font-weight: 700;
        text-decoration: none;
    }

    .pg .pg-tiles li.txtCarriage:hover {
        border-color: var(--pg-navy);
        background: var(--pg-soft);
    }

    .pg .pg-tiles li.txtCarriage a:focus-visible {
        outline: 3px solid var(--pg-accent);
        outline-offset: 1px;
    }

/* ---- Check chips (facilities) ------------------------------------------------- */

.pg .pg-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

    .pg .pg-chips > [class*="col"] {
        flex: none;
        width: auto;
        max-width: none;
        padding: 0;
    }

.pg .pg-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 6px 14px;
    border: 1px solid var(--pg-line);
    border-radius: 999px;
    background: #fff;
    color: var(--pg-ink);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

    .pg .pg-chip input {
        width: 16px;
        height: 16px;
        margin: 0;
        accent-color: var(--pg-navy);
    }

    .pg .pg-chip:has(input:checked) {
        border-color: var(--pg-navy);
        background: var(--pg-navy);
        color: #fff;
    }

    .pg .pg-chip:has(input:focus-visible) {
        outline: 3px solid var(--pg-accent);
        outline-offset: 2px;
    }

/* ---- Chosen dropdowns on these pages ------------------------------------------ */

.pg .pg-select .chosen-container {
    width: 100% !important;
    max-width: 420px;
    margin: 0 !important;
}

.pg .pg-select .chosen-container-single .chosen-single {
    height: 40px;
    line-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--pg-line);
    border-radius: 10px;
    background: #fff;
    box-shadow: none;
    color: var(--pg-ink);
}

    .pg .pg-select .chosen-container-single .chosen-single div b {
        background-position: 0 10px;
    }

/* ---- Carriage Facilities ------------------------------------------------------ */

.pg #carriageTableContainer {
    height: auto;
    max-height: 60vh;
    margin-top: 0;
    overflow-y: auto;
}

/* ---- Carriage Tracker (both pages) -------------------------------------------- */

.pg .carriage-tracker-container {
    padding: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
}

.pg .carriage-tracker-header {
    margin-bottom: 16px;
    padding-bottom: 0;
    border-bottom: 0;
}

    #mainContent .pg .carriage-tracker-header h1,
    .pg .carriage-tracker-header h1 {
        margin: 0 0 4px;
        padding: 0;
        background: none !important;
        color: var(--pg-navy);
        font-size: 2rem;
        font-weight: 400;
    }

.pg .audit-period-info {
    margin: 0;
}

    .pg .audit-period-info h3 {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 16px;
        margin: 0;
        color: var(--pg-muted);
        font-size: 1rem;
        font-weight: 400;
    }

.pg .carriage-search-section,
.pg .carriages-container {
    margin: 0 0 16px;
    border: 1px solid var(--pg-line);
    border-radius: 12px;
    overflow: hidden;
}

.pg .carriage-search-section {
    background: var(--pg-soft);
}

.pg .carriages-container {
    background: #fff;
}

.pg .tracker-section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    margin: 0;
    padding: 14px 18px;
    border-bottom: 1px solid var(--pg-line);
}

    #mainContent .pg .tracker-section-header h2,
    .pg .tracker-section-header h2 {
        margin: 0;
        padding: 0;
        background: none !important;
        color: var(--pg-navy);
        font-size: 1.1rem;
        font-weight: 700;
    }

    .pg .tracker-section-header .carriageSelectTitle p {
        margin: 0 !important;
        color: var(--pg-muted);
    }

.pg .search-controls-container {
    padding: 16px 18px;
}

    .pg .search-controls-container .form-group {
        gap: 10px 12px;
    }

    .pg .search-controls-container label {
        min-width: 0;
        flex: none;
        margin: 0 4px 0 0;
        white-space: nowrap;
    }

    .pg .search-controls-container .searchCarriageNumericOnly {
        width: 220px;
        height: 40px;
        border: 1px solid var(--pg-line);
        border-radius: 10px;
    }

.pg .refresh-btn,
.pg .refresh-btn.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid var(--pg-navy);
    border-radius: 10px;
    background: var(--pg-navy);
    color: #fff;
    font-weight: 700;
}

/* The script puts each tile in a Bootstrap column (col-md-2 col-sm-3 col-6): an even grid instead, 2+ to a row on phones. */
.pg .carriages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    height: auto;
    max-height: 60vh;
    margin: 0;
    padding: 14px;
}

    .pg .carriages-grid > [class*="col"] {
        width: auto;
        max-width: none;
        margin: 0 !important;
        padding: 0;
    }

    .pg .carriages-grid > .loading-spinner,
    .pg .carriages-grid > .alert {
        grid-column: 1 / -1;
        margin: 0;
    }

/* The tiles keep their colours (set by carriageTracker.js: green = audited); only their shape follows the shell. */
.pg .carriage-card {
    border-width: 1px;
    border-style: solid;
    border-radius: 10px;
    box-shadow: none;
    color: var(--pg-ink);
    font-weight: 700;
}

    .pg .carriage-card:hover {
        box-shadow: 0 4px 10px rgba(29, 27, 63, 0.15);
    }

    .pg .carriage-card.carriage-card-clickable {
        cursor: pointer;
    }

/* ---- Auditors ----------------------------------------------------------------- */

.pg #offline-items-message {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px dashed var(--pg-navy);
    border-radius: 10px;
    background: var(--pg-soft);
    font-size: 1rem;
}

    .pg #offline-items-message:empty {
        display: none;
    }

#mainContent .pg #syncData h2,
.pg #syncData h2 {
    margin: 20px 0 10px;
    padding: 0;
    background: none !important;
    color: var(--pg-navy);
    font-size: 1.25rem;
    font-weight: 700;
}

    .pg #syncData h2:first-child {
        margin-top: 0;
    }

.pg #syncData table.syncData {
    border: 1px solid var(--pg-line);
    border-radius: 12px;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    margin-bottom: 8px;
}

    .pg #syncData table.syncData thead th {
        padding: 12px 14px;
        border: 0;
        background: var(--pg-navy);
        color: #fff;
        font-size: 0.95rem;
    }

    .pg #syncData table.syncData tbody td {
        padding: 10px 14px;
        border: 0;
        border-top: 1px solid var(--pg-line);
    }

    .pg #syncData td.location a {
        border: 0;
        color: var(--pg-navy);
        font-weight: 700;
        text-decoration: none;
    }

        .pg #syncData td.location a:hover {
            text-decoration: underline;
        }

    .pg #syncData td.offline span i {
        padding: 6px 12px;
        border: 1px solid var(--pg-line);
        border-radius: 8px;
        background: #fff;
    }

.pg .syncHistoryContainer {
    margin-top: 20px;
    border: 1px solid var(--pg-line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

    .pg .syncHistoryContainer .accordion-button {
        padding: 14px 18px !important;
        color: var(--pg-navy);
        font-size: 1.05rem;
        font-weight: 700;
    }

    .pg .syncHistoryContainer .syncHistoryData {
        padding: 0 18px 14px;
    }

/* ---- Badges, long text, action rows (Stage 8c) --------------------------------- */

.pg-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.pg-badge--bad {
    background: var(--pg-bad-bg);
    color: var(--pg-bad);
}

.pg-badge--good {
    background: var(--pg-good-bg);
    color: var(--pg-good);
}

.pg .pg-break {
    word-break: break-word;
}

.pg-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
}

    .pg-actions [hidden] {
        display: none !important;
    }

.pg .pg-actions__select {
    width: auto;
    min-width: 200px;
    max-width: 340px;
    height: 40px;
    border: 1px solid var(--pg-line);
    border-radius: 10px;
}

.pg-actions__status {
    flex: 1 1 260px;
    margin: 0;
    color: var(--pg-muted);
}

.pg-table-wrap--flush {
    border: 0;
    border-radius: 0;
}

/* ---- Export Databases (drawn by localdbFunctions.js) -------------------------- */

#mainContent .pg .pg-dbexport h2,
.pg .pg-dbexport h2 {
    margin: 0 0 14px !important;
    padding: 0;
    background: none !important;
    color: var(--pg-navy);
    font-size: 1.1rem;
    font-weight: 700;
}

.pg .pg-dbexport .form-check {
    padding-top: 4px;
    padding-bottom: 4px;
}

.pg .pg-dbexport .form-check-input:checked {
    border-color: var(--pg-navy);
    background-color: var(--pg-navy);
}

.pg .pg-dbexport #db-list {
    height: auto; /* styles.css fixes it at 300px: as tall as the list, up to half the window */
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid var(--pg-line);
    background: var(--pg-soft);
}

.pg .pg-dbexport #exportButton {
    min-height: 44px;
    border: 1px solid var(--pg-navy);
    border-radius: 10px;
    background: var(--pg-navy);
    color: #fff;
    font-weight: 700;
}

    .pg .pg-dbexport #exportButton:hover {
        background: var(--pg-navy-deep);
    }

.pg .pg-dbexport #status-message {
    border-radius: 10px;
}

/* ---- Get Assets in Areas (drawn by utility.js renderView) --------------------- */

.pg .pg-assetareas .card {
    border-radius: 12px;
    overflow: hidden;
}

/* styles.css colours every h2 navy: on the navy station header it vanished. */
#mainContent .pg .pg-assetareas .entity-header h2,
.pg .pg-assetareas .entity-header h2 {
    padding: 0;
    background: none !important;
    color: #fff;
}

.pg .pg-assetareas .toolbar {
    border-color: var(--pg-line);
}

/* ---- Danger button --------------------------------------------------------------- */

.pg .pg-btn--danger:not(:disabled):hover {
    border-color: var(--pg-bad);
    background: var(--pg-bad-bg);
    color: var(--pg-bad);
}

/* ---- Radio options under a dropdown (map options) ------------------------------ */

.pg .mapOptionsContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}

    .pg .mapOptionsContainer .form-check-input:checked {
        border-color: var(--pg-navy);
        background-color: var(--pg-navy);
    }

/* ---- Assignments (Stage 8c) ------------------------------------------------------- */

.pg .pg-assign__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

    .pg .pg-assign__grid .pg-card {
        margin: 0;
    }

.pg .pg-assign__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 60px;
}

    .pg .pg-assign__actions .pg-btn {
        justify-content: center;
        min-width: 130px;
    }

.pg.pg-assign #buttonMessage {
    max-width: 160px;
    margin: 0;
    color: var(--pg-bad);
    font-style: normal;
}

.pg.pg-assign .search-input {
    margin: 0 0 10px;
    border-radius: 10px;
}

.pg.pg-assign .unassigned-users-container ul,
.pg.pg-assign .assigned-users-container ul {
    display: block;
    max-height: 55vh;
    margin: 0;
    padding: 0;
    border: 1px solid var(--pg-line);
    border-radius: 10px;
    overflow-y: auto;
}

.pg.pg-assign .unassigned-users-container li,
.pg.pg-assign .assigned-users-container li {
    margin: 0;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--pg-line);
    border-radius: 0;
    white-space: normal;
    word-break: break-word;
    cursor: pointer;
}

    .pg.pg-assign .unassigned-users-container li:hover,
    .pg.pg-assign .assigned-users-container li:hover {
        background: var(--pg-soft);
    }

    .pg.pg-assign li.selected,
    .pg.pg-assign li.selected:hover {
        background: var(--pg-navy);
        color: #fff;
        font-weight: 700;
    }

/* ---- Document tiles: Export and Useful Information (Stage 8c) ------------------ */

.pg .pg-docs.document-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    min-height: 0;
    margin: 0;
    border: 0;
}

.pg .pg-docs .document-item {
    position: relative;
    width: auto;
    padding: 20px 16px 16px;
    border: 1px solid var(--pg-line);
    border-radius: 12px;
    background: #fff;
    text-align: center;
}

    .pg .pg-docs .document-item:hover {
        border-color: var(--pg-navy);
        box-shadow: 0 4px 12px rgba(29, 27, 63, 0.1);
    }

.pg .pg-docs .document-icon-container {
    margin-bottom: 12px;
}

    .pg .pg-docs .document-icon-container a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 64px;
        height: 64px;
        border: 0;
        border-radius: 14px;
        background: var(--pg-soft);
        color: var(--pg-navy);
    }

        .pg .pg-docs .document-icon-container a:hover,
        .pg .pg-docs .document-icon-container a:focus-visible {
            background: var(--pg-navy);
            color: #fff;
        }

        .pg .pg-docs .document-icon-container a:focus-visible {
            outline: 3px solid var(--pg-accent);
            outline-offset: 2px;
        }

.pg .pg-docs .document-title-container p {
    margin: 0 0 4px;
    color: var(--pg-ink);
    font-weight: 700;
}

.pg .pg-docs .document-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
}

.pg .pg-docs .doc-offline-icon {
    cursor: pointer;
    padding: 6px 10px;
    border: 1px solid var(--pg-line);
    border-radius: 8px;
}

.pg .pg-docs .doc-offline-icon.fa-ban {
    color: var(--pg-bad);
}

.pg .pg-docs .doc-offline-icon.fa-download {
    color: var(--pg-good);
}

.pg .pg-docs .doc-unavailable {
    opacity: 0.6;
}

/* ---- Login History (Stage 8c) ----------------------------------------------------- */

.pg-loghistory .card {
    border: 1px solid var(--pg-line);
    border-radius: 12px;
    overflow: hidden;
}

.pg-loghistory .card-header.users-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--pg-line);
    background: var(--pg-soft);
}

    #mainContent .pg-loghistory .card-header h2,
    .pg-loghistory .card-header h2 {
        flex: 1 1 100%;
        margin: 0 !important;
        padding: 0;
        background: none !important;
        color: var(--pg-navy);
        font-size: 1.1rem;
        font-weight: 700;
    }

    .pg-loghistory .card-header form {
        flex: 0 1 auto;
        margin: 0;
    }

    .pg-loghistory .card-header .form-control {
        height: 40px;
        border: 1px solid var(--pg-line);
        border-radius: 10px;
    }

    .pg-loghistory .card-header .btn-primary {
        border-color: var(--pg-navy);
        border-radius: 10px;
        background: var(--pg-navy);
        font-weight: 700;
    }

    .pg-loghistory .card-header .btn-outline-secondary {
        border-color: var(--pg-line);
        border-radius: 10px;
        background: #fff;
        color: var(--pg-navy);
        font-weight: 700;
    }

.pg-loghistory .card-body {
    padding: 16px 18px;
}

.pg-loghistory #login-history-table thead th {
    position: sticky;
    top: 0;
    padding: 12px 14px;
    border: 0;
    background: var(--pg-navy);
    color: #fff;
}

.pg-loghistory #login-history-table tbody td {
    padding: 10px 14px;
    border-top: 1px solid var(--pg-line);
}

/* ---- Login and account pages (Stage 8d) ------------------------------------------ */

.pg.pg-auth {
    display: flex;
    justify-content: center;
    padding: 32px 16px 48px;
}

.pg-auth__card {
    width: 100%;
    max-width: 460px;
    padding: 28px 28px 24px;
    border: 1px solid var(--pg-line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(29, 27, 63, 0.08);
}

    .pg-auth__card .pg__title {
        font-size: 1.75rem !important;
    }

    .pg-auth__card .form-control {
        height: 44px;
        border: 1px solid var(--pg-line);
        border-radius: 10px;
    }

        .pg-auth__card .form-control:focus {
            border-color: var(--pg-navy);
            box-shadow: 0 0 0 3px rgba(var(--brand-navy-rgb),  0.15);
        }

    .pg-auth__card label {
        margin-bottom: 6px;
        color: var(--pg-ink);
        font-weight: 600;
    }

    .pg-auth__card .fieldContainer {
        position: relative;
    }

    .pg-auth__card .pg-btn,
    .pg-auth__card .pg-btn.btn {
        justify-content: center;
        width: 100%;
        min-height: 46px;
        margin-top: 4px;
    }

    .pg-auth__card .validation,
    .pg-auth__card .tocError,
    .pg-auth__card .errorContainer {
        font-size: 0.9rem;
    }

/* styles.css gives these forms fixed widths (#loginform 50%, .registerform 40%, #resetpassword 50%, the forgot
   password email 50%) and floats .form-group labels and inputs side by side: inside the card they fill it. */
.pg-auth__card #loginform,
.pg-auth__card .registerform,
.pg-auth__card #resetpassword,
.pg-auth__card #ForgotPasswordForm,
.pg-auth__card #ForgotPasswordForm input[type=email] {
    width: 100% !important;
    max-width: 100%;
}

.pg-auth__card .form-group {
    clear: none;
    padding: 0;
}

    .pg-auth__card .form-group label,
    .pg-auth__card .form-group input,
    .pg-auth__card .form-group .login {
        float: none;
        width: auto;
        min-width: 0;
        text-align: left;
    }

.pg-auth__card .registerform label {
    padding: 0;
}

.pg-auth__card .registerform .pg__muted {
    margin-bottom: 14px;
}

.pg-auth__card .togglePassword {
    position: absolute;
    top: 38px;
    right: 14px;
    transform: none !important;
    color: var(--pg-muted);
    cursor: pointer;
}

.pg-auth__card .fieldContainer .form-control {
    padding-right: 40px;
}

.pg-auth__actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-top: 8px;
}

    .pg-auth__actions .login.pg-btn {
        width: 100% !important;
        min-width: 0;
        padding: 10px 18px;
    }

    .pg-auth__actions .forgot {
        align-self: center;
        border: 0;
        color: var(--pg-navy);
        font-weight: 600;
    }

.pg-auth__alt {
    margin: 18px 0 0;
    text-align: center;
}

    .pg-auth__alt a {
        border: 0;
        color: var(--pg-navy);
        font-weight: 600;
    }

.pg-auth__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    border-radius: 12px;
    background: var(--pg-bad-bg);
    color: var(--pg-bad);
    font-size: 1.25rem;
}

/* ---- Cards with tables: Permissions, User Management, Login History (8c / 8d) ---- */

.pg-cards .card {
    border: 1px solid var(--pg-line);
    border-radius: 12px;
    overflow: hidden;
}

.pg-cards .card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--pg-line);
    background: var(--pg-soft);
}

    #mainContent .pg-cards .card-header h2,
    .pg-cards .card-header h2 {
        margin: 0;
        padding: 0;
        background: none !important;
        color: var(--pg-navy);
        font-size: 1.1rem;
        font-weight: 700;
    }

    .pg-cards .card-header .form-control {
        height: 40px;
        border: 1px solid var(--pg-line);
        border-radius: 10px;
    }

.pg-cards .card-body {
    padding: 0;
}

.pg-cards .card-body > .table-responsive,
.pg-cards .card-body > p {
    margin: 0;
}

.pg-cards .card-body > p {
    padding: 14px 18px 0;
}

.pg-cards .table {
    margin: 0;
}

/* User Management: rows stay on one line; on a phone the table scrolls sideways inside its card. */
.pg-cards #users-table th,
.pg-cards #users-table td {
    white-space: nowrap;
}

    .pg-cards .table thead th {
        position: sticky;
        top: 0;
        z-index: 1;
        padding: 12px 14px;
        border: 0;
        background: var(--pg-navy);
        color: #fff;
        font-weight: 700;
    }

    .pg-cards .table tbody td {
        padding: 10px 14px;
        border-top: 1px solid var(--pg-line);
        border-bottom: 0;
        vertical-align: middle;
    }

    .pg-cards .table tbody tr:hover td {
        background: var(--pg-soft);
    }

.pg-cards .btn-sm {
    border-radius: 8px;
    font-weight: 600;
}

.pg-cards .btn-primary {
    border-color: var(--pg-navy);
    background: var(--pg-navy);
}

    .pg-cards .btn-primary:hover {
        border-color: var(--pg-navy-deep);
        background: var(--pg-navy-deep);
    }

.pg-cards .badge.bg-success {
    background: var(--pg-good-bg) !important;
    color: var(--pg-good);
}

.pg-cards .badge.bg-danger {
    background: var(--pg-bad-bg) !important;
    color: var(--pg-bad);
}

.pg-cards .badge.bg-secondary {
    background: var(--pg-soft) !important;
    border: 1px solid var(--pg-line);
    color: var(--pg-ink);
}

/* ---- Register User (Stage 8d) ------------------------------------------------- */

.pg .pg-card--form {
    max-width: 640px;
}

    .pg .pg-card--form .form-control {
        height: 44px;
        border: 1px solid var(--pg-line);
        border-radius: 10px;
    }

/* _displayRoles writes <label> then <input type=checkbox> in a .form-group: shown as chips, box first. */
.pg .pg-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

    .pg .pg-roles .form-group {
        display: inline-flex;
        flex-direction: row-reverse;
        align-items: center;
        gap: 8px;
        margin: 0;
        padding: 6px 14px;
        border: 1px solid var(--pg-line);
        border-radius: 999px;
        background: #fff;
    }

        .pg .pg-roles .form-group label {
            float: none;
            width: auto;
            min-width: 0;
            margin: 0;
            padding: 0;
            text-align: left;
            font-weight: 600;
        }

        .pg .pg-roles .form-group input {
            float: none;
            width: 16px !important;
            min-width: 0;
            height: 16px;
            padding: 0;
            accent-color: var(--pg-navy);
        }

        .pg .pg-roles .form-group:has(input:checked) {
            border-color: var(--pg-navy);
            background: var(--pg-navy);
            color: #fff;
        }

/* ---- Small screens ------------------------------------------------------------ */

@media (max-width: 991.98px) {
    .pg.pg-auth {
        padding: 12px 0 32px;
    }

    .pg-auth__card {
        padding: 22px 18px 20px;
        box-shadow: none;
    }

    .pg-cards .table thead th,
    .pg-cards .table tbody td {
        padding: 10px 8px;
    }

    .pg .pg-assign__grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .pg .pg-assign__actions {
        flex-direction: row;
        flex-wrap: wrap;
        padding-top: 0;
    }

        .pg .pg-assign__actions .pg-btn {
            flex: 1 1 100px;
            min-width: 0;
        }

    .pg.pg-assign #buttonMessage {
        flex: 1 1 100%;
        max-width: none;
    }

    .pg .pg-docs.document-container {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .pg .pg-assetareas .map-section {
        padding: 1rem;
    }

    .pg .pg-assetareas .toolbar {
        flex-wrap: wrap;
        gap: 10px;
    }

    #mainContent .pg .pg__title,
    .pg .pg__title,
    #mainContent .pg .carriage-tracker-header h1,
    .pg .carriage-tracker-header h1 {
        font-size: 1.6rem;
    }

    .pg .pg-tiles ul {
        grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    }

    .pg .carriages-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .pg .search-controls-container .form-group {
        flex-direction: column;
        align-items: stretch;
    }

        .pg .search-controls-container .searchCarriageNumericOnly {
            width: 100%;
        }

    .pg .refresh-btn {
        margin-left: 0;
        justify-content: center;
    }

    .pg #syncData th {
        font-size: 0.85rem;
    }

    .pg #syncData table.syncData thead th,
    .pg #syncData table.syncData tbody td {
        padding: 10px 8px;
    }

    .pg #syncData td.syncStatus {
        font-size: 0.85rem;
        line-height: 1.2;
    }
}

/* ---- 2.0.226: Permissions page, responsive ----
   The Users, Roles and Groups cards were three fixed Bootstrap columns from 768px up, so with the sidebar (or on a
   tablet) each card was too narrow for its names and buttons. They now sit in a grid that fits as many columns as the
   space allows, each at least 340px wide: three side by side on a wide screen, two then one as it narrows, and one
   card per row on a phone. Names wrap inside their cell instead of being cut off; the buttons never squash. */
.pg-perms .pg-perms__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 1rem;
    margin: 0;
}

    .pg-perms .pg-perms__grid > [class*="col-"] {
        width: auto;
        max-width: none;
        padding: 0;
        margin: 0;
        min-width: 0;
    }

.pg-perms .card {
    min-width: 0;
}

.pg-perms .table {
    table-layout: auto;
    width: 100%;
}

    .pg-perms .table th,
    .pg-perms .table td {
        vertical-align: middle;
    }

        /* The name column takes the room left; long emails and group names wrap. */
        .pg-perms .table td:first-child,
        .pg-perms .table th:first-child {
            width: auto !important;
            overflow-wrap: anywhere;
            word-break: normal;
        }

        /* The action column is as wide as its buttons, and they stay whole. */
        .pg-perms .table td:last-child,
        .pg-perms .table th:last-child {
            width: 1% !important;
            white-space: nowrap;
            text-align: right;
        }

    .pg-perms .table td:last-child .btn {
        white-space: nowrap;
        margin: 2px 0 2px 4px;
    }

/* User Management's rule keeps #users-table on one line (.pg-cards #users-table td), and styles.css gives
   .table-scroll-y a fixed layout with sideways overflow hidden, which together cut long emails off. Here the names
   wrap and the layout follows the content. */
.pg-perms #users-table th:first-child,
.pg-perms #users-table td:first-child {
    white-space: normal;
}

.pg-perms .table-scroll-y {
    overflow-x: auto;
    table-layout: auto;
}

/* The cards stack on narrow screens, so the long Users list scrolls inside its card rather than pushing Roles and
   Groups far down the page. */
@media (max-width: 991.98px) {
    .pg-perms .table-scroll-y {
        max-height: 420px;
        overflow-y: auto;
    }
}

/* Phones: the search box takes the card's width. (The buttons keep their two lines, which leaves the names more room.) */
@media (max-width: 575.98px) {
    .pg-perms .card-header .form-control {
        width: 100%;
    }
}

/* Very narrow phones: a row's buttons stack, so a group's Manage Permissions and Delete Group fit without a sideways
   scroll. */
@media (max-width: 419.98px) {
    .pg-perms .table td:last-child {
        white-space: normal;
    }

        .pg-perms .table td:last-child .btn {
            display: block;
            width: 100%;
            margin: 4px 0;
        }
}
