/* Brand tokens — values mirror the Marketing site's wwwroot\marketing.css.
   New rules reference these; existing hardcoded colors are left in place. */
:root {
    --saundy-primary: #007AFF;
    --saundy-accent: #00D4FF;
    --saundy-dark-1: #1E2A44;
    --saundy-dark-2: #181A1F;
    --saundy-bg-light: #F8FBFF;
    --saundy-bg-tint: #E6F7FF;
    --saundy-text-muted: #64748b;
    --saundy-text-muted-dark: #94a3b8;
    --saundy-code-bg: #141C2F;

    /* Dark app surfaces — panel gradient mirrors the marketing hero mockup */
    --saundy-app-bg-1: #101830;
    --saundy-app-bg-2: #0C121F;
    --saundy-surface-1: #1D2947;
    --saundy-surface-2: #161D31;
    --saundy-surface-border: rgba(255, 255, 255, 0.09);
    --saundy-text-light: #DCE4F2;
    --saundy-text-light-muted: #8CA0BF;

    --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: "Sora", var(--font-body);
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --ease-out-soft: cubic-bezier(0.22, 0.61, 0.36, 1);

    --bs-body-font-family: var(--font-body);
    --bs-font-monospace: var(--font-mono);
}

h1, h2, h3, h4, h5, h6,
.card-title {
    font-family: var(--font-display);
}

::selection {
    background: rgba(0, 212, 255, 0.35);
}

/* Keys are identifiers — set them in mono so they read as code */
.flag-key {
    font-family: var(--font-mono);
    font-size: 13.5px;
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #F85149;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

.layout {
    display: flex;
    height: 100vh;
}

.content {
    flex: 1;
    padding: 1rem;
}

.sidebar {
    display: flex;
    flex-direction: column;
    flex: 0 0 240px;
    width: 240px;
    background:
        radial-gradient(
            circle 420px at top,
            rgba(0, 212, 255, 0.15),
            transparent
        ),
        linear-gradient(
            180deg,
            #1E2A44,
            #181A1F 100vh
        );

    border-right: 1px solid rgba(255,255,255,0.06);
    color: white;
    transition: width 0.2s ease;
}

/* Desktop: the sidebar stays put while the page scrolls (long docs pages and
   long lists alike), scrolling inside itself if the nav outgrows the viewport.
   Under 768px it is a fixed drawer instead - see the mobile block below. */
@media (min-width: 769px) {
    .sidebar {
        position: sticky;
        top: 0;
        align-self: flex-start;
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
    }
}

.sidebar-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.4px;

    color: #94a3b8;

    margin-bottom: 20px;
    padding-left: 8px;
}

.sidebar-title {
    display: block;
}

@media (max-width: 768px) {
    .mobile-sidebar-title {
        display: block;
        font-size: 13px;
        font-weight: 600;
        letter-spacing: 0.4px;
        color: #94a3b8;
        margin-bottom: 0px;
        padding-left: 8px;
    }
}

/* NAV SYSTEM */
.sidebar-nav {
    gap: 4px;
}

/* BASE LINK */
.sidebar .nav-link {
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;

    gap: 12px;

    padding: 10px 12px;
    border-radius: 10px;

    color: rgba(255,255,255,0.78);

    font-size: 14px;
    font-weight: 500;

    transition: all 0.15s ease;
}

/* ICONS */
.sidebar .nav-link i {
    font-size: 16px;
    opacity: 0.85;
    transition: transform 0.15s var(--ease-out-soft);
}

/* HOVER */
.sidebar .nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.sidebar .nav-link:hover i {
    transform: translateX(2px);
}

/* ACTIVE STATE (very important SaaS detail) */
.sidebar .nav-link.active {
    background: linear-gradient(
        90deg,
        rgba(0, 122, 255, 0.22),
        rgba(0, 212, 255, 0.08)
    );

    color: white;

    border-left: 3px solid #00D4FF;

    padding-left: 9px; /* keeps alignment consistent */

    box-shadow: 0 0 18px rgba(0, 122, 255, 0.20);
}

.sidebar .nav-link.active i {
    opacity: 1;
}

/* COLLAPSIBLE GROUPS */
.sidebar-group {
    display: flex;
    flex-direction: column;
}

.sidebar .sidebar-group-toggle,
.sidebar .sidebar-back {
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}

/* subtle hint that the current page lives inside a collapsed group */
.sidebar .sidebar-group-toggle.child-active {
    color: white;
}

.sidebar .sidebar-group-chevron {
    margin-left: auto;
    font-size: 12px;
    opacity: 0.6;
    transition: transform 0.15s ease;
}

.sidebar-group.expanded .sidebar-group-chevron {
    transform: rotate(180deg);
}

.sidebar-group-items {
    display: flex;
    flex-direction: column;
    gap: 4px;

    margin: 4px 0 4px 14px;
    padding-left: 8px;

    border-left: 1px solid rgba(255,255,255,0.10);
}

.sidebar-group-items .nav-link {
    padding-top: 8px;
    padding-bottom: 8px;
    font-size: 13.5px;
}

.sidebar-group-items .nav-link i {
    font-size: 14px;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
    }

    .d-flex {
        flex-direction: column;
    }

    /* flex rows inside cards stay rows (badge+time headers, label/value lines) */
    .card-view .d-flex,
    .card-detail .d-flex {
        flex-direction: row;
    }

    /* builder rows (section headers, field rows, severity rules, modal option
       rows) stay rows and wrap: the text block takes its line, the grouped
       action buttons right-align on theirs (ms-auto still applies) */
    .builder-row {
        flex-direction: row;
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .builder-row .btn {
        min-height: 40px;
        min-width: 40px;
    }

    /* page header row (title left, action button(s) right) stays a row; wraps
       instead of overlapping if a header ever has too many controls to fit */
    .d-flex.justify-content-between {
        flex-direction: row;
        flex-wrap: wrap;
        row-gap: 8px;
    }
}


