.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

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

.startup-loader-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    background: #f4f7fb;
}

:root[data-theme="dark"] .startup-loader-shell {
    background: #0f1724;
}

.startup-loader-image {
    width: 100px;
    height: 100px;
    object-fit: contain;
    animation: startup-pulse 1.4s ease-in-out infinite;
}

.startup-loader-text {
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #6b7b93;
    text-transform: uppercase;
}

:root[data-theme="dark"] .startup-loader-text {
    color: #92a4bd;
}

.startup-loader-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

.startup-progress {
    width: min(260px, 72vw);
    height: 10px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.24);
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.28);
}

.startup-progress-bar {
    height: 100%;
    width: var(--blazor-load-percentage, 0%);
    background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 100%);
    border-radius: inherit;
    transition: width 0.12s ease-out;
}

:root[data-theme="dark"] .startup-progress-bar {
    background: linear-gradient(90deg, #7cb0ff 0%, #a9caff 100%);
}

.startup-progress-value {
    font-size: 0.85rem;
    color: #6b7b93;
    font-variant-numeric: tabular-nums;
}

:root[data-theme="dark"] .startup-progress-value {
    color: #92a4bd;
}

.startup-progress-value::after {
    content: var(--blazor-load-percentage, "0%");
}

@keyframes startup-pulse {
    0% {
        opacity: 0.35;
        transform: scale(0.94);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0.35;
        transform: scale(0.94);
    }
}

code {
    color: #c02d76;
}

.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;
}
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --sidebar-surface: linear-gradient(180deg, #dff1f4 0%, #cfe6ef 52%, #d8d7ef 100%);
    --topbar-surface: #4f8fa8;
    --border: #e2e6ea;
    --text: #1a1f24;
    --muted: #6b7480;
    --accent: #1f3b5b;
    --accent-weak: #e6edf5;
    --danger: #b21d1d;
}

:root[data-theme="dark"] {
    --bg: #0f1419;
    --surface: #171d24;
    --sidebar-surface: linear-gradient(180deg, #13232c 0%, #183443 52%, #2a2841 100%);
    --topbar-surface: #214455;
    --border: #2a3441;
    --text: #e6edf5;
    --muted: #a7b3c2;
    --accent: #9ec4ef;
    --accent-weak: #1b2a3c;
    --danger: #ff8c8c;
}

body {
    margin: 0;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

.login-shell {
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
}

.app-sidebar {
    width: 240px;
    background: var(--sidebar-surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1.25rem;
    box-sizing: border-box;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.sidebar-brand-logo {
    display: block;
    max-width: 100%;
    height: 44px;
    width: auto;
    object-fit: contain;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav a {
    text-decoration: none;
    color: var(--text);
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
}

.nav-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.2rem 0.3rem 0.4rem;
}

.nav-group summary {
    cursor: pointer;
    padding: 0.45rem 0.5rem;
    font-weight: 600;
    color: var(--accent);
}

.nav-subgroup {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.nav a.active {
    background: var(--accent-weak);
    color: var(--accent);
    font-weight: 600;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--topbar-surface);
}

.app-title {
    font-weight: 600;
    color: #f4fbff;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.user-pill {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    color: #f4fbff;
    background: rgba(255, 255, 255, 0.14);
    font-size: 0.85rem;
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    cursor: pointer;
}

.user-menu-popover {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    z-index: 30;
    min-width: 240px;
    padding: 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.user-menu-section {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.user-menu-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.user-menu-action {
    width: 100%;
    justify-content: flex-start;
}

.app-content {
    padding: 1.5rem;
}

.app-busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(15, 23, 35, 0.34);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.app-busy-card {
    min-width: min(360px, 92vw);
    max-width: 420px;
    padding: 1.2rem 1.35rem;
    border-radius: 16px;
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border) 82%);
    background: color-mix(in srgb, var(--surface) 92%, white 8%);
    box-shadow: 0 20px 48px rgba(8, 18, 30, 0.24);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    text-align: center;
}

.app-busy-spinner {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 4px solid rgba(31, 59, 91, 0.14);
    border-top-color: var(--accent);
    animation: app-busy-spin 0.9s linear infinite;
}

.app-busy-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.app-busy-text {
    color: var(--muted);
    font-size: 0.92rem;
}

@keyframes app-busy-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.page-header h1 {
    margin: 0 0 0.3rem 0;
    font-size: 1.6rem;
}

.muted {
    color: var(--muted);
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-title {
    font-weight: 600;
    margin-bottom: 0.4rem;
}

/* Non-dashboard widget cards (Home uses `.metric-card` — unaffected): shrink padding and
   the big number so per-page metrics take less vertical space. */
.grid > .card {
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
}

.grid > .card .metric-value {
    font-size: clamp(1.05rem, 1.3vw, 1.35rem);
    margin-top: 0.3rem;
    letter-spacing: -0.02em;
}

.grid > .card .card-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.grid > .card .metric-note {
    margin-top: 0.3rem;
    font-size: 0.78rem;
}

.grid > .card .metric-label {
    font-size: 0.72rem;
}

.grid + .panel,
.grid + .filter-panel,
.grid + details.filter-panel {
    margin-top: 1rem;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 1rem;
    width: 100%;
    align-items: stretch;
}

.games-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.games-tab-strip {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.games-tab-strip .btn.is-active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    border-color: transparent;
}

.games-pagination-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    flex-wrap: wrap;
}

.games-pagination-actions {
    display: inline-flex;
    gap: 0.5rem;
}

.game-card {
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
    border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--border) 88%);
    border-radius: 16px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 8px 24px rgba(31, 59, 91, 0.07);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    isolation: isolate;
}

.game-card:hover {
    transform: translateY(-2px);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.06),
        0 16px 40px rgba(31, 59, 91, 0.12);
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border) 72%);
}

.game-card.is-clickable {
    cursor: pointer;
}

.game-card.is-archived {
    cursor: default;
    opacity: 0.78;
    filter: grayscale(0.35);
}

.game-card-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.30;
    filter: blur(12px) saturate(1.2);
    border-radius: 16px;
    /* blur spreads pixels ~12px past the element; clip-path forces the filtered
       output (not just the element box) to the rounded card shape so the yellow
       halo doesn't bleed past the card corners. */
    clip-path: inset(0 round 16px);
    z-index: 0;
    pointer-events: none;
    user-select: none;
}

video.game-card-bg {
    /* First-frame-only for video backgrounds — no autoplay */
    background: var(--surface-muted);
}

.game-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.game-card-content {
    position: relative;
    z-index: 1;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    flex: 1;
    min-height: 0;
}

.game-card-description {
    margin-top: auto;
}

.game-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
    min-width: 0;
}

.game-card-header-title {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
    flex: 1;
    overflow-wrap: anywhere;
}

.game-card-header-title .card-title {
    font-size: 1.1rem;
    margin: 0;
}

.game-card-info {
    display: grid;
    grid-template-columns: 148px minmax(0, 1fr);
    gap: 0.9rem;
    align-items: start;
    min-width: 0;
}

.game-card-image-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    width: 148px;
}

.game-card-image-wrap {
    position: relative;
    width: 148px;
    height: 148px;
}

.game-card-image-wrap .game-status-badge {
    position: absolute;
    top: -8px;
    left: -4px;
    z-index: 2;
    padding: 0.15rem 0.45rem;
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

a.game-card-play,
button.game-card-play,
.btn.game-card-play {
    width: 100%;
    height: 2rem;
    min-height: 2rem;
    max-height: 2rem;
    padding: 0.3rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-align: center;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-sizing: border-box;
    line-height: 1;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

a.game-card-play {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
    color: #3d2a0a;
    border: 1px solid rgba(217, 119, 6, 0.45);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.35) inset,
        0 2px 8px rgba(217, 119, 6, 0.3);
}

a.game-card-play:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.4) inset,
        0 4px 12px rgba(217, 119, 6, 0.4);
}

a.game-card-play:active {
    transform: translateY(0);
    filter: brightness(0.95);
}

button.game-card-play:disabled {
    background: var(--surface-muted);
    color: var(--muted);
    border: 1px solid var(--border);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.7;
}

:root[data-theme="dark"] a.game-card-play {
    background: linear-gradient(135deg, #fde047 0%, #fbbf24 50%, #f59e0b 100%);
    color: #1e1405;
    border-color: rgba(251, 191, 36, 0.5);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.25) inset,
        0 2px 10px rgba(251, 191, 36, 0.25);
}

.game-card-id-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    overflow-wrap: anywhere;
    margin-bottom: 0.15rem;
}

.game-card-id {
    font-size: 0.9rem;
}

.game-card-alias {
    color: var(--muted);
    font-size: 0.85rem;
}

.game-card-reskin-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    margin-bottom: 0.35rem;
    border-radius: 8px;
    background: color-mix(in srgb, #f59e0b 12%, var(--surface) 88%);
    border: 1px solid rgba(245, 158, 11, 0.25);
    font-size: 0.82rem;
    color: var(--text);
    overflow-wrap: anywhere;
}

.game-card-reskin-badge {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #d97706;
    background: rgba(245, 158, 11, 0.15);
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    flex-shrink: 0;
}

:root[data-theme="dark"] .game-card-reskin-badge {
    color: #fbbf24;
}

.game-card-field {
    font-size: 0.88rem;
}

.game-card-controls {
    display: inline-flex;
    gap: 0.35rem;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity 0.2s ease;
}

.game-card:hover .game-card-controls {
    opacity: 1;
}

.game-card-edit {
    min-width: 0;
    width: 1.85rem;
    height: 1.85rem;
    padding: 0.3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    border-radius: 8px;
    backdrop-filter: blur(8px);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
}

.game-card-favorite {
    min-width: 0;
    width: 1.85rem;
    height: 1.85rem;
    padding: 0.3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    border-radius: 8px;
    backdrop-filter: blur(8px);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
}

.game-card-favorite.is-active {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.1);
}

.game-card-image {
    width: 148px;
    height: 148px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--accent) 10%, var(--border) 90%);
    background: var(--surface-soft);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: block;
    box-sizing: border-box;
    padding: 0.5rem;
}

