:root {
    /* GCOOS palette: navy primary, light blue for links/active, orange accent */
    --primary-color: var(--gcoos-navy);
    --primary-dark: #0a2a44;
    --link-color: #0b7fa6;
    --secondary-color: #64748b;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --light-bg: #f0f0f0;
    --border-color: #e2e8f0;
    --text-dark: #1e293b;
    --text-light: var(--secondary-color);
    --sidebar-bg: var(--gcoos-navy);
    --sidebar-text: rgba(255, 255, 255, 0.85);
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(255, 255, 255, 0.14);
    --tab-active: #ffffff;
    --accent-light: #e6f4f9;
    --accent-border: #cfe4ee;
    /* GCOOS brand colors (gcoos.org) */
    --gcoos-navy: #0f3b5c;
    --gcoos-blue: #00a1cb;
    --gcoos-orange: #f19611;
    --header-h: 77px;
    --header-bg: #ffffff;
    --header-border: #e9e9e9;
    --header-text: #222222;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    scroll-behavior: smooth;
    background-color: var(--light-bg);
}

/* min-height, not height: a page taller than the window must grow the body
   with it. A fixed 100% body let long pages spill out of the body's box, and
   the sticky header (which can only stick inside that box) scrolled away on
   short windows. */
body {
    min-height: 100%;
    font-family: Arial, sans-serif;
    font-size: 0.95rem;
    color: var(--text-dark);
    background-color: var(--light-bg);
}

/* Navbar Styling — white header like gcoos.org */
.navbar {
    background-color: var(--header-bg);
    box-shadow: none;
    padding: 1rem;
    border-bottom: 1px solid var(--header-border);
}

.navbar-logo {
    display: flex;
    align-items: center;
    margin-right: 0.75rem;
    padding-right: 0.75rem;
    border-right: 1px solid var(--header-border);
    line-height: 1;
}

.navbar-logo img {
    height: 44px;
    width: auto;
    transition: var(--transition);
}

.navbar-logo:hover img {
    opacity: 0.85;
}

.navbar-brand {
    font-family: Arial, sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: -0.5px;
    white-space: nowrap;
    color: var(--gcoos-navy) !important;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.navbar-brand:hover {
    color: var(--gcoos-blue) !important;
    text-decoration: none;
}

/* Navbar search button */
.navbar .btn-outline-secondary {
    color: var(--header-text);
    border: 1px solid var(--border-color);
    background-color: transparent;
}

.navbar .btn-outline-secondary:hover {
    color: #ffffff;
    background-color: var(--gcoos-navy);
    border-color: var(--gcoos-navy);
}

/* Navbar Nav Links */
.navbar-nav .nav-link {
    color: var(--header-text) !important;
    margin: 0 0.25rem;
    padding: 0.5rem 0.75rem !important;
    white-space: nowrap;
    border-radius: 6px;
    transition: var(--transition);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.45px;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--gcoos-navy) !important;
}

.navbar-nav .nav-link.active {
    background-color: rgba(0, 161, 203, 0.12);
    color: var(--gcoos-navy) !important;
}

.navbar-nav .nav-link i {
    margin-right: 0.5rem;
}

/* Clock UTC */
#clock-utc {
    color: var(--header-text);
    font-weight: 500;
    font-size: 0.85rem;
}

/* The header search box must stay one row: when the header is tight the
   input group would otherwise stack its field and button */
.navbar form[role="search"] {
    flex-shrink: 0;
}

.navbar form[role="search"] .input-group {
    flex-wrap: nowrap;
}

.header-clock {
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-light);
    margin-right: 0.5rem;
    white-space: nowrap;
}

/* Sidebar */
#sidebar-container {
    background-color: var(--sidebar-bg);
    padding: 1rem 0;
    border-right: none;
    box-shadow: none;
    overflow-y: auto;
    overflow-x: hidden;   /* never a horizontal scrollbar: items are narrower than the column */
}

#sidebar-container .list-group {
    border: none;
    gap: 0.5rem;
}

#sidebar-container .list-group-item {
    border: none;
    background-color: transparent;
    width: auto; /* Bootstrap's 100% + side margins overflowed the sidebar */
    padding: 0.75rem 1rem;
    margin: 0 0.75rem;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

#sidebar-container .list-group-item:hover,
#sidebar-container .list-group-item:focus {
    background-color: var(--sidebar-hover);
    color: #ffffff;
    transform: translateX(4px);
}