header {
    background: rgba(15, 21, 38, 0.75);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

header h5 {
    font-size: 15px;
    font-weight: 600;
    color: #E9EFFA;
}

header .text-muted {
    color: var(--saundy-text-light-muted) !important;
}

/* logout button refinement */
header .btn-outline-danger {
    border-radius: 8px;
    font-size: 13px;
}

/* Light/dark toggle in both headers: a ghost icon button. Token-driven, so
   the light layer re-pointing the tokens is all it needs. */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 31px;
    padding: 0;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    background: transparent;
    color: var(--saundy-text-light-muted);
    font-size: 15px;
    line-height: 1;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.theme-toggle:hover {
    color: var(--saundy-text-light);
    background: rgba(0, 212, 255, 0.08);
    border-color: rgba(0, 122, 255, 0.45);
}

/* Segmented preference buttons (Profile > Appearance): share the width
   equally and let a label wrap rather than push the last option off screen. */
.pref-choice .btn {
    flex: 1 1 0;
    min-width: 0;
    white-space: normal;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    line-height: 1.25;
}

.mobile-header {
    display: none;
}

/* Topographic contour tile over the navy gradient — the "site map" backdrop
   that replaces the dev-tool graph-paper grid */
main {
    background:
        url("img/topo-contours.svg") repeat,
        linear-gradient(180deg, var(--saundy-app-bg-1), var(--saundy-app-bg-2) 100vh);
    background-size: 720px 720px, auto;
}

.btn-primary, .btn-success {
    background: #007AFF;
    border: none;
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    transition: all 0.15s ease;
    font-size: 16px;
    font-weight: 400;
    box-shadow: 0 6px 18px rgba(0, 122, 255, 0.12);
}

.btn-create {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 6px 18px rgba(0, 122, 255, 0.12);
}

.btn-create-icon {
    font-size: 20px;
    line-height: 1;
}

.btn-primary:hover, .btn-success:hover {
    background: #006AE0;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.35);
}

.drag-handle {
    cursor: grab;
    font-size: 18px;
    color: #888;
    user-select: none;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.drag-handle:active {
    cursor: grabbing;
}

#itemTable tr:hover {
    background-color: rgba(0, 212, 255, 0.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

tr:hover .drag-handle {
    opacity: 1;
}

#itemTable tr {
    transition: box-shadow 0.2s, background-color 0.2s;
}

tbody tr {
    transition: background-color 0.15s ease;
}

tbody tr:hover {
    background-color: rgba(0, 212, 255, 0.05);
}

.card {
    transition: transform 0.2s var(--ease-out-soft), box-shadow 0.2s var(--ease-out-soft),
        border-color 0.2s var(--ease-out-soft);
    background: linear-gradient(180deg, var(--saundy-surface-1), var(--saundy-surface-2));
    border: 1px solid var(--saundy-surface-border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);

    /* Bootstrap's inner-radius math assumes its default ~6px cards: header and
       list-item backgrounds are near-rectangles that poke past our 16px-rounded
       border at the corners. Clip children to the card's own shape. */
    overflow: hidden;
}

/* Headers and flush list items paint their own (body-coloured) rectangles by
   default - against the card gradient the different navy reads as gaps at the
   edges. Let the card's gradient show through with subtle separators instead. */
.card .card-header {
    background: rgba(255, 255, 255, 0.03);
    border-bottom-color: var(--saundy-surface-border);
}

.card .list-group-item {
    background: transparent;
    border-color: var(--saundy-surface-border);
}

.card .list-group-item-action:hover,
.card .list-group-item-action:focus {
    background: rgba(0, 212, 255, 0.05);
}

.card:hover {
    border-color: rgba(0, 122, 255, 0.35);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
    transform: translateY(-2px);
}

.card-body {
    padding: 28px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: #E9EFFA;
}


.form-label {
    font-size: 13px;
    font-weight: 500;
    color: #A9B7CE;
    margin-bottom: 6px;
}

.form-control {
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);

    padding: 11px 12px;
    font-size: 14px;

    transition: all 0.15s ease;
}

.form-control:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

/* Match <select> to the text inputs: same radius, border, sizing and focus ring.
   Extra right padding leaves room for Bootstrap's caret. */
.form-select {
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);

    padding: 11px 36px 11px 12px;
    font-size: 14px;

    transition: all 0.15s ease;
}

.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}



.btn-primary:disabled,
.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.alert {
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 13px;
}

.alert-info {
    background: rgba(0, 122, 255, 0.10);
    color: #BFDCFF;
    border: 1px solid rgba(0, 122, 255, 0.25);
}

.alert-danger {
    background: rgba(255, 59, 48, 0.10);
    color: #FFB4AE;
    border: 1px solid rgba(255, 59, 48, 0.30);
}

.row.g-4 {
    row-gap: 24px;
}