.game-card:hover .game-card-image {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

/* Queue-loaded card images: hidden until imageQueue marks them as loaded, so the
   catalog doesn't flash with broken-image icons while requests drip through. */
.game-card-image.is-pending,
.game-card-bg.is-pending {
    opacity: 0;
}

.game-card-image.is-loaded,
.game-card-bg.is-loaded {
    transition: opacity 0.3s ease;
}

/* Mascot fallback for missing artwork — dim so operators see at a glance that the
   card has no real cover yet without the image disappearing entirely. Image itself is
   capped at the desktop card-image size (148px) so the mascot doesn't scale up to fill
   responsive wrappers that stretch to 100%. */
.game-card-image.is-fallback {
    opacity: 0.45;
    object-fit: contain;
    box-sizing: border-box;
    width: 148px;
    height: 148px;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    padding: 0.75rem;
    background: var(--surface-soft);
}

.game-form-preview-image.is-fallback {
    opacity: 0.45;
    object-fit: contain;
    padding: 1rem;
}

.game-card-bg.is-fallback {
    opacity: 0.18;
    object-fit: contain;
}

.game-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 0.88rem;
}

.game-card-meta strong {
    color: var(--muted);
    font-weight: 600;
}

.game-card-label-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.game-card-type {
    color: var(--muted);
    font-size: 0.92rem;
}

.game-status-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.22rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    backdrop-filter: blur(4px);
}

.game-status-badge-hot {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    color: #ffffff;
    border: 1px solid rgba(239, 68, 68, 0.6);
}

.game-status-badge-new {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border: 1px solid rgba(16, 185, 129, 0.6);
}

.game-status-badge-top {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: #ffffff;
    border: 1px solid rgba(59, 130, 246, 0.6);
}

.game-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    min-height: 1.75rem;
}

.game-card-feature-block {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-top: 0.5rem;
    border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

.game-card-feature-title {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.game-feature-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.6rem;
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent-weak) 80%, var(--surface) 20%);
    border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--border) 88%);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-strong, var(--accent));
    transition: background 0.15s ease;
}

.game-feature-tag:hover {
    background: color-mix(in srgb, var(--accent-weak) 100%, white 0%);
}

.game-card-description {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
    min-height: 2.8rem;
    overflow-wrap: anywhere;
}

.game-card-actions {
    margin-top: auto;
    display: flex;
    justify-content: flex-start;
}

.game-details-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.game-details-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.game-details-title-row,
.game-details-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.game-details-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 1.35rem;
    font-weight: 800;
}

.game-details-title-icon {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.game-details-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1rem;
    align-items: stretch;
}

.game-details-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.game-details-hero {
    position: relative;
    overflow: hidden;
    min-height: 430px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
}

.game-details-hero-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(14px) saturate(1.1);
    transform: scale(1.06);
    opacity: 0.52;
}

.game-details-art-frame {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 430px;
    padding: 1.25rem;
}

.game-details-demo-frame {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 430px;
    padding: 1.25rem;
}

.game-details-demo-frame-content {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 8px;
    background: #111827;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.24);
}

.game-details-demo-frame.is-mobile .game-details-demo-frame-content {
    width: min(360px, 86vw);
    height: min(640px, 72vh);
}

.game-details-demo-frame.is-desktop .game-details-demo-frame-content {
    width: min(100%, 1040px);
    aspect-ratio: 16 / 9;
    height: auto;
}

.game-details-art {
    width: min(360px, 70%);
    max-height: 390px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.24);
}

.game-details-art.is-fallback {
    opacity: 0.75;
    padding: 1rem;
    background: var(--surface-soft);
}

.game-details-demo-control-row {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: blur(8px);
}

.game-details-demo-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.game-details-mode-switch {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.game-details-mode-option {
    border: 0;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 650;
    padding: 0.55rem 0.9rem;
}

.game-details-mode-option:last-child {
    border-right: 0;
}

.game-details-mode-option.is-active {
    background: var(--accent);
    color: white;
}

.game-details-about {
    min-height: 260px;
}

.game-details-description {
    margin-top: 1rem;
    max-width: 780px;
    color: var(--text);
    line-height: 1.65;
    white-space: pre-line;
}

.game-details-side {
    position: static;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 100%;
}

.game-details-facts {
    display: grid;
    gap: 1rem;
}

.game-details-facts div,
.game-details-side-section {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.game-details-facts strong,
.game-details-side-section strong {
    color: var(--text);
    font-size: 0.86rem;
}

.game-details-facts span {
    color: var(--muted);
}

.game-details-demo-settings,
.form-add-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.game-details-demo-settings {
    justify-content: flex-end;
    margin-left: auto;
}

.game-details-demo-settings .form-row {
    min-width: 170px;
}

.game-details-media-carousel {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.game-details-media-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    text-align: left;
}

.game-details-media-item img,
.game-details-media-video-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: block;
    position: relative;
}

.game-details-media-item img {
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
}

.game-details-media-video-preview {
    overflow: hidden;
    border-radius: 8px;
}

.game-details-media-play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: white;
    font-size: 2rem;
    background: rgba(0, 0, 0, 0.22);
}

.game-details-media-modal {
    width: min(1120px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

.game-details-media-modal-body {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
}

.game-details-media-modal-content {
    display: grid;
    place-items: center;
    min-height: 360px;
    background: #0f172a;
    border-radius: 8px;
    overflow: hidden;
}

.game-details-media-modal-content img,
.game-details-media-modal-content video {
    max-width: 100%;
    max-height: calc(100vh - 180px);
    object-fit: contain;
}

/* Iframe-embedded videos (Drive / YouTube / Vimeo) need an explicit aspect ratio
   since iframes have no intrinsic size; max-height matches the <video> rule so
   the modal layout is consistent regardless of how the asset is hosted. */
.game-details-media-modal-iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: calc(100vh - 180px);
    border: 0;
    background: #000;
}

.game-details-media-modal-nav {
    align-self: stretch;
}

.game-details-media-editor-add,
.game-details-media-editor-list,
.game-details-media-editor-item {
    display: grid;
    gap: 0.6rem;
}

.game-details-media-editor-add {
    grid-template-columns: 1fr;
    align-items: stretch;
}

.media-draft-row {
    display: grid;
    grid-template-columns: 120px minmax(180px, 1fr) minmax(180px, 1fr) minmax(150px, 0.75fr) auto;
    gap: 0.6rem;
    align-items: end;
}

.media-upload-field {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
}

.media-upload-field > span {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
}

.media-upload-input {
    width: 100%;
    min-height: 38px;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel-soft);
    color: var(--text);
    font-size: 0.82rem;
}

.media-url-fallback {
    margin-top: 0.45rem;
}

.media-url-fallback > summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.8rem;
}

.media-url-fallback[open] > summary {
    margin-bottom: 0.45rem;
}

.media-url-fallback-block {
    margin-top: 0;
}

.media-url-fallback-block[open] {
    display: grid;
    gap: 0.45rem;
}

.media-url-fields {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr);
    gap: 0.6rem;
}

.game-details-media-editor-list {
    margin-top: 0.5rem;
}

.game-details-media-editor-item {
    grid-template-columns: 28px 110px minmax(180px, 1fr) minmax(180px, 1fr) minmax(140px, 0.7fr) auto;
    align-items: center;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
    /* Smooth out the dim during a drag so reordering doesn't feel snappy. */
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

/* Source row while a drag is in progress — dimmed so the user sees what's being moved. */
.game-details-media-editor-item.is-dragging {
    opacity: 0.45;
    border-color: var(--accent, #5b8def);
}

.game-details-media-drag {
    cursor: grab;
    color: var(--muted);
    text-align: center;
    user-select: none;
    /* The handle is the only draggable element in the row — make it visibly clickable
       and a touch larger so it's an obvious target. The grabbing cursor flips while held. */
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.25rem 0;
    border-radius: 4px;
}

.game-details-media-drag:hover {
    color: var(--fg);
    background: rgba(255, 255, 255, 0.06);
}

.game-details-media-drag:active {
    cursor: grabbing;
}

@media (max-width: 980px) {
    .game-details-topbar,
    .game-details-title-row,
    .game-details-actions {
        align-items: flex-start;
    }

    .game-details-topbar,
    .game-details-layout {
        grid-template-columns: 1fr;
    }

    .game-details-topbar {
        flex-direction: column;
    }

    .game-details-side {
        position: static;
    }

    .game-details-hero,
    .game-details-art-frame,
    .game-details-demo-frame {
        min-height: 330px;
    }

    .game-details-demo-control-row {
        align-items: stretch;
        flex-direction: column;
    }

    .game-details-demo-settings {
        justify-content: flex-start;
        margin-left: 0;
    }

    .game-details-media-carousel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .game-details-media-editor-add,
    .game-details-media-editor-item {
        grid-template-columns: 1fr;
    }

    .media-draft-row,
    .media-url-fields {
        grid-template-columns: 1fr;
    }
}

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

    .game-card-image-wrap {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
        max-height: 260px;
    }

    .game-card-image-wrap .game-card-image {
        width: 100%;
        height: 100%;
    }

    .games-pagination-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .game-card-info {
        grid-template-columns: 1fr;
    }

    .game-card-image-col {
        width: 100%;
        max-width: 280px;
        margin: 0 auto;
    }
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.panel-title {
    font-weight: 600;
}

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

.form-grid-modal {
    margin-bottom: 1rem;
}

.game-form-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.game-form-preview {
    min-width: 0;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background-color: var(--surface-muted);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    /* Inline `style="--game-form-preview-bg: url(...)"` is consumed by ::before below.
       The pseudo-element exists only to host filter:blur — applying the filter on the
       container would blur the poster and icon too, which is the opposite of what we want. */
    overflow: hidden;
    isolation: isolate;
}

.game-form-preview::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--game-form-preview-bg, none);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Slight overscale + blur produces a clean edge — without it the blurred halo bleeds
       past the container and reveals the underlying surface. */
    transform: scale(1.06);
    filter: blur(14px) saturate(1.05);
    z-index: -1;
    pointer-events: none;
}

.game-form-preview > * {
    position: relative;
    z-index: 1;
}

.game-form-preview-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: rgba(15, 18, 28, 0.35);
    border-radius: 10px;
    display: block;
}

.game-form-preview-icon {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.game-form-layout .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
    align-items: start;
}

.game-form-layout .form-row-full {
    grid-column: 1 / -1;
}

