/* ============================================
   NXIPBridge - Dark Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

/* CSS Variables */
/* Palette lives in theme.css (loaded before this file) —
   retune colors there; no color definitions belong here. */

/* Base Styles */
* {
    box-sizing: border-box;
}

/* Reserve the vertical scrollbar's gutter on every page, whether or not one
   is needed. Without this the gutter appears and disappears as you move
   between a page that scrolls and one that does not — and the content jumps
   sideways by the scrollbar's width each time. The page-enter animation makes
   it worse: it starts the content 6px lower, which briefly extends the
   scrollable area on a page that otherwise fits, so a scrollbar flashes in
   and out on arrival. */
html {
    scrollbar-gutter: stable;
}

/* Safari below 18.2 has no scrollbar-gutter; keep the track permanently
   visible there rather than let the page jump. */
@supports not (scrollbar-gutter: stable) {
    html { overflow-y: scroll; }
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    position: relative;
}

body {
    background-color: var(--bg-body);
}

/* ---- Page transitions: dim -> (delayed spinner) -> fade-and-lift ----
   Full-page navigations, not a SPA router. Leaving: content dims and stops
   accepting clicks. Waiting: the loader fades in only after 150ms, so fast
   switches read as a quick dim-and-refresh. Arriving: the new page's main
   content fades in with a slight upward slide. */
.main-content {
    animation: pageEnter 0.22s ease;
}
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

body.content-leaving .main-content {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

#pageLoader {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    pointer-events: none;
}
body.content-leaving #pageLoader {
    display: flex;
    opacity: 0;
    animation: loaderFadeIn 0.2s ease 0.15s forwards;
}
#pageLoader .spinner-border {
    width: 34px;
    height: 34px;
    border-width: 3px;
    color: var(--primary);
}
@keyframes loaderFadeIn {
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .main-content { animation: none; }
    body.content-leaving .main-content { opacity: 1; transition: none; }
    body.content-leaving #pageLoader { animation: none; opacity: 1; }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.3px;
}

h2 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

h2 i {
    color: var(--primary);
}

/* ============================================
   Layout Wrapper & Sidebar (hover-expand)
   ============================================ */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar - collapsed by default, expands on hover */