#sidebar-container > .list-group > .list-group-item.active,
#sidebar-container > .list-group > .list-group-item[aria-expanded="true"] {
    background-color: var(--sidebar-active);
    color: #ffffff;
    box-shadow: inset 3px 0 0 var(--gcoos-orange);
}

#sidebar-container .list-group-item i {
    width: 20px;
    margin-right: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

#sidebar-container .list-group-item:hover i,
#sidebar-container .list-group-item.active i {
    color: #ffffff;
}

/* Sidebar Submenu */
#sidebar-container .sidebar-submenu {
    font-size: 0.9rem;
}

#sidebar-container .sidebar-submenu a {
    padding: 0.55rem 1rem 0.55rem 2.5rem !important;
    border-left: 2px solid transparent;
    border-radius: 0 8px 8px 0;
    margin-left: 0.75rem;
    color: rgba(255, 255, 255, 0.72);
    transition: var(--transition);
}

#sidebar-container .sidebar-submenu a:hover {
    border-left-color: var(--gcoos-blue);
    background-color: var(--sidebar-hover);
    color: #ffffff;
    transform: none;
}

#sidebar-container .sidebar-submenu a.active {
    border-left-color: var(--gcoos-orange);
    background-color: var(--sidebar-active);
    color: #ffffff;
    font-weight: 600;
}

/* Collapse Button */
#sidebar-container [data-sidebar-collapse] {
    background-color: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0;
    margin-top: 1rem;
    color: rgba(255, 255, 255, 0.7);
}

#sidebar-container [data-sidebar-collapse]:hover {
    background-color: var(--sidebar-hover);
}

/* Sidebar Expanded/Collapsed States */
.sidebar-expanded {
    width: 230px;
    flex: 0 0 230px;
}

.sidebar-collapsed {
    min-width: 60px;
    max-width: 60px;
    flex: 0 0 60px;
    text-align: center;
}

#sidebar-container.sidebar-collapsed .list-group-item {
    padding: 0.75rem 0;
    margin: 0 0.4rem;
    justify-content: center !important;
}

#sidebar-container.sidebar-collapsed .list-group-item:hover {
    transform: none;
}

#sidebar-container.sidebar-collapsed .list-group-item > div {
    justify-content: center !important;
    width: auto !important;
}

#sidebar-container.sidebar-collapsed .list-group-item i,
#sidebar-container.sidebar-collapsed #collapse-icon {
    margin-right: 0 !important;
}

/* Main Content Area: fill the space below the sticky header */
#body-row {
    margin-left: 0;
    margin-right: 0;
    min-height: calc(100vh - var(--header-h));
    /* Sidebar and content always share the row. Without this the content
       column (which cannot shrink below its widest table or navbar) wrapped
       underneath the sidebar on narrow windows. */
    flex-wrap: nowrap;
}

#body-row > .col {
    min-width: 0;
    padding: 1.25rem 1.75rem;
}

/* Status map card: fit the viewport so the map tab needs no page scrollbar */
.map-card-body {
    /* 100px = page padding (20 + 20) + tab row (42) + tab margin (16) + card border (2) */
    height: calc(100vh - var(--header-h) - 100px);
    min-height: 420px;
}

/* Full-height page block (no tabs/title above it): page padding top + bottom */
.page-fill {
    height: calc(100vh - var(--header-h) - 40px);
    min-height: 420px;
}

.page-fill.has-title {
    /* also subtract the page title bar (h2 + padding + border + margin) */
    height: calc(100vh - var(--header-h) - 40px - 71px);
}

/* Forms */
.form-size {
    max-width: 640px;
    margin: 2rem auto;
    background-color: white;
    padding: 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.form-control,
.form-select {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.4rem 0.75rem;
    font-size: 0.95rem;
    line-height: 1.5;
    transition: var(--transition);
    background-color: white;
}

.form-select {
    padding-right: 2.25rem;
}

/* Small inputs match .btn-sm height */
.form-select-sm {
    padding: 0.25rem 1.75rem 0.25rem 0.6rem;
    font-size: 0.82rem;
}

.form-control-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.82rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(15, 59, 92, 0.1);
    background-color: white;
}

.form-label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

/* Buttons */
.btn {
    border-radius: 4px;
    padding: 0.4rem 0.9rem;
    font-weight: 600;
    transition: var(--transition);
    border: none;
    font-size: 0.95rem;
    line-height: 1.5;
}

