/* Victoria V12 — global theme, safe dialogs, Live/Radar/Results and mobile polish */
:root{
  --vx-focus: 0 0 0 4px rgba(45,157,154,.16);
}

/* Keep the whole application on one source of truth for light/dark colors. */
html[data-vx-theme="light"]{
  color-scheme:light;
  --v5-bg:#eef6f5;
  --v5-surface:#fff;
  --v5-surface-2:#f7fbfa;
  --v5-ink:#17343b;
  --v5-ink-2:#2d4d55;
  --v5-teal:#2d9d9a;
  --v5-teal-dark:#1e7472;
  --v5-teal-pale:#def3ef;
  --v5-coral:#f18a7a;
  --v5-line:#d8e7e5;
  --v5-muted:#74878d;
  --v5-shadow:0 18px 50px rgba(23,52,59,.10);
  --v5-shadow-soft:0 10px 28px rgba(23,52,59,.07);
}
html[data-vx-theme="dark"]{
  color-scheme:dark;
  --v5-bg:#050607;
  --v5-surface:#0b0d0f;
  --v5-surface-2:#111417;
  --v5-ink:#f5f7f7;
  --v5-ink-2:#d0d7d7;
  --v5-teal:#61d9cc;
  --v5-teal-dark:#35bdb0;
  --v5-teal-pale:rgba(97,217,204,.14);
  --v5-coral:#ff7d74;
  --v5-line:#242b2e;
  --v5-muted:#96a1a4;
  --v5-shadow:0 24px 75px rgba(0,0,0,.45);
  --v5-shadow-soft:0 14px 40px rgba(0,0,0,.28);
  --bs-body-bg:#050607;
  --bs-body-color:#f5f7f7;
  --bs-tertiary-bg:#111417;
  --bs-secondary-color:#96a1a4;
  --bs-border-color:#242b2e;
}

html,body{min-height:100%;background:var(--v5-bg)!important;color:var(--v5-ink)!important}
body{transition:background .18s ease,color .18s ease}
body.vx-modal-open{overflow:hidden!important;touch-action:none}
body *{scrollbar-color:var(--v5-line) transparent}

/* Generic Bootstrap / legacy blocks that escaped the old theme overrides. */
.bg-white,.bg-light{background:var(--v5-surface)!important;color:var(--v5-ink)!important}
.text-dark{color:var(--v5-ink)!important}
.border{border-color:var(--v5-line)!important}
.card,.card-body,.card-header,.list-group-item,.dropdown-menu,.accordion-item,.accordion-button,.offcanvas,.toast{background:var(--v5-surface)!important;color:var(--v5-ink)!important;border-color:var(--v5-line)!important}
.dropdown-item{color:var(--v5-ink-2)!important}.dropdown-item:hover{background:var(--v5-surface-2)!important;color:var(--v5-ink)!important}
.form-control,.form-select,textarea,input[type="text"],input[type="search"],input[type="email"],input[type="number"],input[type="url"],input[type="date"],input[type="password"],input[type="tel"]{background:var(--v5-surface)!important;color:var(--v5-ink)!important;border-color:var(--v5-line)!important}
.form-control::placeholder,textarea::placeholder{color:var(--v5-muted)!important;opacity:1}
.form-control:focus,.form-select:focus,textarea:focus,input:focus,button:focus-visible,a:focus-visible{outline:none;box-shadow:var(--vx-focus)!important;border-color:var(--v5-teal)!important}
option{background:var(--v5-surface);color:var(--v5-ink)}
.table{--bs-table-bg:transparent!important;--bs-table-color:var(--v5-ink)!important;color:var(--v5-ink)!important}.table td,.table th{border-color:var(--v5-line)!important}
.table>thead,.table-striped>tbody>tr:nth-of-type(odd)>*{--bs-table-accent-bg:var(--v5-surface-2)!important;background:var(--v5-surface-2)!important;color:var(--v5-ink)!important}