/* big touch-friendly sizing is for toggle switches only, not plain checkboxes */
.form-switch .form-check-input {
    min-width: 50px;
    height: 30px;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 10px;
    color: white;
    min-width: 250px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.25s ease-in-out;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Types */
.toast.success { background: #28a745; }
.toast.error   { background: #dc3545; }
.toast.info    { background: #17a2b8; }
.toast.warning { background: #ffc107; color: #000; }

@media (max-width: 768px) {

    .layout {
        flex-direction: column;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        gap: 1rem;
        height: 60px;
        padding: 0 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        background: radial-gradient( circle 420px at top, rgba(0, 212, 255, 0.15), transparent ), linear-gradient( 180deg, #1E2A44, #181A1F );
        color: white;
    }

    .header-right {
        display: flex;
        align-items: center;
        gap: 1rem;
        flex-wrap: nowrap; /* important */
        white-space: nowrap;
        min-width: 0;
    }

    /* truncate the user email instead of overflowing the viewport */
    .header-right .mobile-sidebar-title {
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
        flex: 0 1 auto;
    }

    .hamburger {
        border: none;
        background: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: white;
    }

    .content {
        flex: unset; /* important */
        width: 100%;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        position: fixed;
        /* Open BELOW the 60px mobile header (which sits at z-index 2000) so
           the drawer's top - title + first links - is never hidden behind it,
           and the hamburger stays reachable to close the menu. */
        top: 60px;
        left: 0;
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px); /* mobile browsers with dynamic toolbars */
        width: 240px; /* still used for drawer */
        /* The nav is taller than a phone screen - scroll inside the drawer so
           every item stays reachable. */
        overflow-y: auto;
    }

    /* Keep the header pinned while the page (or drawer) scrolls, so the
       drawer's 60px offset above always lines up with it. */
    .mobile-header {
        position: sticky !important; /* beats the inline position-relative utility */
        top: 0;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 900;
    }
}

.table-view {
    display: block;
}

.card-view {
    display: none;
}

@media (max-width: 768px) {
    .table-view {
        display: none;
    }

    .card-view {
        display: block;
    }

    .card-view .btn {
        min-height: 44px;
    }
}

.responsive-card {
    border: 1px solid var(--saundy-surface-border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: linear-gradient(180deg, var(--saundy-surface-1), var(--saundy-surface-2));
    overflow-wrap: anywhere;
}

.card-detail pre {
    white-space: pre-wrap;
    word-break: break-word;
}

.card-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap; /* safety net: wrap rather than overflow the card */
}

.card-actions-group {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px;
    flex-wrap: wrap;
}

/* Action buttons on the right of a page header (Templates detail, job page,
   Sites, Team, ...). Deliberately NOT a .d-flex: the mobile column rule above
   never touches it, so the buttons stay a row and wrap instead of overflowing
   (three full-size buttons don't fit a 390px viewport alongside .btn nowrap). */
.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 768px) {
    /* Full-width row under the title; buttons share each line evenly and stay
       aligned with each other, touch-sized like .builder-row .btn. */
    .page-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .page-actions .btn {
        flex: 1 1 auto;
        min-height: 40px;
    }
}

.btn {
    white-space: nowrap;
}

/* Bootstrap width utilities aren't responsive; full-width on mobile, natural width from md up */
@media (min-width: 768px) {
    .w-md-auto {
        width: auto !important;
    }
}

.flags-search {
    width: 260px;
}

@media (max-width: 768px) {
    .flags-search {
        width: auto;
        flex: 1 0 0;
        min-width: 140px;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    position: sticky;
    top: 0;
    background: var(--saundy-surface-1);
}

/* The import preview's sticky header, fixing two quirks of a sticky thead
   inside a scrollable modal body:
   - Bootstrap's `.table > :not(caption) > * > *` paints cells with
     --bs-table-bg (transparent) at higher specificity than the global
     `thead th` background, so rows showed through the pinned header.
   - Sticky top:0 pins at the body's CONTENT edge, 16px (--bs-modal-padding)
     below the visible top, so rows scrolling through the padding gap appeared
     above the header. The negative top pulls the pin up to the visible edge.
   z-index keeps the header above the row badges. */
.import-preview-table thead th {
    background-color: var(--saundy-surface-1);
    top: calc(-1 * var(--bs-modal-padding, 1rem));
    z-index: 1;
}

.docs-content {
    max-width: 860px;
    background: linear-gradient(180deg, var(--saundy-surface-1), var(--saundy-surface-2));
    border: 1px solid var(--saundy-surface-border);
    border-radius: 16px;
    padding: 32px 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    line-height: 1.6;
}

.docs-content h1:first-child {
    margin-top: 0;
}

.docs-content table {
    width: 100%;
    margin: 1rem 0;
}

.docs-content th, .docs-content td {
    border: 1px solid rgba(255, 255, 255, 0.10);
    padding: 8px 12px;
}

.docs-content th {
    background: rgba(255, 255, 255, 0.04);
}

.docs-content pre {
    background: var(--saundy-code-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: #c9d1d9; /* readable before highlight.js applies its theme */
    padding: 16px;
    overflow-x: auto;
}

.docs-content pre code.hljs {
    background: transparent;
    padding: 0;
}

.docs-content code {
    font-family: var(--font-mono);
    font-size: 13px;
}

/* Inline code as a tinted chip; code inside pre keeps the dark pane styling */
.docs-content :not(pre) > code {
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid rgba(0, 212, 255, 0.25);
    border-radius: 6px;
    color: #7DE2FF;
    padding: 2px 6px;
}

/* ============================================================
   Inspection fill page: sticky section jump bar + bottom action
   bar. Both sit at z-index 500 - below the drawer (1000), its
   overlay (900), the mobile header (2000) and modals (3000), so
   everything that should cover them does. */

.fill-jump-bar {
    position: sticky;
    top: 0;
    z-index: 500;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    /* Bleed across main's p-4 so the bar spans edge to edge */
    margin: 0 -1.5rem 1rem;
    padding: 0.5rem 1.5rem;
    background: var(--saundy-app-bg-1);
    border-bottom: 1px solid var(--saundy-surface-border);
    scrollbar-width: thin;
}

.fill-jump-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--saundy-surface-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--saundy-text-light);
    font-size: 13px;
    padding: 4px 12px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.fill-jump-btn:hover {
    background: rgba(0, 212, 255, 0.08);
    border-color: rgba(0, 122, 255, 0.45);
}

.fill-jump-btn.fill-jump-error {
    border-color: rgba(255, 99, 90, 0.40);
}

.fill-jump-count {
    color: var(--saundy-text-light-muted);
    font-size: 12px;
}

/* The submissions chip sits apart from the section chips - it jumps to the
   report log, not a form section. */
.fill-jump-submissions {
    margin-left: auto;
    border-color: rgba(0, 122, 255, 0.45);
    color: #6FB5FF;
}

/* Newly added submission row: one soft flash so the eye lands on it after
   the post-submit scroll. */
@keyframes fill-row-flash {
    from {
        background: rgba(0, 212, 255, 0.18);
    }
    to {
        background: transparent;
    }
}

.fill-row-new {
    animation: fill-row-flash 2.5s var(--ease-out-soft) 1;
}

/* Card headers double as collapse toggles - a button needs its chrome reset
   so it reads as the header it replaces. */
.fill-section-header {
    width: 100%;
    color: inherit;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    border: 0;
    border-bottom: 1px solid var(--saundy-surface-border);
}

/* The fill page's field cards are denser than the app-wide 28px card body */
.fill-section .card-body {
    padding: 16px;
}

.fill-section .card-body .field-card:last-child {
    margin-bottom: 0 !important;
}

/* The fill form is a working surface, not a showcase tile - no hover lift */
.fill-section:hover {
    transform: none;
}

.field-invalid {
    border-color: rgba(255, 99, 90, 0.60) !important;
    background: rgba(255, 99, 90, 0.05);
}

/* Last-in-flow + sticky: pinned to the viewport bottom while the form is
   taller than the screen, settling into normal flow at the end. */
.fill-bottom-bar {
    position: sticky;
    bottom: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin: 1rem -1.5rem -1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--saundy-app-bg-2);
    border-top: 1px solid var(--saundy-surface-border);
}

/* Anchor targets stop below the sticky bars when scrolled to */
.fill-section, .field-card, #fill-submissions {
    scroll-margin-top: 56px;
}

/* Report layout designer: same last-in-flow sticky trick as .fill-bottom-bar,
   but scoped to the form column - the save action and the unsaved-changes
   signal stay visible while the long form scrolls. */
.layout-save-bar {
    position: sticky;
    bottom: 0.75rem;
    z-index: 500;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin: 1rem 0 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--saundy-app-bg-2);
    border: 1px solid var(--saundy-surface-border);
    border-radius: 0.5rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.layout-save-dirty {
    color: #FFC864;
}

.layout-save-dirty .bi-circle-fill {
    font-size: 0.5rem;
    vertical-align: 0.1rem;
}

.layout-save-clean {
    color: var(--saundy-text-light-muted);
}

/* Mobile / no-:has fallback: the preview is a fixed-height pane in normal
   page flow (stacked under the form below lg). */
.layout-preview-frame {
    display: block;
    width: 100%;
    height: calc(100vh - 8rem);
    min-height: 480px;
    border: 0;
}

/* ≥lg the designer works as two viewport-capped panes. Each pane sizes
   itself against 100vh (no reliance on any ancestor height chain, which
   the app shell doesn't provide): the form column caps at viewport height
   and scrolls internally (the save bar pins inside that scrollport), and
   the preview pane is viewport-height with the iframe filling it. The
   page heading sits INSIDE the form pane, so with just the app header
   (~60px) + main's p-4 above the row, 7rem of allowance means both panes
   fit the viewport outright and the page has nothing left to scroll. The
   sticky is a fallback for when an alert/banner pushes the row down -
   the small page scroll that creates pins the panes instead of moving
   them. */
@media (min-width: 992px) {
    .layout-designer-form {
        position: sticky;
        top: 1rem;
        align-self: flex-start; /* stop the row stretching it, or sticky can't travel */
        max-height: calc(100vh - 7rem);
        overflow-y: auto;
        scrollbar-width: thin;
    }

    .layout-designer-preview {
        align-self: flex-start;
    }

    .layout-designer-preview-inner {
        position: sticky;
        top: 1rem;
        display: flex;
        flex-direction: column;
        height: calc(100vh - 7rem);
    }

    .layout-preview-shell {
        flex: 1 1 auto;
        min-height: 0;
    }

    .layout-preview-frame {
        height: 100%;
        min-height: 0;
    }
}

@media (max-width: 768px) {
    /* Sit below the 60px sticky mobile header, like the drawer does */
    .fill-jump-bar {
        top: 60px;
    }

    .fill-section, .field-card, #fill-submissions {
        scroll-margin-top: 116px;
    }

    /* Field controls as touch targets (same 44px rule as .card-view .btn) */
    .field-card .btn-group .btn,
    .field-card .form-select,
    .field-card .form-control,
    .field-card .photo-add-btn {
        min-height: 44px;
    }

    .field-card .field-input-number,
    .field-card .field-input-choice,
    .field-card .field-input-severity {
        max-width: 100%;
        width: 100%;
    }

    .field-card .rating-btn {
        font-size: 1.6rem;
        padding: 0.25rem 0.35rem;
    }

    /* Yes/No/NA as thirds of the row - thumb-sized on site */
    .field-card .btn-group {
        display: flex;
        width: 100%;
    }

    .field-card .btn-group .btn {
        flex: 1;
    }
}

/* Site detail cards: on phones the unit grid stacks 1-2 tiles wide and would
   bury the status cards, so the order flips - defects, reports, inspections
   first, the unit list last. Notes and Documents carry no order (0), so they
   lead on phones; Watchers (office config, rarely touched on a phone) goes
   last. Desktop keeps the DOM order (units first). */
@media (max-width: 768px) {
    .site-cards {
        display: flex;
        flex-direction: column;
    }

    .site-cards .site-card-defects { order: 1; }
    .site-cards .site-card-reports { order: 2; }
    .site-cards .site-card-inspections { order: 3; }
    .site-cards .site-card-contains { order: 4; }
    .site-cards .site-card-watchers { order: 5; }
    .site-cards .site-card-schedules { order: 6; }
    .site-cards .site-card-shares { order: 7; }
}

/* Dashboard stat tiles - clickable cards in a wrapping grid */
.dash-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}

.dash-tile {
    display: block;
    padding: 16px 18px;
    text-decoration: none;
    color: var(--saundy-text-light);
}

.dash-tile:hover {
    color: var(--saundy-text-light);
}

.dash-tile-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    line-height: 1.2;
}

