/* ===== Base ===== */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}
@media (min-width: 768px) {
    html { font-size: 16px; }
}
body {
    background-color: #ebedf0;
    margin-bottom: 60px;
}

/* ===== Navbar ===== */
.navbar {
    background-color: #fff !important;
    border-bottom: 1px solid #dee2e6;
}
.navbar-brand {
    font-weight: 600;
    letter-spacing: .02em;
    padding-top: 2px;
    padding-bottom: 2px;
}
.navbar-logo {
    height: 32px;
    width: auto;
}
.navbar-nav .nav-link {
    color: #1a3a5c !important;
    font-weight: 500;
    font-size: .875rem;
    padding: .5rem .75rem !important;
    border-radius: 6px;
    transition: background-color 0.15s ease;
}
.navbar-nav .nav-link:hover {
    color: #142e4a !important;
    background-color: #dde1e6;
}
.navbar-nav .nav-link.active {
    color: #fff !important;
    background-color: #1a3a5c;
    font-weight: 600;
}

/* ===== Cards ===== */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    border-radius: 8px;
}

/* ===== Status badges ===== */
.badge-certified {
    background-color: #198754;
    color: #fff;
}
.badge-pending {
    background-color: #ffc107;
    color: #000;
}
.badge-flow {
    background-color: #0d6efd;
    color: #fff;
}
.status-active  { color: #198754; font-weight: 500; }
.status-inactive { color: #dc3545; font-weight: 500; }
.badge-active {
    background-color: #198754;
    color: #fff;
}
.badge-inactive {
    background-color: #6c757d;
    color: #fff;
}

/* ===== Tables ===== */
.table th {
    font-weight: 600;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #6c757d;
}
.table td {
    vertical-align: middle;
}

/* ===== Buttons ===== */
.btn-primary {
    background-color: #1a3a5c;
    border-color: #1a3a5c;
}
.btn-primary:hover,
.btn-primary:active {
    background-color: #142e4a;
    border-color: #142e4a;
}
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* ===== Search form ===== */
.search-card .card-body {
    padding: 1rem 1.25rem;
}
.search-card .form-label {
    font-size: .7rem;
    font-weight: 500;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .1rem;
    white-space: nowrap;
}
.search-card .form-control,
.search-card .form-select {
    border: none;
    border-bottom: 1.5px solid #ced4da;
    border-radius: 0;
    padding: .2rem .125rem;
    font-size: .8rem;
    background-color: transparent;
    box-shadow: none;
}
.search-card .form-control:focus,
.search-card .form-select:focus {
    border-bottom-color: #1a3a5c;
    box-shadow: 0 1px 0 0 #1a3a5c;
    outline: none;
}
.search-card .form-control::placeholder {
    color: #adb5bd;
    font-size: .75rem;
}
.search-card .form-select {
    background-position: right .25rem center;
    padding-right: 1.5rem;
}
.search-field {
    flex: 0 1 auto;
    min-width: 0;
}
.search-field-sm { max-width: 200px; }
.search-field-md { max-width: 200px; }
.search-field-lg { max-width: 200px; }

/* ===== Detail page ===== */
.detail-label {
    color: #6c757d;
    font-size: .85rem;
    width: 180px;
}

/* ===== Checklist ===== */
.checklist-section {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
    break-inside: avoid;
}
.checklist-section:last-child { margin-bottom: 0; }
.checklist-section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .25rem 1rem;
    background-color: #f4f6f8;
    border-bottom: 1px solid #dee2e6;
    padding: .5rem .875rem;
}
.checklist-section-title {
    margin: 0;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #1a3a5c;
}
.checklist-section-summary {
    font-size: .75rem;
    color: #6c757d;
    white-space: nowrap;
}
.checklist-section-summary .is-flagged { color: #dc3545; font-weight: 600; }

/* Sections holding a finding are tinted so they can be spotted without reading the counts. */
.checklist-section.has-exceptions { border-color: #f5c2c7; }
.checklist-section.has-exceptions .checklist-section-header {
    background-color: #fdf2f3;
    border-bottom-color: #f5c2c7;
}

/* Multi-column rather than a Bootstrap .row: column-rule draws a real divider between columns,
   which a grid cannot do without extra wrapper elements. Items also flow top-to-bottom within a
   column, matching the order the inspector worked through them. */
.checklist-grid {
    column-count: 3;
    column-gap: 2.5rem;
    column-rule: 1px solid #e9ecef;
    padding: .375rem .875rem .625rem;
}
@media (max-width: 1199.98px) { .checklist-grid { column-count: 2; } }
@media (max-width: 767.98px)  { .checklist-grid { column-count: 1; } }

/* max-width is what keeps a status beside its own label. Without it the status drifts to the far
   edge of a ~570px column and reads as if it belonged to the next column's first item. */
.checklist-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: .75rem;
    max-width: 28rem;
    padding: .3rem .125rem;
    border-bottom: 1px solid #f1f3f5;
    font-size: .85rem;
    break-inside: avoid;
}
.checklist-item-label { overflow-wrap: break-word; }

.checklist-status {
    justify-self: end;
    min-width: 6.5rem;
    padding: .1rem .5rem;
    /* Neutral default so a wire value outside the four below still renders as a legible pill
       rather than as borderless text. */
    background-color: #f1f3f5;
    color: #495057;
    border: 1px solid #e9ecef;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-align: center;
    text-transform: uppercase;
    white-space: nowrap;
}
/* Keyed off the raw wire value (pass / repaired / needs_repair / not_applicable) so there is no
   hand-written mapping left to drift out of sync with the Cloud contract. */
.checklist-status-pass           { background-color: #d1e7dd; color: #0f5132; border-color: #badbcc; }
.checklist-status-repaired       { background-color: #fff3cd; color: #664d03; border-color: #ffe69c; }
.checklist-status-needs_repair   { background-color: #f8d7da; color: #842029; border-color: #f5c2c7; }
.checklist-status-not_applicable { background-color: #f1f3f5; color: #868e96; border-color: #e9ecef; }

/* "Exceptions only" switch — hiding is pure CSS, the script only toggles this one class. */
.checklist-no-exceptions { display: none; }
.checklist-exceptions-only .checklist-no-exceptions { display: block; }
.checklist-exceptions-only .checklist-item:not(.is-exception) { display: none; }
.checklist-exceptions-only .checklist-section:not(.has-exceptions) { display: none; }

/* ===== Login / Set Password (standalone pages) ===== */
.standalone-page {
    background-color: #1a3a5c;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin-bottom: 0;
}
.standalone-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,.2);
    padding: 2.5rem;
}
.standalone-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}
.standalone-logo img {
    height: 80px;
    width: auto;
}
.standalone-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a3a5c;
    text-align: center;
    margin-bottom: .5rem;
}
.standalone-subtitle {
    text-align: center;
    color: #6c757d;
    margin-bottom: 1.5rem;
    font-size: .9rem;
}

/* Password requirements */
.req { font-size: .85rem; }
.req-met   { color: #198754; }
.req-unmet { color: #6c757d; }

/* ===== Dashboard ===== */
.dashboard-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dashboard-card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.dashboard-metric-label {
    font-size: .85rem;
    font-weight: 500;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.dashboard-metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a3a5c;
    line-height: 1.2;
}
.dashboard-metric-hint {
    font-size: .8rem;
    color: #adb5bd;
    margin-top: 2px;
}
.dashboard-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.dashboard-icon-blue {
    background-color: #e7f1ff;
    color: #0d6efd;
}
.dashboard-icon-green {
    background-color: #d1e7dd;
    color: #198754;
}
.dashboard-icon-teal {
    background-color: #d2f4ea;
    color: #0d9488;
}
.dashboard-icon-amber {
    background-color: #fff3cd;
    color: #cc8a00;
}
.dashboard-icon-red {
    background-color: #f8d7da;
    color: #dc3545;
}

/* ===== Inspector header =====
   Identity, email and the IECMVI verdict as one block. The facts grid reflows on its own rather than
   using Bootstrap columns, because how many facts a Rolodex contact carries varies a lot. */
.inspector-header-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a3a5c;
    line-height: 1.2;
}
.inspector-header-sub {
    font-size: .9rem;
    color: #6c757d;
}
.inspector-header-email {
    font-size: .9rem;
}
/* A fixed column count, not auto-fit. auto-fit sizes each grid independently from its own content,
   so a 4-item row and a 3-item row landed on different tracks and the labels did not line up. Every
   fact lives in one grid with one set of tracks, so column 1 is column 1 on every row.
   minmax(0, 1fr) rather than 1fr: a bare 1fr floors at the content width, which a 36-character
   organization GUID would blow straight past. */
.inspector-header-facts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .9rem 1.5rem;
    align-items: start;
}
@media (max-width: 1199.98px) {
    .inspector-header-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
    .inspector-header-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 575.98px) {
    .inspector-header-facts { grid-template-columns: minmax(0, 1fr); }
}
.inspector-header-fact-label {
    font-size: .7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.inspector-header-fact-value {
    font-size: .9rem;
    /* The organization GUID has no spaces to break on and would otherwise widen its track. */
    overflow-wrap: anywhere;
}

/* ===== Inspector activity trend =====
   A bar chart made of divs. Command ships no charting library and this does not justify adding one:
   twelve rows, one length each, and it prints. Only the fill width is an inline style. */
.activity-bar-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 2px 0;
    text-decoration: none;
    color: inherit;
}
.activity-bar-row:hover .activity-bar-fill {
    background-color: #2d5f94;
}
.activity-bar-row:hover .activity-bar-value {
    color: #1a3a5c;
}
.activity-bar-label {
    flex: 0 0 5.5rem;
    font-size: .75rem;
    color: #6c757d;
    white-space: nowrap;
}
.activity-bar-track {
    flex: 1 1 auto;
    height: 14px;
    background-color: #ebedf0;
    border-radius: 3px;
    overflow: hidden;
}
.activity-bar-fill {
    display: block;
    height: 100%;
    background-color: #1a3a5c;
    border-radius: 3px;
    transition: background-color .15s ease;
}
.activity-bar-value {
    flex: 0 0 3rem;
    text-align: right;
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
    color: #6c757d;
}

/* ===== Footer ===== */
footer {
    font-size: .85rem;
}

/* ===== Print ===== */
@media print {
    .navbar, .no-print { display: none !important; }
    .card { box-shadow: none; border: 1px solid #dee2e6; }
    footer { display: none; }
    body { background-color: #fff; }

    /* Browsers ignore break-inside: avoid on an element taller than a page, so the 28-item In-Cab
       section still splits rather than leaving a blank page. */
    .checklist-section { break-inside: avoid; border-color: #adb5bd; }
    .checklist-grid { column-gap: 1.5rem; }
    /* Status is carried entirely by the pill's fill colour, so it has to survive the default
       "do not print backgrounds" behaviour. */
    .checklist-status,
    .checklist-section-header {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Same reason: a trend bar is nothing but its fill, so it has to survive the default
       "do not print backgrounds" behaviour or every month prints as an empty track. */
    .activity-bar-track,
    .activity-bar-fill {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
