/* Theme variables are set per page from Admin > Settings (see includes/appearance.php). */
:root {
    --ct-primary: #14142b;
    --ct-primary-2: #1f1f3d;
    --ct-secondary: #5b2a86;
    --ct-accent: #c9a227;
    --ct-accent-hover: #b48f1c;
    --ct-on-accent: #1b1b1b;
    --ct-bg: #f4f3f8;
    --ct-tint: color-mix(in srgb, var(--ct-secondary) 6%, #fff);
    --ct-border: color-mix(in srgb, var(--ct-secondary) 12%, #fff);
    --ct-sidebar-text: color-mix(in srgb, #fff 80%, var(--ct-primary));
}

/* ---------- Text size (Settings) ---------- */
html.text-sm { font-size: 14px; }
html.text-md { font-size: 16px; }
html.text-lg { font-size: 17.5px; }
html.text-xl { font-size: 19px; }

body { background-color: var(--ct-bg); background-image: var(--ct-pattern-light, none); background-attachment: fixed; font-size: .95rem; }
a { color: var(--ct-secondary); }
.text-gold { color: var(--ct-accent) !important; }
.bg-gold { background: var(--ct-accent) !important; color: var(--ct-on-accent) !important; }
.btn-gold { background: var(--ct-accent); border-color: var(--ct-accent); color: var(--ct-on-accent); font-weight: 600; }
.btn-gold:hover, .btn-gold:focus, .btn-gold:active { background: var(--ct-accent-hover) !important; border-color: var(--ct-accent-hover) !important; color: var(--ct-on-accent) !important; }
.btn-gold:disabled { background: var(--ct-accent); border-color: var(--ct-accent); color: var(--ct-on-accent); opacity: .6; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--ct-secondary); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--ct-secondary) 25%, transparent); }
.form-check-input:checked { background-color: var(--ct-secondary); border-color: var(--ct-secondary); }