.sidebar {
    width: var(--sidebar-collapsed-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar.expanded {
    width: var(--sidebar-width);
    box-shadow: var(--shadow-lg);
}

/* Hide text / chevrons when collapsed */
.sidebar .sidebar-brand span,
.sidebar .sidebar-link > span,
.sidebar .sidebar-link .collapse-icon,
.sidebar .user-details,
.sidebar .btn-logout > span,
.sidebar .sidebar-section {
    white-space: nowrap;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.expanded .sidebar-brand span,
.sidebar.expanded .sidebar-link > span,
.sidebar.expanded .sidebar-link .collapse-icon,
.sidebar.expanded .user-details,
.sidebar.expanded .btn-logout > span,
.sidebar.expanded .sidebar-section {
    opacity: 1;
    max-width: 200px;
}

/* Brand / header */
.sidebar-header {
    /* 12px left + 28px brand icon centers on the 52px collapsed rail (26px),
       matching the nav icons (16px + 20px box). */
    padding: 12px 14px 12px 12px;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* Pin button — only visible when sidebar is expanded */
.sidebar-pin {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}
.sidebar.expanded .sidebar-pin {
    opacity: 1;
    pointer-events: auto;
}
.sidebar-pin:hover {
    color: var(--primary);
    border-color: var(--border-color-hover);
    background: var(--bg-card-hover);
}
.sidebar.pinned .sidebar-pin {
    color: var(--primary);
    border-color: rgba(var(--primary-rgb),0.35);
    background: rgba(var(--primary-rgb),0.1);
}
.sidebar.pinned .sidebar-pin i {
    transform: rotate(-45deg);
    display: inline-block;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}
/* The generic a:hover rule would tint the whole wordmark on hover */
.sidebar-brand:hover {
    color: var(--text-primary);
}

/* Brand wordmark — matches the traffic-map display: bold, wide-tracked
   caps with the BRIDGE half in the primary accent. */
.brand-word {
    font-weight: 700;
    letter-spacing: 2.5px;
    font-size: 14px;
}
.brand-word em {
    font-style: normal;
    color: var(--primary);
}

.sidebar-brand .brand-icon {
    /* Bare mark (SVG) — no square background. */
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand .brand-icon img {
    width: 100%;
    height: auto;
    /* The mark is solid brand blue (#005da4), which lands around 2.5:1 on the
       sidebar — dark in every theme, light mode included. Render it white, as
       the login panel does, so it still reads at 28px. */
    filter: brightness(0) invert(1);
}

/* The console's top bar carries the same wordmark on the same surface, so it
   takes the same treatment — .brand-word alone is the wrong shape: this
   overrides its tracking and puts the mark in the mono face. */
.sidebar-brand span,
.console-brand {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* Nav */
.sidebar-nav {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-item {
    position: relative;
    margin: 1px 0;
}

.sidebar-section {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 14px 16px 6px;
    text-transform: uppercase;
    list-style: none;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    min-height: 34px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    position: relative;
    transition: color 0.15s ease, background 0.15s ease;
}

.sidebar-link > i:first-child {
    font-size: 15px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.8;
}

.sidebar-link:hover {
    color: var(--text-sidebar-hover);
    background: transparent;
}

/* Hover: subtle white left-edge indicator */
.sidebar-link:hover::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: rgba(var(--ink-rgb),0.4);
}

/* Active: primary blue left-edge + tinted bg */
.sidebar-link.active {
    color: var(--primary);
    background: var(--bg-sidebar-active);
}

.sidebar-link.active > i:first-child {
    opacity: 1;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: var(--primary);
}

.sidebar-link.active:hover::before {
    background: var(--primary);
}

/* Tooltip when collapsed (shows on hover over link) */
.sidebar:not(.expanded) .sidebar-link[data-title]:hover::after,
.sidebar:not(.expanded) .btn-logout[data-title]:hover::after,
.sidebar:not(.expanded) .user-info[data-title]:hover::after {
    content: attr(data-title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    padding: 6px 10px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 12px;
    border-radius: var(--border-radius-sm);
    white-space: nowrap;
    z-index: 1100;
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

/* Submenu (expand/collapse) */
.sidebar-link .collapse-icon {
    font-size: 9px;
    margin-left: auto;
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.sidebar-submenu {
    list-style: none;
    padding: 6px 0;
    margin: 0;
    position: fixed;
    /* 4px breathing room from the sidebar, matching the user pop-out */
    left: calc(var(--sidebar-width) + 4px);
    top: 0; /* set dynamically via JS */
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    z-index: 1100;
    pointer-events: none;
}

/* Invisible bridge over the 4px gap so hovering across it doesn't count
   as leaving the sidebar (which would close the flyout mid-crossing). */
.sidebar-submenu::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 0;
    bottom: 0;
    width: 5px;
}

.sidebar-item.has-submenu.expanded > .sidebar-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}

.sidebar-item.has-submenu.expanded > .sidebar-link .collapse-icon {
    /* The chevron points right at the flyout; a quarter turn down reads as
       "open" (a half turn would point it back at the sidebar). */
    transform: rotate(90deg);
}

.sidebar-submenu .sidebar-link {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 32px;
}

.sidebar-submenu .sidebar-link:hover::before,
.sidebar-submenu .sidebar-link.active::before {
    left: 0;
}

/* Footer */
.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding: 6px 0;
}

.sidebar-user {
    display: flex;
    flex-direction: column;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    /* 12px left + 28px avatar centers on the 52px collapsed rail (26px). */
    padding: 8px 16px 8px 12px;
    min-height: 44px;
    color: var(--text-sidebar);
    position: relative;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-indigo), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-on-accent);
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-form { margin: 0; }

/* Clickable user card (bottom of sidebar) -> pop-out menu */
.user-menu-trigger {
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}
.user-menu-trigger:hover { background: var(--bg-sidebar-hover); }
.user-menu-trigger[aria-expanded="true"] { background: var(--bg-card-hover); }
.user-menu-chevron {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.sidebar .user-menu-chevron {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.expanded .user-menu-chevron { opacity: 1; max-width: 20px; }

/* Pop-out menu — fixed-positioned by JS (the sidebar clips overflow) */
.user-menu {
    position: fixed;
    z-index: 1200;
    min-width: 210px;
    background: var(--bg-card);
    border: 1px solid var(--border-color-hover);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.user-menu.open { opacity: 1; transform: translateX(0); }
.user-menu-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 6px;
}
.user-menu-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-menu-role { font-size: 11px; color: var(--text-muted); }
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    text-align: left;
}
.user-menu-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.user-menu-item-danger { color: var(--accent-red); }
.user-menu-item-danger:hover {
    background: rgba(var(--accent-red-rgb),0.1);
    color: var(--accent-red);
}
.user-menu-logout { margin: 0; }

/* Settings page — theme picker cards */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.theme-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--bg-inner);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: var(--transition);
}
.theme-card:hover { border-color: var(--border-color-hover); background: var(--bg-card-hover); }
.theme-card.selected { border-color: var(--primary); background: rgba(var(--primary-rgb),0.06); }
.theme-swatches { display: flex; gap: 4px; }
.theme-swatch {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid var(--border-color-hover);
}
.theme-card-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.theme-check { color: var(--primary); opacity: 0; font-size: 14px; }
.theme-card.selected .theme-check { opacity: 1; }
.theme-card-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

.btn-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-sidebar);
    padding: 8px 16px;
    min-height: 34px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    position: relative;
    transition: color 0.15s ease;
}

.btn-logout > i:first-child {
    font-size: 15px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.8;
}

.btn-logout:hover {
    background: transparent;
    color: var(--accent-red);
}

.btn-logout:hover::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: var(--accent-red);
}


/* ============================================
   Main Content
   ============================================ */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-collapsed-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Pinned: sidebar stays expanded and main content shifts to match.
   We key off html.sidebar-pinned (set synchronously in <head> from localStorage)
   so the layout is correct on first paint — no jump when navigating between pages. */
html.sidebar-pinned .sidebar {
    width: var(--sidebar-width);
    box-shadow: none;
}
html.sidebar-pinned .sidebar .sidebar-brand span,
html.sidebar-pinned .sidebar .sidebar-link > span,
html.sidebar-pinned .sidebar .sidebar-link .collapse-icon,
html.sidebar-pinned .sidebar .user-details,
html.sidebar-pinned .sidebar .btn-logout > span,
html.sidebar-pinned .sidebar .sidebar-section {
    opacity: 1;
    max-width: 200px;
}
html.sidebar-pinned .sidebar .sidebar-pin {
    opacity: 1;
    pointer-events: auto;
    color: var(--primary);
    border-color: rgba(var(--primary-rgb),0.35);
    background: rgba(var(--primary-rgb),0.1);
}
html.sidebar-pinned .sidebar .sidebar-pin i {
    transform: rotate(-45deg);
    display: inline-block;
}
html.sidebar-pinned .main-wrapper {
    margin-left: var(--sidebar-width);
}

/* Docs mode: persistent wide sidebar so doc titles aren't truncated.
   Layered on top of .sidebar-pinned (which already keeps labels visible). */
html.docs-mode .sidebar {
    width: 290px;
}
html.docs-mode .main-wrapper {
    margin-left: 290px;
}
html.docs-mode .sidebar .sidebar-link > span {
    white-space: normal;
    line-height: 1.3;
    max-width: 230px;
}
html.docs-mode .sidebar .sidebar-link {
    align-items: flex-start;
    padding-top: 9px;
    padding-bottom: 9px;
}
html.docs-mode .sidebar .sidebar-link > i:first-child {
    margin-top: 1px;
}

.main-content {
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Site footer — Rock Communications branding. margin-top:auto pins it to
   the bottom of the viewport on short pages. */
.app-footer {
    margin-top: auto;
    padding: 20px 24px 18px;
    text-align: center;
}

.app-footer img {
    width: 190px;
    max-width: 60%;
    height: auto;
}


.content-wrapper {
    padding: 24px;
    max-width: none;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    margin: 0;
}

.page-title i {
    color: var(--primary);
    margin-right: 8px;
}

/* Live Badge */
.live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    border-radius: 20px;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse-anim 2s ease-in-out infinite;
}

@keyframes pulse-anim {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-color-hover);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
    font-size: 13px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
}

