:root {
    /* Brand tokens from favicon (near-black + orange smile) */
    --gv-primary: #e85800;
    --gv-primary-dark: #c84800;
    --gv-primary-darker: #a24006;
    --gv-accent: #f05900;
    --gv-sidebar-bg: #111111;
    --gv-sidebar-bg-2: #1c1c1c;
    --gv-ink: #141414;
    --gv-muted: #6b6b6b;
    --gv-line: rgba(17, 17, 17, 0.12);
    --gv-surface: #f2f2f0;
    --gv-surface-2: #e8e8e4;
    --gv-panel: #ffffff;
    --gv-accent-soft: #fde8d9;
    --gv-gold: #e8a04a;
    --gv-success: #1f8a5b;
    --gv-danger: #c23b3b;
    --gv-scanner-bg: #0d0d0d;
    --gv-shadow: 0 10px 30px rgba(17, 17, 17, 0.1);
    --gv-radius: 14px;

    /* House aliases */
    --g-ink: var(--gv-ink);
    --g-muted: var(--gv-muted);
    --g-line: var(--gv-line);
    --g-surface: var(--gv-surface);
    --g-surface-2: var(--gv-surface-2);
    --g-panel: var(--gv-panel);
    --g-navy: var(--gv-sidebar-bg);
    --g-accent: var(--gv-primary);
    --g-accent-soft: var(--gv-accent-soft);
    --g-gold: var(--gv-gold);
    --g-success: var(--gv-success);
    --g-danger: var(--gv-danger);
    --g-shadow: var(--gv-shadow);
    --g-radius: var(--gv-radius);
}

html, body {
    min-height: 100%;
    color: var(--g-ink);
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

body.app-body {
    background:
        radial-gradient(1100px 480px at 0% 0%, rgba(232, 160, 74, 0.1), transparent 55%),
        radial-gradient(900px 420px at 100% 0%, rgba(232, 88, 0, 0.1), transparent 50%),
        linear-gradient(165deg, var(--g-surface) 0%, var(--g-surface-2) 100%);
    background-attachment: fixed;
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--g-panel);
    border: 1px solid var(--g-line);
    border-radius: var(--g-radius);
    box-shadow: var(--g-shadow);
    padding: 2rem;
}

.brand-mark {
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--g-navy);
    font-size: 1.35rem;
}

/* Moderator shell — tablet-first width (CIMA: viewport meta width=1024 +
   min-width:1024). Height tracks the viewport only — no 1024px height floor.

   Strategy:
   - min-width: 1024px only (horizontal scroll if narrower)
   - Shell + columns = 100vh − pad so footer (hide + logout) stays on-screen
   - Nav scrolls inside sidebar; main scrolls inside .mod-main
   - Document must not need vertical scroll just to reach logout */
