:root {
    --bg: #0b1220;
    --panel: #111a2e;
    --card: #0f1930;
    --text: #e8eefc;
    --muted: #a8b3cf;
    --line: #1f2a44;
    --btn: #2b6cff;
    --warning: #ff6600;
    --danger: #ff3b3b;
    --success: #18b35a;
    /* Sidebar link highlight (dark themes: lighter overlay so it stands out) */
    --sidebar-link-hover: rgba(255, 255, 255, 0.06);
    --sidebar-link-active: rgba(255, 255, 255, 0.12);
    --sidebar-link-active-hover: rgba(255, 255, 255, 0.16);
}

/* Theme variants */
body.theme-dark-blue {
    --bg: #0b1220;
    --panel: #0b1430;
    --card: #0f1930;
    --text: #e8eefc;
    --muted: #a8b3cf;
    --line: #1f2a44;
    --btn: #2b6cff;
}

body.theme-dark {
    --bg: #0b0b0b;
    --panel: #121212;
    --card: #1c1c1e;
    --text: #ffffff;
    --muted: #8e8e93;
    --line: #38383a;
    --btn: #0a84ff;
}

body.theme-light {
    --bg: #f3f4f6;    /* slate-100 */
    --panel: #ffffff; /* white panel/sidebar */
    --card: #f9fafb;  /* subtle card contrast */
    --text: #020617;  /* slate-950 */
    --muted: #4b5563; /* slate-600 - darker for readability */
    --line: #e5e7eb;  /* slate-200 borders */
    --btn: #2563eb;   /* slightly richer blue */
    /* Sidebar link highlight (light: dark overlay so current page is clear) */
    --sidebar-link-hover: rgba(15, 23, 42, 0.06);
    --sidebar-link-active: rgba(15, 23, 42, 0.1);
    --sidebar-link-active-hover: rgba(15, 23, 42, 0.14);
}


/* Logo Handling */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--line);
}

/* When there IS a logo */
.brand.has-logo {
    padding: 14px 14px 18px 14px;
}

/* When there is NO logo — flatter, cleaner */
.brand.no-logo {
    padding: 10px 14px;
}

.brand-logo {
    max-height: 36px;
    width: auto;
}


* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--site-font, system-ui, -apple-system, Segoe UI, Roboto, sans-serif);
    background: var(--bg);
    color: var(--text);
}

/* Desktop scale normalization to mimic ~80% browser zoom */
@media (min-width: 1024px) {
    body {
        zoom: 0.8;
    }
    /* Compensate viewport-sized containers when zoom is applied */
    .app {
        min-height: calc(100dvh / 0.8);
    }
    .sidebar {
        min-height: calc(100dvh / 0.8);
        height: calc(100dvh / 0.8) !important;
    }
    /* Keep modals visually tall at desktop zoom */
    .modal {
        max-height: calc(92dvh / 0.8);
    }
    /* Page-specific modal sizing moved here from view files */
    #modalOverlay .modal { /* Users edit modal */
        max-height: calc(96dvh / 0.8) !important;
        min-height: calc(78dvh / 0.8);
    }
    #missionModal .modal { /* Data Sync edit mission modal */
        max-height: calc(96dvh / 0.8) !important;
        min-height: calc(82dvh / 0.8);
    }
    #dataFeedModalOverlay .modal { /* Integrations create streaming feed modal */
        max-height: calc(96dvh / 0.8) !important;
        min-height: calc(82dvh / 0.8);
    }
    #locHistOverlay .modal { /* Locate history modal */
        max-height: calc(85dvh / 0.8) !important;
    }
    .modalCard { /* Audit log details modal card */
        max-height: calc(80dvh / 0.8) !important;
    }
}