.btn-sm,
.btn-group-sm > .btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.82rem;
    border-radius: 3px;
}


.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(15, 59, 92, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(15, 59, 92, 0.3);
    color: white;
}

.btn-primary:active {
    background-color: var(--primary-dark);
    box-shadow: 0 2px 4px rgba(15, 59, 92, 0.2);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
    color: white;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #047857;
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
    color: white;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background-color: #d97706;
    color: white;
}

.btn-info {
    background-color: var(--info-color);
    color: white;
}

.btn-info:hover {
    background-color: #0891b2;
    color: white;
}

.btn-outline-primary {
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    background-color: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

.btn-outline-secondary.active,
.btn-outline-primary.active,
.btn-check:checked + .btn-outline-secondary,
.btn-check:checked + .btn-outline-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
}

.site-button {
    width: auto !important;
    min-width: 76px;
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Map control panel (status page): keep native inputs inside the panel */
#controlSidebar select,
#controlSidebar input[type="text"],
#controlSidebar input[type="number"] {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Page tabs — flat underline style (gcoos.org look) */
.nav-tabs {
    border-bottom: 1px solid var(--border-color);
    gap: 0.25rem;
}

.nav-tabs .nav-link {
    color: var(--text-light);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    margin-bottom: -1px;
    padding: 0.5rem 0.9rem;
    font-weight: 600;
    transition: color 0.2s, border-color 0.2s;
}

.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus {
    color: var(--primary-color);
    border-color: transparent;
    border-bottom-color: rgba(241, 150, 17, 0.45);
    isolation: auto;
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
    color: var(--primary-color);
    background: transparent;
    border-color: transparent;
    border-bottom-color: var(--gcoos-orange);
}

.nav-tabs .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.45rem;
    vertical-align: middle;
}

/* Bare .card-body used as a page section (no surrounding card): no extra padding */
.tab-content > .tab-pane > .card-body,
main.col-sm > .card-body {
    padding: 0.25rem 0 0;
}

/* Cards */
.card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.card-header {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    padding: 1.25rem;
}

/* Tabs inside card headers */
.card-header .nav-tabs {
    border-bottom: none;
}

.card-header .card-header-tabs {
    margin-top: 0;
    margin-bottom: 0;
}

.card-header .nav-tabs .nav-link {
    color: rgba(255, 255, 255, 0.8);
    border: none;
    background: transparent;
    font-weight: 500;
    padding: 0.5rem 1rem;
    margin-bottom: 0;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.card-header .nav-tabs .nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
}

.card-header .nav-tabs .nav-link.active {
    color: var(--primary-color);
    background-color: var(--tab-active);
    font-weight: bold;
    border: none;
    border-radius: 4px;
}

.card-header .text-muted,
.card-header small {
    color: rgba(255, 255, 255, 0.78) !important;
}


.card-body {
    padding: 1.5rem;
}

/* Alerts */
.alert {
    border: none;
    border-radius: 4px;
    padding: 1rem 1.5rem;
    font-weight: 500;
}

.alert-warning {
    background-color: #fffbeb;
    color: #92400e;
    border-left: 4px solid var(--warning-color);
}

.alert-danger {
    background-color: #fee2e2;
    color: #7f1d1d;
    border-left: 4px solid var(--danger-color);
}