.game-form-layout .form-section-title {
    grid-column: 1 / -1;
    margin: 0.4rem 0 -0.2rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

.game-form-layout .form-actions {
    grid-column: 1 / -1;
    margin-top: 0.3rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-actions {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
}

.input {
    padding: 0.55rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.95rem;
}

.input-end-value {
    width: 160px;
    max-width: 100%;
}

.input-amount {
    width: 96px;
    max-width: 100%;
}

.inline-input {
    width: 150px;
    max-width: 100%;
}

.input-requirement-id {
    width: 180px;
    max-width: 100%;
}

.input-requirement-text {
    width: 280px;
    max-width: 100%;
}

.input-requirement-number {
    width: 96px;
    max-width: 100%;
}

.input-requirement-json {
    width: 360px;
    max-width: 100%;
}

.input.input-end-value {
    width: 160px;
    max-width: 100%;
}

.input.input-amount,
.input.input-requirement-number {
    width: 120px;
    max-width: 100%;
}

.input.input-requirement-id {
    width: 220px;
    max-width: 100%;
}

.input.input-requirement-text {
    width: 320px;
    max-width: 100%;
}

.input.input-requirement-json {
    width: 420px;
    max-width: 100%;
}

.btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn.secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn.ghost {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-inline {
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th,
.table td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.status-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.requirements-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.login-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
}

.login-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.login-card h1 {
    margin-top: 0;
}

.login-card-header h1 {
    margin-bottom: 0.25rem;
}

.login-divider {
    margin: 1rem 0;
    display: flex;
    align-items: center;
    color: var(--muted);
    font-size: 0.85rem;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--border);
}

.login-divider span {
    padding: 0 0.65rem;
}

.error {
    margin-top: 0.8rem;
    color: var(--danger);
}

.mono {
    font-family: "SF Mono", "Cascadia Mono", "Consolas", monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Spin detail visualisation: reel states + win-line cards */
.reel-states {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin: 0.4rem 0 0.9rem;
}

.reel-state {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.reel-state-label {
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.reel-grid {
    display: grid;
    gap: 4px;
    padding: 0.45rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border, rgba(15, 23, 42, 0.08));
}

.reel-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    height: 2.2rem;
    padding: 0 0.35rem;
    border-radius: 6px;
    background: #fff;
    color: var(--ink, #0f172a);
    font-family: "SF Mono", "Cascadia Mono", "Consolas", monospace;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.reel-cell.is-hit {
    background: #bbf7d0;
    border-color: #16a34a;
    color: #14532d;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.25);
}

.winline-list {
    display: grid;
    gap: 0.6rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    margin: 0.4rem 0 0.9rem;
}

.winline-card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.6rem;
    border-radius: 10px;
    border: 1px solid var(--border, rgba(15, 23, 42, 0.08));
    background: var(--surface, #fff);
}

.winline-card-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.winline-tag {
    display: inline-flex;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.15);
    color: #92400e;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.winline-meta {
    color: var(--muted);
    font-size: 0.8rem;
}

.winline-card-footer {
    display: flex;
    justify-content: flex-end;
}

.winline-prize {
    font-weight: 700;
    color: var(--ink, #0f172a);
    font-size: 0.92rem;
}

/* Trigger badges in the spin-detail Triggers column. Different colour per
   feature so a cert auditor can scan a long list and spot bonus / free
   spin / jackpot rows without reading the cell text. */
.trigger-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    margin-right: 0.25rem;
    line-height: 1.4;
}

.trigger-bonus {
    background: rgba(245, 158, 11, 0.15);
    color: #92400e;
}

.trigger-freespins {
    background: rgba(34, 197, 94, 0.18);
    color: #14532d;
}

.trigger-jackpot {
    background: rgba(168, 85, 247, 0.18);
    color: #581c87;
}

/* Round-context summary above the JSON grids. Two-column key/value flow
   that wraps responsively — keeps cert identifiers (UserId / SessionId /
   ExternalRoundId etc.) visible without forcing the auditor to scroll the
   raw JSON pane. */
.round-context-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.45rem 1rem;
    margin: 0.4rem 0 0.9rem;
}

.round-context-kv {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.round-context-key {
    font-size: 0.74rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.round-context-val {
    font-size: 0.88rem;
    word-break: break-all;
    font-family: "SF Mono", "Cascadia Mono", "Consolas", monospace;
}

/* Anonymize toggle in the History export toolbar. Inline checkbox + label
   that aligns with the Export buttons; uses the accent colour to match
   the platform-game-mappings checkbox style. */
.anonymize-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    user-select: none;
    margin-right: 0.5rem;
    font-size: 0.88rem;
}

.anonymize-toggle input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--accent);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 16, 24, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 1.5rem;
    box-sizing: border-box;
}

.modal {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    width: min(980px, 100%);
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Game preview modal — iframe-based demo launcher with device-mode toggles. */
.game-preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 16, 24, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 1.25rem;
    box-sizing: border-box;
}

.game-preview-modal {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    width: min(1400px, 100%);
    height: min(920px, 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.game-preview-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.game-preview-title {
    font-weight: 600;
    font-size: 1rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.game-preview-modes {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.game-preview-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    line-height: 30px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 3;
}

.game-preview-close:hover {
    background: var(--surface-muted);
}

.game-preview-stage {
    flex: 1;
    min-height: 0;
    background: #0b0e12;
    overflow: hidden;
    position: relative;
    display: block;
}

.game-preview-frame {
    border: 0;
    display: block;
    /* width/height/transform/margins are driven by gamePreview.observe JS helper.
       Defaults here just avoid flicker before the first resize observation fires. */
    width: 1280px;
    height: 720px;
    transform-origin: top left;
}

/* Mobile (<=700px wide): modal goes full-viewport, chrome hides, only a floating
   close button remains. Device-mode toggles are meaningless on a phone — the user
   rotates the device physically. */
@media (max-width: 700px) {
    .game-preview-overlay {
        padding: 0;
    }

    .game-preview-modal {
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }

    .game-preview-header {
        display: none;
    }

    .game-preview-stage {
        width: 100%;
        height: 100%;
    }

    .game-preview-frame {
        width: 100% !important;
        height: 100% !important;
        transform: none !important;
        margin: 0 !important;
    }

    .game-preview-close {
        background: rgba(9, 16, 24, 0.7);
        color: #fff;
        border-color: transparent;
        width: 36px;
        height: 36px;
        line-height: 32px;
        font-size: 1.5rem;
    }
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.modal-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.modal-body {
    padding: 1rem 1.25rem 1.25rem;
    overflow: auto;
}

.modal-footer {
    padding: 0 1.25rem 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.endpoint-switcher {
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.endpoint-switcher.compact {
    min-width: 220px;
}

.endpoint-switcher-label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.endpoint-switcher-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.endpoint-switcher-select {
    min-width: 0;
    flex: 1;
    background: var(--surface);
    color: var(--text);
}

.endpoint-switcher-caption {
    font-size: 0.78rem;
    line-height: 1.35;
    word-break: break-word;
}

.endpoint-pill {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.18);
    color: #f4fbff;
}

.quest-editor-requirements {
    margin-top: 0.5rem;
}

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

    .game-form-layout .form-grid {
        grid-template-columns: 1fr;
    }

    .game-form-preview-image {
        max-height: 240px;
        aspect-ratio: auto;
        height: auto;
    }

    .app-shell {
        flex-direction: column;
    }

    .app-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .app-content {
        padding: 1rem;
    }

    .login-card-header {
        flex-direction: column;
    }

    .endpoint-switcher,
    .endpoint-switcher.compact {
        width: 100%;
        min-width: 0;
    }

    .user-menu-popover {
        right: auto;
        left: 0;
        min-width: min(240px, calc(100vw - 2rem));
    }

}

/* Backoffice redesign baseline */

:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --surface-soft: #eef3f8;
    --sidebar-surface: #1f2b3d;
    --sidebar-surface-alt: #243247;
    --topbar-surface: rgba(255, 255, 255, 0.88);
    --border: #e5ebf3;
    --border-strong: #d5deea;
    --text: #1e293b;
    --muted: #6b7b93;
    --accent: #3b82f6;
    --accent-strong: #1d4ed8;
    --accent-weak: #eff6ff;
    --success: #12966f;
    --danger: #cc4b4b;
    --shadow-sm: 0 10px 30px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 18px 48px rgba(15, 23, 42, 0.12);
}

:root[data-theme="dark"] {
    --bg: #0f1724;
    --surface: #111c2d;
    --surface-muted: #162235;
    --surface-soft: #1b2940;
    --sidebar-surface: #0b1220;
    --sidebar-surface-alt: #132038;
    --topbar-surface: rgba(11, 18, 32, 0.84);
    --border: #22324a;
    --border-strong: #2d4260;
    --text: #e8eef8;
    --muted: #92a4bd;
    --accent: #7cb0ff;
    --accent-strong: #a9caff;
    --accent-weak: #15253b;
    --success: #44c191;
    --danger: #ff8a8a;
    --shadow-sm: 0 16px 40px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 24px 56px rgba(0, 0, 0, 0.32);
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Manrope", "IBM Plex Sans", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), transparent 24%),
        linear-gradient(180deg, #f7f9fc 0%, var(--bg) 18%, var(--bg) 100%);
    color: var(--text);
    line-height: 1.5;
}

:root[data-theme="dark"] body {
    background:
        radial-gradient(circle at top left, rgba(124, 176, 255, 0.08), transparent 22%),
        linear-gradient(180deg, #0d1522 0%, var(--bg) 22%, var(--bg) 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

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

.login-shell {
    align-items: stretch;
    justify-content: center;
    padding: 2rem;
}

.shell-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(9, 16, 28, 0.42);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 90;
}

.shell-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}

.app-sidebar {
    width: 276px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 24%),
        linear-gradient(180deg, var(--sidebar-surface) 0%, var(--sidebar-surface-alt) 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    padding: 1.35rem 1rem 1rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.brand-block {
    justify-content: flex-start;
    gap: 1rem;
    margin-bottom: 0;
}

.sidebar-brand-logo {
    width: 64px;
    height: 64px;
    padding: 0.65rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.sidebar-brand-title {
    color: #f8fbff;
    font-weight: 800;
    font-size: 1.08rem;
    line-height: 1.1;
}

.sidebar-brand-subtitle {
    margin-top: 0.2rem;
    color: rgba(225, 234, 245, 0.7);
    font-size: 0.85rem;
}

.sidebar-close,
.shell-nav-toggle {
    display: none !important;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.nav-section-label {
    margin-top: 0.7rem;
    padding: 0 0.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(225, 234, 245, 0.45);
}

.nav a {
    display: flex;
    align-items: center;
    min-height: 2.8rem;
    padding: 0.7rem 0.9rem;
    border-radius: 14px;
    color: rgba(240, 246, 255, 0.84);
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
    transform: translateX(1px);
}

.nav a.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.22), rgba(59, 130, 246, 0.08));
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(124, 176, 255, 0.2);
    font-weight: 700;
}

.nav-group {
    border: none;
    border-radius: 16px;
    padding: 0.15rem 0;
    background: rgba(255, 255, 255, 0.03);
}

.nav-group summary {
    list-style: none;
    cursor: pointer;
    padding: 0.8rem 0.9rem 0.55rem;
    font-weight: 700;
    color: #f8fbff;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-subgroup {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 0.45rem 0.45rem;
}

.nav-subgroup a {
    min-height: 2.45rem;
    padding-left: 0.95rem;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 80;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--topbar-surface);
    border-bottom: 1px solid rgba(213, 222, 234, 0.85);
    backdrop-filter: blur(16px);
}

:root[data-theme="dark"] .app-topbar {
    border-bottom-color: rgba(45, 66, 96, 0.8);
}

.topbar-primary {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.topbar-eyebrow {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.app-title {
    font-weight: 800;
    font-size: 1.3rem;
    letter-spacing: -0.03em;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topbar-chip {
    display: inline-flex;
    align-items: center;
    min-height: 2.4rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

.user-pill {
    min-height: 2.55rem;
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}

.user-menu-popover {
    top: calc(100% + 0.75rem);
    min-width: 260px;
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.app-content {
    padding: 1.6rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1.35rem;
}

.page-header-copy {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    max-width: 70rem;
}

.page-kicker,
.auth-eyebrow,
.auth-card-kicker,
.dashboard-card-kicker {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.page-header h1,
.login-card h1,
.auth-copy h1 {
    margin: 0.2rem 0 0.4rem;
    font-size: clamp(1.8rem, 2vw, 2.45rem);
    line-height: 1.05;
    letter-spacing: -0.045em;
}

.muted {
    color: var(--muted);
}

.panel,
.card,
.login-card,
.metric-card,
.modal {
    background: color-mix(in srgb, var(--surface) 92%, white 8%);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
}

.panel {
    padding: 1.15rem 1.2rem;
    margin-bottom: 1rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-title {
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.panel-subtitle {
    margin-top: 0.18rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.platform-specific-section {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.35rem;
}

.platform-specific-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 0.15rem;
}

.platform-specific-section .panel {
    margin-bottom: 0;
}

.card {
    padding: 1.1rem;
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-title {
    font-weight: 800;
    margin: 0.35rem 0;
    letter-spacing: -0.02em;
}

.card-body {
    color: var(--muted);
}

.dashboard-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric-card {
    padding: 1.1rem 1.15rem;
}

.metric-card-accent {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(59, 130, 246, 0.03) 68%), var(--surface);
}

.metric-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
}

.metric-value {
    margin-top: 0.55rem;
    font-size: clamp(1.5rem, 2vw, 2.1rem);
    font-weight: 800;
    letter-spacing: -0.05em;
}

.metric-note {
    margin-top: 0.45rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.action-compact-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.85rem;
    min-height: 0;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
}

.action-compact-card .card-title {
    margin-top: 0.35rem;
}

.action-compact-actions {
    margin-top: 0;
}

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

.dashboard-secondary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.dashboard-gauge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1rem;
    align-items: start;
}

.dashboard-home-panel {
    min-width: 0;
    overflow: hidden;
}

.dashboard-gauge-grid:has(.casino-tree-menu) {
    position: relative;
    z-index: 100;
}

.dashboard-home-panel:has(.casino-tree-menu),
.dashboard-ggr-layout:has(.casino-tree-menu),
.dashboard-ggr-control-rail:has(.casino-tree-menu) {
    position: relative;
    z-index: 100;
    overflow: visible;
}

.dashboard-home-panel .panel-header > div,
.dashboard-home-panel .dashboard-gauge-summary {
    min-width: 0;
}

.dashboard-home-panel .panel-subtitle,
.dashboard-home-panel .metric-note {
    overflow-wrap: anywhere;
}

.dashboard-widget-loading {
    min-height: 148px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.dashboard-metric-loading {
    margin-top: 0.8rem;
    min-height: 56px;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
}

.dashboard-widget-spinner {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(31, 59, 91, 0.14);
    border-top-color: var(--accent);
    animation: app-busy-spin 0.9s linear infinite;
    flex: 0 0 auto;
}

.dashboard-card {
    min-height: 164px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 25%, var(--border) 75%);
    box-shadow: var(--shadow-md);
}

.games-metrics {
    margin-top: -0.15rem;
}

/* Metric card colored left border variants */
.metric-card-bordered {
    border-left: 4px solid var(--border);
}

.metric-card-blue {
    border-left-color: #3b82f6;
}

.metric-card-purple {
    border-left-color: #8b5cf6;
}

.metric-card-green {
    border-left-color: #10b981;
}

.metric-card-orange {
    border-left-color: #f59e0b;
}

/* Gauge panel */
.dashboard-gauge-panel {
    min-width: 0;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), transparent 30%),
        linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
}

.dashboard-gauge-wrap {
    display: grid;
    grid-template-columns: minmax(110px, 140px) minmax(0, 1fr);
    gap: 1rem;
    align-items: center;
}

.dashboard-gauge-summary {
    min-width: 0;
}

.dashboard-gauge-value {
    font-size: clamp(1.6rem, 2.2vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    color: var(--text);
}

.dashboard-gauge-share {
    margin-top: 0.15rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--muted);
}

.dashboard-widget-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
    flex-wrap: wrap;
    min-width: 0;
}

.dashboard-ggr-layout {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 1rem;
    align-items: stretch;
}

.dashboard-ggr-control-rail {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding-right: 1rem;
    border-right: 1px solid var(--border);
}

.dashboard-ggr-control-rail .panel-subtitle {
    margin-top: 0.35rem;
    line-height: 1.35;
}

.dashboard-ggr-controls {
    width: 100%;
    justify-content: flex-start;
    align-items: stretch;
    flex-direction: column;
    gap: 0.5rem;
}

.dashboard-ggr-controls .toolbar-select,
.dashboard-ggr-controls .btn {
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
}

.dashboard-ggr-controls .input {
    min-height: 2.55rem;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
    border-radius: 12px;
    font-size: 0.9rem;
}

.dashboard-ggr-controls .btn {
    min-height: 2.5rem;
}

.dashboard-ggr-body {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dashboard-ggr-body .dashboard-widget-loading,
.dashboard-ggr-body .error,
.dashboard-ggr-body .dashboard-gauge-wrap {
    width: 100%;
}

.dashboard-ggr-panel .dashboard-gauge-wrap {
    grid-template-columns: minmax(100px, 128px) minmax(0, 1fr);
    gap: 1rem;
}

.dashboard-gauge-status {
    display: inline-flex;
    align-items: center;
    margin-top: 0.45rem;
    padding: 0.38rem 0.72rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.dashboard-gauge-status-good {
    background: rgba(5, 150, 105, 0.12);
    color: #047857;
}

.dashboard-gauge-status-warning {
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
}

.dashboard-gauge-status-danger {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.dashboard-gauge-status-muted {
    background: rgba(148, 163, 184, 0.14);
    color: #475569;
}

/* Circular donut gauge */
.dashboard-donut-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.dashboard-donut {
    width: 100%;
    max-width: 140px;
    height: auto;
    display: block;
}

.dashboard-donut-track {
    fill: none;
    stroke: rgba(148, 163, 184, 0.18);
    stroke-width: 10;
}

.dashboard-donut-fill {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s ease;
}

.dashboard-donut-good {
    stroke: #059669;
}

.dashboard-donut-warning {
    stroke: #d97706;
}

.dashboard-donut-danger {
    stroke: #dc2626;
}

.dashboard-donut-muted {
    stroke: rgba(148, 163, 184, 0.4);
}

.dashboard-donut-value {
    fill: var(--text);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.dashboard-donut-label {
    fill: var(--muted);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Charts grid */
.dashboard-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Bar chart */
.dashboard-bar-chart {
    width: 100%;
    height: auto;
    display: block;
}

.dashboard-bar {
    opacity: 0.85;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.dashboard-bar-positive {
    fill: var(--accent);
}

.dashboard-bar-negative {
    fill: #e16a6a;
}

.dashboard-bar:hover {
    opacity: 1;
}

.dashboard-bar-axis {
    stroke: color-mix(in srgb, var(--border) 82%, var(--text) 18%);
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.dashboard-bar-value {
    fill: var(--text);
    font-size: 0.58rem;
    font-weight: 700;
}

.dashboard-bar-label {
    fill: var(--muted);
    font-size: 0.62rem;
    font-weight: 600;
}

.dashboard-trend-summary {
    margin-top: 0.85rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    gap: 0.65rem;
}

.dashboard-trend-summary-item {
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
}

.dashboard-trend-summary-label {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-trend-summary-value {
    margin-top: 0.32rem;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 800;
    line-height: 1.2;
}

/* Pie/donut chart */
.dashboard-pie-wrap {
    display: grid;
    grid-template-columns: minmax(100px, 140px) minmax(0, 1fr);
    gap: 1rem;
    align-items: center;
}

.dashboard-pie-chart {
    width: 100%;
    max-width: 140px;
    height: auto;
    display: block;
}

.dashboard-pie-segment {
    fill: none;
    stroke-width: 10;
}

.dashboard-pie-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dashboard-pie-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
}

.dashboard-pie-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.dashboard-pie-legend-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 600;
}

.dashboard-pie-legend-pct {
    font-weight: 800;
    color: var(--muted);
    flex-shrink: 0;
}

/* Stat cards grid */
.dashboard-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.dashboard-stat-panel {
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
}

.dashboard-stat-header {
    margin-bottom: 0.35rem;
}

.dashboard-stat-value {
    font-size: clamp(1.5rem, 2vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text);
}

.dashboard-stat-trend {
    margin-top: 0.35rem;
    font-size: 0.82rem;
    font-weight: 700;
}

.dashboard-trend-up {
    color: #059669;
}

.dashboard-trend-down {
    color: #dc2626;
}

.dashboard-trend-muted {
    color: var(--muted);
}

/* Sparkline */
.dashboard-sparkline {
    width: 100%;
    max-width: 120px;
    height: 32px;
    margin-top: 0.55rem;
    display: block;
}

.dashboard-sparkline-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dashboard-sparkline-accent {
    stroke: #f59e0b;
}

.dashboard-sparkline-green {
    stroke: #10b981;
}

.dashboard-sparkline-purple {
    stroke: #8b5cf6;
}

/* Stat card layout with mini donut */
.dashboard-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.dashboard-mini-donut {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.dashboard-mini-donut .dashboard-donut-track {
    stroke-width: 6;
}

.dashboard-mini-donut .dashboard-donut-fill {
    stroke-width: 6;
}

/* Alert stat panel */
.dashboard-stat-alert {
    border-left: 4px solid #dc2626;
}

.dashboard-stat-value-danger {
    color: #dc2626;
}

:root[data-theme="dark"] .dashboard-stat-value-danger {
    color: #ff8a8a;
}

.utility-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.utility-card {
    padding: 1.1rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
}

.utility-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.utility-actions {
    margin-top: 0.9rem;
}

.filter-panel {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
    overflow: hidden;
}

.filter-panel:has(.casino-tree-menu) {
    position: relative;
    z-index: 80;
    overflow: visible;
}

.filter-panel summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.05rem;
}

.filter-panel summary::-webkit-details-marker {
    display: none;
}

.filter-panel-toggle {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.filter-panel-body {
    padding: 0 1.05rem 1.05rem;
    border-top: 1px solid var(--border);
}

.filter-actions {
    align-items: flex-end;
}

.config-filter-pairs {
    display: grid;
    gap: 0.9rem;
}

.config-filter-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.75rem;
}

.config-filter-button {
    min-width: 7.5rem;
}

.compact-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 2.75rem;
    padding: 0.55rem 0.8rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
}

.casino-scope-picker {
    max-width: 100%;
}

.casino-scope-controls {
    display: grid;
    grid-template-columns: minmax(12rem, 1fr) auto minmax(12rem, 1fr) auto auto;
    gap: 0.65rem;
    align-items: center;
}

.scope-selected-list {
    color: var(--muted);
    font-size: 0.88rem;
    overflow-wrap: anywhere;
}

.casino-tree-select {
    position: relative;
    width: min(100%, 42rem);
}

.casino-tree-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    width: 100%;
    min-height: 2.9rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
    box-sizing: border-box;
}

.casino-tree-trigger:hover:not(:disabled),
.casino-tree-trigger[aria-expanded="true"],
.casino-tree-trigger[aria-expanded="True"] {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border) 55%);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent 90%);
}

.casino-tree-trigger:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

.casino-tree-trigger span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.casino-tree-trigger-icon {
    color: var(--muted);
    flex: 0 0 auto;
}

.casino-tree-menu {
    position: absolute;
    z-index: 90;
    top: calc(100% + 0.45rem);
    left: 0;
    width: min(42rem, calc(100vw - 3rem));
    max-height: min(32rem, calc(100vh - 12rem));
    overflow: auto;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.casino-tree-section + .casino-tree-section,
.casino-tree-empty {
    margin-top: 0.75rem;
}

.casino-tree-section-title {
    margin: 0.15rem 0 0.45rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.casino-tree-node,
.casino-tree-branch-header {
    width: 100%;
    min-height: 2.25rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
    box-sizing: border-box;
}

.casino-tree-node {
    display: block;
}

.casino-tree-node:hover,
.casino-tree-branch-header:hover {
    background: var(--surface-soft);
    border-color: var(--border);
}

.casino-tree-node.is-selected {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border) 65%);
    background: color-mix(in srgb, var(--accent) 12%, transparent 88%);
    color: var(--accent-strong);
    font-weight: 750;
}

.casino-tree-node-root + .casino-tree-node-root,
.casino-tree-node-scope {
    margin-top: 0.3rem;
}

.casino-tree-branch {
    margin-top: 0.35rem;
}

.casino-tree-branch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.casino-tree-branch-toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    flex: 1 1 auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.casino-tree-branch-toggle::before {
    content: "▸";
    flex: 0 0 auto;
    color: var(--muted);
}

.casino-tree-branch.is-open > .casino-tree-branch-header > .casino-tree-branch-toggle::before {
    content: "▾";
}

.casino-tree-branch-toggle > span {
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
    color: var(--text);
}

.casino-tree-branch-nested {
    margin-left: 1rem;
}

.casino-tree-pick {
    flex: 0 0 auto;
    min-height: 1.8rem;
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.74rem;
    font-weight: 750;
    cursor: pointer;
}

.casino-tree-pick:hover {
    background: var(--surface-soft);
}

.casino-tree-pick.is-selected {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border) 55%);
    background: color-mix(in srgb, var(--accent) 14%, transparent 86%);
    color: var(--accent-strong);
}

.casino-tree-pick.is-partial {
    border-color: color-mix(in srgb, var(--warning, #f59e0b) 40%, var(--border) 60%);
    background: color-mix(in srgb, var(--warning, #f59e0b) 12%, transparent 88%);
}

.casino-tree-leaves {
    display: grid;
    gap: 0.25rem;
    margin: 0.25rem 0 0.35rem 2rem;
}

.casino-tree-node-casino {
    font-size: 0.86rem;
}

.casino-tree-empty {
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 0.88rem;
}

.dashboard-card .card-title {
    font-size: 1.05rem;
}

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

.form-grid-modal {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.form-row-wide {
    grid-column: 1 / -1;
}

.form-row label {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--muted);
}

.form-actions {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    flex-wrap: wrap;
}

.assignment-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.assignment-card {
    /* Grid items already stretch vertically via default align-items: stretch; an explicit
       min-height: 100% against an implicit parent height caused a layout feedback loop that
       grew the card on scroll inside collapsible panels. */
    align-self: stretch;
}

.assignment-chip-actions,
.assignment-actions {
    margin-top: 1rem;
}

.selection-summary {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.selection-summary-label {
    margin-bottom: 0.7rem;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.selection-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.selection-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 2.55rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 700;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.selection-chip:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border) 72%);
    background: var(--surface-soft);
    transform: translateY(-1px);
}

.selection-chip-remove {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.assignment-toggle-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
}

.toggle-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.05rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
    cursor: pointer;
}

.toggle-copy {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
}

.toggle-title {
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.toggle-description {
    color: var(--muted);
    font-size: 0.88rem;
}

.checkbox-input {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0.15rem 0 0;
    accent-color: var(--accent);
    flex: 0 0 auto;
}

.casino-inline-note {
    margin-top: 0.9rem;
}

.toolbar {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    flex-wrap: wrap;
}

.user-management-search {
    min-width: min(24rem, 100%);
    flex: 1 1 18rem;
}

.user-management-import-bar {
    margin-bottom: 0.75rem;
}

.user-management-inline-actions {
    margin-top: 0.55rem;
}

.table-sort-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.table-sort-button:hover {
    color: var(--accent-strong);
}

.user-management-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.7rem;
    padding: 0.6rem 0.9rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text);
}

.user-management-toggle input[type="checkbox"] {
    margin: 0;
    accent-color: var(--accent);
}

.user-management-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.selection-list {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.55rem;
    max-height: 20rem;
    overflow: auto;
    padding: 0.25rem;
}

.selection-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.7rem 0.8rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text);
}

.selection-item input[type="checkbox"] {
    margin-top: 0.15rem;
    accent-color: var(--accent);
}

.danger-text {
    color: var(--danger);
}

.user-management-grant-list {
    display: grid;
    gap: 0.85rem;
    margin-top: 1rem;
}

.user-management-grant-row {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 0.85rem;
    align-items: end;
    padding: 0.95rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
}

.user-management-grant-row .form-row {
    min-width: 0;
}

.user-management-grant-row-action {
    justify-content: end;
}

@media (max-width: 960px) {
    .user-management-grant-row {
        grid-template-columns: 1fr;
    }

    .user-management-grant-row-action {
        justify-content: stretch;
    }

    .user-management-grant-row-action .btn {
        width: 100%;
    }
}

.analytics-tab-strip {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.analytics-tab-strip .btn {
    min-width: max-content;
}

.analytics-toolbar {
    margin-top: 1rem;
}

.analytics-filter-summary {
    margin-top: 0.75rem;
    line-height: 1.55;
}

.analytics-insight-grid {
    margin-bottom: 1rem;
}

.analytics-insight-card {
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
}

.analytics-insight-card-accent {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(59, 130, 246, 0.03) 68%), var(--surface);
}

.analytics-summary-grid {
    margin-bottom: 1rem;
}

.analytics-summary-card {
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
}

.analytics-summary-value {
    margin-top: 0.55rem;
    font-size: clamp(1.2rem, 1.9vw, 1.8rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text);
    overflow-wrap: anywhere;
}

.analytics-ggr-drivers-panel {
    margin-bottom: 1rem;
}

.analytics-driver-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 1rem;
}

.analytics-driver-table {
    margin: 0;
}

@media (max-width: 1080px) {
    .analytics-driver-grid {
        grid-template-columns: 1fr;
    }
}

.table td.analytics-risk-cell {
    font-weight: 700;
    border-left: 3px solid transparent;
    box-shadow: inset 0 0 0 1px transparent;
}

.table td.analytics-risk-good {
    color: #166534;
    border-left-color: #16a34a;
    background: color-mix(in srgb, #16a34a 13%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #16a34a 18%, transparent);
}

.table td.analytics-risk-watch {
    color: #92400e;
    border-left-color: #f59e0b;
    background: color-mix(in srgb, #f59e0b 15%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #f59e0b 20%, transparent);
}

.table td.analytics-risk-danger {
    color: #991b1b;
    border-left-color: #dc2626;
    background: color-mix(in srgb, #dc2626 14%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #dc2626 20%, transparent);
}

[data-theme="dark"] .table td.analytics-risk-good,
.theme-dark .table td.analytics-risk-good {
    color: #86efac;
    background: color-mix(in srgb, #22c55e 18%, transparent);
}

[data-theme="dark"] .table td.analytics-risk-watch,
.theme-dark .table td.analytics-risk-watch {
    color: #fcd34d;
    background: color-mix(in srgb, #f59e0b 20%, transparent);
}

[data-theme="dark"] .table td.analytics-risk-danger,
.theme-dark .table td.analytics-risk-danger {
    color: #fca5a5;
    background: color-mix(in srgb, #ef4444 19%, transparent);
}

.analytics-inline-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.85rem 0 1rem;
}

.analytics-inline-filters .field {
    display: grid;
    gap: 0.35rem;
    min-width: 10rem;
}

.analytics-inline-filters .field span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.analytics-inline-filters .field select {
    width: 100%;
    min-height: 2.5rem;
    padding: 0.62rem 2.6rem 0.62rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    appearance: none;
    background-color: var(--surface);
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 3px),
        calc(100% - 12px) calc(50% - 3px);
    background-repeat: no-repeat;
    background-size: 6px 6px, 6px 6px;
    color: var(--text);
    box-shadow: none;
}

.analytics-inline-filters .field select:hover {
    border-color: var(--border-strong);
}

.analytics-inline-filters .field select:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border) 45%);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent 86%);
}

.analytics-insight-value {
    margin-top: 0.55rem;
    font-size: clamp(1.1rem, 1.9vw, 1.7rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    overflow-wrap: anywhere;
}

.analytics-feedback-block {
    margin-top: 0.75rem;
    white-space: pre-wrap;
}

.analytics-chart-note {
    margin-bottom: 0.5rem;
}

.analytics-chart-wrap {
    width: 100%;
    min-height: 300px;
    overflow: auto hidden;
}

.analytics-chart {
    width: 100%;
    min-width: 720px;
    height: 300px;
    display: block;
}

.analytics-chart-bar {
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.analytics-chart-bar:hover {
    opacity: 0.85;
}

/* Analytics widget charts */
.analytics-widget-chart {
    width: 100%;
    max-width: 460px;
    height: auto;
    display: block;
}

.analytics-widget-chart-wide {
    max-width: 100%;
}

.analytics-widget-bar {
    fill: var(--accent, #3b82f6);
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

.analytics-widget-bar:hover {
    opacity: 1;
}

.analytics-widget-bar-green {
    fill: #10b981;
}

.analytics-widget-bar-purple {
    fill: #8b5cf6;
}

.analytics-widget-label {
    fill: var(--muted, #6b7b93);
    font-size: 0.55rem;
    font-weight: 600;
}

.analytics-retention-dot {
    fill: var(--accent, #3b82f6);
}

.analytics-retention-value {
    fill: var(--text, #1e293b);
    font-size: 0.65rem;
    font-weight: 700;
}

.analytics-selected-point-card {
    margin-top: 1rem;
}

.analytics-selected-point-body {
    padding: 0;
}

.analytics-selected-point-actions {
    margin-top: 0.75rem;
}

.analytics-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.85rem;
}

.analytics-detail-item {
    padding: 0.9rem 1rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 14px;
    background: rgba(148, 163, 184, 0.08);
}

.analytics-detail-label {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.analytics-detail-value {
    margin-top: 0.35rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    overflow-wrap: anywhere;
}

.analytics-scope-grid {
    margin-top: 1rem;
}

.input {
    min-height: 2.9rem;
    padding: 0.7rem 0.9rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
    box-sizing: border-box;
    width: 100%;
}

.input:hover {
    border-color: var(--border-strong);
}

.input:focus,
input.input:focus,
select.input:focus,
textarea.input:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border) 45%);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent 86%);
}

textarea.input {
    min-height: 7rem;
    resize: vertical;
}

.gamification-modal-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    align-items: start;
}

.gamification-level-grid {
    grid-template-columns: minmax(220px, 1fr) minmax(320px, 1fr);
    align-items: start;
}

.gamification-wizard-step-switch {
    margin-bottom: 1rem;
}

.gamification-wizard-actions {
    margin-top: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.gamification-requirement-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    align-items: start;
}

.gamification-requirement-grid .form-row-wide {
    grid-column: 1 / -1;
}

.gamification-modal-grid .form-actions,
.gamification-level-grid .form-actions {
    align-items: center;
    flex-wrap: wrap;
}

.gamification-modal-grid input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
}

.gamification-widget-preview-layout {
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(240px, 1fr);
    gap: 1rem;
    align-items: stretch;
}

.gamification-widget-preview-stage {
    min-height: 520px;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, transparent 92%), transparent 46%),
        color-mix(in srgb, var(--panel-soft) 72%, var(--background) 28%);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

.gamification-widget-preview-shell {
    --widget-preview-accent: #7c3aed;
    --widget-preview-secondary: #554bff;
    --widget-preview-panel-bg: linear-gradient(180deg, #111827, #1f2937);
    --widget-preview-body-bg: rgba(31, 41, 55, 0.70);
    --widget-preview-card-bg: rgba(255, 255, 255, 0.12);
    --widget-preview-border: #7c3aed;
    --widget-preview-dock-bg: rgba(17, 24, 39, 0.76);
    --widget-preview-head-overlay: rgba(124, 58, 237, 0.20);
    --widget-preview-head-opacity: 0.72;
    width: min(360px, 100%);
    padding: 0.85rem;
    border: 1px solid var(--widget-preview-border);
    border-radius: 16px;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.22);
}

.gamification-widget-preview-shell.is-dark {
    color: #f8fafc;
    background:
        linear-gradient(180deg, transparent 0%, var(--widget-preview-body-bg) 100%),
        var(--widget-preview-panel-bg);
}

.gamification-widget-preview-shell.is-light {
    color: #1f2937;
    background:
        linear-gradient(180deg, transparent 0%, var(--widget-preview-body-bg) 100%),
        var(--widget-preview-panel-bg);
}

.gamification-widget-preview-header,
.gamification-widget-preview-tabs,
.gamification-widget-preview-store,
.gamification-widget-preview-balance {
    display: flex;
    align-items: center;
}

.gamification-widget-preview-header {
    position: relative;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.65rem;
    overflow: hidden;
    border-radius: 12px;
    background:
        linear-gradient(180deg, var(--widget-preview-head-overlay), transparent),
        color-mix(in srgb, var(--widget-preview-accent) 10%, transparent 90%);
}

.gamification-widget-preview-header::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: var(--widget-preview-head-opacity);
    pointer-events: none;
    background:
        radial-gradient(circle at 20% 18%, color-mix(in srgb, var(--widget-preview-secondary) 42%, transparent 58%), transparent 30%),
        radial-gradient(circle at 82% 12%, color-mix(in srgb, var(--widget-preview-accent) 36%, transparent 64%), transparent 28%);
}

.gamification-widget-preview-header > * {
    position: relative;
    z-index: 1;
}

.gamification-widget-preview-header span,
.gamification-widget-preview-card span,
.gamification-widget-preview-store span,
.gamification-widget-preview-summary span {
    font-size: 0.72rem;
    opacity: 0.72;
}

.gamification-widget-preview-header strong {
    display: block;
    font-size: 1rem;
    line-height: 1.1;
}

.gamification-widget-preview-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(180deg, var(--widget-preview-accent), var(--widget-preview-secondary));
    font-size: 1.15rem;
    line-height: 1;
}

.gamification-widget-preview-close:disabled {
    opacity: 0.38;
}

.gamification-widget-preview-balance {
    justify-content: space-between;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.75rem;
    border-radius: 999px;
    background: var(--widget-preview-dock-bg);
}

.gamification-widget-preview-tabs {
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.gamification-widget-preview-tabs button {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.45rem 0.35rem;
    border: 1px solid color-mix(in srgb, var(--widget-preview-accent) 28%, transparent 72%);
    border-radius: 999px;
    color: inherit;
    background: transparent;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gamification-widget-preview-tabs button.is-active {
    color: #fff;
    background: linear-gradient(180deg, var(--widget-preview-accent), var(--widget-preview-secondary));
}

.gamification-widget-preview-card,
.gamification-widget-preview-store > div,
.gamification-widget-preview-summary {
    border: 1px solid color-mix(in srgb, var(--widget-preview-border) 52%, transparent 48%);
    border-radius: 12px;
    background: var(--widget-preview-card-bg);
}

.gamification-widget-preview-card {
    padding: 0.85rem;
    margin-bottom: 0.75rem;
}

.gamification-widget-preview-card strong {
    display: block;
    margin: 0.2rem 0 0.65rem;
    font-size: 1rem;
}

.gamification-widget-preview-progress {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.28);
}

.gamification-widget-preview-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--widget-preview-accent), var(--widget-preview-secondary));
}

.gamification-widget-preview-card button {
    width: 100%;
    min-height: 34px;
    margin-top: 0.75rem;
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: linear-gradient(180deg, var(--widget-preview-accent), var(--widget-preview-secondary));
    font-weight: 800;
}

.gamification-widget-preview-store {
    gap: 0.55rem;
}

.gamification-widget-preview-store > div {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.7rem;
}

.gamification-widget-preview-store strong {
    display: block;
    color: var(--widget-preview-accent);
}

.gamification-widget-preview-summary {
    padding: 1rem;
    align-self: start;
    display: grid;
    gap: 0.8rem;
}

.gamification-widget-preview-summary div {
    display: grid;
    gap: 0.2rem;
}

.gamification-widget-preview-summary strong {
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.gamification-widget-menu-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.55rem;
}

.gamification-widget-menu-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 38px;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-soft);
    font-size: 0.88rem;
    font-weight: 700;
}

