:root {
    --bg: #0b1220;
    --panel: #111a2e;
    --card: #0f1930;
    --text: #e8eefc;
    --muted: #a8b3cf;
    --line: #1f2a44;
    --btn: #2b6cff;
    --warning: #ff6600;
    --caution: #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;
    font-size: 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* <label class="btn"> file pickers etc.: global `label` uses smaller type + column layout — match real buttons */
label.btn {
    flex-direction: row;
    gap: 0;
}

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

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

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

.btn.caution {
    background: var(--caution);
    border-color: var(--caution);
    color: #fff;
}

.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;
}

.table tbody tr.mouRow--signed td {
    background: rgba(24, 179, 90, 0.14);
}

.table tbody tr.mouRow--pending td {
    background: rgba(255, 102, 0, 0.12);
}

/* ======================
   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;
}

.userAgreementModal {
    width: min(760px, 96vw);
}

.mouEditorModal {
    width: min(1040px, 96vw);
}

.mouAssignModal {
    width: min(920px, 96vw);
}

.mouHero {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    padding: 24px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 28%),
        linear-gradient(180deg, color-mix(in srgb, var(--panel) 90%, #2563eb 10%), var(--panel));
}

.mouHero__copy h1 {
    margin: 4px 0 10px 0;
}

.mouHero__copy p {
    max-width: 760px;
    margin: 0;
}

.mouHero__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.mouEyebrow {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.mouSectionHeader {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 14px;
}

.mouSectionHeader h2,
.mouSectionHeader p {
    margin: 0;
}

.mouSectionHeader p {
    margin-top: 4px;
}

.mouBadgeRow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 0;
}

.mouBadge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: rgba(37, 99, 235, 0.12);
    color: var(--text);
    border: 1px solid rgba(37, 99, 235, 0.18);
}

.mouBadge--soft {
    background: rgba(148, 163, 184, 0.18);
    border-color: rgba(148, 163, 184, 0.22);
}

.mouBadge--accent {
    background: rgba(234, 179, 8, 0.18);
    border-color: rgba(234, 179, 8, 0.28);
}

.mouCardGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 14px;
}

.mouSummaryCard {
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-radius: 18px;
}

.mouSummaryCard h3 {
    margin: 10px 0 6px 0;
}

.mouSummaryCard__top {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.mouMetaPill {
    min-width: 84px;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 88%, #0f172a 12%);
    text-align: center;
}

.mouMetaPill strong,
.mouMetaPill span {
    display: block;
}

.mouMetaPill span {
    font-size: 0.8rem;
    color: var(--muted);
}

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

.mouAgencyList__row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 93%, #020617 7%);
}

.mouStatus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    min-width: 94px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.mouStatus--ok {
    background: rgba(34, 197, 94, 0.16);
    color: #16a34a;
}

.mouStatus--pending {
    background: rgba(234, 179, 8, 0.16);
    color: #b45309;
}

.mouStatus--soft {
    background: rgba(148, 163, 184, 0.16);
    color: var(--muted);
}

.mouActionRow {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mouActionRow form {
    display: inline-flex;
}

.mouActionRow .btn {
    width: auto;
}

.table .mouActionRow {
    align-items: center;
}

.mouTargetList {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px dashed var(--line);
}

.mouWorkspace {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.9fr);
    gap: 14px;
}

.mouWorkspace--formSplit {
    grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
    align-items: stretch;
}

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

.mouWorkspace__document,
.mouWorkspace__sidebar {
    min-width: 0;
}

.mouWorkspace--formSplit > .mouWorkspace__document,
.mouWorkspace--formSplit > .mouWorkspace__sidebar {
    display: flex;
    flex-direction: column;
}

.mouWorkspace--formSplit .mouAdminForm {
    flex: 1 1 auto;
}

.mouWorkspace--formSplit .mouSectionHeader {
    min-height: 34px;
    align-items: center;
}

.mouWorkspace--formSplit .mouSectionHeader > div {
    flex: 1 1 auto;
    min-width: 0;
}

.mouWorkspace--formSplit [data-user-agreement-fields] {
    flex: 1 1 auto;
}

.mouWorkspace--formSplit [data-user-agreement-title-wrap] {
    min-width: 0;
}

.mouWorkspace--formSplit [data-user-agreement-fields][hidden] {
    display: none !important;
}

.mouWorkspace > .card,
.mouWorkspace > .mouWorkspace__document,
.mouWorkspace > .mouWorkspace__sidebar {
    margin: 0;
}

.mouWorkspace__sidebar--sticky {
    align-self: start;
}

@media (min-width: 992px) {
    .mouWorkspace__sidebar--sticky {
        position: sticky;
        top: 12px;
        max-height: calc(100vh - 24px);
        overflow-y: auto;
    }
}

.mouViewerCard {
    padding: 0;
    overflow: hidden;
}

.mouViewerToolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.mouDocumentShell {
    padding: 22px;
    line-height: 1.6;
}

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

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

.mouDocumentShell blockquote {
    margin: 1rem 0;
    padding-left: 1rem;
    border-left: 4px solid var(--line);
    color: var(--muted);
}

.signed-shell .signed-header,
.signed-shell .signed-header *,
.signed-shell .signed-body,
.signed-shell .signed-body * {
    color: #111827 !important;
    -webkit-text-fill-color: #111827 !important;
}

.signed-shell .signed-header,
.signed-shell .signed-body {
    background: #ffffff;
}

.signed-shell .signed-header a,
.signed-shell .signed-body a {
    color: #2563eb !important;
}

.mouSignatureCanvas {
    width: 100%;
    max-width: 520px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    touch-action: none;
}

.mouPdfFrame {
    display: block;
    width: 100%;
    min-height: 780px;
    border: 0;
    background: #ffffff;
}

.mouCallout {
    margin-bottom: 12px;
}

.mouListCardTableWrap {
    width: 100%;
}

.mouListCardTable td {
    vertical-align: top;
}

.mouListCardTable .cardTitleText {
    display: block;
    font-weight: 600;
    line-height: 1.35;
}

.mouListCardTable .cardTitleMeta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.mouListCardTable .cardActionsRow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.mouListCardTable .cardActionsRow form {
    display: inline-flex;
}

.mouListCardTable .cardActionsRow .btn,
.mouListCardTable .cardActionsRow .muted {
    width: auto;
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
}

.mouPageHeader {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.mouPageHeader__intro {
    flex: 1 1 320px;
    min-width: 0;
}

.mouPageHeader__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.mouPageHeader__actions .btn {
    width: auto;
}

.mouCallout--warning {
    border-color: var(--warning);
}

.mouCallout--danger {
    border-color: var(--danger);
}

.mouEmptyState {
    text-align: center;
    padding: 18px;
}

.mouEmptyState h3 {
    margin: 0 0 6px 0;
}

.mouAdminForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mouAdminForm textarea {
    width: 100%;
    min-height: 220px;
    box-sizing: border-box;
}

.mouCheckboxLabel {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.mouSectionHeader__toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.mouAgreementTopRow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 220px);
    gap: 12px;
    align-items: start;
}

.mouToggleField {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-width: 0;
}

.mouToggleField__control {
    height: 42px;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    box-sizing: border-box;
}

.mouSwitch {
    position: relative;
    display: inline-flex;
    width: 46px;
    height: 26px;
    flex: 0 0 auto;
}

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

.mouSwitch input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.mouSwitch__slider {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: color-mix(in srgb, var(--line) 70%, #000 30%);
    border: 1px solid var(--line);
    transition: background 0.2s ease, border-color 0.2s ease;
    position: relative;
}

.mouSwitch__slider::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease;
}

.mouSwitch input:checked + .mouSwitch__slider {
    background: color-mix(in srgb, var(--success) 78%, #ffffff 22%);
    border-color: color-mix(in srgb, var(--success) 70%, #ffffff 30%);
}

.mouSwitch input:checked + .mouSwitch__slider::after {
    transform: translateX(20px);
}

.mouFormFooter {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.mouFormFooter .btn {
    width: auto;
}

.mouFormFooter__leftAction {
    margin-right: auto;
}

.mouCustomFieldEditor {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: color-mix(in srgb, var(--panel) 94%, #0f172a 6%);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mouCustomFieldEditor__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

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

.mouCustomFieldEditor__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.mouCustomFieldEditor__row .btn {
    width: auto;
}

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

.mouAgencyCheckboxGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.mouAgencyCheckbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--panel) 93%, #020617 7%);
}

.mouAssignServerwideBox {
    margin-top: 2px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--panel) 94%, #0f172a 6%);
}

.mouAssignServerwideLabel {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.mouAssignAgencyList {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mouAssignAgencyRow {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(248, 81, 73, 0.35);
    background: rgba(248, 81, 73, 0.14);
    user-select: none;
    min-height: 30px;
    text-align: left;
}

.mouAssignAgencyRow__check {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.mouAssignAgencyRow__signing {
  padding-left: 24px;
}

.mouAssignSigningRow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.mouAssignSigningField {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 180px;
}

.mouAssignCopyLinkBtn {
  flex: 0 0 auto;
  align-self: flex-end;
  white-space: nowrap;
}

.mouAssignSigningField input,
.mouAssignSigningField select {
    width: 100%;
}

.mouAssignAgencyRow input[type="checkbox"] {
    margin: 0;
    flex: 0 0 auto;
}

.mouAssignAgencyRow span {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mouAssignAgencyRow--selected {
    border-color: rgba(46, 160, 67, 0.45);
    background: rgba(46, 160, 67, 0.18);
}

.mouAssignAgencyRow--locked {
    border-color: rgba(46, 160, 67, 0.35);
    background: rgba(46, 160, 67, 0.1);
}

.mouAssignAgencyRow--locked .mouAssignAgencyRow__check {
    cursor: not-allowed;
}

.mouAssignAgencyRow__signedBadge {
    font-size: 12px;
    font-weight: 600;
    color: #3fb950;
}

.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;
    }

    .mouHero,
    .mouSectionHeader,
    .mouSummaryCard__top,
    .mouViewerToolbar,
    .mouAgencyList__row {
        flex-direction: column;
        align-items: stretch;
    }

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

    .mouListCardTableWrap {
        overflow-x: hidden;
    }

    .mouListCardTable {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0 12px;
    }

    .mouListCardTable thead {
        display: none;
    }

    .mouListCardTable tbody tr {
        display: flex;
        flex-direction: column;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--panel);
        overflow: hidden;
    }

    .mouActiveDocsTable .cardTitleCell { order: 1; }
    .mouActiveDocsTable .mouVersionCell { order: 2; }
    .mouActiveDocsTable .mouAgencyCell { order: 3; }
    .mouActiveDocsTable .mouStatusCell { order: 4; }
    .mouActiveDocsTable .cardActionsCell { order: 5; }

    .mouDocumentsTable .cardTitleCell { order: 1; }
    .mouDocumentsTable .mouVersionCell { order: 2; }
    .mouDocumentsTable .mouAssignmentCell { order: 3; }
    .mouDocumentsTable .mouSignatureCountCell { order: 4; }
    .mouDocumentsTable .cardActionsCell { order: 5; }

    .mouSignatureTable .cardTitleCell { order: 1; }
    .mouSignatureTable .mouStatusCell { order: 2; }
    .mouSignatureTable .mouSigningMethodCell { order: 3; }
    .mouSignatureTable .mouAgencyCell { order: 4; }
    .mouSignatureTable .mouSignerCell { order: 5; }
    .mouSignatureTable .mouSignedVersionCell { order: 6; }
    .mouSignatureTable .mouCurrentVersionCell { order: 7; }
    .mouSignatureTable .mouScopeCell { order: 8; }
    .mouSignatureTable .cardActionsCell { order: 9; }

    .mouArchivedTable .cardTitleCell { order: 1; }
    .mouArchivedTable .mouStatusCell { order: 2; }
    .mouArchivedTable .mouAgencyCell { order: 3; }
    .mouArchivedTable .mouSignedVersionCell { order: 4; }
    .mouArchivedTable .mouCurrentVersionCell { order: 5; }
    .mouArchivedTable .mouScopeCell { order: 6; }
    .mouArchivedTable .mouArchivedAtCell { order: 7; }
    .mouArchivedTable .cardActionsCell { order: 8; }

    .mouListCardTable tbody td {
        display: block;
        border-top: none;
        padding: 8px 12px;
        word-break: normal;
        overflow-wrap: normal;
        min-width: 0 !important;
        max-width: none !important;
        white-space: normal;
    }

    .mouListCardTable tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--muted);
        margin-bottom: 4px;
    }

    .mouListCardTable .cardTitleCell::before,
    .mouListCardTable .cardActionsCell::before {
        display: none;
    }

    .mouListCardTable .cardTitleCell {
        padding-top: 12px;
        padding-bottom: 4px;
    }

    .mouListCardTable .cardActionsCell {
        border-top: 1px solid var(--line);
        padding-top: 10px;
        padding-bottom: 12px;
    }

    .mouListCardTable .cardActionsRow {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
        min-width: 0;
    }

    .mouListCardTable .cardActionsRow .btn,
    .mouListCardTable .cardActionsRow .muted {
        width: 100% !important;
        max-width: 100%;
        min-width: 0;
        margin: 0;
        white-space: nowrap;
        word-break: normal !important;
        overflow-wrap: normal !important;
        box-sizing: border-box;
        text-align: center;
    }

    .mouListCardTable .cardActionsRow .muted {
        grid-column: 1 / -1;
        padding: 8px 0;
    }

    .mouListCardTable .cardActionsRow form {
        display: block !important;
        width: 100%;
    }

    .mouPageHeader {
        align-items: stretch;
    }

    .mouPageHeader__actions,
    .mouViewerToolbar .mouActionRow {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mouPageHeader__actions .btn,
    .mouViewerToolbar .mouActionRow .btn {
        width: 100%;
    }

    .mouViewerToolbar {
        padding: 16px;
    }

    .mouDocumentShell {
        padding: 16px;
    }

    .mouDocumentShell table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mouPdfFrame {
        min-height: 68vh;
    }

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

@media (max-width: 640px) {
    .mouPageHeader__actions,
    .mouViewerToolbar .mouActionRow,
    .mouListCardTable .cardActionsRow {
        grid-template-columns: 1fr;
    }
}

/* ======================
   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;
}

/* Managed agencies: compact checkbox dropdown (Access Control, Users) */
.ma-multiselect-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 420px;
}
.ma-multiselect-label {
  display: block;
  font-weight: 500;
  font-size: 0.92rem;
}
.ma-multiselect.filter-multiselect {
  position: relative;
  display: block;
  width: 100%;
}
.ma-multiselect .filter-toggle {
  width: 100%;
  text-align: left;
  justify-content: space-between;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ma-multiselect .filter-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  min-width: 0;
  max-width: none;
  max-height: 280px;
  overflow: hidden;
  flex-direction: column;
  background: var(--card, #111827);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  padding: 0;
  display: none;
}
.ma-multiselect.open .filter-menu {
  display: flex;
}
.ma-multiselect .filter-menu-inner {
  padding: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ma-multiselect-search {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: var(--input-bg, rgba(0, 0, 0, 0.2));
  color: inherit;
  font-size: 13px;
}
.ma-multiselect-list {
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}
.ma-multiselect .filter-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
}
.ma-multiselect .filter-option:hover {
  background: rgba(255, 255, 255, 0.04);
}
.ma-multiselect .filter-option input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
  width: 1.125em;
  height: 1.125em;
}
.ma-multiselect .filter-option span {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.ma-multiselect-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.ma-multiselect-actions .link-btn {
  padding: 4px 0;
  font-size: 12px;
}
.ma-multiselect-summary {
  font-size: 0.88rem;
  line-height: 1.35;
}