/* Collapsible cards (bridges/systems pages): when the body is collapsed the
   header's divider sits on the card's bottom edge and reads as a stray
   underline — only draw it while the body is open. */
.bridge-card .card-header,
.system-card .card-header {
    border-bottom: none;
}
.bridge-card:has(.collapse.show) .card-header,
.system-card:has(.collapse.show) .card-header {
    border-bottom: 1px solid var(--border-color);
}

.card-header i {
    color: var(--primary);
    margin-right: 7px;
    font-size: 14px;
}

.card-body {
    padding: 18px;
}

/* Stat Cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 18px;
    position: relative;
    overflow: hidden;
    box-shadow:
        var(--shadow-md),
        inset 0 1px 0 rgba(var(--ink-rgb),0.04);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    border-color: var(--border-color-hover);
}

/* Accent variants: the color wash is layered OVER the opaque card
   surface (not used as the whole background) so cards stay solid on
   light themes instead of showing the page through a 7% tint. */
.stat-card.accent-green {
    background: linear-gradient(rgba(var(--accent-green-rgb),0.07), rgba(var(--accent-green-rgb),0.07)) var(--bg-card);
    border-color: rgba(var(--accent-green-rgb),0.2);
    border-left-color: var(--accent-green);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(var(--accent-green-rgb),0.04);
}

.stat-card.accent-blue {
    background: linear-gradient(rgba(var(--primary-rgb),0.07), rgba(var(--primary-rgb),0.07)) var(--bg-card);
    border-color: rgba(var(--primary-rgb),0.2);
    border-left-color: var(--primary);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(var(--primary-rgb),0.04);
}

.stat-card.accent-indigo {
    background: linear-gradient(rgba(var(--accent-indigo-rgb),0.07), rgba(var(--accent-indigo-rgb),0.07)) var(--bg-card);
    border-color: rgba(var(--accent-indigo-rgb),0.2);
    border-left-color: var(--accent-indigo);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(var(--accent-indigo-rgb),0.04);
}

.stat-card.accent-teal {
    background: linear-gradient(rgba(var(--accent-teal-rgb),0.07), rgba(var(--accent-teal-rgb),0.07)) var(--bg-card);
    border-color: rgba(var(--accent-teal-rgb),0.2);
    border-left-color: var(--accent-teal);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(var(--accent-teal-rgb),0.04);
}

.stat-card.accent-red {
    background: linear-gradient(rgba(var(--accent-red-rgb),0.07), rgba(var(--accent-red-rgb),0.07)) var(--bg-card);
    border-color: rgba(var(--accent-red-rgb),0.2);
    border-left-color: var(--accent-red);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(var(--accent-red-rgb),0.04);
}

.stat-card.accent-yellow {
    background: linear-gradient(rgba(var(--accent-yellow-rgb),0.07), rgba(var(--accent-yellow-rgb),0.07)) var(--bg-card);
    border-color: rgba(var(--accent-yellow-rgb),0.2);
    border-left-color: var(--accent-yellow);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(var(--accent-yellow-rgb),0.04);
}

.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    font-size: 16px;
}

.stat-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(var(--text-muted-rgb),0.85);
    margin-bottom: 6px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    text-shadow: var(--stat-value-shadow);
}

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.stat-sub.ok {
    color: var(--accent-green);
}

.stat-sub a {
    color: var(--text-muted);
    text-decoration: none;
}

.stat-sub a:hover {
    color: var(--primary);
}

/* Panel Cards */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 18px;
    box-shadow: var(--panel-shadow);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.panel:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--panel-shadow-hover);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 7px;
}

.panel-title i {
    font-size: 14px;
    color: var(--primary);
}

.updated-tag {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.panel-count {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 4px;
}

/* Compact time-window tab selector, used in panel headers (Activity,
   Bridge Group Health, etc.). */
.window-tabs {
    display: inline-flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 3px;
    gap: 2px;
}
.window-tabs button {
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.window-tabs button.active {
    background: var(--primary-light);
    color: var(--primary);
}
.window-tabs button:not(.active):hover {
    color: var(--text-primary);
}

/* Bridge Group Health rows */
.bgh-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}
.bgh-row:last-child { border-bottom: 0; }
.bgh-row:hover { background: var(--bg-card-hover); color: inherit; }
.bgh-row .bgh-name {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bgh-row .bgh-rate {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    text-align: right;
}
.bgh-row .bgh-meta {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
}
.bgh-row .bgh-bar {
    height: 4px;
    border-radius: 2px;
    background: rgba(var(--ink-rgb),0.04);
    overflow: hidden;
    margin-top: 4px;
    grid-column: 1 / -1;
}
.bgh-row .bgh-bar > div {
    height: 100%;
    transition: width 0.3s ease;
}

.retry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.retry-cell {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
}
.retry-cell .retry-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}
.retry-cell .retry-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}
.retry-bar-block { font-size: 12px; }
.retry-bar-row {
    display: flex;
    justify-content: space-between;
    margin: 6px 0 2px;
}
.retry-bar {
    height: 4px;
    background: var(--bg-card);
    border-radius: 2px;
    overflow: hidden;
}
.retry-bar > div {
    height: 100%;
    transition: width 0.3s ease;
}