/* Theme toggle button (top-right, floating) */
.theme-toggle {
    position: fixed;
    top: 10px;
    right: 12px;
    z-index: 1200;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 8px;
    background: rgba(0,0,0,0.35);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.theme-toggle__icon {
    display: block;
}

/* Default: dark mode => show moon */
.theme-toggle__icon--sun {
    display: none;
}

body.theme-light .theme-toggle__icon--sun {
    display: block;
}

body.theme-light .theme-toggle__icon--moon {
    display: none;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* ======================
   SIDEBAR
   ====================== */

.sidebar {
    width: 240px;
    padding: 18px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar for sidebar (desktop + mobile) */
.sidebar {
    scrollbar-width: none;          /* Firefox */
}

.sidebar::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;                  /* Safari and Chrome */
}

/* Desktop sticky sidebar: stays visible while main content scrolls */
@media (min-width: 991px) {
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;  /* sidebar scrolls if it gets too tall */
    }
}

.version-text {
    display: block;
    margin-top: 6px;
    opacity: .6;
    font-size: 11px;
    text-align: center;
  }

.update-available-form {
    margin-top: 8px;
    text-align: center;
}

.update-available-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 999px;               /* SUPER rounded rectangle */
    border: none;
    background: var(--btn);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.04),
                0 6px 16px rgba(0,0,0,0.45);
    transition:
        transform 80ms ease-out,
        box-shadow 80ms ease-out,
        background 150ms ease-out,
        opacity 120ms ease-out;
}

.update-available-help {
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.7;
    text-align: left;
    word-break: break-word;
}

.update-available-help pre {
    margin: 4px 0 0;
    padding: 4px 6px;
    font-size: 10px;
    background: rgba(0,0,0,0.45);
    border-radius: 4px;
    overflow-x: auto;
}


.update-available-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0,0,0,0.55);
    background: #3b7cff;
}

.update-available-pill:active {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(0,0,0,0.6);
    opacity: 0.9;
}

/* Update modal (uses base .modalOverlay/.modal styles) */
.updateOverlay {
    /* Ensure the update modal always stays above any in-page popovers/tooltips */
    z-index: 20000;
    isolation: isolate;
    position: fixed;
    inset: 0;
    background: transparent; /* backdrop handled by .updateOverlayBackdrop */
}

.updateOverlayBackdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 0;
}

.updateModal {
    position: relative;
    z-index: 1;
    width: min(720px, 96vw);
}

.update-meta {
    margin: 0 0 10px;
    opacity: 0.85;
}

.update-inline-help {
    font-size: 12px;
    opacity: 0.8;
}

.update-log-wrap {
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
}

.update-log {
    height: 220px;
    overflow: auto;
    padding: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 11px;
    line-height: 1.4;
}

.update-log-line {
    white-space: pre-wrap;
    word-break: break-word;
    opacity: 0.95;
}




  

.brand {
    font-weight: 800;
    letter-spacing: .5px;
    margin-bottom: 18px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.nav-top {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* IE/Edge legacy */
}

.nav-top::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;                  /* Chrome/Safari */
}

.nav-bottom {
    margin-top: auto; /* stays pinned at bottom while nav-top scrolls */
    flex: 0 0 auto;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    text-align: center;
}

.sidebar a {
    display: block;
    padding: 10px;
    margin: 6px 0;
    color: var(--text);
    text-decoration: none;
    border-radius: 10px;
}

.sidebar a:hover {
    background: var(--sidebar-link-hover);
}

.sidebar a.active {
    background: var(--sidebar-link-active);
    border-radius: 8px;
    font-weight: 600;
}

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

/* Sidebar collapsible sections */
.nav-section {
  margin: 4px 0;
}

.nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  margin: 2px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.nav-section-toggle:hover {
  background: rgba(255,255,255,.06);
}

.nav-section-chevron {
  opacity: 0.8;
  transition: transform 0.2s ease;
}

.nav-section.collapsed .nav-section-chevron {
  transform: rotate(-90deg);
}

.nav-section-links {
  overflow: hidden;
  transition: max-height 0.2s ease-out;
}

