/* 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;
}

.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 {
    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;
}

.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;
}

.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. 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; }
}

/* 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;
}

.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-only: <html data-bs-theme="dark"> 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. */
[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;
}