.dash-tile-label {
    font-size: 13px;
    font-weight: 600;
    margin-top: 2px;
}

.dash-tile-sub {
    font-size: 12px;
    color: var(--saundy-text-light-muted);
    margin-top: 2px;
}

.dash-tile-danger .dash-tile-value {
    color: #FF8A80;
}

/* Empty states - a card that explains the thing and offers the one next action.
   Static containers: no hover lift (that cue belongs to clickable cards). */
.empty-state,
.empty-state:hover {
    transform: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    border-color: var(--saundy-surface-border);
}

.empty-state .card-body {
    padding: 40px 28px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.empty-state-compact .card-body {
    padding: 24px;
}

.empty-state-icon {
    font-size: 2.5rem;
    line-height: 1;
    color: var(--saundy-text-light-muted);
    opacity: 0.8;
    margin-bottom: 12px;
}

.empty-state-compact .empty-state-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.empty-state-title {
    margin-bottom: 6px;
}

.empty-state-text {
    max-width: 440px;
}

.empty-state-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px 12px;
    margin-top: 18px;
}

/* Getting-started checklist on the dashboard (OnboardingChecklist.razor) */
.onboarding-hero,
.onboarding-hero:hover {
    transform: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    border-color: rgba(0, 122, 255, 0.35);
}

.onboarding-hero .card-body {
    padding: 24px 28px;
}

.onboarding-heading {
    font-family: var(--font-display);
    font-weight: 600;
    margin-bottom: 4px;
}

.onboarding-intro {
    max-width: 64ch;
    color: var(--saundy-text-light-muted);
    margin-bottom: 18px;
}

.onboarding-progress {
    font-size: 12px;
    font-weight: 600;
    color: var(--saundy-primary);
    background: rgba(0, 122, 255, 0.12);
    border-radius: 999px;
    padding: 3px 10px;
}

.onboarding-subheading {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--saundy-text-light-muted);
    margin: 16px 0 6px;
}

.onboarding-steps {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.onboarding-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--saundy-surface-border);
    border-radius: 12px;
}

.onboarding-step-icon {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    color: var(--saundy-primary);
    background: rgba(0, 122, 255, 0.14);
}

.onboarding-step-text {
    min-width: 0;
    flex: 1 1 200px;
}

.onboarding-step-title {
    font-weight: 600;
    font-size: 14px;
}

.onboarding-step-why {
    font-size: 12.5px;
    color: var(--saundy-text-light-muted);
}

.onboarding-step-cta {
    margin-left: auto;
    flex: 0 0 auto;
}

.onboarding-step-done .onboarding-step-icon {
    color: #4ADE80;
    background: rgba(74, 222, 128, 0.14);
}

.onboarding-step-done .onboarding-step-title {
    text-decoration: line-through;
    color: var(--saundy-text-light-muted);
    font-weight: 500;
}

.onboarding-step-disabled {
    opacity: 0.6;
}

.onboarding-footer {
    display: flex;
    align-items: center;
    margin-top: 12px;
}

.onboarding-hero .onboarding-collapsed {
    padding: 12px 20px;
}

@media (max-width: 575.98px) {
    .onboarding-step {
        flex-wrap: wrap;
    }

    .onboarding-step-cta {
        margin-left: 48px;
    }
}

.field-input-number {
    max-width: 220px;
}

.field-input-choice {
    max-width: 280px;
}

.field-input-severity {
    max-width: 150px;
}

.auth-docs-link {
    position: fixed;
    bottom: 20px;
    right: 24px;
    z-index: 10;
}

.auth-docs-link a {
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    text-decoration: none;
}

.auth-docs-link a:hover {
    color: white;
    text-decoration: underline;
}

/* ===== Dark theme layer =====
   The portal is dark-first: :root tokens hold dark values and the plain rules
   above hard-code a fair number of dark literals. <html data-bs-theme="dark">
   (the static default in App.razor) lets Bootstrap theme its own components
   (modals, dropdowns, tables, inputs); the overrides below retune its palette
   to the Saundy navy and adapt light-assuming utility classes used in page
   markup. The light theme is the layer at the END of this file - it switches
   in when saundyTheme (app.js) flips the attribute to "light". */
[data-bs-theme="dark"] {
    /* Native widgets (select popups, scrollbars, date pickers) render dark */
    color-scheme: dark;

    --bs-body-bg: #0F1526;
    --bs-body-color: var(--saundy-text-light);
    --bs-secondary-color: var(--saundy-text-light-muted);
    --bs-tertiary-color: rgba(140, 160, 191, 0.6);
    --bs-border-color: rgba(255, 255, 255, 0.10);
    --bs-secondary-bg: #232E4E;
    --bs-tertiary-bg: #1B2440;
    --bs-link-color: #58AFFF;
    --bs-link-hover-color: #7DC2FF;
    --bs-link-color-rgb: 88, 175, 255;
    --bs-link-hover-color-rgb: 125, 194, 255;

    /* -subtle backgrounds (rule boxes, audit badges) as navy-friendly tints
       instead of Bootstrap's charcoal defaults */
    --bs-light-bg-subtle: rgba(255, 255, 255, 0.04);
    --bs-dark-bg-subtle: rgba(255, 255, 255, 0.06);
    --bs-secondary-bg-subtle: rgba(148, 163, 184, 0.10);
    --bs-primary-bg-subtle: rgba(0, 122, 255, 0.12);
    --bs-success-bg-subtle: rgba(40, 200, 100, 0.12);
    --bs-info-bg-subtle: rgba(0, 212, 255, 0.08);
    --bs-warning-bg-subtle: rgba(254, 188, 46, 0.10);
    --bs-danger-bg-subtle: rgba(255, 99, 90, 0.10);
}