.gamification-widget-menu-option input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
}

.modal.gamification-reward-modal {
    width: min(1480px, calc(100vw - 2.5rem));
}

.gamification-reward-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.gamification-reward-card {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.gamification-reward-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.gamification-reward-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    align-items: start;
}

.gamification-reward-grid .form-row-wide {
    grid-column: 1 / -1;
}

.gamification-inline-scope-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 0.6rem;
    min-width: 520px;
}

.config-json-cell {
    max-width: 34rem;
}

.config-json-preview {
    display: block;
    max-width: 34rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
}

.config-editor-modal {
    width: min(1180px, 100%);
    max-height: min(92vh, 980px);
}

.config-json-form-row {
    grid-column: 1 / -1;
}

.json-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.55rem;
}

.json-status {
    margin-left: auto;
    font-size: 0.82rem;
    font-weight: 700;
}

.json-status.valid {
    color: var(--success);
}

.json-status.invalid {
    color: var(--danger);
}

.config-json-editor {
    min-height: 52vh;
    line-height: 1.5;
    tab-size: 2;
    white-space: pre;
    overflow: auto;
}

.config-json-form-row .CodeMirror {
    min-height: 52vh;
    height: 52vh;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.config-json-form-row .CodeMirror-gutters {
    border-right: 1px solid var(--border);
    background: var(--surface-muted);
}

.config-json-form-row .CodeMirror-linenumber {
    color: var(--muted);
}

.gamification-schema-builder {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.gamification-schema-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    align-items: end;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
}

.gamification-json-advanced {
    margin-top: 0.25rem;
}

.gamification-json-advanced .config-json-editor,
.gamification-json-advanced .CodeMirror {
    min-height: 240px;
    height: 240px;
}

.config-json-form-row .CodeMirror-cursor {
    border-left-color: var(--text);
}

.config-json-form-row .CodeMirror-selected {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.config-json-meta {
    min-height: 2.8rem;
    display: flex;
    align-items: center;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.9rem;
}

select.input,
.endpoint-switcher-select {
    appearance: none;
    padding-right: 2.8rem;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 3px),
        calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.page-size-select {
    width: auto;
    min-width: 5.25rem;
    flex: 0 0 5.25rem;
    padding-right: 2.2rem;
}

/* Narrow inline select for toolbars where labels and selects flow horizontally
   (history transactions toolbar, etc.). The default .input is 100% width which
   makes selects stack vertically inside a flex toolbar — this class auto-sizes
   them so they fit on one line. */
.toolbar-select {
    width: auto;
    min-width: 9rem;
    flex: 0 0 auto;
}

/* Platform-game-mappings modal form. Modal stretches comfortably wide for
   readability of game labels (Name — GameId — Alias is long), but full-width
   inputs at that width look like billboards. Cap field width and left-align so
   the form reads as a tidy column rather than a wall of stretched controls. */
.platform-mapping-form-row {
    max-width: 28rem;
}

.platform-mapping-form-row--inline {
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
}

.platform-mapping-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    user-select: none;
}

.platform-mapping-checkbox input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--accent);
}