.bridge-list-scroll {
    max-height: 360px;
    overflow-y: auto;
    margin: 0 -4px;
    padding: 0 4px;
}
.bridge-list-scroll::-webkit-scrollbar { width: 6px; }
.bridge-list-scroll::-webkit-scrollbar-track { background: transparent; }
.bridge-list-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color-hover);
    border-radius: 3px;
}

/* Section tabs (maintenance page) */
.nav-tabs {
    border-bottom: 1px solid var(--border-color);
    gap: 4px;
}
.nav-tabs .nav-link {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 8px 8px 0 0;
    padding: 8px 16px;
}
.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    border-color: transparent;
    background: var(--bg-card-hover);
}
.nav-tabs .nav-link.active {
    color: var(--primary);
    background: var(--bg-card);
    border-color: var(--border-color) var(--border-color) var(--bg-card);
}

/* SSO lock badge on user avatars (users page) */
.sso-lock {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color-hover);
    display: flex;
    align-items: center;
    justify-content: center;
}
.sso-lock i {
    font-size: 8px;
    color: var(--text-secondary);
    line-height: 1;
}

/* Live call feed (dashboard) — mirrors the traffic-map ticker */
.feed-item {
    display: flex;
    gap: 10px;
    background: var(--bg-inner);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 12px 8px 9px;
    margin-bottom: 8px;
    font-size: 12.5px;
    transition: border-color 0.15s ease;
}
.feed-item:hover { border-color: var(--border-color-hover); }
.feed-item.feed-active {
    border-color: rgba(var(--accent-green-rgb), 0.35);
    background: linear-gradient(rgba(var(--accent-green-rgb), 0.04), rgba(var(--accent-green-rgb), 0.04)) var(--bg-inner);
}
.feed-item.feed-new { animation: feedIn 0.45s ease; }
@keyframes feedIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}
.feed-rail {
    flex-shrink: 0;
    width: 3px;
    border-radius: 3px;
    margin: 1px 0;
}
.feed-main { flex: 1; min-width: 0; }
.feed-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.feed-who {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.feed-bridge {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.feed-time {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    margin-left: auto;
}
.feed-live-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
    animation: livepulse 1.6s ease-in-out infinite;
}
@keyframes livepulse { 50% { opacity: 0.35; } }
.feed-route {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}
.feed-site {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-secondary);
    background: rgba(var(--ink-rgb), 0.05);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 1px 7px;
}
.feed-site.feed-src {
    color: var(--text-primary);
    font-weight: 600;
    background: rgba(var(--primary-rgb), 0.10);
    border-color: rgba(var(--primary-rgb), 0.25);
}
.feed-arrow { font-size: 11px; color: var(--text-muted); }
.feed-nodest {
    font-size: 10.5px;
    color: var(--text-muted);
    font-style: italic;
}

/* Health Status */
.health-ok {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(var(--accent-green-rgb),0.08);
    border: 1px solid rgba(var(--accent-green-rgb),0.2);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-green);
    margin-bottom: 10px;
}

.health-degraded {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(var(--accent-orange-rgb),0.08);
    border: 1px solid rgba(var(--accent-orange-rgb),0.2);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-orange);
    margin-bottom: 10px;
}

.health-msg {
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 2px;
}

/* Latency Items */
.latency-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: nowrap;
    min-width: 0;
    transition: transform 0.5s ease;
}

.latency-item:last-child {
    border-bottom: none;
}

.lat-rank {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    width: 18px;
    flex-shrink: 0;
    white-space: nowrap;
}

.lat-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    flex: 0 0 auto;
    max-width: 90px;
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lat-bar-wrap {
    flex: 1;
    min-width: 60px;
    height: 5px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.lat-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                background 0.6s ease;
}

.lat-val {
    font-size: 11px;
    font-family: var(--font-mono);
    min-width: 50px;
    text-align: right;
    color: var(--text-secondary);
    flex-shrink: 0;
    white-space: nowrap;
}

/* Bridge Items */
.bridge-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-inner);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: border-color 0.15s ease, background 0.15s ease;
}
/* Clickable variant (dashboard Bridge Groups card) — link chrome off,
   name keeps its own colors instead of the global link blue */
a.bridge-item-link {
    text-decoration: none;
}
a.bridge-item-link .bridge-name {
    color: var(--text-primary);
}
a.bridge-item-link:hover {
    border-color: var(--border-color-hover);
}
a.bridge-item-link:hover .bridge-name {
    color: var(--primary);
}

.bridge-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
}

.bridge-item:last-child {
    margin-bottom: 0;
}

.bridge-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Activity Items */
.activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
    border-bottom: none;
}