.nav-section.collapsed .nav-section-links {
  max-height: 0 !important;
  margin: 0;
  padding: 0;
  opacity: 0;
}

.nav-section-links a {
  padding-left: 20px;
  margin: 2px 0;
}

/* ======================
   MAIN CONTENT
   ====================== */

.main {
    flex: 1;
    padding: 26px;
}

h1 {
    margin: 0 0 14px 0;
}

h2 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: var(--muted);
}

/* ======================
   CARDS / LAYOUT
   ====================== */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    margin: 14px 0;
    box-shadow: 0 18px 35px rgba(15,23,42,.32);
}

.row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.grid3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}

@media (max-width: 900px) {
    .grid2 {
        grid-template-columns: 1fr;
    }
}

/* ======================
   FORMS
   ====================== */

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text);
}

input,
select,
textarea {
    background: var(--panel);  
    border: 1px solid var(--line);
    color: var(--text);
    padding: 10px;
    border-radius: 10px;
    outline: none;
    font-family: inherit;
    font-size: 14px;
}

input:focus,
select:focus {
    border-color: var(--btn);
}

.btn {
    background: var(--btn);
    border: none;
    color: white;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn:hover {
    filter: brightness(1.05);
}

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

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

/* Special button color for Mutual Aid QR */
.btn.qr {
    background: #7c3aed;
}

/* ======================
   SEGMENTED CONTROL
   ====================== */

.segmented {
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}

.segBtn {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
}

.segBtn:hover {
    filter: brightness(1.03);
}

.segBtn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Ensure good contrast in modal segmented controls */
.modal .segBtn {
    color: var(--text);
}

/* ======================
   TABLES
   ====================== */

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    border-top: 1px solid var(--line);
    padding: 10px;
    text-align: left;
}

.table thead th {
    border-top: none;
    color: var(--text);
    font-size: 12px;
}

/* ======================
   CHECKLIST BOX (reused)
   ====================== */

.groupsBox {
    margin-top: 10px;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 12px;
    padding: 10px;
    max-height: 360px;
    overflow: auto;
}

.groupItem {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
}

.groupItem:hover {
    background: rgba(15,23,42,.06);
}

.groupItem input {
    margin: 0;
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.groupItem span {
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ======================
   PASSWORD FIELDS (show/hide — same pattern as users-manage)
   ====================== */

.passwordWrap {
    position: relative;
    display: flex;
    align-items: center;
}

.passwordWrap input {
    width: 100%;
    box-sizing: border-box;
    padding-right: 2.5rem;
}

.passwordToggle {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
}

.passwordToggle:focus-visible {
    outline: 2px solid var(--accent, #fff);
    outline-offset: 2px;
}

/* ======================
   MESSAGES
   ====================== */

.msg {
    margin-left: 10px;
}

.msg.ok {
    color: #5bff8a;
}

.msg.bad {
    color: #ff7a7a;
}

.msg.pending {
    color: #e8c170;
}

/* ======================
   MODALS
   ====================== */

.modalOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 1000;
}

.modal {
    width: min(1100px, 96vw);
    max-height: 92vh;
    overflow: auto;
    position: relative;
    isolation: isolate;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,.45);
}

.modalHeader {
    position: sticky;
    top: 0;
    background: var(--panel);
    z-index: 5;
    opacity: 1;
    border-bottom: 1px solid var(--line);
    padding: 14px;
    display: flex;
    justify-content: space-between;
}

.modalBody {
    padding: 14px;
}

.noScroll {
    overflow: hidden;
}

/* Hide floating top controls while any modal is open */
body.modal-open .theme-toggle,
body.modal-open .sidebarToggle {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* =========================================================
   MOBILE SIDEBAR TOGGLE
   ========================================================= */

.sidebarToggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1101;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
}

.sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1100;
}