html:has(body.moderator-body) {
    min-width: 1024px;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

body.moderator-body {
    min-width: 1024px;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.mod-shell {
    --mod-sidebar-width: 240px;
    --mod-shell-pad-y: 2.5rem; /* padding-top + padding-bottom */
    /* Columns fill the viewport content area (shell pad excluded) */
    --mod-col-height: calc(100vh - var(--mod-shell-pad-y));

    display: flex;
    gap: 1rem;
    align-items: stretch;
    box-sizing: border-box;
    width: 100%;
    min-width: 1024px;
    height: 100vh;
    max-height: 100vh;
    padding: 1.25rem 1.25rem 1.25rem 1rem;
}

/* Override Bootstrap .collapse-horizontal height:auto so aside fills shell.
   Only when .show — do not fight .collapsing width/display. */
.mod-sidebar.collapse-horizontal.show {
    width: var(--mod-sidebar-width) !important;
    max-width: var(--mod-sidebar-width);
    flex: 0 0 var(--mod-sidebar-width);
    height: var(--mod-col-height) !important;
    max-height: var(--mod-col-height) !important;
    min-height: 0;
    display: flex !important;
    flex-direction: column;
    align-self: stretch;
    overflow: hidden;
}

/* Explicit height (CIMA pattern) — percentage heights fail when parent is auto */
.mod-sidebar-panel {
    flex: 1 1 auto;
    height: var(--mod-col-height);
    max-height: var(--mod-col-height);
    min-height: 0;
    width: 100%;
    align-self: stretch;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--g-radius);
    background: linear-gradient(180deg, var(--gv-sidebar-bg) 0%, var(--gv-sidebar-bg-2) 100%);
    color: #fff;
    box-shadow: var(--g-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Brand pinned at top — never shrinks */
.mod-sidebar-brand {
    flex-shrink: 0;
}

/* Only the nav link list scrolls; footer stays pinned */
.mod-sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Active event + hide/logout — always visible at bottom of black panel */
.mod-sidebar-footer {
    flex: 0 0 auto;
    flex-shrink: 0;
    margin-top: auto;
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.mod-sidebar-footer-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.mod-sidebar-panel a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    margin-bottom: 0.25rem;
}

.mod-sidebar-panel a:hover,
.mod-sidebar-panel a.active {
    background: rgba(232, 88, 0, 0.22);
    color: #fff;
}

.mod-sidebar-panel a.active {
    box-shadow: inset 3px 0 0 var(--gv-primary);
}

.mod-sidebar-icon-btn {
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
}

/* Round red logout — beside hide, not full-width */
.mod-sidebar-logout-btn {
    color: #fff;
    background-color: #dc3545;
    border-color: #dc3545;
}

.mod-sidebar-logout-btn:hover,
.mod-sidebar-logout-btn:focus-visible {
    color: #fff;
    background-color: #bb2d3b;
    border-color: #b02a37;
}

.mod-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: var(--mod-col-height);
    max-height: var(--mod-col-height);
    align-self: stretch;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mod-main-panel,
.main-panel {
    /* min-width:0 so wide DataTables content cannot inflate past .mod-main */
    min-width: 0;
    max-width: 100%;
    padding: 1.25rem 1.5rem 2rem;
}

.mod-main-panel {
    min-height: 100%;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--g-line);
    border-radius: var(--g-radius);
    box-shadow: var(--g-shadow);
}

/* Instant sidebar collapse (sibling pattern) */
.collapse-duration-0.collapse,
.collapse-duration-0.collapsing {
    transition: none !important;
}

.mod-sidebar-toggle-float {
    position: fixed;
    left: 0;
    bottom: 1.5rem;
    z-index: 1030;
    border-radius: 0 999px 999px 0;
    border: 0;
    background: var(--gv-sidebar-bg);
    color: #fff;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.55rem 0.85rem 0.55rem 0.7rem;
    box-shadow: var(--g-shadow);
    opacity: 0.9;
}

.mod-sidebar-toggle-float:hover {
    opacity: 1;
    color: #fff;
    background: var(--gv-primary);
}

/* Prevent flash before Bootstrap applies persisted collapsed state */
html.mod-sidebar-collapsed #modSidebar.collapse {
    display: none !important;
}

html.mod-sidebar-collapsed .mod-sidebar-toggle-float.collapse {
    display: inline-flex !important;
    height: auto;
}

.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, var(--gv-sidebar-bg) 0%, var(--gv-sidebar-bg-2) 100%);
    color: #fff;
    padding: 1.25rem 1rem;
}

.sidebar a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    margin-bottom: 0.25rem;
}

.sidebar a:hover,
.sidebar a.active {
    background: rgba(232, 88, 0, 0.22);
    color: #fff;
}

.stat-card {
    background: var(--g-panel);
    border: 1px solid var(--g-line);
    border-radius: var(--g-radius);
    box-shadow: var(--g-shadow);
    padding: 1.1rem 1.2rem;
    height: 100%;
}

.stat-card .label {
    color: var(--g-muted);
    font-size: 0.85rem;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--g-navy);
}

.panel {
    background: var(--g-panel);
    border: 1px solid var(--g-line);
    border-radius: var(--g-radius);
    box-shadow: var(--g-shadow);
    padding: 1.2rem;
    /* Contain wide tables; scroll here only as fallback if scrollBody mis-measures */
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.btn-gravitas {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--gv-primary);
    --bs-btn-border-color: var(--gv-primary);
    --bs-btn-hover-bg: var(--gv-primary-dark);
    --bs-btn-hover-border-color: var(--gv-primary-dark);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--gv-primary-darker);
    --bs-btn-active-border-color: var(--gv-primary-darker);
    --bs-btn-active-color: #fff;
}