/* Make cards from V5–V11 obey the same surface variables. */
.v5-event-card,.v5-candidate-card,.v5-feature,.v5-toolbar,.v5-profile-section,.v5-detail-hero,.v5-candidate-hero,.v5-stat,.v5-podium-card,.v5-carousel,.v5-list-card,.v5-auth-grid,.v5-app-card,.v5-fin-card,.v5-candidate-admin-card,.v5-admin-hero,.v5-admin-stat,.v5-admin-panel,.v5-card,
.v9-live-kpi,.v9-admin-kpi,.v9-live-main,.v9-live-side,.v9-card-shell,.v9-radar-card,.v9-battle-card,.v9-notification,.v9-stories-card,.v9-admin-command,.v9-report-card,.v9-notif-toolbar,.v11-panel,.v11-podium-card,.v11-result-card,.v11-empty,.vx-card,.vx-side-card,.vx-comments-card,.vx-event-mini,.vx-podium-card{
  background:var(--v5-surface)!important;color:var(--v5-ink)!important;border-color:var(--v5-line)!important;
}
.v5-event-cover,.v5-candidate-media,.v5-hero-media,.v5-detail-media,.v5-story-media,.v9-radar-photo,.v11-radar-card .photo,.vx-candidate-photo-wrap{background:var(--v5-surface-2)!important}
.v5-float,.v5-user-chip,.v5-icon-btn,.v5-install-btn,.v5-carousel-btn,.v5-story-rank,.v5-event-status,.v5-chip,.v5-inline-pill,.v5-tabs,.v5-empty,.v5-app-facts span,.v5-code-chip,.v9-ranking-row,.v9-quick-grid>a,.v9-battle-card .compare-stats div,.v9-story-item,.v9-leader-card,.v9-story-type button,.v11-result-row,.v11-soft-pill,.v11-updated{background:var(--v5-surface-2)!important;color:var(--v5-ink)!important;border-color:var(--v5-line)!important}
.v5-event-card h3,.v5-candidate-card h3,.v5-section-head h2,.v5-page-title h1,.vx-card h2,.vx-card h3,.v11-panel h2,.v11-result-card h2,.v11-radar-card h2{color:var(--v5-ink)!important}
.v5-lead,.v5-page-title p,.v5-section-head p,.v5-event-copy,.v5-candidate-sub,.v5-muted,.v5-meta-row,.v5-story-meta,.v9-radar-meta,.v9-ranking-row .v9-name small,.v9-ranking-row .v9-score small,.v11-rank-row .name small,.v11-rank-row .score small,.v11-activity-row small,.v11-activity-row time,.v11-podium-card small,.v11-result-card>small,.vx-hero-lead{color:var(--v5-muted)!important}

/* Candidate detail: preserve legibility and keep every action above ordinary content. */
.vx-candidate-hero,.vx-card,.vx-hero-actions,.vx-share-row{isolation:isolate}
.vx-candidate-hero .btn,.vx-card .btn{position:relative;z-index:4;pointer-events:auto}
.vx-number-card{background:var(--v5-surface)!important;color:var(--v5-ink)!important;border-color:var(--v5-line)!important}
.vx-live-chip{background:var(--v5-surface)!important;color:var(--v5-ink)!important;border-color:var(--v5-line)!important}
.vx-story-item p,.vx-comment-body,.vx-comment-head p,.vx-bubble p{color:var(--v5-ink)!important}
.v9-story-composer textarea,.v9-story-composer input,.v9-story-composer select{background:var(--v5-surface-2)!important;color:var(--v5-ink)!important;border-color:var(--v5-line)!important}