.act-who {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.act-action {
    font-size: 12px;
    color: var(--text-secondary);
    flex: 1;
}

.act-tag {
    font-size: 10px;
    background: rgba(var(--accent-indigo-rgb),0.15);
    color: var(--accent-indigo);
    border: 1px solid rgba(var(--accent-indigo-rgb),0.25);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.act-time {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

/* Bottom Grid */
.bottom-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.span-2 {
    grid-column: span 2;
}

/* ============================================
   Tables
   ============================================ */
.table {
    margin-bottom: 0;
    color: var(--text-primary);
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-striped-bg: rgba(var(--ink-rgb),0.02);
    --bs-table-striped-color: var(--text-primary);
    --bs-table-hover-bg: var(--bg-card-hover);
    --bs-table-hover-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    background-color: transparent;
}

.table > :not(caption) > * > * {
    background-color: transparent;
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
    box-shadow: none;
}

.table-responsive {
    background: transparent;
}

.table thead tr,
.table-light,
.table-light > th,
.table-light > td {
    background-color: transparent !important;
    color: var(--text-muted) !important;
}

.table th {
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 14px;
}

.table td {
    padding: 12px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

/* Inline-edit rows (bridges/systems): cells are filled edge-to-edge with
   controls, so the row separator hugs each field and reads like an
   underline under the dropdowns — let the controls define the rows. */
.bridge-row td,
.site-row td,
.add-row td {
    border-bottom: none;
}

.table tbody tr {
    transition: var(--transition);
}

.table-hover tbody tr:hover {
    background-color: var(--bg-card-hover);
}

.table-actions {
    white-space: nowrap;
    text-align: right;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    font-weight: 500;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--btn-primary-bg) 0%, var(--btn-primary-bg-2) 100%);
    border: none;
    color: var(--btn-primary-text);
    font-weight: 600;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--btn-primary-bg-2) 0%, var(--btn-primary-hover-2) 100%);
    color: var(--btn-primary-text);
    transform: translateY(-1px);
}

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

.btn-outline-primary:hover {
    background-color: var(--primary-light);
    border-color: var(--btn-primary-bg);
    color: var(--btn-primary-bg);
}

/* Keep Bootstrap's default :active/:focus styles from flashing through
   under the primary buttons. */
.btn-primary:active,
.btn-primary.active,
.btn-primary:focus,
.btn-primary:focus-visible {
    background: linear-gradient(135deg, var(--btn-primary-bg-2) 0%, var(--btn-primary-hover-2) 100%) !important;
    color: var(--btn-primary-text) !important;
    border-color: transparent !important;
    box-shadow: 0 0 0 3px var(--primary-light) !important;
}

.btn-outline-primary:active,
.btn-outline-primary.active,
.btn-outline-primary:focus,
.btn-outline-primary:focus-visible {
    background-color: var(--primary-light) !important;
    border-color: var(--btn-primary-bg) !important;
    color: var(--btn-primary-bg) !important;
    box-shadow: 0 0 0 3px var(--primary-light) !important;
}

.btn-outline-secondary {
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: transparent;
}

.btn-outline-secondary:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--border-color-hover);
    color: var(--text-primary);
}

.btn-outline-danger {
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    background: transparent;
}

.btn-outline-danger:hover {
    background-color: rgba(var(--accent-red-rgb),0.15);
    color: var(--accent-red);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    font-weight: 600;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 20px;
    letter-spacing: 0.03em;
}

.badge.bg-success,
.badge-enabled {
    background: rgba(var(--accent-green-rgb),0.12) !important;
    color: var(--accent-green) !important;
    border: 1px solid rgba(var(--accent-green-rgb),0.25);
}

.badge.bg-secondary,
.badge-disabled {
    background: rgba(var(--text-muted-rgb),0.12) !important;
    color: var(--text-secondary) !important;
    border: 1px solid rgba(var(--text-muted-rgb),0.25);
}

.badge.bg-danger {
    background: rgba(var(--accent-red-rgb),0.12) !important;
    color: var(--accent-red) !important;
    border: 1px solid rgba(var(--accent-red-rgb),0.25);
}

.badge.bg-primary {
    background: rgba(var(--primary-rgb),0.12) !important;
    color: var(--primary) !important;
    border: 1px solid rgba(var(--primary-rgb),0.25);
}

.badge.bg-warning {
    background: rgba(var(--accent-orange-rgb),0.12) !important;
    color: var(--accent-orange) !important;
    border: 1px solid rgba(var(--accent-orange-rgb),0.25);
}

.badge.bg-info {
    background: rgba(var(--accent-indigo-rgb),0.12) !important;
    color: var(--accent-indigo) !important;
    border: 1px solid rgba(var(--accent-indigo-rgb),0.25);
}

/* ============================================
   Forms
   ============================================ */
.form-label {
    font-weight: 500;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.form-control,
.form-select {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-input);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.15);
    color: var(--text-primary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* Enabled checkboxes sitting directly in table cells (systems/bridges
   status column): bump them up so they're an easy click target. */
.table td > .form-check-input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
    vertical-align: middle;
}

/* File inputs: theme the native "Choose File" button, which Bootstrap
   otherwise paints light gray — a white block on the dark theme. */
.form-control[type="file"] {
    padding: 6px 10px;
}
.form-control[type="file"]::file-selector-button {
    background-color: var(--bg-card-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 12px;
    margin-right: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}
/* Bootstrap ships its own light-gray hover rule at
   .form-control:hover:not(:disabled):not([readonly])::file-selector-button —
   mirror its selector so this wins and the button stays on theme. */
.form-control[type="file"]:hover:not(:disabled):not([readonly])::file-selector-button {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-color-hover);
}

/* Native select dropdown options + date/time picker widgets */
.form-select,
select.form-control,
select,
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"] {
    color-scheme: dark;
}

.form-select option,
select option {
    background-color: var(--bg-input);
    color: var(--text-primary);
}