/* Custom (non-JS) modals use `class="modal d-block"` and must sit above the app
   chrome - the top header and mobile header are at z-index 2000, tenant menus at
   2100 - or the dialog renders behind them. */
.modal.d-block {
    z-index: 3000;
    /* Hand-rolled modals have no Bootstrap JS to lock the page body, so stop
       wheel/touch scrolling from chaining to the page when the modal (or a
       modal-dialog-scrollable body) hits its top or bottom. Both elements are
       scroll containers (overflow-y auto via Bootstrap), which is what makes
       overscroll-behavior take effect. */
    overscroll-behavior: contain;
}

.modal.d-block .modal-body {
    overscroll-behavior: contain;
}

/* Labeled switches: the app-wide 50x30 switch overflows Bootstrap's form-check
   layout (which reserves space for a standard-size input), jamming the label
   against it. Flex layout with an explicit gap instead. */
.switch-labeled {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 0;
}

.switch-labeled .form-check-input {
    float: none;
    margin-left: 0;
    flex-shrink: 0;
}

.switch-labeled .form-check-label {
    cursor: pointer;
}

/* Modals on the navy surface, with a glassy blurred backdrop */
[data-bs-theme="dark"] .modal {
    backdrop-filter: blur(6px);
}

[data-bs-theme="dark"] .modal-content {
    background: linear-gradient(180deg, var(--saundy-surface-1), var(--saundy-surface-2));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.09) !important;
}

