:root {
  color-scheme: light;
  --navy: #10243b;
  --navy-soft: #1b3857;
  --gold: #b8934e;
  --gold-pale: #f3ead7;
  --ink: #18293c;
  --muted: #647286;
  --paper: #f6f7f9;
  --line: #e0e5eb;
  --white: #fff;
  --green: #266348;
  --red: #8e3f38;
  --shadow: 0 14px 36px rgb(16 36 59 / 8%);
  --radius: 18px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; scroll-padding-top: 106px; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); font-size: 16px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #d5b36f; outline-offset: 3px; }
[hidden] { display: none !important; }

.topbar { position: sticky; z-index: 20; top: 0; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 96%); backdrop-filter: blur(12px); }
.nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; width: min(100%, 1180px); min-height: 68px; margin-inline: auto; padding: 9px max(16px, env(safe-area-inset-right)) 9px max(16px, env(safe-area-inset-left)); }
.brand { display: inline-flex; min-width: 0; align-items: center; gap: 10px; color: var(--navy); font-weight: 800; letter-spacing: .025em; }
.brand img { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 50%; object-fit: contain; background: #fff; }
.brand-title { display: block; max-width: 250px; color: #16804b; font-size: 12px; line-height: 1.25; letter-spacing: .07em; text-align: center; }
.brand-title .brand-title-main, .brand-title .brand-title-connector, .brand-title .brand-title-tail { display: block; }
.brand-title .brand-title-main { white-space: nowrap; }
.brand-title .brand-subtitle { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .12em; }
.brand-title .brand-title-connector { color: #000; }
.navlinks { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; color: #405168; font-size: 13px; font-weight: 650; }
.navlinks a { display: inline-flex; min-height: 44px; align-items: center; padding-inline: 5px; }
.navlinks a:hover, .navlinks a[aria-current="page"] { color: var(--navy); }
.navlinks .ranking-link { gap: 6px; border: 1px solid var(--green); border-radius: 10px; padding-inline: 13px; background: var(--green); color: var(--white); }
.navlinks .ranking-link:hover, .navlinks .ranking-link[aria-current="page"] { border-color: #1d4e38; background: #1d4e38; color: var(--white); }

.hero { position: relative; overflow: hidden; background: radial-gradient(ellipse at 92% 10%, rgb(184 147 78 / 18%), transparent 34%), linear-gradient(145deg, #10243b, #1c3b5c); color: var(--white); }
.hero-inner { display: grid; width: min(100%, 1180px); min-height: 400px; grid-template-columns: 1fr; align-items: center; gap: 22px; margin-inline: auto; padding: clamp(42px, 10vw, 72px) max(20px, env(safe-area-inset-right)) clamp(42px, 10vw, 72px) max(20px, env(safe-area-inset-left)); }
.eyebrow { margin: 0 0 10px; color: var(--gold); font-size: 11px; font-weight: 750; letter-spacing: .16em; line-height: 1.4; text-transform: uppercase; }
.hero .eyebrow { color: #e3c88f; }
.hero h1, .page-title { max-width: 760px; margin: 0; font-family: "Aptos Display", "Segoe UI", Arial, sans-serif; font-size: clamp(36px, 10vw, 54px); font-weight: 800; letter-spacing: -.035em; line-height: 1.06; }
.hero p { max-width: 560px; margin: 17px 0 24px; color: #e3eaf1; font-size: 16px; }
.hero-mark { display: none; }

.container, .admin-layout { width: min(100%, 1180px); margin-inline: auto; padding: 34px max(16px, env(safe-area-inset-right)) 52px max(16px, env(safe-area-inset-left)); }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 19px; }
.section-head h1, .section-head h2, .page-title { color: var(--navy); }
.section-head h2, .panel h2 { margin: 0; font-family: "Aptos Display", "Segoe UI", Arial, sans-serif; font-size: clamp(23px, 6vw, 30px); letter-spacing: -.02em; line-height: 1.2; }
.section-head p:not(.eyebrow) { margin: 7px 0 0; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; clip-path: inset(50%); }
.status { display: inline-flex; min-height: 36px; align-items: center; border-radius: 999px; padding: 7px 12px; font-size: 12px; font-weight: 750; }
.open { background: #e6f2ec; color: #225d40; }
.closed { background: #f6eae8; color: var(--red); }

.candidate-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 17px; }
.candidate-card { display: flex; overflow: hidden; min-width: 0; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); transition: box-shadow .18s ease, transform .18s ease; }
.candidate-card:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgb(16 36 59 / 12%); }
.candidate-card-topline { display: flex; justify-content: flex-end; padding: 9px 12px 0; }
.candidate-vote-count { display: inline-flex; min-height: 32px; align-items: center; gap: 6px; border: 1px solid #f0d9dc; border-radius: 999px; padding: 5px 10px; background: #fff8f8; color: var(--navy); font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.candidate-vote-heart { color: #c62838; font-size: 17px; line-height: 1; }
.competition-card-name { margin: 0 0 8px; font-size: 12px; font-weight: 800; letter-spacing: .04em; overflow-wrap: anywhere; }
.competition-card-name--udm { color: var(--green); }
.competition-card-name--rap { color: #1d5f9b; }
.candidate-card > img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: center 30%; background: #e7ebef; }
.candidate-body { display: flex; flex: 1; flex-direction: column; padding: 18px; }
.candidate-body h3 { margin: 0; color: var(--navy); font-family: "Aptos Display", "Segoe UI", Arial, sans-serif; font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.candidate-role { margin: 0 0 6px; color: #80642e; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; overflow-wrap: anywhere; }
.candidate-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.candidate-meta span { max-width: 100%; border: 1px solid #e6eaf0; border-radius: 999px; padding: 4px 9px; color: #4a5a6e; font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.candidate-meta b { color: var(--navy); font-size: 10px; text-transform: uppercase; }
.candidate-intro { display: -webkit-box; overflow: hidden; margin: 12px 0 0; color: var(--muted); line-height: 1.55; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.candidate-slogan { margin: 13px 0 0; border-left: 3px solid var(--gold); padding: 2px 0 2px 12px; color: var(--navy-soft); font-family: "Aptos Display", "Segoe UI", Arial, sans-serif; font-size: 15px; font-style: italic; line-height: 1.45; overflow-wrap: anywhere; }
.candidate-actions { display: grid; gap: 9px; margin-top: auto; padding-top: 16px; }
.candidate-actions .btn { width: 100%; min-height: 48px; }
.btn { display: inline-flex; min-width: 44px; min-height: 46px; align-items: center; justify-content: center; border: 1px solid #cbd4df; border-radius: 11px; padding: 10px 16px; background: var(--white); color: var(--navy); font-size: 14px; font-weight: 700; line-height: 1.2; text-align: center; cursor: pointer; touch-action: manipulation; transition: background-color .16s ease, transform .16s ease; }
.btn:hover { background: #f3f5f8; }
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: var(--navy); background: var(--navy); color: var(--white); }
.btn.primary:hover { background: var(--navy-soft); }
.btn:disabled { opacity: .56; cursor: not-allowed; }
.small { min-height: 44px; padding: 8px 12px; font-size: 13px; }
.empty { border: 1px dashed #cbd4df; border-radius: 14px; padding: 22px; background: var(--white); color: var(--muted); }
.competition-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 18px 0; }
.search-field input, .filter-field select, .result-competition-field select { width: 100%; min-height: 48px; border: 1px solid #cbd4df; border-radius: 11px; padding: 10px 13px; background: var(--white); color: var(--ink); font-size: 16px; }
.competition-directory { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0 0 20px; }
.competition-chip { display: grid; min-width: 0; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 4px 10px; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 13px; padding: 12px; background: #fff; box-shadow: 0 8px 20px rgb(16 36 59 / 4%); }
.competition-chip strong { color: var(--navy); overflow-wrap: anywhere; }
.competition-chip .status { grid-row: span 2; }
.competition-chip small { color: var(--muted); }
.selected-competition-label { margin: 10px 0; color: var(--navy); font-size: 18px; font-weight: 800; }
.competition-admin { margin-bottom: 16px; }
.competition-form { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; }
.competition-admin-list { margin: 14px 0; }
.competition-admin-list .manage-row { border-top: 1px solid var(--line); }
.competition-admin-list .manage-row > div { flex-basis: 100%; }

.checkout-dialog { width: min(calc(100vw - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right))), 520px); max-height: min(92dvh, 760px); overflow: auto; border: 0; border-radius: 20px; padding: 22px; box-shadow: 0 24px 80px rgb(8 22 38 / 30%); color: var(--ink); }
.checkout-dialog::backdrop { background: rgb(10 25 43 / 72%); backdrop-filter: blur(3px); }
.checkout-dialog h2 { margin: 0; color: var(--navy); font: 800 24px/1.2 "Aptos Display", "Segoe UI", Arial, sans-serif; }
.vote-choice-group { display: grid; gap: 10px; margin: 18px 0; border: 0; padding: 0; }
.vote-choice-group legend { margin-bottom: 8px; color: var(--navy); font-weight: 750; }
.vote-choice-option { display: grid; grid-template-columns: 22px minmax(0,1fr); align-items: center; gap: 8px 10px; border: 1px solid #cbd4df; border-radius: 12px; padding: 12px; background: #fff; cursor: pointer; }
.vote-choice-option.is-selected { border-color: var(--green); background: #f5faf7; box-shadow: 0 0 0 2px rgb(38 99 72 / 10%); }
.vote-choice-option input[type="radio"] { grid-row: span 2; width: 20px; height: 20px; margin: 0; accent-color: var(--green); }
.vote-choice-title { color: var(--navy); font-weight: 750; }
.vote-choice-option select, .vote-choice-option input[type="number"] { grid-column: 2; width: 100%; min-height: 46px; border: 1px solid #cbd4df; border-radius: 10px; padding: 9px 11px; background: #fff; color: var(--ink); font-size: 16px; }
.vote-choice-option select:disabled, .vote-choice-option input:disabled { background: #f0f2f5; color: var(--muted); cursor: not-allowed; }
.checkout-dialog .dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 18px; }
.checkout-dialog .dialog-actions .btn { width: 100%; }
.checkout-dialog select { width: 100%; min-height: 48px; border: 1px solid #cbd4df; border-radius: 10px; padding: 10px 12px; background: #fff; }
.checkout-total { border-radius: 11px; padding: 12px; background: var(--gold-pale); color: #463819; font-weight: 750; }
.checkout-error { min-height: 1.5em; color: var(--red); }

.result-list { display: grid; gap: 12px; }
.result-row { display: grid; min-width: 0; grid-template-columns: 34px 52px minmax(0, 1fr); align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 15px; padding: 13px; background: var(--white); box-shadow: 0 8px 24px rgb(16 36 59 / 5%); }
.result-row img { width: 52px; height: 52px; border-radius: 11px; object-fit: cover; background: #e7ebef; }
.rank { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: #f1f3f6; color: var(--navy); font-weight: 800; }
.result-row:first-child .rank { background: var(--gold-pale); color: #755a21; }
.result-main { min-width: 0; }
.result-main strong { display: block; overflow-wrap: anywhere; color: var(--navy); }
.result-count { grid-column: 3; color: var(--muted); font-size: 13px; font-weight: 700; }
.bar { height: 8px; overflow: hidden; margin-top: 8px; border-radius: 99px; background: #e9edf2; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--navy-soft), var(--gold)); }

.footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; border-top: 1px solid var(--line); padding: 22px max(18px, env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: #fff; color: var(--muted); font-size: 12px; text-align: center; }
.footer img { width: 35px; height: 35px; border-radius: 50%; object-fit: contain; }

.login-wrap { width: min(100%, 440px); margin: 32px auto 54px; padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
.panel, .stat { min-width: 0; border: 1px solid var(--line); border-radius: 16px; padding: 18px; background: var(--white); box-shadow: var(--shadow); }
.panel h2 { color: var(--navy); }
.field { display: grid; gap: 7px; margin: 14px 0; }
.field label { color: #405168; font-size: 14px; font-weight: 700; }
.field input, .field textarea, .field select { width: 100%; min-height: 48px; border: 1px solid #cbd4df; border-radius: 10px; padding: 11px 12px; background: #fff; color: var(--ink); font-size: 16px; }
.field input:read-only { background: #f0f2f5; color: var(--muted); }
.field textarea { min-height: 104px; resize: vertical; }
.field input[type="file"] { height: auto; min-height: 50px; padding: 9px; }
.field input[type="checkbox"], input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--navy); vertical-align: middle; }
.field input[type="checkbox"] { min-height: 22px; }
.admin-layout { padding-top: 26px; }
.admin-layout > .section-head h1 { margin: 0; font: 800 clamp(28px, 8vw, 36px)/1.1 "Aptos Display", "Segoe UI", Arial, sans-serif; }
.stats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 18px 0; }
.stat small { display: block; color: var(--muted); font-size: 13px; }
.stat b { display: block; margin-top: 4px; color: var(--navy); font: 800 clamp(23px, 7vw, 29px)/1.2 "Aptos Display", "Segoe UI", Arial, sans-serif; overflow-wrap: anywhere; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.admin-grid > *, .admin-grid section { min-width: 0; }
.manage-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 13px 0; }
.manage-row > div { min-width: 0; flex: 1 1 100%; overflow-wrap: anywhere; }
.manage-row small { display: block; color: var(--muted); }
.manage-row .btn { flex: 1 1 auto; }
.https-note { border: 1px solid #ead8af; border-radius: 12px; padding: 12px; background: #fbf5e8; color: #5b4820; font-size: 14px; }
.login-wrap .btn { width: 100%; }
.admin-layout hr { height: 1px; border: 0; margin: 23px 0; background: var(--line); }
.admin-layout h3 { color: var(--navy); }
.admin-layout .dialog-actions { display: flex; gap: 10px; margin-top: 12px; }
.admin-layout .dialog-actions > .btn { flex: 1; }
.transaction-history { margin: 18px 0; }
.transaction-history > .section-head { align-items: flex-start; }
.transaction-history > .section-head .dialog-actions { flex-wrap: wrap; margin-top: 0; }
.transaction-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 12px; }
.transaction-filters .field { min-width: 0; }
.transaction-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 12px 0 20px; }
.transaction-stats .stat { padding: 14px; }
.transaction-stats .stat small { line-height: 1.35; }
.transaction-stats .stat b { font-size: clamp(18px, 5vw, 25px); }
.transaction-table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.transaction-table { width: 100%; min-width: 1420px; border-collapse: collapse; font-size: 13px; }
.transaction-table th, .transaction-table td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
.transaction-table th { position: sticky; top: 0; background: #f5f7fa; color: var(--navy); font-size: 12px; white-space: nowrap; }
.transaction-table td { overflow-wrap: anywhere; }
.transaction-table tbody tr:last-child td { border-bottom: 0; }
.transaction-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; }
.transaction-pagination span { color: var(--muted); font-size: 13px; text-align: center; }
.transaction-detail { width: min(calc(100vw - 24px), 820px); }
.transaction-detail .section-head { align-items: flex-start; gap: 12px; }
.transaction-detail dl { display: grid; grid-template-columns: minmax(110px, .7fr) minmax(0, 1.3fr); gap: 10px 14px; margin: 20px 0; }
.transaction-detail dt { color: var(--muted); font-size: 13px; }
.transaction-detail dd { min-width: 0; margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.transaction-events { padding-left: 20px; }
.transaction-events li { margin: 12px 0; }
.transaction-events small { display: block; color: var(--muted); }
.transaction-status-error { color: #a52222; font-weight: 700; }

@media (min-width: 540px) {
  .nav { flex-wrap: nowrap; }
  .brand-title { max-width: 250px; font-size: 13px; }
  .navlinks { width: auto; justify-content: flex-end; gap: 14px; font-size: 14px; }
  .candidate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .competition-tools { grid-template-columns: minmax(0, 1.6fr) minmax(190px, .7fr); }
  .competition-directory { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .competition-form { grid-template-columns: repeat(2, minmax(0,1fr)); align-items: end; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .transaction-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .transaction-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .result-row { grid-template-columns: 36px 58px minmax(0, 1fr) auto; gap: 14px; padding: 15px; }
  .result-row img { width: 58px; height: 58px; }
  .result-count { grid-column: auto; white-space: nowrap; }
  .panel, .stat { padding: 21px; }
}

@media (min-width: 800px) {
  html { scroll-padding-top: 82px; }
  .nav { min-height: 76px; }
  .brand img { width: 48px; height: 48px; }
  .hero-inner { min-height: 455px; grid-template-columns: minmax(0, 1.4fr) minmax(190px, .6fr); gap: 35px; }
  .hero-mark { display: grid; width: min(22vw, 230px); aspect-ratio: 1; place-items: center; justify-self: center; border: 1px solid rgb(255 255 255 / 30%); border-radius: 50%; background: rgb(255 255 255 / 6%); }
  .hero-mark img { width: 76%; aspect-ratio: 1; border-radius: 50%; padding: 14px; object-fit: contain; background: #fff; }
  .container, .admin-layout { padding-top: 48px; }
  .candidate-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
  .competition-directory { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .admin-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
  .transaction-filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .transaction-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .admin-layout > .section-head { margin-bottom: 24px; }
}

@media (min-width: 1200px) {
  .hero-inner { min-height: 490px; }
  .candidate-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