.alert-success {
    background-color: #ecfdf5;
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.alert-info {
    background-color: var(--accent-light);
    color: var(--primary-dark);
    border: 1px solid var(--primary-color);
}

.flash-messages { padding-top: 1rem; }
.flash-messages .alert { margin-bottom: 0.75rem; }
.admin-subnav ~ .flash-messages { padding-left: 0; padding-right: 0; }   /* admin column is already padded */

.alert-dismissible .btn-close {
    filter: none;
    opacity: 0.8;
}

.alert-dismissible .btn-close:hover {
    opacity: 1;
}

/* Tables */
.table {
    border-collapse: collapse;
    background-color: white;
}

.table thead th {
    background-color: var(--primary-color);
    color: white;
    border-bottom: none;
    font-weight: 700;
    padding: 8px 12px;
    text-align: left;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.table tbody tr {
    border-bottom: 1px solid var(--accent-border);
    transition: var(--transition);
}

.table tbody tr:nth-child(even) {
    background-color: #f5f9fc;
}

.table tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

.table tbody tr:hover {
    background-color: var(--accent-light);
}

.table tbody td {
    padding: 6px 12px;
    color: var(--text-dark);
    vertical-align: middle;
}

/* Radials status row colors (stale=fatal, aging=warning, fresh=ok). */
.table tbody tr.radial-status-danger > td {
    background-color: #fee2e2 !important;
}

.table tbody tr.radial-status-warning > td {
    background-color: #fffbeb !important;
}

.table tbody tr.radial-status-success > td {
    background-color: #ecfdf5 !important;
}

/* Newest file holds no vectors: the row keeps its age colour; the Latest
   cell carries a red "empty" tag and the time of the last valid vectors. */
.status-latest-line { display: inline-flex; align-items: center; white-space: nowrap; }
.status-empty-tag { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 8px; font-size: 11px; font-weight: 600; line-height: 16px; color: #fff; background: #dc2626; }
.status-empty-note { font-size: 11px; color: #b91c1c; }

.dataTables_wrapper {
    margin-top: 0.75rem;
}

/* Custom DataTables layouts: '<"top"i>rt<"bottom"flp>' — give the bars room and align their parts */
.dataTables_wrapper .top {
    padding: 0.25rem 0 0.5rem;
}

.dataTables_wrapper .bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
    padding: 0.75rem 0;
}

.dataTables_wrapper .bottom .dataTables_paginate {
    margin-left: auto;
}

.dataTables_wrapper .bottom .dataTables_filter,
.dataTables_wrapper .bottom .dataTables_length {
    margin: 0;
}

/* Pagination, everywhere (DataTables pages and the admin lists): navy, not
   Bootstrap's default blue */
.pagination {
    --bs-pagination-color: var(--primary-color);
    --bs-pagination-bg: #ffffff;
    --bs-pagination-border-color: var(--border-color);
    --bs-pagination-hover-color: var(--primary-color);
    --bs-pagination-hover-bg: var(--accent-light);
    --bs-pagination-hover-border-color: var(--accent-border);
    --bs-pagination-focus-color: var(--primary-color);
    --bs-pagination-focus-bg: var(--accent-light);
    --bs-pagination-focus-box-shadow: 0 0 0 0.2rem rgba(15, 59, 92, 0.2);
    --bs-pagination-active-color: #ffffff;
    --bs-pagination-active-bg: var(--primary-color);
    --bs-pagination-active-border-color: var(--primary-color);
    --bs-pagination-disabled-color: #9ca3af;
    --bs-pagination-disabled-bg: #ffffff;
    --bs-pagination-disabled-border-color: var(--border-color);
    --bs-pagination-border-radius: 6px;
    margin-bottom: 0;
}

.pagination .page-link {
    font-size: 0.85rem;
    padding: 0.3rem 0.65rem;
    font-weight: 500;
}

.pagination .page-item.active .page-link {
    box-shadow: 0 1px 3px rgba(15, 59, 92, 0.3);
}

.dataTables_wrapper .dataTables_info,
.list-footer .record-count {
    color: var(--text-light);
    font-size: 0.85rem;
    padding-top: 0;
}

/* Admin list footer: count on the left, pages on the right */
.list-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.75rem 0;
}

/* Edit and Delete Controls */
td.details-control {
    text-align: center;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 600;
    /* Colour only: "all" also animated the row-hover highlight in this one
       cell, so it trailed the rest of the row by 0.3 s. */
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

td.details-control:hover {
    color: var(--gcoos-blue);
}

tr.shown td.details-control {
    color: var(--danger-color);
}

/* Badges */
.badge {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Dropdown Menus */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 0;
}

.dropdown-item {
    padding: 0.75rem 1.5rem;
    color: var(--text-dark);
    transition: var(--transition);
    font-size: 0.95rem;
}

.dropdown-item:hover {
    background-color: var(--accent-light);
    color: var(--primary-color);
}

.dropdown-item.active {
    background-color: var(--primary-color);
    color: white;
}

/* The small per-site menu in the status table */
.site-menu {
    padding: 0.25rem 0;
    min-width: 10rem;
}

.site-menu .dropdown-item {
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
}

.site-menu .dropdown-item.disabled {
    color: #9ca3af;
    cursor: default;
}


/* Modals */
.modal-content {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.modal-header {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px 8px 0 0;
    padding: 1.25rem 1.5rem;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.modal-title {
    font-weight: 700;
    font-size: 1.25rem;
}

/* Navbar Toggler */
.navbar-toggler {
    border: none;
    padding: 0.5rem;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.25rem rgba(0, 0, 0, 0.1);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2834, 34, 34, 0.9%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Links */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Header links: icon + label on wide screens (>= 1200px, where the clock
   also appears), icon only below that so the one-line header never wraps
   or clips. Labels never break onto a second line. */
@media (max-width: 1199.98px) {
    .navbar .nav-label {
        display: none;
    }

    .navbar-nav .nav-link i {
        margin-right: 0;
        font-size: 1.1rem;
    }

    .navbar-nav .nav-link {
        padding: 0.5rem 0.65rem !important;
        margin: 0 0.15rem;
    }
}

/* A list box (<select multiple>) sizes itself to its longest option and
   can push a form wider than the screen; keep it inside its container. */
select {
    max-width: 100%;
}

/* Tablets and below */
@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .navbar-logo img {
        height: 34px;
    }

    #body-row > .col {
        padding: 1rem;
    }

    .form-size {
        padding: 1.5rem;
        margin: 1rem;
    }

    .table {
        font-size: 0.85rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.75rem 0.5rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

/* Phone widths: the logo, brand text, hamburger and three icons do not fit
   side by side, so drop the brand text (the logo still links home). */
@media (max-width: 575.98px) {
    .navbar {
        padding: 0.5rem;
    }

    .navbar .navbar-brand {
        display: none;
    }

    .navbar-logo {
        margin-right: 0.5rem;
        padding-right: 0.5rem;
    }

    .navbar-logo img {
        height: 30px;
    }

    .navbar-nav .nav-link {
        padding: 0.4rem 0.45rem !important;
        margin: 0;
    }

    .navbar .navbar-toggler {
        padding: 0.25rem 0.4rem;
        margin-left: 0.25rem;
    }

    /* Grouped toggle buttons (report filters) may wrap onto a second line */
    .btn-group-sm {
        flex-wrap: wrap;
    }
}

/* Wide screens: the sidebar stays put under the header while the content
   scrolls. It only scrolls itself if it is taller than the window. */
@media (min-width: 992px) {
    #sidebar-container {
        position: sticky;
        top: var(--header-h);
        align-self: flex-start;
        /* fills the window below the header; the body has nothing below the
           content row, so sticky never has to push it up */
        height: calc(100vh - var(--header-h));
    }
}

/* Below the navbar's expand point (lg = 992px) the sidebar is hidden and the
   hamburger slides it in as an overlay. "show" must beat Bootstrap's
   d-none (display:none !important), hence the !important here. */
@media (max-width: 991.98px) {
    #sidebar-container {
        position: fixed;
        top: var(--header-h);
        left: -260px;
        width: 230px;
        height: calc(100vh - var(--header-h));
        z-index: 1040;
        transition: left 0.25s ease;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.25);
    }

    #sidebar-container.show {
        display: block !important;
        left: 0;
    }
}


/* Print Styles */
@media print {
    .navbar,
    #sidebar-container {
        display: none;
    }

    .card {
        box-shadow: none;
        border-color: #000;
    }
}

/* Form layout helpers */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.5rem;
    margin-left: -0.5rem;
}