/* Bootstrap-free, non-blocking dialog. Avoids stale modal-backdrop state on candidate.php. */
.vx-safe-modal[hidden]{display:none!important;visibility:hidden!important;pointer-events:none!important}
.vx-safe-modal{position:fixed!important;inset:0!important;z-index:5000!important;display:flex!important;align-items:center!important;justify-content:center!important;padding:18px!important;background:rgba(3,7,8,.72)!important;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);opacity:0;pointer-events:none;visibility:hidden;transition:opacity .18s ease,visibility .18s ease;overscroll-behavior:contain}
.vx-safe-modal.is-open{opacity:1;visibility:visible;pointer-events:auto}
.vx-safe-modal__dialog{width:min(560px,100%);max-height:min(92vh,920px);overflow:auto;overscroll-behavior:contain;background:var(--v5-surface)!important;color:var(--v5-ink)!important;border:1px solid var(--v5-line);border-radius:28px;box-shadow:0 35px 110px rgba(0,0,0,.45);transform:translateY(12px) scale(.985);transition:transform .2s ease}
.vx-safe-modal.is-open .vx-safe-modal__dialog{transform:none}
.vx-safe-modal__dialog--wide{width:min(980px,100%)}
.vx-safe-modal__head{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:17px 19px;border-bottom:1px solid var(--v5-line);position:sticky;top:0;background:color-mix(in srgb,var(--v5-surface) 94%,transparent);backdrop-filter:blur(10px);z-index:2}
.vx-safe-modal__body{padding:20px}.vx-safe-modal__foot{display:flex;justify-content:flex-end;gap:9px;flex-wrap:wrap;padding:15px 20px;border-top:1px solid var(--v5-line);position:sticky;bottom:0;background:var(--v5-surface);z-index:2}
.vx-safe-modal__close{width:42px;height:42px;border:1px solid var(--v5-line);border-radius:14px;background:var(--v5-surface-2);color:var(--v5-ink);display:grid;place-items:center;cursor:pointer;flex:0 0 auto}
.vx-safe-modal__close:hover{background:var(--v5-teal-pale);color:var(--v5-teal-dark);border-color:var(--v5-teal)}
.vx-qr-shell{width:min(360px,100%);margin:auto;padding:12px;border-radius:22px;background:#fff;box-shadow:0 15px 45px rgba(0,0,0,.14)}
.vx-qr-shell img{display:block;width:100%;height:auto;aspect-ratio:1;object-fit:contain;background:#fff;border-radius:12px}
.vx-social-card-preview{width:100%;overflow:hidden;border:1px solid var(--v5-line);border-radius:22px;background:var(--v5-surface-2);box-shadow:var(--v5-shadow-soft)}
.vx-social-card-preview img{display:block;width:100%;height:auto;max-height:68vh;object-fit:contain}
#candidateVideoModalPlayer{display:block;width:100%;max-height:78vh;background:#000;object-fit:contain}

/* Stronger theme for the Live / Results / Radar family. */
.v11-live-hero,.v11-radar-hero,.v11-results-hero{min-height:260px}
.v11-live-hero,.v11-radar-hero,.v11-results-hero{box-shadow:0 28px 90px rgba(6,26,27,.18)}
html[data-vx-theme="dark"] .v11-live-hero,html[data-vx-theme="dark"] .v11-radar-hero,html[data-vx-theme="dark"] .v11-results-hero{box-shadow:0 28px 90px rgba(0,0,0,.44)}
.v11-live-toolbar select,.v11-radar-toolbar select,.v11-results-tools select{background:var(--v5-surface)!important;color:var(--v5-ink)!important;border-color:var(--v5-line)!important;box-shadow:none!important}
.v11-live-status,.v11-radar-status{color:#fff}
.v11-radar-grid,.v11-results-podium,.v11-live-podium{min-width:0}
.v11-radar-card,.v11-result-card,.v11-rank-row,.v11-result-row{min-width:0}
.v11-radar-card .body,.v11-result-card,.v11-result-row .identity{min-width:0}
.v11-radar-card .metrics span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.v11-radar-card .metrics span i{flex:0 0 auto}
.v11-result-row .votes small,.v11-result-row .identity small{color:var(--v5-muted)!important}
.v11-live-orb,.v11-result-total{flex:0 0 auto}
.v11-kpis article{background:var(--v5-surface)!important;color:var(--v5-ink)!important;border:1px solid var(--v5-line)!important}

/* Dark-mode utilities used by Bootstrap and legacy pages. */
html[data-vx-theme="dark"] .alert-light{background:#0b0d0f!important;color:#e6eeee!important;border-color:#242b2e!important}
html[data-vx-theme="dark"] .modal-backdrop{background:#000!important}
html[data-vx-theme="dark"] .nav-link{color:var(--v5-ink-2)}
html[data-vx-theme="dark"] .nav-link:hover{color:#fff}
html[data-vx-theme="dark"] .progress{background:#171b1d!important}
html[data-vx-theme="dark"] .btn-close{filter:invert(1) grayscale(1) brightness(1.9)!important}
html[data-vx-theme="dark"] .btn-outline-secondary{color:#dbe3e3!important;border-color:#394246!important}
html[data-vx-theme="dark"] .btn-outline-secondary:hover{background:#151a1c!important;color:#fff!important}
html[data-vx-theme="dark"] .table-hover>tbody>tr:hover>*{--bs-table-accent-bg:#111417!important;color:#fff!important}
html[data-vx-theme="dark"] .accordion-button:not(.collapsed){background:#111417!important;color:#fff!important}
html[data-vx-theme="dark"] .accordion-button::after{filter:invert(1) grayscale(1)}

/* Header and mobile navigation: more stable, more app-like and safe-area aware. */
.v5-desktop-header,.v5-mobile-header{backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);box-shadow:0 8px 28px rgba(0,0,0,.06)}
.v5-mobile-header{padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right));box-shadow:0 10px 32px rgba(0,0,0,.10)!important}
.v5-mobile-actions{gap:8px}
.v5-mobile-actions .v7-theme-btn,.v5-mobile-actions .v7-menu-btn{min-width:42px;min-height:42px;border-radius:14px}
.v7-mobile-menu{border-radius:22px!important;box-shadow:0 30px 70px rgba(0,0,0,.16)!important;overscroll-behavior:contain}
.v5-mobile-bottom{padding-bottom:max(7px,env(safe-area-inset-bottom));height:calc(66px + env(safe-area-inset-bottom));bottom:max(9px,env(safe-area-inset-bottom))}
html[data-vx-theme="dark"] .v5-desktop-header,html[data-vx-theme="dark"] .v5-mobile-header{background:rgba(5,6,7,.92)!important;border-color:#1d2426!important;box-shadow:0 10px 34px rgba(0,0,0,.38)!important}
html[data-vx-theme="dark"] .v5-mobile-bottom{background:rgba(5,6,7,.95)!important;border-color:#1d2426!important;box-shadow:0 20px 60px rgba(0,0,0,.5)!important}

/* Inline style safety: only neutralize white surfaces in dark mode. */
html[data-vx-theme="dark"] [style*="background:#fff"],
html[data-vx-theme="dark"] [style*="background: #fff"],
html[data-vx-theme="dark"] [style*="background:#ffffff"],
html[data-vx-theme="dark"] [style*="background: #ffffff"],
html[data-vx-theme="dark"] [style*="background-color:#fff"],
html[data-vx-theme="dark"] [style*="background-color: #fff"],
html[data-vx-theme="dark"] [style*="background-color:#ffffff"],
html[data-vx-theme="dark"] [style*="background-color: #ffffff"]{background:var(--v5-surface)!important;color:var(--v5-ink)!important;border-color:var(--v5-line)!important}

/* Radar: fix grid clipping, card heights and mobile breakpoints. */
.v11-radar-hero .v11-radar-toolbar form{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.v11-radar-toolbar select{min-width:180px}
.v11-radar-status{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.v11-radar-visual{width:min(260px,100%);margin-inline:auto}
.v11-radar-card .photo img{display:block}

@media(max-width:900px){
  .v11-live-hero,.v11-radar-hero,.v11-results-hero{grid-template-columns:1fr;padding:26px;border-radius:26px}
  .v11-radar-visual{width:min(240px,100%)}
  .v11-radar-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:640px){
  .v5-shell{width:min(100% - 20px,var(--v5-max))}
  .v5-page{padding-top:20px}
  .v11-radar-grid,.v11-results-podium,.v11-live-podium{grid-template-columns:1fr}
  .v11-radar-toolbar form{display:grid;grid-template-columns:1fr;width:100%}
  .v11-radar-toolbar select,.v11-radar-toolbar .btn{width:100%}
  .v11-results-tools{display:grid;grid-template-columns:1fr;width:100%}
  .v11-results-tools>*{width:100%}
  .v11-live-toolbar{display:grid;grid-template-columns:1fr;width:100%}
  .v11-live-toolbar>*{width:100%}
  .v11-live-orb,.v11-result-total{width:170px;height:170px;margin-inline:auto}
  .vx-safe-modal{padding:10px!important;align-items:flex-end}
  .vx-safe-modal__dialog{max-height:94vh;border-radius:24px}
  .vx-safe-modal__head{padding:14px}.vx-safe-modal__body{padding:15px}.vx-safe-modal__foot{padding:12px 15px}
  .vx-safe-modal__foot .btn{flex:1 1 150px}
}
@media(prefers-reduced-motion:reduce){
  body{transition:none}
  .vx-safe-modal,.vx-safe-modal__dialog,.v11-radar-card,.v11-rank-row{transition:none!important}
  .v11-radar-visual .sweep,.v5-marquee-track,.vx-live-dot,.vx-vote-btn:not(:disabled){animation:none!important}
}


/* V12.1: force the theme through legacy/inline light surfaces without touching photos. */
html[data-vx-theme="dark"] .bg-body,.bg-light-subtle{background:var(--v5-surface-2)!important}
html[data-vx-theme="dark"] .bg-white,[data-vx-theme="dark"] .bg-white{background:var(--v5-surface)!important}
html[data-vx-theme="dark"] .shadow,.html[data-vx-theme="dark"] .shadow-sm,.html[data-vx-theme="dark"] .shadow-lg{box-shadow:var(--v5-shadow-soft)!important}
html[data-vx-theme="dark"] .list-group,.html[data-vx-theme="dark"] .pagination{--bs-list-group-bg:var(--v5-surface)!important;--bs-list-group-color:var(--v5-ink)!important;--bs-list-group-border-color:var(--v5-line)!important}
html[data-vx-theme="dark"] .v5-role-card,html[data-vx-theme="dark"] .v5-activity,html[data-vx-theme="dark"] .v5-log-row{border-color:var(--v5-line)!important}
html[data-vx-theme="dark"] .v5-empty,html[data-vx-theme="dark"] .v5-auth-grid,html[data-vx-theme="dark"] .v5-profile-section,html[data-vx-theme="dark"] .v5-toolbar{background:var(--v5-surface)!important;color:var(--v5-ink)!important}
html[data-vx-theme="dark"] .v5-feature-icon,html[data-vx-theme="dark"] .v5-log-icon{background:var(--v5-teal-pale)!important;color:var(--v5-teal)!important}
html[data-vx-theme="dark"] .badge.bg-white,html[data-vx-theme="dark"] .badge[style*="#fff"],html[data-vx-theme="dark"] .badge[style*="#ffffff"]{background:var(--v5-surface-2)!important;color:var(--v5-ink)!important;border:1px solid var(--v5-line)!important}
html[data-vx-theme="dark"] [style*="background:#f8f9fa"],html[data-vx-theme="dark"] [style*="background: #f8f9fa"],html[data-vx-theme="dark"] [style*="background:#f7fbfa"],html[data-vx-theme="dark"] [style*="background: #f7fbfa"],html[data-vx-theme="dark"] [style*="background:#f5f5f5"],html[data-vx-theme="dark"] [style*="background: #f5f5f5"]{background:var(--v5-surface-2)!important;color:var(--v5-ink)!important;border-color:var(--v5-line)!important}
html[data-vx-theme="dark"] .form-check-input{background-color:var(--v5-surface)!important;border-color:var(--v5-line)!important}
html[data-vx-theme="dark"] .form-check-label,html[data-vx-theme="dark"] .form-label{color:var(--v5-ink-2)!important}

/* Safe modal hardening: one overlay, no ghost backdrop, no page-wide invisible blocker. */
.vx-safe-modal{contain:layout paint style;isolation:isolate}
.vx-safe-modal__dialog{pointer-events:auto;touch-action:auto}
.vx-safe-modal__dialog *{pointer-events:auto}
.vx-safe-modal .btn,.vx-safe-modal a,.vx-safe-modal button{cursor:pointer}
html[data-vx-theme="dark"] .vx-safe-modal__head,html[data-vx-theme="dark"] .vx-safe-modal__foot{background:rgba(11,13,15,.94)!important}
html[data-vx-theme="dark"] .vx-safe-modal .text-muted{color:var(--v5-muted)!important}

/* Candidate page actions stay clickable even when legacy modal CSS is present. */
#candidateQrBtn,#socialCardBtn,#supporterBtn,#reportCandidateBtn,.vx-primary-cta{position:relative;z-index:10;pointer-events:auto!important}
body.vx-modal-open .v5-mobile-bottom,body.vx-modal-open .v5-mobile-header{z-index:1000}

/* Live / Radar / Results: keep every grid item shrinkable and readable on narrow screens. */
.v11-live-grid>*,.v11-kpis>*,.v11-radar-grid>*,.v11-results-podium>*,.v11-results-list>*{min-width:0}
.v11-live-hero,.v11-radar-hero,.v11-results-hero{overflow:clip}
.v11-radar-hero>div:first-child,.v11-live-hero>div:first-child,.v11-results-hero>div:first-child{min-width:0}
.v11-radar-card .metrics{min-width:0}
.v11-radar-card .metrics span{min-height:30px}
.v11-results-tools form{min-width:0}

@media(max-width:640px){
  .v5-mobile-header{position:sticky!important;top:0;z-index:1200}
  .v7-mobile-menu{z-index:1210!important}
  .v5-mobile-bottom{z-index:1190!important}
  .v11-radar-hero,.v11-live-hero,.v11-results-hero{gap:18px;padding:22px!important}
  .v11-radar-visual{order:-1}
  .v11-radar-card .photo{height:250px}
  .vx-candidate-hero{overflow:visible}
}