.btn {
    min-height: 2.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, white 8%), var(--accent));
    color: #ffffff;
    border: 1px solid transparent;
    padding: 0.65rem 1rem;
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.18);
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px rgba(59, 130, 246, 0.22);
}

.btn.secondary,
.btn.ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    box-shadow: none;
}

.btn.secondary {
    color: var(--accent-strong);
    border-color: color-mix(in srgb, var(--accent) 20%, var(--border) 80%);
    background: color-mix(in srgb, var(--accent-weak) 40%, var(--surface) 60%);
}

.btn.ghost:hover:not(:disabled),
.btn.secondary:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border) 72%);
    background: var(--surface-soft);
    box-shadow: none;
}

.btn-inline,
.icon-btn {
    min-width: 2.7rem;
    padding-inline: 0.7rem;
}

.icon-btn {
    padding: 0.55rem 0.7rem;
}

.btn-sm {
    min-height: 2rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 10px;
}

.btn-icon {
    min-height: 2rem;
    min-width: 2rem;
    padding: 0.35rem;
    font-size: 0.85rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn.is-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
}

.visually-hidden-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.file-import-button {
    margin: 0;
    white-space: nowrap;
}

/* Panel header toolbar (right-aligned compact actions) */
.panel-header-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-shrink: 0;
}