.form-group.row label {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

.col-form-label {
    font-weight: 600;
    color: var(--text-dark);
}

.col-sm-2, .col-sm-3, .col-sm-4 {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

/* Form enhancements */
input[readonly] {
    background-color: var(--light-bg);
    color: var(--text-light);
    cursor: not-allowed;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.form-control:disabled,
.form-control[disabled] {
    background-color: var(--light-bg);
    opacity: 0.7;
}

/* Table Enhancements */
.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(15, 59, 92, 0.02);
}

.table-hover tbody tr:hover {
    background-color: var(--accent-light);
}

/* Icon enhancements */
.fa-fw {
    width: 1rem;
    text-align: center;
}

i[class^="fas"],
i[class^="far"] {
    vertical-align: -0.125em;
}

/* Focus states for accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus,
a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* =====================================================================
   Admin pages (Flask-Admin): the category bar under the header. The
   markup comes from Flask-Admin's layout.menu(); its own admin.css loads
   after this file, hence the !important on the colours.
   ===================================================================== */
.admin-subnav {
    background-color: var(--primary-dark);
    padding: 0;
    margin: -2rem -2rem 1.5rem -2rem;
    border-radius: 0;
}

/* Items stay on one line each; the bar wraps between items on narrow screens */
.admin-subnav .navbar-nav {
    flex-direction: row;
    flex-wrap: wrap;
}

.admin-subnav .navbar-nav > li {
    display: flex;
}

.admin-subnav .nav-link {
    display: flex;
    align-items: center;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.8) !important;
    padding: 12px 16px !important;
    font-size: 14px;
    font-weight: 500;
    border-radius: 0 !important;
    margin: 0 !important;
    transition: background-color 0.3s;
}

/* hover, and the toggle of the menu that is open */
.admin-subnav .nav-link:hover,
.admin-subnav .nav-link.show {
    color: #ffffff !important;
    background-color: var(--primary-color) !important;
}

/* the current section */
.admin-subnav li.active > .nav-link,
.admin-subnav .nav-link.active {
    background-color: #ffffff !important;
    color: var(--primary-color) !important;
    font-weight: bold;
}

/* Clicking a toggle focuses it and Bootstrap draws a halo that looks like
   an oversized box on the navy bar */
.admin-subnav .nav-link:focus,
.admin-subnav .nav-link:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.admin-subnav .dropdown-menu {
    --bs-dropdown-spacer: 0;       /* flush with the bar, no gap */
    border: 1px solid var(--accent-border);
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
}

.admin-subnav .dropdown-item {
    padding: 8px 16px;
    font-size: 14px;
    color: #333;
}

.admin-subnav .dropdown-item:hover {
    background-color: var(--accent-light);
    color: var(--primary-color);
}

.admin-subnav .dropdown-item.active {
    background-color: var(--primary-color) !important;
    color: white !important;
}

.admin-subnav .dropdown-toggle::after {
    margin-left: 0.3em;
}

/* Flask-Admin marks the caret with a Glyphicon that is not loaded */
.admin-subnav .glyphicon {
    display: none;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary-color) !important;
}