@media (max-width: 990px) {

    .sidebarToggle {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .sidebarOverlay {
        display: block;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    .sidebar {
        display: flex !important;      /* keep flex so nav-bottom stays at bottom */
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 240px;
        transform: translateX(-105%);
        transition: transform .2s ease;
        z-index: 1102;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebarOverlay {
        opacity: 1;
        pointer-events: auto;
    }

    .main {
        padding-top: 64px;
    }
}

/* ======================
   GLOBAL MOBILE OVERFLOW HARDENING
   Prevent page-level horizontal scrolling on small screens.
   ====================== */
@media (max-width: 990px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .app,
    .main,
    .card,
    .row,
    .grid2,
    .grid3,
    .modal,
    .modalBody {
        min-width: 0;
        max-width: 100%;
    }

    /* Inline/flex form blocks often carry min-width via inline styles; relax on mobile */
    .row > label,
    .row > div,
    .card label,
    .card .col,
    .card .row > * {
        min-width: 0 !important;
        max-width: 100%;
    }

    .row > label,
    .card label {
        flex: 1 1 100%;
    }

    input,
    select,
    textarea,
    .btn {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    /* Keep button rows usable (buttons should size to content there) */
    .row .btn,
    .modalHeader .btn {
        width: auto;
    }

    /* Keep wide tables usable but avoid expanding page width */
    .table {
        width: 100%;
        table-layout: auto;
    }
    .table th,
    .table td {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Long strings/URLs/code blocks should wrap instead of pushing layout wider */
    pre,
    code,
    .msg,
    .chips,
    .muted {
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}

/* ======================
   SETTINGS PAGE HELPERS
   ====================== */

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.settings-label {
    font-weight: 600;
}

.settings-help {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Callsign builder chips */
.callsign-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    font-size: 0.8rem;
}

.callsign-chip[data-type="text"] {
    background: #fefce8;
}

.callsign-chip select,
.callsign-chip input[type="text"] {
    font-size: 0.8rem;
}

.callsign-chip-move {
    cursor: grab;
    user-select: none;
    font-size: 0.85rem;
    opacity: 0.75;
}

.callsign-chip.dragging {
    opacity: 0.7;
}

/* Callsign format blocks (horizontal row) - compact so ~7 fit at 1920px */
.callsign-block {
    max-width: 240px;
    min-width: 0;
    padding: 0.3rem 0.4rem !important;
    border-radius: 0.4rem !important;
}
.callsign-block .callsign-block-inner {
    display: grid;
    grid-template-columns: 22px 1fr 30px;
    gap: 0.4rem;
    align-items: center;
    min-width: 0;
}
.callsign-block .callsign-block-handle {
    cursor: grab;
    user-select: none;
    font-size: 0.95rem;
    text-align: center;
}
.callsign-block select,
.callsign-block input[type="text"] {
    font-size: 0.8rem;
    padding: 0.25rem 0.4rem;
    min-width: 0;
    max-width: 100%;
}
.callsign-block .callsign-block-delete {
    padding: 0.2rem 0.35rem;
    font-size: 0.75rem;
}

/* ======================
   SETUP MY DEVICE
   ====================== */

.iosSetupGrid {
    display: grid;
    gap: 14px;
    align-items: start;
}

.iosSetupGrid--two {
    grid-template-columns: 1fr 1fr;
}

.iosSetupGrid--three {
    grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 900px) {

    .iosSetupGrid--two,
    .iosSetupGrid--three {
        grid-template-columns: 1fr;
    }
}

/* Setup My Device — iOS & Android: single card per app, vertical steps inside */
.iosSetupGrid > .iosAppGroup {
    margin-top: 0;
    margin-bottom: 0;
}

.iosAppGroupTitle {
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.iosStep {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.iosStep + .iosStep {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.iosStepHeading {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.btn.tile {
    width: 100%;
    padding: 18px 16px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    text-align: left;
}

.btn.tile .title {
    font-size: 16px;
    font-weight: 700;
}

.btn.tile .desc {
    font-size: 13px;
    font-weight: 500;
    opacity: 0.9;
    line-height: 1.25;
}