a.link-gravitas {
    color: var(--gv-primary);
    text-decoration: none;
    font-weight: 600;
}

a.link-gravitas:hover,
a.link-gravitas:focus {
    color: var(--gv-primary-dark);
    text-decoration: underline;
}

.table > :not(caption) > * > * {
    vertical-align: middle;
}

.badge-soft {
    background: var(--g-accent-soft);
    color: var(--gv-primary-dark);
}

table.dataTable thead th {
    white-space: nowrap;
    border-bottom-color: rgba(232, 88, 0, 0.28) !important;
}

/* DataTables scrollX — pin scroll shell to panel; body scrolls sideways (CIMA/Jetour).
   .mod-main keeps overflow-x:hidden so the page does not grow; horizontal scroll lives
   in .dataTables_scrollBody (panel overflow-x:auto is a fallback only).
   Do NOT put overflow:hidden on .panel / .mod-main-panel — that clips Actions with no bar. */
.dataTables_wrapper {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.dataTables_scroll {
    width: 100% !important;
    max-width: 100%;
    clear: both;
}

.dataTables_wrapper .dataTables_scrollBody {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
    max-width: 100%;
}

.dataTables_wrapper .dataTables_scrollHead {
    overflow: hidden !important;
    width: 100% !important;
}

/* Name / attendee columns must stay on one line so content width triggers scrollX */
table.dataTable th.col-name,
table.dataTable td.col-name,
.dataTables_wrapper .dataTables_scrollHead th.col-name,
.dataTables_wrapper .dataTables_scrollBody td.col-name {
    white-space: nowrap;
}

/* Actions stay on one line so the full button group is reachable via sideways scroll */
.dataTables_wrapper .dataTables_scrollBody td.text-nowrap,
.dataTables_wrapper .dataTables_scrollHead th.text-nowrap {
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--gv-primary) !important;
    border-color: var(--gv-primary) !important;
    color: #fff !important;
}

.dt-buttons .btn {
    margin-right: 0.35rem;
}

/* Bootstrap modals — brand chrome (Import / Add / Edit attendee, etc.) */
.modal-content {
    border: 1px solid var(--gv-line);
    border-radius: var(--gv-radius);
    overflow: hidden;
    box-shadow: var(--gv-shadow);
}

.modal-header {
    background: linear-gradient(90deg, var(--gv-accent-soft) 0%, #ffffff 62%);
    border-bottom: 1px solid rgba(232, 88, 0, 0.22);
    box-shadow: inset 0 3px 0 var(--gv-primary);
}

.modal-title {
    color: var(--gv-ink);
    font-weight: 650;
}

.modal-footer {
    border-top: 1px solid rgba(232, 88, 0, 0.14);
    background: linear-gradient(180deg, #fff 0%, var(--gv-surface) 100%);
}

/* SweetAlert2 — Gravitas brand chrome (scanner + moderator) */
.gv-swal-popup {
    position: relative !important;
    border: 1px solid rgba(232, 88, 0, 0.32) !important;
    border-radius: var(--gv-radius) !important;
    box-shadow: 0 16px 40px rgba(17, 17, 17, 0.18) !important;
    padding-top: 1.75rem !important;
}

.gv-swal-popup::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gv-primary) 0%, var(--gv-accent) 55%, var(--gv-gold) 100%);
    border-radius: var(--gv-radius) var(--gv-radius) 0 0;
}

.gv-swal-title {
    color: var(--gv-ink) !important;
    font-weight: 700 !important;
}

.gv-swal-confirm {
    background-color: var(--gv-primary) !important;
    border-color: var(--gv-primary) !important;
    color: #fff !important;
    box-shadow: none !important;
}

.gv-swal-confirm:hover,
.gv-swal-confirm:focus {
    background-color: var(--gv-primary-dark) !important;
    border-color: var(--gv-primary-dark) !important;
}

.gv-swal-cancel {
    background-color: #6b6b6b !important;
    border-color: #6b6b6b !important;
    color: #fff !important;
    box-shadow: none !important;
}

.swal2-timer-progress-bar {
    background: var(--gv-primary) !important;
}

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

.swal2-success [class^="swal2-success-line"] {
    background-color: var(--gv-primary) !important;
}