/* Column settings side drawer */
.column-settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 16, 24, 0.35);
    z-index: 1200;
    backdrop-filter: blur(4px);
}

.column-settings-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 85vw);
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    z-index: 1201;
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.2s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.column-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.column-settings-actions {
    display: flex;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.column-settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.65rem 1.1rem;
}

.column-settings-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--text);
}

.column-settings-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    flex-shrink: 0;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
    overflow: hidden;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.table-sort-btn {
    background: transparent;
    border: 0;
    padding: 0;
    color: inherit;
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.table-sort-btn:hover {
    color: var(--text);
}

.table-sort-indicator {
    font-size: 0.7em;
    opacity: 0.7;
}

.table th,
.table td {
    text-align: left;
    padding: 0.9rem 0.8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table-toggle-cell {
    vertical-align: middle;
}

.table-actions {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    flex-wrap: wrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: 0.32rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-pill-positive {
    background: color-mix(in srgb, var(--success) 12%, var(--surface) 88%);
    border-color: color-mix(in srgb, var(--success) 32%, var(--border) 68%);
    color: #166534;
}

.status-pill-muted {
    background: color-mix(in srgb, var(--surface-muted) 70%, var(--surface) 30%);
    color: var(--muted);
}

.table tbody tr:hover td {
    background: color-mix(in srgb, var(--accent-weak) 35%, transparent 65%);
}

.table-wrap {
    width: 100%;
    overflow: auto;
}

.table-detail-row td {
    background: color-mix(in srgb, var(--surface-muted) 72%, var(--surface) 28%);
}

.room-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 1rem;
    align-items: start;
}

.room-detail-panel {
    min-width: 0;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.room-detail-title {
    margin-bottom: 0.6rem;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.compact-table {
    font-size: 0.82rem;
}

.compact-table th,
.compact-table td {
    padding: 0.4rem 0.45rem;
}

.login-shell {
    background:
        radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 20%, transparent) 0%, transparent 28%),
        radial-gradient(circle at bottom right, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 40%),
        var(--bg);
}

.auth-shell {
    width: min(1100px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 460px);
    gap: 1.4rem;
    align-items: stretch;
}

.auth-copy {
    padding: 2rem 1rem 2rem 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-copy p {
    max-width: 48ch;
    color: var(--muted);
    font-size: 1rem;
    margin: 0;
}

.auth-feature-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.9rem;
    margin-top: 1.3rem;
}

.auth-feature-card {
    padding: 1rem 1.05rem;
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface) 75%, transparent);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
    color: var(--text);
}