/* Replace WebKit's near-invisible calendar glyph with a bright custom SVG.
   color-scheme: dark above also nudges browsers that don't expose this
   pseudo-element (e.g. Firefox) toward a light-on-dark indicator. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2338bdf8'><path d='M4 0a1 1 0 0 1 1 1v1h6V1a1 1 0 1 1 2 0v1h1.5A1.5 1.5 0 0 1 16 3.5v11A1.5 1.5 0 0 1 14.5 16h-13A1.5 1.5 0 0 1 0 14.5v-11A1.5 1.5 0 0 1 1.5 2H3V1a1 1 0 0 1 1-1zM1.5 5a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-13z'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px 14px;
    width: 18px;
    height: 18px;
    padding: 0;
    margin-right: 2px;
    cursor: pointer;
    opacity: 0.85;
    filter: none;
    transition: opacity 0.15s ease;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="month"]::-webkit-calendar-picker-indicator:hover,
input[type="week"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Disabled form controls keep the dark theme */
.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
    background-color: rgba(var(--ink-rgb),0.02);
    color: var(--text-muted);
    border-color: var(--border-color);
    opacity: 0.6;
    cursor: not-allowed;
}

.form-text {
    font-size: 11px;
    color: var(--text-muted);
}

/* ============================================================
   Custom dropdown (custom-select.js) — replaces the native
   <select> chrome with a fully themeable menu. The native
   <select> stays in the DOM, visually hidden but focusable, so
   form submission and required-validation keep working.
   ============================================================ */
.c-select {
    position: relative;
    display: block;
    width: 100%;
}

/* Inside an input-group, behave like a form-control flex child instead of
   a full-width block (which would wrap the group's buttons to a new line),
   and square off the joined corners. */
.input-group > .c-select {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}
.input-group > .c-select:not(:last-child) .c-select__trigger {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.input-group > .c-select:not(:first-child) .c-select__trigger {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Native select: kept for submit/validation, hidden behind the trigger.
   Not display:none so `required` fields stay focusable on submit.
   opacity needs !important: higher-specificity rules like
   .form-select:disabled { opacity: 0.6 } would otherwise make the
   ghost select visible again on top of the trigger. */
.c-select > select {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0 !important;
    pointer-events: none;
}

/* The trigger also carries the select's form-select[-sm] classes (copied
   by custom-select.js) so contextual page CSS keeps applying. Kill the
   Bootstrap chrome those classes drag in — we draw our own chevron. */
.c-select__trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: auto;
    text-align: left;
    background-image: none;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary);
    transition: var(--transition);
    cursor: pointer;
}

.c-select__trigger:hover {
    border-color: var(--border-color-hover);
}

.c-select.is-open .c-select__trigger,
.c-select__trigger:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.c-select__value {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.c-select__value--placeholder {
    color: var(--text-muted);
}

.c-select__chevron {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.c-select.is-open .c-select__chevron {
    transform: rotate(180deg);
}

.c-select.is-disabled .c-select__trigger {
    background-color: rgba(var(--ink-rgb), 0.02);
    color: var(--text-muted);
    border-color: var(--border-color);
    opacity: 0.6;
    cursor: not-allowed;
}

/* Small variant (mirrors .form-select-sm usage) */
.c-select--sm .c-select__trigger {
    padding: 6px 10px;
    font-size: 12px;
}

/* Menu — appended to <body>, positioned by JS (position: fixed) */
.c-select__menu {
    position: fixed;
    z-index: 1080; /* above modals' content, below tooltips */
    max-height: 280px;
    overflow-y: auto;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.c-select__menu.is-open {
    opacity: 1;
    transform: translateY(0);
}

.c-select__option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.c-select--sm .c-select__menu .c-select__option {
    font-size: 12px;
    padding: 6px 10px;
}

.c-select__option.is-active {
    background-color: var(--bg-card-hover);
}

.c-select__option.is-selected {
    color: var(--primary);
}

/* Check mark on the selected option (reserve space so labels align) */
.c-select__option::before {
    content: "\F633"; /* bi-check2 */
    font-family: "bootstrap-icons";
    font-size: 13px;
    flex: 0 0 auto;
    width: 14px;
    opacity: 0;
}

.c-select__option.is-selected::before {
    opacity: 1;
}

.c-select__option--placeholder {
    color: var(--text-muted);
}

.form-check-input {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

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

.input-group-text {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    gap: 4px;
}

.page-link {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: var(--border-radius-sm) !important;
    transition: var(--transition);
}

.page-link:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--border-color-hover);
    color: var(--text-primary);
}

.page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--text-on-primary);
}

.page-item.disabled .page-link {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-muted);
    opacity: 0.5;
}

/* ============================================
   Alerts
   ============================================ */
.alert-custom {
    border-radius: var(--border-radius);
    font-size: 13px;
}

.alert-danger {
    background-color: rgba(var(--accent-red-rgb),0.1);
    border: 1px solid rgba(var(--accent-red-rgb),0.25);
    color: var(--accent-red);
}

.alert-success {
    background-color: rgba(var(--accent-green-rgb),0.1);
    border: 1px solid rgba(var(--accent-green-rgb),0.25);
    color: var(--accent-green);
}

.alert-info {
    background-color: var(--primary-light);
    border: 1px solid rgba(var(--primary-rgb),0.25);
    color: var(--primary);
}

.alert-warning {
    background-color: rgba(var(--accent-orange-rgb),0.1);
    border: 1px solid rgba(var(--accent-orange-rgb),0.25);
    color: var(--accent-orange);
}

/* ============================================
   Modals
   ============================================ */
.modal-content {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    color: var(--text-secondary);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 16px 20px;
}

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ============================================
   List Groups
   ============================================ */
.list-group-item {
    background-color: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 0;
    color: var(--text-primary);
    transition: var(--transition);
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item-action:hover {
    background-color: var(--bg-card-hover);
}

/* ============================================
   Code/Pre
   ============================================ */
code {
    background-color: var(--bg-card);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font-mono);
}

pre {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 14px;
    overflow-x: auto;
    color: var(--text-primary);
}