/* =====================================================================
   Status map control panel (built in status/index.jinja2 buildSidebar)
   ===================================================================== */
.ctl-row { display: flex; align-items: center; gap: 4px; }
.ctl-row-wide { gap: 6px; }
.ctl-sm { font-size: 11px; }
.ctl-xs { font-size: 10px; }
.ctl-xxs { font-size: 9px; padding: 0 4px; }
.ctl-muted { color: #6b7280; }
.ctl-tight { line-height: 1.3; }
.ctl-noselect { user-select: none; }
.ctl-label { font-size: 11px; margin: 0; white-space: nowrap; }
.ctl-heading { font-size: 11px; font-weight: bold; margin-bottom: 3px; }
.ctl-heading.ctl-xs { font-weight: 600; }
.ctl-btn { font-size: 11px; padding: 1px 6px; }
.ctl-btn.ctl-xs { font-size: 10px; }
.ctl-select { font-size: 11px; padding: 1px 3px; }
.ctl-select.ctl-xs { font-size: 10px; padding: 0 2px; }
.ctl-input { width: 50px; font-size: 10px; padding: 1px 3px; }
.ctl-input-narrow { width: 45px; }
.ctl-input-wide { width: 55px; font-size: 11px; }
.ctl-w28 { display: inline-block; width: 28px; }
.ctl-w30 { display: inline-block; width: 30px; }
.ctl-panel { margin: 6px 0 0; padding: 5px 8px; background: #f8f9fa; border-radius: 4px; border: 1px solid #dee2e6; }
.ctl-section { margin-top: 8px; border-top: 1px solid #dee2e6; padding-top: 6px; }
.ctl-count { min-height: 15px; }
.ctl-chev { font-size: 9px; width: 12px; margin-right: 3px; }
.ctl-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; font-size: 11px; }
.clickable { cursor: pointer; }
.dop-help-popover { max-width: 340px; font-size: 12px; line-height: 1.4; }

/* Status map: floating panels, legend, home button, site list */
.map-panel { background: #fff; padding: 6px 10px; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.3); font-size: 11px; line-height: 18px; }
.map-legend { max-width: 230px; }
.map-legend-head { font-weight: 600; margin-right: 6px; }
.map-legend-row { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.map-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); margin: 0 2px 0 6px; flex: none; }
.map-legend .swatch:first-of-type { margin-left: 0; }
.map-legend .swatch-line { width: 16px; height: 4px; border-radius: 2px; border: 0; box-shadow: none; margin: 0 4px 0 0; }
.leaflet-bar a.map-home-btn { font-size: 14px; color: #333; }
.radial-miss-popup .leaflet-popup-content { font-size: 11px; line-height: 1.4; margin: 8px 10px; }
.radial-site-label { cursor: pointer; margin: 1px 0 1px 15px; font-size: 11px; line-height: 16px; padding-left: 18px; text-indent: -18px; }
.radial-site-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; border: 1px solid rgba(0,0,0,.2); }
/* Half-white dot for a site whose newest file is empty: a faint outline keeps the white half visible on light base maps. */
.site-empty-icon svg { display: block; filter: drop-shadow(0 0 1px rgba(0,0,0,.45)); }
.radial-site-label.is-active .radial-site-name { font-weight: bold; }
.radial-site-note { color: #6b7280; margin-left: 4px; font-size: 10px; }

/* Status map: sidebar one-offs (folded from inline styles 2026-10-26) */
.ctl-alert { font-size: 11px; line-height: 1.4; }
.ctl-hr { margin: 6px 0; }
.ctl-help { color: #2563eb; font-weight: normal; }
.ctl-flag { gap: 2px; margin: 0; }
.ctl-inline-rel { position: relative; display: inline-block; }
.ctl-datetime { font-size: 10px; padding: 1px 4px; width: 128px; }
.ctl-utc-label { position: absolute; left: 100px; top: 50%; transform: translateY(-50%); font-size: 10px; color: #6b7280; pointer-events: none; }
.ctl-panel.ctl-panel-balance { margin: 4px 0 6px; padding: 6px 8px; }
.map-panel-narrow { min-width: 120px; }
.map-sidebar { width: 240px; min-width: 240px; overflow-y: auto; padding: 10px 12px; border-right: 1px solid #dee2e6; font-size: 12px; line-height: 20px; }
.map-canvas { flex: 1; border-radius: 0 4px 4px 0; }

/* Status map: colour bars (velocity legend, totals colorbar, balance panel) */
.colorbar { display: flex; height: 12px; width: 100%; margin: 4px 0; border: 1px solid #ccc; }
.colorbar-tight { margin: 2px 0; }
.colorbar-cell { flex: 1; }
.colorbar-ticks { display: flex; justify-content: space-between; font-size: 10px; }

/* Status page: network-status tab header and its age legend */
.status-scroll { overflow-y: auto; }
.status-tabs-header { padding: 8px 12px; }
.status-tabs { font-size: 13px; flex: none; }
.status-legend { gap: 8px; white-space: nowrap; }
.status-legend-group { gap: 6px; }
.status-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid; }
.status-swatch-green { background-color: #16a34a; border-color: #15803d; }
.status-swatch-yellow { background-color: #ca8a04; border-color: #a16207; }
.status-swatch-red { background-color: #dc2626; border-color: #b91c1c; }
.link-dotted { text-decoration: underline dotted; cursor: pointer; }
.th-35 { width: 35%; }

/* Status page: total-vector inspector and radial popups */
.chart-box { position: relative; }
.chart-box-dop { height: 110px; }
.chart-box-arrow { width: 340px; height: 340px; margin: 0 auto; }
.chart-box-series { height: 220px; }
.inspector-section { border-top: 1px solid #e5e7eb; padding-top: 10px; }
.kv-cols { display: flex; gap: 8px; }
.kv-col-sep { border-left: 1px solid #e5e7eb; padding-left: 16px; }
.kv-row { display: flex; line-height: 1.85; font-size: 13px; }
.kv-key { color: #6b7280; min-width: 95px; flex-shrink: 0; }
.kv-key-narrow { min-width: 65px; }
.kv-val { font-weight: 500; }
.kv-dop { font-weight: 600; }
.kv-note { font-size: 11px; color: #6b7280; margin-top: 6px; max-width: 190px; line-height: 1.3; }
.radial-map-box { height: 400px; margin-bottom: 12px; border-radius: 6px; border: 1px solid #dee2e6; }
.radial-popup { font-size: 12px; line-height: 1.6; }
.qc-fail { color: #e74c3c; font-weight: bold; }
.qc-pass { color: green; }