.swal2-success .swal2-success-ring {
    border-color: rgba(232, 88, 0, 0.35) !important;
}

.swal2-warning {
    border-color: var(--gv-gold) !important;
    color: var(--gv-primary) !important;
}

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

/* Scanner — simple tablet/mobile: masthead → video → floating controls */
.scanner-page {
    background:
        radial-gradient(900px 520px at 50% -8%, rgba(232, 88, 0, 0.32), transparent 58%),
        radial-gradient(640px 420px at 100% 100%, rgba(232, 88, 0, 0.12), transparent 50%),
        linear-gradient(180deg, #0a0a0a 0%, var(--gv-scanner-bg) 42%, #111111 100%);
    color: #fff;
    min-height: 100vh;
    margin: 0;
}

.scanner-shell {
    position: relative;
    max-width: 810px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 1.5rem 1rem 5.5rem;
    box-sizing: border-box;
    background-color: transparent;
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
}

.scanner-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    position: relative;
}

.scanner-masthead {
    width: 100%;
    max-width: 640px;
    height: auto;
    display: block;
}

.scanner-masthead-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 7.5rem;
    padding: 1.25rem 1.5rem;
    box-sizing: border-box;
    border-radius: 18px;
    background:
        radial-gradient(ellipse 55% 80% at 78% 30%, rgba(232, 88, 0, 0.55), transparent 70%),
        linear-gradient(135deg, #0d0d0d 0%, #111111 55%, #1c1c1c 100%);
    box-shadow: inset 0 4px 0 0 #e85800;
}

.scanner-masthead-icon {
    width: 7rem;
    height: 7rem;
    display: block;
    object-fit: contain;
    border-radius: 1.15rem;
}

.scanner-video-wrap {
    position: relative;
    width: 100%;
    max-width: 420px;
}

.scanner-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 0 2px rgba(232, 88, 0, 0.55), 0 16px 36px rgba(0, 0, 0, 0.45);
}

.scanner-container.is-disabled {
    opacity: 0.35;
    filter: grayscale(0.35);
}

.scanner-container video,
#video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    background: #000;
}

.scanner-closed-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background:
        radial-gradient(circle at 50% 40%, rgba(232, 88, 0, 0.18), transparent 55%),
        rgba(13, 13, 13, 0.62);
    border-radius: 1rem;
}

.scanner-closed-card {
    text-align: center;
    background: rgba(17, 17, 17, 0.94);
    border: 1px solid rgba(232, 88, 0, 0.45);
    box-shadow: 0 0 0 1px rgba(232, 88, 0, 0.12), 0 12px 28px rgba(0, 0, 0, 0.45);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    max-width: 22rem;
}

.scanner-closed-card .bi {
    font-size: 1.5rem;
    color: var(--gv-accent);
    display: block;
    margin-bottom: 0.5rem;
}

.scanner-controls {
    position: fixed;
    z-index: 20;
    display: flex;
    gap: 0.75rem;
    pointer-events: none;
    bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
    right: max(1.25rem, calc((100vw - 810px) / 2 + 1.25rem));
}

.scanner-controls .btn {
    pointer-events: auto;
    width: 2.75rem;
    height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-gravitas-scanner {
    background-color: var(--gv-primary);
    color: #fff;
    border: 1px solid rgba(253, 232, 217, 0.35);
    box-shadow: 0 6px 18px rgba(232, 88, 0, 0.35);
    opacity: 0.95;
}

.btn-gravitas-scanner:hover,
.btn-gravitas-scanner:focus {
    background-color: var(--gv-primary-dark);
    color: #fff;
    border-color: rgba(253, 232, 217, 0.55);
    box-shadow: 0 8px 22px rgba(232, 88, 0, 0.5);
    opacity: 1;
}

.btn-gravitas-scanner:active {
    background-color: var(--gv-primary-darker);
}

.check-in-in {
    color: green;
    font-weight: 600;
}

.check-in-out {
    color: var(--gv-primary);
    font-weight: 600;
}

@media (min-width: 768px) and (max-width: 1024px) {
    .scanner-shell {
        font-size: 1.05rem;
    }
}

@media (max-width: 991.98px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 20;
    }

    .sidebar .nav-stack {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .sidebar a {
        margin-bottom: 0;
    }
}