/* ---------- Login ---------- */
.login-body {
    min-height: 100vh;
    background: var(--ct-pattern-dark, none),
                radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--ct-secondary) 55%, transparent) 0, transparent 45%),
                radial-gradient(circle at 80% 80%, color-mix(in srgb, var(--ct-accent) 30%, transparent) 0, transparent 40%),
                var(--ct-primary);
    background-attachment: fixed;
    display: flex; align-items: center; justify-content: center;
}
/* Custom background photo (Settings): photo under a theme-colored overlay so text stays readable. */
/* Event photo layer (slideshow). The body must be transparent for the fixed layer behind it to show. */
body:has(> .ct-photo-bg) { background: transparent; }
html:has(body > .ct-photo-bg) { background: var(--ct-primary); }
.ct-photo-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.ct-photo-bg .ct-slide { position: absolute; inset: 0; background: center / cover no-repeat; opacity: 0; transition: opacity 1.6s ease; }
.ct-photo-bg .ct-slide.active { opacity: 1; }
.ct-photo-bg.public .ct-slide.active { animation: ct-slow-zoom 24s ease-out both; }
@keyframes ct-slow-zoom { from { transform: scale(1); } to { transform: scale(1.1); } }
.ct-photo-bg::after { content: ""; position: absolute; inset: 0; }
.ct-photo-bg.public::after {
    background: var(--ct-pattern-dark, none),
                linear-gradient(160deg, color-mix(in srgb, var(--ct-primary) 70%, transparent), color-mix(in srgb, var(--ct-secondary) 50%, transparent) 60%, color-mix(in srgb, var(--ct-primary) 80%, transparent));
}
.ct-photo-bg.work::after { background: var(--ct-pattern-light, none), color-mix(in srgb, var(--ct-bg) 86%, transparent); }
html:has(body > .ct-photo-bg.work) { background: var(--ct-bg); }
@media (prefers-reduced-motion: reduce) {
    .ct-photo-bg .ct-slide { transition: none; }
    .ct-photo-bg.public .ct-slide.active { animation: none; }
}
@media print { .ct-photo-bg { display: none; } }
.login-card { width: 100%; max-width: 440px; border: 0; border-radius: 1rem; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.login-card .card-header { background: var(--ct-pattern-dark, none), linear-gradient(135deg, var(--ct-primary-2), var(--ct-secondary)); color: #fff; text-align: center; padding: 2rem 1.5rem 1.5rem; border: 0; }
.login-card .card-header img { height: 64px; }
.login-card .brand-title { font-size: 1.9rem; font-weight: 800; letter-spacing: .15em; color: var(--ct-accent); }
.login-card .brand-tag { font-size: .78rem; opacity: .85; }

/* ---------- Admin layout ---------- */
.admin-wrap { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px; flex-shrink: 0; background: var(--ct-pattern-dark, none), var(--ct-primary); color: var(--ct-sidebar-text);
    position: sticky; top: 0; height: 100vh; overflow-y: auto; padding-bottom: 2rem;
}
.sidebar .brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand img { height: 38px; }
.sidebar .brand-name { color: var(--ct-accent); font-weight: 800; letter-spacing: .12em; }
.sidebar .brand-sub { font-size: .75rem; opacity: .7; }
.sidebar .nav-link { color: var(--ct-sidebar-text); display: flex; align-items: center; gap: .65rem; padding: .5rem 1.25rem; font-size: .9rem; border-left: 3px solid transparent; }
.sidebar .nav-link.sub { padding-left: 1.9rem; font-size: .86rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: color-mix(in srgb, var(--ct-accent) 16%, transparent); color: var(--ct-accent); border-left-color: var(--ct-accent); }
.sidebar .nav-group { text-transform: uppercase; font-size: .7rem; letter-spacing: .12em; opacity: .55; padding: 1rem 1.25rem .3rem; }
.sidebar { display: flex; flex-direction: column; padding-bottom: 0; }
.side-nav { flex: 1; padding-bottom: 1rem; }
.side-nav .nav-text { flex: 1; min-width: 0; }
.side-nav .nav-group {
    display: flex; align-items: center; width: 100%; background: none; border: 0; color: inherit; text-align: left;
    padding: .9rem 1.25rem .3rem; font-weight: 600; cursor: pointer;
}
.side-nav .nav-group:hover { opacity: .9; }
.side-nav .nav-group i { margin-left: auto; font-size: .7rem; transition: transform .15s; }
.side-nav .nav-section.collapsed .nav-group i { transform: rotate(-90deg); }
.side-nav .nav-section.collapsed .nav-items { display: none; }
.side-nav .nav-section.has-active .nav-group { opacity: .85; color: var(--ct-accent); }
.side-nav .nav-items .nav-link { padding-left: 1.6rem; font-size: .87rem; }
.nav-badge { font-size: .68rem; font-weight: 700; line-height: 1; padding: .28rem .45rem; border-radius: 1rem; background: rgba(255,255,255,.15); color: #fff; }
.nav-badge.live { background: #198754; animation: live-pulse 2s infinite; }
.nav-badge.warn { background: #ffc107; color: #3d2f00; }
.nav-badge.ok { background: #198754; }
.nav-badge.info { background: rgba(255,255,255,.18); }
.round-dot { width: .5rem; height: .5rem; border-radius: 50%; background: rgba(255,255,255,.25); flex-shrink: 0; }
.round-dot.is-open { background: #2ecc71; box-shadow: 0 0 0 3px rgba(46,204,113,.25); }
.round-dot.is-closed { background: #f0ad4e; }
.round-dot.is-done { background: rgba(255,255,255,.6); }
.side-footer { position: sticky; bottom: 0; background: var(--ct-primary); border-top: 1px solid rgba(255,255,255,.08); padding: .35rem 0; }
.side-user { display: flex; align-items: center; gap: .6rem; padding: .35rem 1.25rem; font-size: .8rem; opacity: .7; }
.side-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }

/* Event Day status bar (below the topbar) */
.event-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.1rem; padding: .5rem 1.5rem; font-size: .88rem;
    border-bottom: 1px solid var(--ct-border); background: #fafafc;
}
.event-bar.live { background: color-mix(in srgb, #198754 7%, #fff); border-bottom-color: color-mix(in srgb, #198754 25%, #fff); }
.event-bar.idle { color: #6c6c85; padding-top: .35rem; padding-bottom: .35rem; }
.event-bar > i { font-size: 1.05rem; }
.live-pill { display: inline-flex; align-items: center; gap: .35rem; background: #198754; color: #fff; font-weight: 700; font-size: .7rem; letter-spacing: .08em; padding: .2rem .55rem; border-radius: 1rem; }
.live-dot { width: .45rem; height: .45rem; border-radius: 50%; background: #fff; animation: live-pulse 1.4s infinite; }
.event-stat { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.event-progress { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: rgba(0,0,0,.1); overflow: hidden; }
.event-progress > span { display: block; height: 100%; background: #198754; }
.event-links { display: inline-flex; gap: .35rem; }

/* Page header: breadcrumb, title, description, actions */
.page-head { margin-bottom: 1.25rem; }
.page-crumbs { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: #8a8aa3; margin-bottom: .3rem; }
.page-crumbs a { color: inherit; text-decoration: none; }
.page-crumbs a:hover { color: var(--ct-secondary); }
.page-crumbs .bi-chevron-right { font-size: .6rem; opacity: .7; }
.page-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }
.page-head-text { min-width: 0; flex: 1; }
.page-title { font-size: 1.45rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: .55rem; }
.page-title > i { color: var(--ct-secondary); font-size: 1.25rem; }
.page-desc { color: #6c6c85; font-size: .88rem; margin-top: .15rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 767.98px) {
    .event-bar { padding: .45rem .85rem; gap: .4rem .8rem; }
    .event-links .btn span { display: none; }
    .page-title { font-size: 1.2rem; }
    .page-desc { font-size: .8rem; }
}
.layout-mobile .event-bar { padding: .45rem .85rem; }
.layout-mobile .event-links .btn span { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; background: #fff; padding: .85rem 1.5rem; border-bottom: 1px solid var(--ct-border); position: sticky; top: 0; z-index: 10; border-top: 3px solid var(--ct-accent); }
.content { padding: 1.5rem; flex: 1; }
.footer-note { font-size: .75rem; color: #8a8aa3; text-align: center; padding: 1rem; }
.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }

/* Sidebar becomes a slide-in drawer: below 992px (auto), 1200px (tablet), always (mobile) */
@media (max-width: 991.98px) {
    html:not(.layout-pc) .sidebar { position: fixed; left: -280px; z-index: 1050; transition: left .2s; }
    html:not(.layout-pc) .sidebar.show { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.5); }
    html:not(.layout-pc) .sidebar-toggle { display: inline-block; }
}
@media (max-width: 1199.98px) {
    .layout-tablet .sidebar { position: fixed; left: -280px; z-index: 1050; transition: left .2s; }
    .layout-tablet .sidebar.show { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.5); }
    .layout-tablet .sidebar-toggle { display: inline-block; }
}
.layout-mobile .sidebar { position: fixed; left: -280px; z-index: 1050; transition: left .2s; }
.layout-mobile .sidebar.show { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.5); }
.layout-mobile .sidebar-toggle { display: inline-block; }
body:has(.sidebar.show) .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1040; }

.card { border: 0; border-radius: .8rem; box-shadow: 0 1px 3px rgba(20,20,43,.08); }
.card-header { background: #fff; border-bottom: 1px solid var(--ct-border); font-weight: 600; }
.stat-card { padding: 1.1rem 1.25rem; display: flex; flex-direction: row; align-items: center; gap: 1rem; }
.stat-card .icon { width: 48px; height: 48px; border-radius: .7rem; display: grid; place-items: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-card .label { font-size: .8rem; color: #6c6c85; text-transform: uppercase; letter-spacing: .05em; }
.status-badge { font-size: .75rem; letter-spacing: .05em; }

.table thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: #6c6c85; background: var(--ct-tint); white-space: nowrap; }
.table td { vertical-align: middle; }
.rank-pill { display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; border-radius: 1rem; font-weight: 700; background: #eeecf5; }
.rank-1 { background: var(--ct-accent); color: var(--ct-on-accent); }
.rank-2 { background: #c0c0c8; }
.rank-3 { background: #cd8f5a; color: #fff; }
.row-tie { background: #fff3cd !important; }
.row-eliminated td { opacity: .55; }

.avatar-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #e9e7f2; border: 2px solid rgba(255,255,255,.6); }
.avatar-md { width: 48px; height: 48px; border-radius: .5rem; object-fit: cover; background: #e9e7f2; }

/* ---------- Candidate / judge cards ---------- */
.profile-card { border-radius: .9rem; overflow: hidden; text-align: center; background: #fff; box-shadow: 0 2px 8px rgba(20,20,43,.08); height: 100%; }
.profile-card .photo { aspect-ratio: 3/4; background: linear-gradient(180deg, #ecebf4, #d9d6ea); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.profile-card .photo img { width: 100%; height: 100%; object-fit: cover; }
.profile-card .body { padding: .75rem; border-top: 3px solid var(--ct-accent); }
.profile-card .num { font-weight: 800; letter-spacing: .08em; color: var(--ct-secondary); font-size: .85rem; }
.profile-card .name { font-weight: 700; }
.profile-card .rep { font-size: .85rem; color: #6c6c85; }
.profile-card.judge .photo { aspect-ratio: 1/1; }

/* ---------- Judge UI ---------- */
.judge-nav { background: var(--ct-pattern-dark, none), linear-gradient(90deg, var(--ct-primary), var(--ct-secondary)); color: #fff; border-bottom: 3px solid var(--ct-accent); }
.judge-nav .navbar-brand { color: var(--ct-accent); font-weight: 800; letter-spacing: .12em; }
.round-banner { border-radius: 1rem; padding: 1.25rem 1.5rem; color: #fff; background: linear-gradient(135deg, #1d6b45, #2f9e6a); }
.round-banner.closed { background: linear-gradient(135deg, #5c5c70, #7d7d93); }
.round-banner.submitted { background: linear-gradient(135deg, var(--ct-primary-2), var(--ct-secondary)); }
.round-tile { border-radius: .9rem; padding: 1rem 1.25rem; background: #fff; box-shadow: 0 1px 3px rgba(20,20,43,.08); height: 100%; }
.round-tile.is-open { outline: 3px solid #2f9e6a; }

.score-photo { width: 100%; max-width: 320px; aspect-ratio: 3/4; object-fit: cover; border-radius: 1rem; background: linear-gradient(180deg, #ecebf4, #d9d6ea); box-shadow: 0 6px 20px rgba(20,20,43,.15); }
.score-input { font-size: 1.35rem; font-weight: 700; text-align: center; max-width: 140px; }
.score-input.is-invalid { background-image: none; padding-right: .75rem; }
.score-col { width: 180px; }
.table:has(.score-slider) .score-col { width: 300px; }
.score-slider-wrap { max-width: 280px; margin: .5rem auto 0; }
.score-slider { height: 1.6rem; }
.score-slider::-webkit-slider-thumb { background: var(--ct-accent); width: 1.4rem; height: 1.4rem; margin-top: -.45rem; }
.score-slider::-moz-range-thumb { background: var(--ct-accent); width: 1.4rem; height: 1.4rem; }
.score-slider::-webkit-slider-runnable-track { background: color-mix(in srgb, var(--ct-secondary) 18%, #fff); }
.score-slider::-moz-range-track { background: color-mix(in srgb, var(--ct-secondary) 18%, #fff); }
.score-slider.is-empty::-webkit-slider-thumb { background: #b9b9c6; }
.score-slider.is-empty::-moz-range-thumb { background: #b9b9c6; }
.touch .score-slider { height: 2.4rem; }
.touch .score-slider::-webkit-slider-thumb { width: 2rem; height: 2rem; margin-top: -.75rem; }
.touch .score-slider::-moz-range-thumb { width: 2rem; height: 2rem; }
.score-total { font-size: 2.4rem; font-weight: 800; color: var(--ct-secondary); }
.cand-strip { display: flex; flex-wrap: wrap; gap: .4rem; }
.cand-strip .btn { min-width: 3rem; font-weight: 700; }
.cand-strip .btn.current { outline: 3px solid var(--ct-accent); outline-offset: 1px; }

/* ---------- Eligibility matrix ---------- */
.elig-toggle { width: 2.2rem; height: 2.2rem; padding: 0; border-radius: .5rem; font-size: 1.1rem; }

/* ---------- Theme picker (Settings) ---------- */
.theme-option { cursor: pointer; border-radius: .8rem; border: 2px solid transparent; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow: hidden; height: 100%; display: block; }
.theme-option:hover { transform: translateY(-2px); transition: transform .15s; }
.btn-check:checked + .theme-option { border-color: var(--ct-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ct-accent) 35%, transparent); }
.theme-swatch { height: 54px; display: flex; }
.theme-swatch span { flex: 1; }
.theme-swatch .swatch-main { flex: 2.5; }
.pattern-option { cursor: pointer; border: 2px solid var(--ct-border); border-radius: .8rem; padding: .4rem; height: 100%; display: flex; flex-direction: column; gap: .35rem; background: #fff; text-align: center; }
.btn-check:checked + .pattern-option { border-color: var(--ct-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ct-accent) 35%, transparent); }
.pattern-swatch { display: block; height: 56px; border-radius: .5rem; }
/* Settings page: section tabs + sticky save bar */
.settings-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.settings-nav { position: sticky; top: 90px; flex-direction: column; flex-wrap: nowrap; gap: .25rem; background: #fff; border-radius: .8rem; padding: .5rem; box-shadow: 0 1px 3px rgba(20,20,43,.08); }
.settings-nav .nav-link { display: flex; align-items: center; gap: .7rem; text-align: left; color: #3b3b52; border-radius: .6rem; padding: .6rem .75rem; position: relative; }
.settings-nav .nav-link > i { font-size: 1.15rem; width: 1.4rem; text-align: center; color: var(--ct-secondary); }
.settings-nav .nav-link:hover { background: var(--ct-tint); }
.settings-nav .nav-link.active { background: var(--ct-primary); color: #fff; }
.settings-nav .nav-link.active > i { color: var(--ct-accent); }
.settings-nav .nav-link.danger { color: #b02a37; margin-top: .35rem; border-top: 1px solid var(--ct-border); border-radius: 0 0 .6rem .6rem; }
.settings-nav .nav-link.danger > i { color: #dc3545; }
.settings-nav .nav-link.danger.active { background: #b02a37; color: #fff; }
.settings-nav .nav-link.danger.active > i { color: #fff; }
.settings-nav .nav-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.settings-nav .nav-title { font-weight: 600; font-size: .9rem; }
.settings-nav .nav-sub { font-size: .72rem; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-nav .dirty-dot { display: none; width: .5rem; height: .5rem; border-radius: 50%; background: #fd7e14; margin-left: auto; flex-shrink: 0; }
.settings-nav .nav-link.is-dirty .dirty-dot { display: block; }
.settings-head { margin-bottom: 1rem; }
.settings-head h2 { font-weight: 700; }
.settings-savebar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; background: rgba(255,255,255,.96); backdrop-filter: blur(4px);
    border: 1px solid var(--ct-border); border-radius: .8rem; padding: .65rem .9rem; margin-bottom: 1rem; box-shadow: 0 -4px 16px rgba(20,20,43,.06); }
.settings-savebar .dirty-note { display: none; font-size: .82rem; color: #b35900; }
.settings-savebar button[type=reset] { display: none; }
.settings-form.is-dirty .settings-savebar { border-color: #fd7e14; }
.settings-form.is-dirty .settings-savebar .dirty-note, .settings-form.is-dirty .settings-savebar button[type=reset] { display: inline-block; }
.settings-savebar .btn-gold { margin-left: auto; }
.settings-form.is-dirty .settings-savebar .btn-gold { margin-left: 0; }
.settings-link-card:hover { box-shadow: 0 4px 14px rgba(20,20,43,.12); }
@media (max-width: 991.98px) {
    .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
    .settings-nav { top: 70px; z-index: 6; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
    .settings-nav::-webkit-scrollbar { display: none; }
    .settings-nav .nav-link { flex-shrink: 0; padding: .5rem .7rem; }
    .settings-nav .nav-sub { display: none; }
    .settings-nav .nav-link.danger { margin-top: 0; border-top: 0; border-radius: .6rem; }
    .settings-nav .dirty-dot { position: absolute; top: .35rem; right: .35rem; }
}
.event-photo { border: 1px solid var(--ct-border); border-radius: .6rem; overflow: hidden; background: #fff; }
.event-photo:has(input[type=checkbox]:checked) { opacity: .45; outline: 2px solid #dc3545; }
.event-photo:has(input[type=radio]:checked) { border-color: var(--ct-accent); box-shadow: 0 0 0 2px var(--ct-accent); }
.event-photo-img { aspect-ratio: 16 / 10; background: var(--ct-tint) center / cover no-repeat; position: relative; }
.event-photo-img .badge { position: absolute; top: .35rem; left: .35rem; }
.event-photo-actions { display: flex; justify-content: space-between; gap: .25rem; padding: .3rem .5rem; }
.event-upload-preview { display: flex; flex-wrap: wrap; gap: .4rem; }
.event-upload-preview span { width: 84px; height: 52px; border-radius: .4rem; background: center / cover no-repeat; border: 1px solid var(--ct-border); }
.theme-option .info { padding: .5rem .65rem; }
.theme-option .name { font-weight: 700; font-size: .9rem; }
.theme-option .desc { font-size: .75rem; color: #6c6c85; }
.layout-option { cursor: pointer; border: 2px solid var(--ct-border); border-radius: .8rem; padding: .75rem; height: 100%; display: block; background: #fff; }
.btn-check:checked + .layout-option { border-color: var(--ct-secondary); background: var(--ct-tint); }
.layout-option i { font-size: 1.6rem; color: var(--ct-secondary); }

/* ---------- Touch devices (tablet / mobile modes, or Auto on touchscreens) ---------- */
.touch .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; }
.touch .btn-sm { min-height: 38px; }
.touch .btn-lg { min-height: 54px; }
.touch .form-control, .touch .form-select { min-height: 46px; font-size: 1rem; }
.touch .form-check-input { width: 1.35em; height: 1.35em; }
.touch .form-switch .form-check-input { width: 2.6em; }
.touch .score-input { font-size: 1.7rem; min-height: 62px; max-width: 170px; }
.touch .cand-strip .btn { min-width: 3.4rem; min-height: 48px; font-size: 1.05rem; }
.touch .sidebar .nav-link { padding-top: .75rem; padding-bottom: .75rem; }
.touch .elig-toggle { width: 2.9rem; height: 2.9rem; }
.touch .page-link { min-width: 40px; min-height: 40px; display: grid; place-items: center; }

/* ---------- Tablet mode ---------- */
.layout-tablet .content { padding: 1.25rem; }
.layout-tablet .score-photo { max-width: 280px; }

/* ---------- Phone: forced Mobile mode, or Auto on small screens ---------- */
.layout-mobile .content { padding: .85rem; }
.layout-mobile .topbar { padding: .6rem .85rem; }
.layout-mobile .stat-card { padding: .8rem; gap: .65rem; }
.layout-mobile .stat-card .value { font-size: 1.1rem; }
.stat-card > div:last-child { min-width: 0; }
.stat-card .value { overflow-wrap: anywhere; }
.layout-mobile .stat-card .icon { width: 38px; height: 38px; font-size: 1.1rem; }
.layout-mobile .score-layout > * { flex: 0 0 100%; max-width: 100%; }
.layout-mobile .row > [class*="col-md-"], .layout-mobile .row > [class*="col-lg-"], .layout-mobile .row > [class*="col-xl-"] { flex: 0 0 100%; max-width: 100%; }
.layout-mobile .row > .col-6 { flex: 0 0 50%; max-width: 50%; }
.layout-mobile .cat-col { display: none; }
.layout-mobile .container-xl { padding-left: .75rem; padding-right: .75rem; }
.layout-mobile .round-banner { padding: 1rem; }
.layout-mobile .round-banner .fs-3 { font-size: 1.25rem !important; }

.layout-mobile .score-photo, .layout-mobile .score-profile .score-photo { max-width: 170px; }
.layout-mobile .cand-strip { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .25rem; -webkit-overflow-scrolling: touch; }
.layout-mobile .cand-strip .btn { flex-shrink: 0; }
.layout-mobile .score-actions { position: sticky; bottom: 0; z-index: 20; background: #fff; margin: 0 -.75rem; padding: .65rem .75rem; box-shadow: 0 -4px 12px rgba(0,0,0,.12); flex-wrap: nowrap !important; }
.layout-mobile .score-actions .btn { flex: 1; padding-left: .4rem; padding-right: .4rem; font-size: 1rem; }
.layout-mobile .score-actions .btn-label-long { display: none; }
.layout-mobile .card-footer .btn-lg { width: 100%; }

@media (max-width: 767.98px) {
    .layout-auto .content { padding: .85rem; }
    .layout-auto .topbar { padding: .6rem .85rem; }
    .layout-auto .score-photo { max-width: 170px; }
    .layout-auto .cand-strip { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .25rem; }
    .layout-auto .cand-strip .btn { flex-shrink: 0; }
    .layout-auto .score-actions { position: sticky; bottom: 0; z-index: 20; background: #fff; margin: 0 -.75rem; padding: .65rem .75rem; box-shadow: 0 -4px 12px rgba(0,0,0,.12); flex-wrap: nowrap !important; }
    .layout-auto .score-actions .btn { flex: 1; padding-left: .4rem; padding-right: .4rem; font-size: 1rem; }
    .layout-auto .score-actions .btn-label-long { display: none; }
    .layout-auto .card-footer .btn-lg { width: 100%; }
    .layout-auto .round-banner .fs-3 { font-size: 1.25rem !important; }
}
@media (max-width: 575.98px) {
    .layout-auto .cat-col { display: none; }
    .layout-auto .stat-card { padding: .8rem; gap: .65rem; }
    .layout-auto .stat-card .value { font-size: 1.1rem; }
    .layout-auto .stat-card .icon { width: 38px; height: 38px; font-size: 1.1rem; }
}

/* ---------- PC mode: compact ---------- */
.layout-pc .content { padding: 1.5rem 2rem; }

/* ---------- Print / reports ---------- */
.report-page { background: #fff; max-width: 1000px; margin: 0 auto; padding: 2rem 2.5rem; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.report-head { text-align: center; border-bottom: 3px double var(--ct-accent); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.report-head h1 { font-size: 1.5rem; font-weight: 800; margin: .3rem 0; }
.report-head h2 { font-size: 1.1rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ct-secondary); }
.report-table th, .report-table td { border: 1px solid #bbb !important; padding: .35rem .5rem !important; font-size: .88rem; }
.report-table thead th { background: var(--ct-tint) !important; color: #222; }
.signatures { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2.5rem 2rem; margin-top: 3.5rem; }
.signatures .sig { border-top: 1px solid #333; text-align: center; padding-top: .3rem; font-size: .85rem; }
.winner-block { text-align: center; margin: 1.2rem 0; }
.winner-block .title { font-size: 1.1rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ct-secondary); font-weight: 700; }
.winner-block .who { font-size: 1.4rem; font-weight: 800; }
@media (max-width: 767.98px) {
    .report-page { padding: 1rem; }
}

/* ---------- Analytics ---------- */
.bg-gold-subtle { background: var(--ct-tint); color: var(--ct-secondary); }
.min-w-0 { min-width: 0; }
.ct-bar { position: relative; height: .7rem; border-radius: 1rem; background: #ecebf2; overflow: hidden; }
.ct-bar-fill { height: 100%; border-radius: 1rem; background: linear-gradient(90deg, var(--ct-secondary), var(--ct-accent)); transition: width .6s ease; }
.ct-bar:has(.ct-bar-text) { height: 1.15rem; }
.ct-bar-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding-right: .5rem; font-size: .72rem; font-weight: 700; color: #333; }
.ranking-bars { display: flex; flex-direction: column; gap: .55rem; }
.rank-row { display: flex; align-items: center; gap: .75rem; padding: .45rem .6rem; border-radius: .6rem; background: #fff; border: 1px solid #eee; }
.rank-row.rank-top { border-color: color-mix(in srgb, var(--ct-accent) 45%, #fff); background: color-mix(in srgb, var(--ct-accent) 7%, #fff); }
.rank-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.rank-score { font-size: 1.15rem; font-weight: 800; min-width: 4.2rem; text-align: right; color: var(--ct-secondary); }
.rank-cutoff { display: flex; align-items: center; gap: .5rem; color: #c0392b; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.rank-cutoff::before, .rank-cutoff::after { content: ""; flex: 1; border-top: 2px dashed currentColor; }
.histogram { display: flex; align-items: flex-end; gap: .35rem; height: 190px; padding-top: 1.2rem; }
.histo-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.histo-bar { width: 100%; min-height: 2px; border-radius: .35rem .35rem 0 0; background: linear-gradient(180deg, var(--ct-accent), var(--ct-secondary)); }
.histo-count { font-size: .75rem; font-weight: 700; }
.histo-label { font-size: .7rem; color: #888; margin-top: .2rem; }
.heatmap td, .heatmap th { white-space: nowrap; }
.cat-card .avatar-md { width: 42px; height: 42px; }

/* ---------- Audience live feed ---------- */
.live-body { background: var(--ct-pattern-dark, none), linear-gradient(160deg, var(--ct-primary), var(--ct-primary-2) 45%, var(--ct-secondary)); background-attachment: fixed; min-height: 100vh; color: #fff; }
.live-header { display: flex; align-items: center; gap: .9rem; padding: 1rem clamp(1rem, 4vw, 2.5rem); }
.live-header img { width: 46px; height: 46px; }
.live-title { font-size: clamp(1.15rem, 3vw, 1.7rem); font-weight: 800; letter-spacing: .02em; }
.live-main { max-width: 1200px; margin: 0 auto; padding: 0 clamp(.75rem, 3vw, 2rem) 2rem; }
.live-main .card, .live-card { background: #fff; color: #222; border: 0; border-radius: 1rem; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.live-card { padding: clamp(.9rem, 2vw, 1.5rem); }
.live-tabs { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: 1rem; padding-bottom: .2rem; }
.live-tabs a { flex-shrink: 0; color: #fff; text-decoration: none; padding: .45rem 1rem; border-radius: 2rem; background: rgba(255,255,255,.12); font-weight: 600; display: inline-flex; align-items: center; gap: .4rem; }
.live-tabs a.active { background: var(--ct-accent); color: var(--ct-on-accent); }
.live-dot { width: .55rem; height: .55rem; border-radius: 50%; background: #ff3b3b; display: inline-block; animation: livePulse 1.2s infinite; }
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.live-badge { display: inline-flex; align-items: center; gap: .35rem; }
.live-badge .live-dot { background: #fff; }
.live-round-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; }
.live-round-head h2 { font-size: clamp(1.5rem, 4vw, 2.4rem); font-weight: 800; margin: 0 0 .25rem; }
.live-progress { margin-left: auto; min-width: 180px; text-align: right; }
.live-progress .ct-bar { background: rgba(255,255,255,.2); }
.live-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.live-kpis > div { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: .8rem; padding: .7rem 1rem; }
.live-kpis span { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.live-kpis b { font-size: 1.5rem; }
.live-section { font-size: 1.05rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .9rem; }
.live-card .live-section { color: var(--ct-secondary); }
.live-body > .live-main > .live-section { color: #fff; }
.live-podium { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.podium-item { text-align: center; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 1rem; padding: 1rem; width: 200px; }
.podium-item img { width: 110px; height: 110px; object-fit: cover; border-radius: 50%; border: 3px solid var(--ct-accent); background: #fff; margin-bottom: .5rem; }
.podium-first { order: -1; width: 240px; background: color-mix(in srgb, var(--ct-accent) 30%, transparent); }
.podium-first img { width: 140px; height: 140px; }
.podium-label { color: var(--ct-accent); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .85rem; }
.live-lineup { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; margin-top: 1rem; }
.lineup-item { background: rgba(255,255,255,.1); border-radius: .8rem; padding: .6rem; text-align: center; font-size: .85rem; font-weight: 600; }
.lineup-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: .6rem; background: #fff; margin-bottom: .4rem; }
.live-empty { text-align: center; padding: 5rem 1rem; }
.live-empty i { font-size: 3.5rem; color: var(--ct-accent); }
.live-empty h2 { font-weight: 800; margin-top: .75rem; }
.live-footer { text-align: center; font-size: .8rem; opacity: .7; padding: 1rem 1rem 2rem; }
/* ---------- About page ---------- */
.about-page { max-width: 1000px; }
.about-logo { width: 84px; height: 84px; }
.about-name { font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 800; letter-spacing: .12em; color: var(--ct-secondary); margin: .5rem 0 .2rem; }
.about-tagline { color: var(--ct-accent-hover); font-weight: 600; margin-bottom: 1rem; }
.about-desc { max-width: 680px; margin: 0 auto; color: #555; }
.about-avatar { flex-shrink: 0; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; font-weight: 800; color: var(--ct-on-accent); background: linear-gradient(135deg, var(--ct-accent), var(--ct-accent-hover)); }
.about-avatar-school { background: linear-gradient(135deg, var(--ct-secondary), var(--ct-primary)); color: #fff; }
.about-feature-icon { flex-shrink: 0; width: 42px; height: 42px; border-radius: .7rem; display: grid; place-items: center; font-size: 1.2rem; background: var(--ct-tint); color: var(--ct-secondary); }

@media (max-width: 575.98px) {
    .rank-row { gap: .5rem; padding: .4rem; }
    .rank-row .avatar-md { width: 38px; height: 38px; }
    .rank-score { font-size: 1rem; min-width: 3.2rem; }
    .live-progress { margin-left: 0; text-align: left; width: 100%; }
    .podium-item { width: 45%; }
    .podium-first { width: 100%; }
}
@media print {
    html { font-size: 16px !important; }
    body { background: #fff !important; }
    .no-print, .sidebar, .topbar, .footer-note { display: none !important; }
    .report-page { box-shadow: none; padding: 0; max-width: none; }
    .content { padding: 0; }
    a { text-decoration: none; color: inherit; }
}

/* Judge Encoding Monitor */
.enc-judge { border: 1px solid var(--bs-border-color); transition: border-color .15s, box-shadow .15s; }
.enc-judge:hover { border-color: var(--bs-dark); }
.enc-judge.active { border-color: var(--bs-dark); box-shadow: 0 0 0 2px rgba(0,0,0,.15); }
.enc-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #adb5bd; flex-shrink: 0; }
.enc-dot.on { background: #20c997; box-shadow: 0 0 0 3px rgba(32,201,151,.25); }
.enc-table td, .enc-table th { white-space: nowrap; }
.enc-table td.enc-empty { background: #fafafa; }
.enc-recent { background: #fff3cd !important; animation: enc-flash 1.2s ease-out; }
.enc-legend { padding: 0 .35rem; border-radius: .25rem; }
@keyframes enc-flash { from { background: #ffe08a; } }

/* Monitoring Team page */
.team-header { display: flex; align-items: center; gap: .75rem; padding: .75rem clamp(1rem, 3vw, 1.5rem); background: var(--ct-primary, #1b1b3a); color: #fff; }
.team-header img { width: 38px; height: 38px; }