.auth-feature-card .muted {
    color: var(--muted);
}

.auth-feature-title {
    margin-bottom: 0.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.auth-card {
    padding: 1.6rem;
    align-self: center;
}

.auth-card-header {
    margin-bottom: 1rem;
}

.auth-actions {
    margin-top: 0.6rem;
}

.google-login-btn {
    width: 100%;
    min-height: 2.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border: 1px solid #dadce0;
    border-radius: 4px;
    background: #ffffff;
    color: #3c4043;
    cursor: pointer;
    font-family: "Roboto", "IBM Plex Sans", "Segoe UI", sans-serif;
    font-size: 0.92rem;
    font-weight: 500;
    letter-spacing: 0;
    box-shadow: none;
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.google-login-btn:hover:not(:disabled) {
    background: #f8fafd;
    border-color: #d2e3fc;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.18);
}

.google-login-btn:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

.google-login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.google-login-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

:root[data-theme="dark"] .google-login-btn {
    background: #ffffff;
    color: #3c4043;
    border-color: #dadce0;
}

.auth-card-footer {
    margin-top: 1rem;
    font-size: 0.84rem;
}

.auth-google-overlay {
    align-items: flex-start;
    padding-top: min(14vh, 6rem);
}

.auth-google-modal {
    width: min(440px, 100%);
}

.auth-google-modal .modal-body p {
    margin-top: 0;
}

.error {
    margin-top: 0.8rem;
    padding: 0.8rem 0.95rem;
    border-radius: 14px;
    background: color-mix(in srgb, var(--danger) 10%, var(--surface) 90%);
    border: 1px solid color-mix(in srgb, var(--danger) 20%, var(--border) 80%);
    color: var(--danger);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 16, 24, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 1.25rem;
    box-sizing: border-box;
    backdrop-filter: blur(8px);
}

.modal {
    width: min(1040px, 100%);
    max-height: min(88vh, 900px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
}

.modal-title {
    font-weight: 800;
    font-size: 1.08rem;
    letter-spacing: -0.02em;
}

.modal-body {
    padding: 1rem 1.2rem 1.2rem;
    overflow: auto;
    background: color-mix(in srgb, var(--surface) 95%, var(--surface-muted) 5%);
}

.endpoint-switcher-label,
.user-menu-label {
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.language-selector {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.language-selector-label {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.language-selector-input {
    min-width: 7.5rem;
    width: auto;
}

.user-menu-section .language-selector {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
}

.user-menu-section .language-selector-input,
.user-menu-select {
    width: 100%;
    min-width: 0;
}

.endpoint-pill {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

@media (max-width: 1200px) {
    .dashboard-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .dashboard-gauge-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    .login-shell {
        padding: 1.25rem;
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-copy {
        padding: 0;
    }

    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(86vw, 320px);
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-md);
    }

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

    .sidebar-close,
    .shell-nav-toggle {
        display: inline-flex !important;
    }

    .app-topbar {
        padding: 0.95rem 1rem;
    }

    .app-content {
        padding: 1rem;
    }

    .panel {
        padding: 1rem;
    }

    .panel-header,
    .page-header,
    .games-pagination-summary {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-grid,
    .assignment-layout,
    .assignment-toggle-grid,
    .dashboard-card-grid,
    .dashboard-secondary-grid,
    .grid,
    .games-grid,
    .dashboard-metrics {
        grid-template-columns: 1fr;
    }

    .casino-scope-controls {
        grid-template-columns: 1fr;
    }

    .casino-tree-select,
    .casino-tree-menu {
        width: 100%;
    }

    .form-actions,
    .toolbar,
    .games-pagination-actions,
    .analytics-tab-strip {
        width: 100%;
    }

    .filter-panel summary {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-actions .btn,
    .toolbar .btn,
    .games-pagination-actions .btn,
    .table-actions .btn {
        flex: 1 1 180px;
    }

    .config-filter-pair {
        grid-template-columns: 1fr;
    }

    .config-filter-button {
        width: 100%;
    }

    .modal {
        width: 100%;
        max-height: 100vh;
        height: auto;
        border-radius: 18px;
    }

    .modal-body {
        padding-bottom: 1.3rem;
    }

    .user-menu-popover {
        left: auto;
        right: 0;
        min-width: min(260px, calc(100vw - 2rem));
    }

    .dashboard-gauge-wrap {
        grid-template-columns: 1fr;
    }

    .dashboard-ggr-layout {
        grid-template-columns: 1fr;
    }

    .dashboard-ggr-control-rail {
        padding-right: 0;
        padding-bottom: 1rem;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .dashboard-donut {
        margin: 0 auto;
    }

    .dashboard-pie-wrap {
        grid-template-columns: 1fr;
    }

    .dashboard-pie-chart {
        margin: 0 auto;
    }

    .dashboard-stat-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .app-topbar {
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-chip {
        order: 2;
    }

    .user-menu {
        margin-left: auto;
    }

    .auth-card {
        padding: 1.25rem;
    }

    .metric-card,
    .card,
    .panel {
        border-radius: 18px;
    }

    .table {
        font-size: 0.86rem;
    }

    .analytics-tab-strip {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.2rem;
    }

    .analytics-tab-strip .btn {
        flex: 0 0 auto;
    }

    .analytics-chart {
        min-width: 880px;
    }

    .table th,
    .table td {
        padding: 0.75rem 0.65rem;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .responsive-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.9rem;
    }

    .responsive-table tr {
        border: 1px solid var(--border);
        border-radius: 18px;
        background: color-mix(in srgb, var(--surface) 94%, var(--surface-muted) 6%);
        box-shadow: var(--shadow-sm);
        overflow: hidden;
    }

    .responsive-table td {
        border-bottom: 1px solid var(--border);
        padding: 0.8rem 0.9rem;
    }

    .responsive-table td:last-child {
        border-bottom: none;
    }

    .responsive-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.35rem;
        font-size: 0.72rem;
        font-weight: 800;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--muted);
    }

    .responsive-table td[colspan]::before,
    .responsive-table td[data-label=""]::before {
        display: none;
    }

    .responsive-table .table-actions {
        width: 100%;
    }

    .responsive-table .table-actions .btn,
    .responsive-table .table-actions a.btn {
        flex: 1 1 140px;
    }

    .responsive-table .table-toggle-cell {
        padding-bottom: 0.6rem;
    }

    .responsive-table .table-toggle-cell::before {
        margin-bottom: 0.2rem;
    }

    .table-detail-row {
        margin-top: -0.35rem;
    }

.table-detail-row td {
    padding-top: 0.35rem;
}

.audit-log-value {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.45;
}

.audit-log-value-details {
    width: 100%;
}

.audit-log-value-details summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    list-style: none;
}

.audit-log-value-details summary::-webkit-details-marker {
    display: none;
}

.audit-log-value-details[open] summary {
    margin-bottom: 0.5rem;
}

/* RTL culture support. Keep this late in the file so it overrides the older
   physical left/right rules without broad CSS churn. */
:root[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

:root[dir="rtl"] .app-sidebar {
    border-right: 0;
    border-left: 1px solid var(--border);
}

:root[dir="rtl"] .app-topbar,
:root[dir="rtl"] .topbar-primary,
:root[dir="rtl"] .topbar-actions,
:root[dir="rtl"] .panel-header,
:root[dir="rtl"] .page-header,
:root[dir="rtl"] .form-actions,
:root[dir="rtl"] .toolbar,
:root[dir="rtl"] .table-actions,
:root[dir="rtl"] .dashboard-gauge-wrap,
:root[dir="rtl"] .dashboard-stat-row,
:root[dir="rtl"] .dashboard-pie-wrap,
:root[dir="rtl"] .language-selector {
    direction: rtl;
}

:root[dir="rtl"] .topbar-actions,
:root[dir="rtl"] .panel-header-actions {
    justify-content: flex-start;
}

:root[dir="rtl"] .user-menu-popover {
    right: auto;
    left: 0;
}

:root[dir="rtl"] .user-menu-action {
    justify-content: flex-start;
}

:root[dir="rtl"] .table th,
:root[dir="rtl"] .table td {
    text-align: right;
}

:root[dir="rtl"] .dashboard-ggr-control-rail {
    padding-right: 0;
    padding-left: 1rem;
    border-right: 0;
    border-left: 1px solid var(--border);
}

:root[dir="rtl"] .column-settings-drawer {
    right: auto;
    left: 0;
    border-left: 0;
    border-right: 1px solid var(--border);
    animation-name: slideInLeft;
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

:root[dir="rtl"] code,
:root[dir="rtl"] pre,
:root[dir="rtl"] input,
:root[dir="rtl"] textarea,
:root[dir="rtl"] .CodeMirror,
:root[dir="rtl"] .topbar-chip,
:root[dir="rtl"] .endpoint-pill,
:root[dir="rtl"] .metric-value,
:root[dir="rtl"] .dashboard-stat-value,
:root[dir="rtl"] .dashboard-gauge-value,
:root[dir="rtl"] .dashboard-trend-summary-value,
:root[dir="rtl"] .dashboard-pie-legend-pct,
:root[dir="rtl"] .amount,
:root[dir="rtl"] .audit-log-value {
    direction: ltr;
    unicode-bidi: isolate;
}

:root[dir="rtl"] select {
    direction: rtl;
}

@media (max-width: 960px) {
    :root[dir="rtl"] .app-sidebar {
        right: 0;
        left: auto;
        transform: translateX(100%);
    }

    :root[dir="rtl"] .app-sidebar.is-open {
        transform: translateX(0);
    }

    :root[dir="rtl"] .dashboard-ggr-control-rail {
        padding-left: 0;
        border-left: 0;
        border-bottom: 1px solid var(--border);
    }
}

.table-subvalue {
    margin-top: 0.2rem;
    font-size: 0.74rem;
    color: var(--muted);
    word-break: break-word;
}

.table-subvalue-selectable {
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

.toggle-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    margin: 4px 0;
    white-space: nowrap;
}

.toggle-line input {
    flex: 0 0 auto;
}

.analytics-inline-filters select.analytics-inline-select {
    width: 100%;
    min-width: 10rem;
    min-height: 2.5rem;
    padding: 0.62rem 2.6rem 0.62rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    appearance: none;
    background-color: var(--surface);
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 3px),
        calc(100% - 12px) calc(50% - 3px);
    background-repeat: no-repeat;
    background-size: 6px 6px, 6px 6px;
    color: var(--text);
    box-shadow: none;
}

.analytics-inline-filters select.analytics-inline-select:hover {
    border-color: var(--border-strong);
}

.analytics-inline-filters select.analytics-inline-select:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border) 45%);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent 86%);
}

.history-sticky-column {
    position: sticky;
    z-index: 3;
    background: var(--surface, #fff);
    box-shadow: 1px 0 0 var(--border);
}

thead .history-sticky-column {
    z-index: 4;
}

.history-empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--muted);
}

.history-empty-illustration {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 0.75rem;
    border: 2px solid var(--border);
    border-radius: 50%;
    position: relative;
}

.history-empty-illustration::after {
    content: "";
    position: absolute;
    width: 1.1rem;
    height: 2px;
    right: -0.55rem;
    bottom: 0.35rem;
    background: var(--border);
    transform: rotate(45deg);
}

.history-pagination {
    flex-wrap: wrap;
    gap: 0.4rem;
}

.history-pagination .is-active {
    border-color: var(--primary, var(--accent));
    color: var(--primary, var(--accent));
}

.history-page-input {
    width: 5rem;
}

.table-link {
    color: var(--primary, var(--accent));
    font-weight: 600;
    text-decoration: none;
}

.table-link:hover {
    text-decoration: underline;
}

.history-column-settings-drawer {
    width: min(34rem, 96vw);
}

.history-column-pin-zone,
.history-column-unpin-zone {
    margin: 0.75rem 1rem 0;
    padding: 0.7rem 0.9rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--muted);
    background: var(--surface-muted, rgba(0, 0, 0, 0.025));
}

.history-column-settings-list {
    gap: 0.5rem;
}

.history-column-settings-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.65rem;
    align-items: center;
}

.history-column-settings-item.is-pinned {
    border-color: var(--primary, var(--accent));
}

.history-column-drag {
    cursor: grab;
    color: var(--muted);
    user-select: none;
}

.history-column-pin-btn {
    white-space: nowrap;
}

.column-settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.history-details-grid,
.history-log-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
}

.history-details-grid-primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.history-detail-item,
.history-log-item {
    min-width: 0;
    display: grid;
    gap: 0.35rem;
    align-content: start;
    padding: 0.85rem 1rem;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.history-detail-item-wide,
.history-log-item-wide {
    grid-column: span 2;
}

.history-detail-label,
.history-log-key {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.history-detail-value,
.history-log-value {
    overflow-wrap: anywhere;
    font-weight: 600;
    line-height: 1.35;
}

.history-detail-item-code .history-detail-value,
.history-log-value,
.history-spin-log-table code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.88rem;
}

.history-log-section {
    margin-top: 1rem;
}

.history-log-section-title {
    margin-bottom: 0.55rem;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 700;
}

.account-status-dot {
    display: inline-block;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    margin-right: 0.4rem;
    background: var(--muted);
}

.account-status-dot.is-active {
    background: #148a42;
}

.account-status-dot.is-banned {
    background: #c83232;
}

.account-status-dot.is-unknown {
    background: #a0a0a0;
}

.history-logs-toggle {
    margin-bottom: 1rem;
}

.history-spin-log-table {
    min-width: 78rem;
}

.history-spin-log-table td {
    vertical-align: top;
}

.history-spin-log-table code {
    white-space: normal;
    overflow-wrap: anywhere;
}

.history-log-result {
    max-width: 36rem;
    max-height: 10rem;
    overflow: auto;
    margin: 0;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    background: var(--background);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.82rem;
}

@media (max-width: 720px) {
    .history-sticky-column {
        position: static;
        box-shadow: none;
    }

    .history-column-settings-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .history-column-pin-btn {
        grid-column: 2;
        justify-self: start;
    }

    .history-details-grid-primary,
    .history-details-grid,
    .history-log-grid {
        grid-template-columns: 1fr;
    }

    .history-detail-item-wide,
    .history-log-item-wide {
        grid-column: auto;
    }
}