/* ============================================
   Pagination
   ============================================ */
.pagination .page-link {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    padding: 8px 12px;
    transition: var(--transition);
}

.pagination .page-link:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--primary);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--text-on-primary);
}

.pagination .page-item.disabled .page-link {
    background-color: transparent;
    color: var(--text-muted);
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    padding: 2rem;
    position: relative;
}

.login-page::before {
    content: '';
    position: fixed;
    top: -200px;
    left: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(var(--primary-rgb),0.08) 0%, transparent 70%);
    pointer-events: none;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 10;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.login-brand .brand-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--accent-indigo));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-accent);
    font-size: 24px;
    margin-bottom: 1rem;
}

.login-brand h1 {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.login-brand p {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0.25rem 0 0 0;
}

/* Input with icon inside */
.input-icon-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    z-index: 1;
    pointer-events: none;
}

.input-with-icon {
    padding-left: 40px;
}

/* ============================================
   Empty States
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state > i {
    font-size: 3rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-bottom: 1rem;
    display: block;
}

.empty-state p {
    color: var(--text-primary);
    font-size: 15px;
    margin: 0 0 0.5rem;
}

.empty-state a:not(.btn) {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.empty-state a:not(.btn):hover {
    text-decoration: underline;
}

/* ============================================
   Toast
   ============================================ */
.toast {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1200px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bottom-grid {
        grid-template-columns: 1fr 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }
}


/* ============================================
   Utilities
   ============================================ */
.text-primary {
    color: var(--primary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.bg-primary-light {
    background-color: var(--primary-light);
}

.border-primary {
    border-color: var(--primary) !important;
}

.font-mono {
    font-family: var(--font-mono);
}

/* ============================================
   Collapsible Bridge Groups
   ============================================ */
.collapse-icon {
    transition: transform 0.2s ease;
    font-size: 12px;
    color: var(--text-muted);
}

[aria-expanded="true"] .collapse-icon {
    transform: rotate(90deg);
}

.card-header .btn-link {
    color: var(--text-primary);
    text-decoration: none;
}

.card-header .btn-link:hover {
    color: var(--primary);
}

.card-header .btn-link h5 {
    font-size: 14px;
    font-weight: 600;
}

/* Links */
a {
    color: var(--primary);
}

a:hover {
    color: var(--primary-dark);
}

/* ============================================
   Help / Docs Pages
   ============================================ */
.doc-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 28px;
    align-items: start;
}
@media (max-width: 991.98px) {
    .doc-layout { grid-template-columns: 1fr; }
    .doc-nav { display: none; }
}

.doc-nav {
    position: sticky;
    top: 24px;
    padding: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.doc-nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 10px;
}

.doc-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.doc-nav a {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 5px 8px;
    border-radius: 6px;
    transition: var(--transition);
    border-left: 2px solid transparent;
}
.doc-nav a:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.doc-nav a.doc-page.active { color: var(--primary); font-weight: 600; }
.doc-nav .doc-subnav a.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: rgba(var(--primary-rgb),0.08);
}
.doc-nav .doc-subnav {
    margin: 4px 0 12px 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border-color);
}
.doc-nav .doc-subnav a { font-size: 11px; padding: 4px 8px; }

/* In-sidebar doc subnav (TOC inside the main sidebar on the help page) */
.sidebar .doc-subnav {
    list-style: none;
    margin: 4px 0 8px 40px;
    padding: 0 0 0 10px;
    border-left: 1px solid var(--border-color);
}
.sidebar .doc-subnav li { margin: 0; }
.sidebar .doc-subnav a {
    display: block;
    font-size: 11px;
    padding: 4px 8px;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-left: -12px;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.sidebar .doc-subnav a:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.sidebar .doc-subnav a.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: rgba(var(--primary-rgb),0.08);
}

.doc-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    margin-bottom: 6px;
}
.doc-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.doc-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary);
    border-radius: var(--border-radius);
    padding: 20px 22px;
    margin-bottom: 16px;
    scroll-margin-top: 24px;
}
.doc-section.accent-green  { border-left-color: var(--accent-green); }
.doc-section.accent-indigo { border-left-color: var(--accent-indigo); }
.doc-section.accent-teal   { border-left-color: var(--accent-teal); }
.doc-section.accent-orange { border-left-color: var(--accent-orange); }
.doc-section.accent-yellow { border-left-color: var(--accent-yellow); }

.doc-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.doc-section-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: rgba(var(--primary-rgb),0.12);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.doc-section.accent-green  .doc-section-icon { background: rgba(var(--accent-green-rgb),0.12); color: var(--accent-green); }
.doc-section.accent-indigo .doc-section-icon { background: rgba(var(--accent-indigo-rgb),0.12); color: var(--accent-indigo); }
.doc-section.accent-teal   .doc-section-icon { background: rgba(var(--accent-teal-rgb),0.12); color: var(--accent-teal); }
.doc-section.accent-orange .doc-section-icon { background: rgba(var(--accent-orange-rgb),0.12); color: var(--accent-orange); }
.doc-section.accent-yellow .doc-section-icon { background: rgba(var(--accent-yellow-rgb),0.12); color: var(--accent-yellow); }

.doc-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.doc-section h6 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 18px;
    margin-bottom: 10px;
}

.doc-section p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
}
.doc-section p:last-child { margin-bottom: 0; }
.doc-section strong { color: var(--text-primary); }

.doc-section ol, .doc-section ul {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.7;
    padding-left: 20px;
}
.doc-section ol li, .doc-section ul li {
    margin-bottom: 6px;
}