[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .modal-content.rounded-3 {
    border-radius: 16px !important;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: rgba(255, 255, 255, 0.08);
}

/* Utilities that hardcode the light theme in page markup */
[data-bs-theme="dark"] .bg-white {
    background: linear-gradient(180deg, var(--saundy-surface-1), var(--saundy-surface-2)) !important;
    border: 1px solid var(--saundy-surface-border);
}

[data-bs-theme="dark"] .text-dark {
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
}

[data-bs-theme="dark"] .table-light {
    --bs-table-bg: var(--saundy-surface-1);
    --bs-table-color: #A9B7CE;
    border-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .bg-light {
    background-color: rgba(255, 255, 255, 0.04) !important;
}

/* Badges as tinted outline pills — the marketing mockup look */
[data-bs-theme="dark"] .badge {
    font-weight: 600;
}

[data-bs-theme="dark"] .badge.bg-primary,
[data-bs-theme="dark"] .badge.text-bg-primary {
    background: rgba(0, 122, 255, 0.14) !important;
    border: 1px solid rgba(0, 122, 255, 0.45);
    color: #6FB5FF !important;
}

[data-bs-theme="dark"] .badge.bg-success {
    background: rgba(40, 200, 100, 0.14) !important;
    border: 1px solid rgba(40, 200, 100, 0.40);
    color: #5AE39B !important;
}

[data-bs-theme="dark"] .badge.bg-secondary {
    background: rgba(148, 163, 184, 0.12) !important;
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #A9B7CE !important;
}

[data-bs-theme="dark"] .badge.bg-warning {
    background: rgba(254, 188, 46, 0.12) !important;
    border: 1px solid rgba(254, 188, 46, 0.45);
    color: #FEBC2E !important;
}

[data-bs-theme="dark"] .badge.bg-danger {
    background: rgba(255, 99, 90, 0.12) !important;
    border: 1px solid rgba(255, 99, 90, 0.40);
    color: #FF8A80 !important;
}

[data-bs-theme="dark"] .badge.bg-info {
    background: rgba(0, 212, 255, 0.10) !important;
    border: 1px solid rgba(0, 212, 255, 0.40);
    color: #7DE2FF !important;
}

[data-bs-theme="dark"] .badge.bg-light {
    background: rgba(148, 163, 184, 0.10) !important;
    border: 1px solid rgba(148, 163, 184, 0.35) !important;
    color: #C3CFE2 !important;
}

/* Toggle switches — blue glow when on, navy track when off */
.form-switch .form-check-input {
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-switch .form-check-input:not(:checked) {
    background-color: #33405E;
    border-color: rgba(255, 255, 255, 0.15);
}

.form-switch .form-check-input:checked {
    background-color: var(--saundy-primary);
    border-color: var(--saundy-primary);
    box-shadow: 0 0 12px rgba(0, 122, 255, 0.45);
}

/* Row action kebab + dropdown styling */
.btn-kebab {
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--saundy-text-light-muted);
    line-height: 1;
    padding: 6px 9px;
}

.btn-kebab:hover,
.btn-kebab:focus,
.btn-kebab[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

[data-bs-theme="dark"] .dropdown-menu {
    background: var(--saundy-surface-1);
    border: 1px solid var(--saundy-surface-border);
    border-radius: 12px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
    font-size: 13.5px;
    padding: 6px;
}

[data-bs-theme="dark"] .dropdown-item {
    border-radius: 8px;
    color: var(--saundy-text-light);
    padding: 8px 10px;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background: rgba(0, 122, 255, 0.15);
    color: white;
}

[data-bs-theme="dark"] .dropdown-item.text-danger:hover,
[data-bs-theme="dark"] .dropdown-item.text-danger:focus {
    background: rgba(255, 99, 90, 0.12);
}

[data-bs-theme="dark"] .dropdown-divider {
    border-color: rgba(255, 255, 255, 0.10);
}

/* Table panels: let row dropdowns escape instead of clipping; keep the
   rounded corners by rounding the corner cells themselves. */
[data-bs-theme="dark"] .bg-white.rounded-3.overflow-hidden {
    overflow: visible !important;
}

[data-bs-theme="dark"] .bg-white.rounded-3 thead th:first-child {
    border-top-left-radius: calc(0.5rem - 1px);
}

[data-bs-theme="dark"] .bg-white.rounded-3 thead th:last-child {
    border-top-right-radius: calc(0.5rem - 1px);
}

[data-bs-theme="dark"] .bg-white.rounded-3 tbody tr:last-child td {
    border-bottom: 0;
}

[data-bs-theme="dark"] .bg-white.rounded-3 tbody tr:last-child td:first-child {
    border-bottom-left-radius: calc(0.5rem - 1px);
}

[data-bs-theme="dark"] .bg-white.rounded-3 tbody tr:last-child td:last-child {
    border-bottom-right-radius: calc(0.5rem - 1px);
}

/* Roomier rows, like the mockup */
.table > :not(caption) > * > * {
    padding: 13px 16px;
}

/* Sub-labels and chips inside mono key cells read better in the body font */
.flag-key .text-muted,
.flag-key .badge {
    font-family: var(--font-body);
    font-weight: 400;
}

.flag-key .badge {
    font-weight: 600;
    vertical-align: 2px;
}

/* Environment selector as a cyan pill — echoes the mockup's Production pill */
.env-pill {
    background-color: rgba(0, 212, 255, 0.10);
    border: 1px solid rgba(0, 212, 255, 0.45);
    border-radius: 999px;
    color: #7DE2FF;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 36px 8px 16px;
    width: auto;
}

.env-pill:focus {
    border-color: var(--saundy-accent);
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.15);
    color: #7DE2FF;
}

/* Options in the native popup list (fallback for browsers without
   customizable selects — e.g. Firefox) */
[data-bs-theme="dark"] select option {
    background-color: var(--saundy-surface-1);
    color: var(--saundy-text-light);
}

/* Customizable <select> (Chromium 135+): render the popup as a DOM panel
   styled like the kebab menus — rounded, padded, brand hover. Browsers
   without support ignore this block and keep the native popup above. */
@supports (appearance: base-select) {
    select.form-select,
    select.form-select::picker(select) {
        appearance: base-select;
    }

    /* Bootstrap already draws its own caret via background-image */
    select.form-select::picker-icon {
        display: none;
    }

    select.form-select::picker(select) {
        background: var(--saundy-surface-1);
        border: 1px solid var(--saundy-surface-border);
        border-radius: 12px;
        box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
        margin-top: 4px;
        opacity: 1;
        padding: 6px;
        transform: translateY(0);
        transition: opacity 0.15s ease, transform 0.15s var(--ease-out-soft),
            overlay 0.15s ease allow-discrete, display 0.15s ease allow-discrete;
    }

    @starting-style {
        select.form-select::picker(select) {
            opacity: 0;
            transform: translateY(-4px);
        }
    }

    select.form-select option {
        background: transparent;
        border-radius: 8px;
        color: var(--saundy-text-light);
        font-size: 13.5px;
        font-weight: 500;
        padding: 8px 10px;
    }

    select.form-select option:hover,
    select.form-select option:focus {
        background: rgba(0, 122, 255, 0.15);
        color: white;
    }

    select.form-select option::checkmark {
        color: var(--saundy-accent);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
/* Quick-phrase picker rows (QuickPhrasesModal / QuickPhrasesSheet): the whole
   row is the label, so a 44px tap anywhere on the sentence toggles the tick. */
.quick-phrase-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 44px;
    padding: .5rem 1rem;
    margin: 0;
    border-top: 1px solid var(--bs-border-color);
    cursor: pointer;
    line-height: 1.3;
}

.quick-phrase-row:hover {
    background: var(--bs-tertiary-bg);
}

.quick-phrase-row .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    flex-shrink: 0;
}

/* ===== Light theme layer =====
   Flipping <html data-bs-theme> to "light" (saundyTheme.apply in app.js; the
   inline boot script in App.razor on first paint) makes Bootstrap 5.3 supply
   its light palette and switches the dark layer above off. This block does
   the rest:
     1. re-points the --saundy-* tokens - their NAMES stay (rules above
        reference them): under light, app-bg = page, surface = card,
        text-light = text;
     2. retunes the --bs-* variables the dark layer sets;
     3. overrides every rule above that hard-codes a dark-only colour or
        shadow, grouped by area and listed by selector.
   Anything not mentioned is token-driven (fixed by 1) or reads fine on both.
   Sections 1-3 were first written in Mobile\wwwroot\mobile.css against a copy
   of this file; this is now the canonical copy - on the next re-sync of
   app.css into Mobile, the matching sections of mobile.css become redundant
   (only its chrome tokens, section 4 there, stay mobile-specific). */
[data-bs-theme="light"] {
    color-scheme: light;

    /* 1. tokens */
    /* Cooler grey-blue rather than white-on-white: the page sits a step
       below the cards, the cards a step below the inputs. */
    --saundy-app-bg-1: #E9EEF5;
    --saundy-app-bg-2: #D8E0EB;
    --saundy-surface-1: #F6F8FB;
    --saundy-surface-2: #EDF1F7;
    --saundy-surface-border: rgba(30, 42, 68, 0.12);
    --saundy-text-light: #1E2A44;
    --saundy-text-light-muted: #64748b;
    --saundy-code-bg: #EEF3FA;

    /* 2. Bootstrap. Body bg stays white - it drives inputs and modals; the
       page tint comes from main's gradient. */
    --bs-body-bg: #FFFFFF;
    --bs-body-color: #1E2A44;
    --bs-body-color-rgb: 30, 42, 68;
    --bs-secondary-color: #64748b;
    --bs-tertiary-color: rgba(100, 116, 139, 0.6);
    --bs-border-color: rgba(30, 42, 68, 0.12);
    --bs-secondary-bg: #E4EAF2;
    --bs-tertiary-bg: #EDF1F7;
    --bs-link-color: #007AFF;
    --bs-link-color-rgb: 0, 122, 255;
    --bs-link-hover-color: #006AE0;
    --bs-link-hover-color-rgb: 0, 106, 224;
    --bs-primary-bg-subtle: rgba(0, 122, 255, 0.10);
    --bs-success-bg-subtle: rgba(22, 163, 74, 0.10);
    --bs-info-bg-subtle: rgba(0, 212, 255, 0.12);
    --bs-warning-bg-subtle: rgba(254, 188, 46, 0.18);
    --bs-danger-bg-subtle: rgba(255, 59, 48, 0.10);
    --bs-secondary-bg-subtle: rgba(100, 116, 139, 0.10);
    --bs-light-bg-subtle: #EDF1F7;
    --bs-dark-bg-subtle: rgba(30, 42, 68, 0.06);
}

/* 3. Rules above with dark-only literals. */

/* --- App shell: sidebar, headers, page backdrop --- */

/* main: the topo map is white ink in the dark file; a navy-ink twin for light.
   The shorthand resets background-size, so it is restated. */
[data-bs-theme="light"] main {
    background:
        url("img/topo-contours-light.svg") repeat,
        linear-gradient(180deg, var(--saundy-app-bg-1), var(--saundy-app-bg-2) 100vh);
    background-size: 720px 720px, auto;
}

/* The sidebar goes light with the page (the mobile app's top bar does the
   same) - same gradient shape, light stops; navy text; primary blue for the
   active link because cyan fails contrast on white. */
[data-bs-theme="light"] .sidebar {
    background:
        radial-gradient(circle 420px at top, rgba(0, 212, 255, 0.10), transparent),
        linear-gradient(180deg, #F2F5F9, #E4EAF2 100vh);
    border-right: 1px solid rgba(30, 42, 68, 0.10);
    color: #1E2A44;
}

[data-bs-theme="light"] .sidebar-title,
[data-bs-theme="light"] .mobile-sidebar-title {
    color: #64748b;
}

[data-bs-theme="light"] .sidebar .nav-link {
    color: rgba(30, 42, 68, 0.78);
}

[data-bs-theme="light"] .sidebar .nav-link:hover {
    background: rgba(30, 42, 68, 0.06);
    color: #1E2A44;
}

[data-bs-theme="light"] .sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(0, 122, 255, 0.14), rgba(0, 212, 255, 0.04));
    color: #007AFF;
    border-left-color: #007AFF;
    box-shadow: 0 0 18px rgba(0, 122, 255, 0.10);
}

[data-bs-theme="light"] .sidebar .sidebar-group-toggle.child-active {
    color: #1E2A44;
}

[data-bs-theme="light"] .sidebar-group-items {
    border-left-color: rgba(30, 42, 68, 0.12);
}

/* Desktop top bar: translucent light glass over the page */
[data-bs-theme="light"] header {
    background: rgba(242, 245, 249, 0.80);
    border-bottom: 1px solid rgba(30, 42, 68, 0.10);
}

[data-bs-theme="light"] header h5 {
    color: #1E2A44;
}

@media (max-width: 768px) {
    /* The mobile header is a <header> too, so the glass rule above would win
       over .mobile-header's gradient on specificity - restate it light. */
    [data-bs-theme="light"] .mobile-header {
        border-bottom: 1px solid rgba(30, 42, 68, 0.10);
        background:
            radial-gradient(circle 420px at top, rgba(0, 212, 255, 0.10), transparent),
            linear-gradient(180deg, #F2F5F9, #E4EAF2);
        color: #1E2A44;
    }

    [data-bs-theme="light"] .hamburger {
        color: #1E2A44;
    }

    [data-bs-theme="light"] .overlay {
        background: rgba(30, 42, 68, 0.35);
    }
}

/* --- Cards, forms, tables --- */

[data-bs-theme="light"] .card {
    box-shadow: 0 10px 30px rgba(30, 42, 68, 0.08);
}

[data-bs-theme="light"] .card:hover {
    box-shadow: 0 14px 40px rgba(30, 42, 68, 0.14);
}

[data-bs-theme="light"] .card .card-header {
    background: rgba(30, 42, 68, 0.03);
}

[data-bs-theme="light"] .card-title {
    color: #1E2A44;
}

[data-bs-theme="light"] .form-label {
    color: #475569;
}

[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
    border-color: rgba(30, 42, 68, 0.18);
}

/* The dark track (#33405E) is invisible-knob-on-navy tuned; Bootstrap's own
   light knob (25% black) needs a light track. */
[data-bs-theme="light"] .form-switch .form-check-input:not(:checked) {
    background-color: #CBD5E1;
    border-color: rgba(30, 42, 68, 0.20);
}

@supports (appearance: base-select) {
    [data-bs-theme="light"] select.form-select::picker(select) {
        box-shadow: 0 14px 40px rgba(30, 42, 68, 0.18);
    }

    [data-bs-theme="light"] select.form-select option:hover,
    [data-bs-theme="light"] select.form-select option:focus {
        color: #1E2A44;
    }
}

[data-bs-theme="light"] .validation-message {
    color: #C2362F;
}

/* Row hover shadow was black-on-navy */
[data-bs-theme="light"] #itemTable tr:hover {
    box-shadow: 0 2px 8px rgba(30, 42, 68, 0.10);
}

/* Tables that sit straight on main (queues, lists) - Bootstrap light would
   paint them a hard white slab (the dark layer made them transparent). */
[data-bs-theme="light"] .table {
    --bs-table-bg: transparent;
}

/* Headings use .text-dark; Bootstrap's is a neutral charcoal - use ours. */
[data-bs-theme="light"] .text-dark {
    color: var(--bs-body-color) !important;
}

/* --- Alerts, modals, buttons --- */

[data-bs-theme="light"] .alert-info {
    background: rgba(0, 122, 255, 0.08);
    color: #0B4F9C;
    border-color: rgba(0, 122, 255, 0.30);
}

[data-bs-theme="light"] .alert-danger {
    background: rgba(255, 59, 48, 0.08);
    color: #A32D25;
    border-color: rgba(255, 59, 48, 0.30);
}

/* Same rounded, floating treatment the dark layer gives modals, on a white
   surface; the inline 50% black scrim softens to navy (inline styles need
   the !important). */
[data-bs-theme="light"] .modal {
    backdrop-filter: blur(6px);
}

[data-bs-theme="light"] .modal.d-block {
    background: rgba(30, 42, 68, 0.45) !important;
}

[data-bs-theme="light"] .modal-content,
[data-bs-theme="light"] .modal-content.rounded-3 {
    border: 0;
    border-radius: 16px !important;
    box-shadow: 0 24px 70px rgba(30, 42, 68, 0.22), 0 0 0 1px rgba(30, 42, 68, 0.08) !important;
}

/* Brand blue for outline buttons (Bootstrap's is its own #0d6efd). */
[data-bs-theme="light"] .btn-outline-primary {
    --bs-btn-color: #007AFF;
    --bs-btn-border-color: #007AFF;
    --bs-btn-hover-bg: #007AFF;
    --bs-btn-hover-border-color: #007AFF;
    --bs-btn-active-bg: #006AE0;
    --bs-btn-active-border-color: #006AE0;
}

/* --- Page-specific surfaces --- */

/* Docs: card-like panel; tables, code chips and panes were white-alpha */
[data-bs-theme="light"] .docs-content {
    box-shadow: 0 10px 30px rgba(30, 42, 68, 0.08);
}

[data-bs-theme="light"] .docs-content th,
[data-bs-theme="light"] .docs-content td {
    border-color: rgba(30, 42, 68, 0.12);
}

[data-bs-theme="light"] .docs-content th {
    background: rgba(30, 42, 68, 0.04);
}

[data-bs-theme="light"] .docs-content pre {
    border-color: rgba(30, 42, 68, 0.10);
    color: #1E2A44;
}

[data-bs-theme="light"] .docs-content :not(pre) > code {
    background: rgba(0, 122, 255, 0.08);
    border-color: rgba(0, 122, 255, 0.25);
    color: #0B4F9C;
}

/* Inspection fill page */
[data-bs-theme="light"] .fill-jump-bar {
    box-shadow: 0 2px 8px rgba(30, 42, 68, 0.06);
}

[data-bs-theme="light"] .fill-jump-btn {
    background: #F6F8FB;
}

[data-bs-theme="light"] .fill-jump-submissions {
    color: #007AFF;
}

/* Report layout designer save bar */
[data-bs-theme="light"] .layout-save-bar {
    box-shadow: 0 6px 18px rgba(30, 42, 68, 0.12);
}

[data-bs-theme="light"] .layout-save-dirty {
    color: #B45309;
}

/* Dashboard */
[data-bs-theme="light"] .dash-tile-danger .dash-tile-value {
    color: #C62828;
}

/* Empty states + getting-started checklist */
[data-bs-theme="light"] .empty-state,
[data-bs-theme="light"] .empty-state:hover,
[data-bs-theme="light"] .onboarding-hero,
[data-bs-theme="light"] .onboarding-hero:hover {
    box-shadow: 0 6px 18px rgba(30, 42, 68, 0.08);
}

[data-bs-theme="light"] .onboarding-hero,
[data-bs-theme="light"] .onboarding-hero:hover {
    border-color: rgba(0, 122, 255, 0.3);
}

[data-bs-theme="light"] .empty-state-icon {
    color: #64748B;
}

[data-bs-theme="light"] .empty-state-title,
[data-bs-theme="light"] .onboarding-heading,
[data-bs-theme="light"] .onboarding-step-title {
    color: #1E2A44;
}

[data-bs-theme="light"] .onboarding-intro,
[data-bs-theme="light"] .onboarding-step-why,
[data-bs-theme="light"] .onboarding-subheading {
    color: #5B6B84;
}

[data-bs-theme="light"] .onboarding-progress {
    background: rgba(0, 122, 255, 0.10);
}

[data-bs-theme="light"] .onboarding-step {
    border-color: #E2E8F0;
    background: #FFFFFF;
}

[data-bs-theme="light"] .onboarding-step-icon {
    background: rgba(0, 122, 255, 0.10);
}

[data-bs-theme="light"] .onboarding-step-done .onboarding-step-icon {
    color: #1B7F4C;
    background: rgba(25, 135, 84, 0.12);
}

[data-bs-theme="light"] .onboarding-step-done .onboarding-step-title {
    color: #5B6B84;
}

/* Docs link pinned over the page corner */
[data-bs-theme="light"] .auth-docs-link a {
    color: rgba(30, 42, 68, 0.75);
}

[data-bs-theme="light"] .auth-docs-link a:hover {
    color: #1E2A44;
}

/* ---- Photo lightbox ------------------------------------------------------ */

/* Same viewer as Mobile\wwwroot\mobile.css; saundyLightbox (app.js) owns the
   markup and gestures. Full-screen over the whole shell (mobile header 2000,
   Bootstrap modals 1055). touch-action none keeps the browser from stealing
   the pinch/pan for page zoom or scroll. Deliberately the same near-black in
   both themes - it is a photo viewer. */
.photo-thumb {
    cursor: zoom-in;
}

.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 12, 18, 0.94);
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
    touch-action: none;
    overscroll-behavior: contain;
    -webkit-user-select: none;
    user-select: none;
}