/* Numbered step list */
.doc-steps {
    list-style: none;
    padding: 0;
    counter-reset: doc-step;
}
.doc-steps li {
    counter-increment: doc-step;
    position: relative;
    padding-left: 40px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.doc-steps li::before {
    content: counter(doc-step);
    position: absolute;
    left: 0; top: 0;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(var(--primary-rgb),0.12);
    color: var(--primary);
    border: 1px solid rgba(var(--primary-rgb),0.3);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
}
.doc-steps li strong { color: var(--text-primary); }

.doc-section .table {
    font-size: 12px;
    margin-top: 4px;
}
.doc-section .table th {
    font-size: 10px;
    background: rgba(var(--ink-rgb),0.02) !important;
}
.doc-section .table tbody tr:nth-child(odd) {
    background: rgba(var(--ink-rgb),0.01);
}

.doc-callout {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(var(--primary-rgb),0.06);
    border: 1px solid rgba(var(--primary-rgb),0.2);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 12px;
}
.doc-callout i {
    color: var(--primary);
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}
.doc-callout.warning {
    background: rgba(var(--accent-orange-rgb),0.06);
    border-color: rgba(var(--accent-orange-rgb),0.2);
}
.doc-callout.warning i { color: var(--accent-orange); }

/* Markdown-rendered help pages */
.doc-lead {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}
.doc-lead p { margin-bottom: 10px; }
.doc-lead p:last-child { margin-bottom: 0; }
.doc-lead strong { color: var(--text-primary); }
.doc-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 18px;
    margin-bottom: 10px;
}
.doc-section blockquote {
    padding: 12px 14px;
    background: rgba(var(--primary-rgb),0.06);
    border: 1px solid rgba(var(--primary-rgb),0.2);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    margin: 12px 0;
}
.doc-section blockquote p { margin: 0 0 6px 0; font-size: 12px; }
.doc-section blockquote p:last-child { margin-bottom: 0; }
.doc-section pre {
    background: var(--bg-console);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.6;
    overflow-x: auto;
    margin: 10px 0;
}
.doc-section pre code { background: transparent; padding: 0; color: inherit; font-size: inherit; }
.doc-section code {
    background: rgba(var(--ink-rgb),0.06);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}
.doc-section a { color: var(--primary); }
.doc-section table { width: 100%; }

/* Sequence diagram (dark theme) — used on call flow help page */
.seq { position: relative; margin: 0 auto; max-width: 640px; }
.seq-head { display: flex; text-align: center; font-weight: 600; font-size: 11px; color: var(--text-secondary); margin-bottom: 0; text-transform: uppercase; letter-spacing: 0.06em; }
.seq-head > div {
    flex: 1; padding: 8px 4px;
    background: rgba(var(--ink-rgb),0.04);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin: 0 2px;
}
.seq-body { position: relative; padding: 10px 0; }
.seq-body::before, .seq-body::after, .seq-body .seq-mid-line {
    content: ''; position: absolute; top: 0; bottom: 0; width: 1px;
    background: var(--border-color); z-index: 0;
}
.seq-body::before { left: 16.66%; }
.seq-body .seq-mid-line { left: 50%; position: absolute; }
.seq-body::after { left: 83.33%; }
.seq-msg { position: relative; z-index: 1; display: flex; align-items: center; min-height: 28px; font-size: 11px; font-family: var(--font-mono); }
.seq-msg .seq-l, .seq-msg .seq-m, .seq-msg .seq-r { flex: 1; text-align: center; position: relative; }
.seq-arrow { position: relative; display: flex; align-items: center; flex: 1; }
.seq-arrow .seq-line { flex: 1; height: 1px; }
.seq-arrow .seq-label {
    position: absolute; width: 100%; text-align: center; top: -13px;
    font-size: 10px; white-space: nowrap;
}
.seq-sip   .seq-line { background: var(--primary); }
.seq-sip   .seq-label { color: var(--primary); }
.seq-ok    .seq-line { background: var(--accent-green); }
.seq-ok    .seq-label { color: var(--accent-green); }
.seq-voice .seq-line { background: var(--accent-teal); }
.seq-voice .seq-label { color: var(--accent-teal); }
.seq-end   .seq-line { background: var(--accent-red); }
.seq-end   .seq-label { color: var(--accent-red); }
.seq-grant .seq-line { background: var(--accent-yellow); }
.seq-grant .seq-label { color: var(--accent-yellow); }
.seq-oaa   .seq-line { background: var(--text-muted); }
.seq-oaa   .seq-label { color: var(--text-muted); }
.seq-arr-r::after  { content: ''; border: 4px solid transparent; border-left: 6px solid; display: inline-block; }
.seq-arr-l::before { content: ''; border: 4px solid transparent; border-right: 6px solid; display: inline-block; }
.seq-sip   .seq-arr-r::after  { border-left-color: var(--primary); }
.seq-sip   .seq-arr-l::before { border-right-color: var(--primary); }
.seq-ok    .seq-arr-r::after  { border-left-color: var(--accent-green); }
.seq-ok    .seq-arr-l::before { border-right-color: var(--accent-green); }
.seq-voice .seq-arr-r::after  { border-left-color: var(--accent-teal); }
.seq-voice .seq-arr-l::before { border-right-color: var(--accent-teal); }
.seq-end   .seq-arr-r::after  { border-left-color: var(--accent-red); }
.seq-end   .seq-arr-l::before { border-right-color: var(--accent-red); }
.seq-grant .seq-arr-r::after  { border-left-color: var(--accent-yellow); }
.seq-grant .seq-arr-l::before { border-right-color: var(--accent-yellow); }
.seq-oaa   .seq-arr-r::after  { border-left-color: var(--text-muted); }
.seq-note { font-size: 10px; color: var(--text-muted); font-style: italic; }
.seq-gap { min-height: 6px; }

/* Live-status freshness hint, sat inline after the page subtitle. */
.status-tick {
    margin-left: 8px;
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