.photo-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.photo-lightbox-close {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: 10px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 10px;
    background: rgba(24, 26, 31, 0.7);
    color: #E9EFFA;
    font-size: 18px;
    cursor: pointer;
}

/* Prev/next chevrons + the "n / m" counter, shown only when the viewer was
   opened over more than one photo. Exempt from gesture tracking (see the
   .photo-lightbox-nav guard in saundyLightbox), like the close button. */
.photo-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(24, 26, 31, 0.7);
    color: #E9EFFA;
    font-size: 18px;
    cursor: pointer;
}

.photo-lightbox-prev {
    left: calc(10px + env(safe-area-inset-left, 0px));
}

.photo-lightbox-next {
    right: calc(10px + env(safe-area-inset-right, 0px));
}

.photo-lightbox-counter {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(24, 26, 31, 0.7);
    color: #E9EFFA;
    font-size: 12.5px;
}

/* ---- Report viewer ------------------------------------------------------- */

/* Desktop path: the native PDF viewer in an iframe. dvh (not vh) so the iOS
   URL bar collapsing doesn't push the footer buttons under the fold; inside
   modal-fullscreen-md-down the body is a flex child, so just fill it. */
.report-frame {
    display: block;
    width: 100%;
    height: calc(100dvh - 13rem);
    min-height: 420px;
    border: 0;
}

@media (max-width: 767.98px) {
    .report-frame {
        height: 100%;
        min-height: 0;
    }
}

/* Touch path: pdf.js canvases (saundyPdfViewer). Pages are drawn at
   devicePixelRatio into fit-to-width canvases; zoom only changes the CSS width
   (--pdf-fit-width x --pdf-zoom), so it re-uses the already-sharp backing
   store instead of re-rendering. width: max-content lets zoomed pages overflow
   into horizontal scroll. The viewer owns pan/pinch, so touch-action none
   keeps the browser from also scrolling under the gesture; overscroll-behavior
   contain stops a pan running into the page behind. */
.pdf-scroll {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: none;
    overscroll-behavior: contain;
    background: var(--saundy-surface-2);
}

/* A tablet (touch, but wider than md) gets canvases inside the ordinary
   modal-xl, whose body has no height of its own - cap it like the iframe. */
@media (min-width: 768px) {
    .modal-body.pdf-scroll {
        max-height: calc(100dvh - 13rem);
        min-height: 420px;
    }
}

.pdf-pages {
    width: max-content;
    min-width: 100%;
    padding: 8px;
}

.pdf-pages .pdf-page {
    display: block;
    width: calc(var(--pdf-fit-width, 100%) * var(--pdf-zoom, 1));
    margin: 0 auto 8px;
    background: #fff;
    border-radius: 4px;
}

/* ---------------------------------------------------------------------------
   Developer docs (/docs). Content is rendered markdown inside .docs-content;
   the table of contents lives in DocsLayout's sidebar and reuses the portal
   sidebar styles above. Everything is token-driven so both themes work; code
   panes stay dark in light mode on purpose (the usual docs look, and
   highlight.js ships one theme). */
:root {
    --saundy-docs-inline-code: #7DE2FF;
    --saundy-docs-inline-code-bg: rgba(0, 212, 255, 0.08);
    --saundy-docs-inline-code-border: rgba(0, 212, 255, 0.25);
}

[data-bs-theme="light"] {
    --saundy-docs-inline-code: #0B5FB3;
    --saundy-docs-inline-code-bg: rgba(0, 122, 255, 0.07);
    --saundy-docs-inline-code-border: rgba(0, 122, 255, 0.22);
}

.docs-content {
    background: linear-gradient(180deg, var(--saundy-surface-1), var(--saundy-surface-2));
    border: 1px solid var(--saundy-surface-border);
    border-radius: 16px;
    padding: 28px 36px;
    line-height: 1.65;
    max-width: 920px;
}

@media (max-width: 575.98px) {
    .docs-content {
        padding: 20px 18px;
    }
}

.docs-content h1:first-child {
    margin-top: 0;
}

.docs-content h1 {
    font-size: 1.6rem;
    margin-bottom: 1rem;
}

.docs-content h2 {
    font-size: 1.25rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--saundy-surface-border);
}

.docs-content h3 {
    font-size: 1.05rem;
    margin-top: 1.5rem;
}

.docs-content h1, .docs-content h2, .docs-content h3, .docs-content h4 {
    scroll-margin-top: 1rem;
}

@media (max-width: 767.98px) {
    .docs-content h1, .docs-content h2, .docs-content h3, .docs-content h4 {
        scroll-margin-top: 72px;
    }
}

.docs-content table {
    width: 100%;
    margin: 1rem 0;
    font-size: 0.92rem;
}

.docs-content th, .docs-content td {
    border: 1px solid var(--saundy-surface-border);
    padding: 8px 12px;
    vertical-align: top;
}

.docs-content th {
    background: rgba(127, 127, 127, 0.08);
    text-align: left;
}

.docs-content pre {
    background: #0d1117;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: #c9d1d9;
    padding: 14px 16px;
    overflow-x: auto;
    font-size: 13px;
}

.docs-content pre code.hljs {
    background: transparent;
    padding: 0;
}

.docs-content code {
    font-family: var(--font-mono);
    font-size: 0.86em;
}

.docs-content :not(pre) > code {
    background: var(--saundy-docs-inline-code-bg);
    border: 1px solid var(--saundy-docs-inline-code-border);
    border-radius: 6px;
    color: var(--saundy-docs-inline-code);
    padding: 1px 6px;
}

.docs-content blockquote {
    border-left: 3px solid var(--saundy-primary);
    margin: 1rem 0;
    padding: 4px 16px;
    background: rgba(0, 122, 255, 0.06);
    border-radius: 0 8px 8px 0;
}

.docs-content blockquote p:last-child {
    margin-bottom: 0;
}

.docs-content img {
    max-width: 100%;
}
