:root {
  --navy-950: #050d1d;
  --navy-900: #07162f;
  --navy-800: #0b2347;
  --blue-600: #087be8;
  --blue-500: #16a7f5;
  --cyan-300: #82ddff;
  --white: #ffffff;
  --slate-50: #f5f9fd;
  --slate-100: #e9f0f7;
  --slate-300: #b9c7d8;
  --slate-500: #65758b;
  --slate-700: #34445b;
  --danger: #d53848;
  --success: #0d9b70;
  --shadow: 0 24px 70px rgba(0, 17, 44, .18);
  --radius-lg: 28px;
  --radius-md: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--navy-950); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--white);
  background:
    radial-gradient(circle at 8% 15%, rgba(13, 132, 229, .2), transparent 25rem),
    linear-gradient(145deg, var(--navy-950), var(--navy-900) 52%, #081d3c);
  font-family: "Source Sans 3", sans-serif;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ambient { position: fixed; border-radius: 999px; filter: blur(2px); pointer-events: none; opacity: .35; }
.ambient-one { width: 28rem; height: 28rem; right: -16rem; top: 5rem; border: 1px solid rgba(74, 182, 255, .4); }
.ambient-two { width: 12rem; height: 12rem; left: 42%; bottom: -8rem; background: rgba(0, 127, 255, .18); filter: blur(40px); }

.site-header {
  width: min(1240px, calc(100% - 48px));
  height: 104px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 8;
}
.brand img { width: 150px; height: 72px; object-fit: contain; }
.admin-link, .back-button { color: var(--slate-300); background: none; border: 0; padding: 10px; }
.admin-link:hover, .back-button:hover { color: var(--white); }

.app-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; position: relative; z-index: 1; }
.app-shell:focus { outline: none; }
.screen { animation: appear .42s ease both; }
.login-layout { min-height: calc(100vh - 144px); display: grid; grid-template-columns: 1.25fr .75fr; align-items: center; gap: 80px; padding-bottom: 72px; }
.hero-copy { max-width: 700px; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; color: var(--cyan-300); font-family: "Lexend", sans-serif; font-size: 12px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue-500); box-shadow: 0 0 0 6px rgba(22, 167, 245, .12); }
h1, h2, h3 { font-family: "Lexend", sans-serif; margin: 0; letter-spacing: -.035em; }
.hero-copy h1 { font-size: clamp(48px, 6.5vw, 88px); line-height: .98; margin: 28px 0 30px; }
.hero-copy h1 span { color: transparent; background: linear-gradient(110deg, #92e6ff, #0d88ee); background-clip: text; -webkit-background-clip: text; }
.hero-copy > p { max-width: 590px; color: var(--slate-300); font-size: 20px; line-height: 1.6; }
.trust-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 36px; }
.trust-row span { color: #c9d8e8; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.1); border-radius: 99px; padding: 9px 14px; font-size: 14px; }

.panel { background: var(--white); color: var(--navy-900); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.login-card { padding: 42px; }
.step-mark { width: fit-content; color: var(--blue-600); background: #eaf5ff; border-radius: 99px; padding: 7px 12px; font-weight: 600; font-size: 13px; }
.login-card h2 { font-size: 31px; margin: 22px 0 10px; }
.login-card > p { color: var(--slate-500); line-height: 1.55; margin: 0 0 28px; }
label { display: block; color: var(--slate-700); font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.input-wrap { position: relative; }
.input-wrap svg { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); width: 21px; fill: none; stroke: var(--slate-500); stroke-width: 1.8; }
input { width: 100%; height: 56px; border: 1px solid #cbd7e4; border-radius: 14px; padding: 0 17px; color: var(--navy-900); background: var(--slate-50); outline: none; transition: .2s; }
.input-wrap input { padding-left: 50px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(22, 167, 245, .14); background: var(--white); }
.field-error { min-height: 21px; color: var(--danger) !important; font-size: 14px; margin: 7px 0 !important; }
.primary-button, .secondary-button { min-height: 52px; border-radius: 14px; border: 0; font-family: "Lexend", sans-serif; font-weight: 600; display: inline-flex; justify-content: center; align-items: center; gap: 12px; padding: 0 22px; transition: transform .18s, box-shadow .18s, background .18s; }
.primary-button { color: var(--white); background: linear-gradient(115deg, var(--blue-600), #10aaf5); box-shadow: 0 10px 24px rgba(8, 123, 232, .25); }
.login-card .primary-button { width: 100%; }
.primary-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.primary-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(8, 123, 232, .32); }
.primary-button:disabled { opacity: .48; cursor: not-allowed; box-shadow: none; }
.secondary-button { color: var(--slate-700); background: var(--slate-100); }
.demo-note { margin: 20px 0 0 !important; padding-top: 18px; border-top: 1px solid var(--slate-100); text-align: center; font-size: 13px; }

.vote-header { display: flex; justify-content: space-between; align-items: end; gap: 32px; margin: 40px 0 50px; }
.vote-header h1 { font-size: clamp(36px, 5vw, 58px); margin: 12px 0; }
.vote-header p { color: var(--slate-300); margin: 0; font-size: 18px; }
.group-section { margin-bottom: 54px; }
.group-heading { display: flex; align-items: start; gap: 18px; margin-bottom: 22px; }
.group-index { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center; color: var(--cyan-300); background: rgba(22,167,245,.12); border: 1px solid rgba(130,221,255,.18); font-family: "Lexend"; font-weight: 700; }
.group-heading h2 { font-size: 25px; }
.group-heading p { color: var(--slate-300); margin: 6px 0 0; }
.candidate-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.candidate-card {
  position: relative;
  min-height: 180px;
  padding: 22px;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-100);
  color: var(--navy-900);
  background: var(--white);
  cursor: pointer;
  transition: transform .2s, border-color .2s, background .2s, box-shadow .2s;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .03);
}
.candidate-card:hover:not(.disabled) {
  transform: translateY(-3px);
  border-color: var(--blue-500);
  background: var(--slate-50);
  box-shadow: 0 8px 24px rgba(0, 17, 44, .08);
}
.candidate-card.selected {
  border-color: var(--blue-500);
  background: linear-gradient(145deg, #eef7ff, #e3f2fd);
  box-shadow: 0 8px 24px rgba(8, 123, 232, .12), inset 0 0 0 1px rgba(8, 123, 232, .1);
}
.candidate-card.disabled {
  opacity: .5;
  cursor: not-allowed;
  background: var(--slate-100);
  border-color: var(--slate-300);
}
.candidate-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.candidate-card:focus-within {
  outline: 3px solid rgba(8, 123, 232, .3);
  outline-offset: 3px;
}
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.number {
  color: var(--blue-600);
  font: 700 13px "Lexend";
  letter-spacing: .08em;
}
.check {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid var(--slate-300);
  border-radius: 50%;
}
.check svg {
  width: 14px;
  fill: none;
  stroke: transparent;
  stroke-width: 2.3;
}
.selected .check {
  background: var(--blue-500);
  border-color: var(--blue-500);
}
.selected .check svg {
  stroke: var(--white);
}
.candidate-card h3 {
  font-size: 18px;
  margin: 28px 0 7px;
  color: var(--navy-950);
}
.candidate-card p {
  color: var(--slate-500);
  margin: 0;
  line-height: 1.45;
}
.self-badge {
  display: inline-block;
  margin-top: 13px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}
.submit-bar { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 0; margin: 36px 0 40px; }
.submit-bar .field-error { min-height: 0; margin: 0 !important; text-align: center; }

.centered-screen { min-height: calc(100vh - 150px); display: grid; place-items: center; padding-bottom: 60px; }
.success-card { width: min(620px, 100%); padding: 58px; text-align: center; }
.success-icon { width: 72px; height: 72px; margin: 0 auto 28px; border-radius: 50%; display: grid; place-items: center; color: var(--white); background: linear-gradient(145deg, var(--success), #21c68f); box-shadow: 0 12px 30px rgba(13,155,112,.3); }
.success-icon svg { width: 34px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.success-card h1 { font-size: 38px; margin: 15px 0; }
.success-card > p { color: var(--slate-500); font-size: 18px; line-height: 1.6; }
.receipt { margin-top: 30px; padding: 17px; border-radius: 14px; background: var(--slate-50); }
.receipt span, .receipt strong { display: block; }
.receipt span { color: var(--slate-500); font-size: 13px; }
.receipt strong { margin-top: 5px; letter-spacing: .13em; }


.admin-panel { width: min(920px, 100%); padding: 42px; }
.admin-panel h1 { font-size: 38px; margin: 12px 0 25px; }
.back-button { color: var(--slate-500); margin: -10px 0 24px -10px; }
.admin-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.result-summary { display: flex; gap: 12px; margin: 26px 0; }
.metric { flex: 1; padding: 18px; background: var(--slate-50); border-radius: 14px; }
.metric span, .metric strong { display: block; }
.metric span { color: var(--slate-500); font-size: 13px; }
.metric strong { font: 700 27px "Lexend"; margin-top: 3px; }
.result-group { margin-top: 30px; }
.result-group h2 { margin-bottom: 12px; }
.tie-warning { color: #965f00; background: #fff4d6; border-radius: 10px; padding: 10px 13px; }
.result-row { display: grid; grid-template-columns: 40px 52px 1fr auto; align-items: center; gap: 10px; border-top: 1px solid var(--slate-100); padding: 12px 4px; }
.result-row.winner { background: #f0f9ff; }
.result-row.tie { background: #fffaf0; }
.rank { color: var(--slate-500); text-align: center; }
.result-votes { font-family: "Lexend"; font-weight: 700; }

@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 960px) {
  .login-layout { grid-template-columns: 1fr 420px; gap: 35px; }
  .candidate-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .site-header, .app-shell { width: min(100% - 28px, 600px); }
  .site-header { height: 86px; }
  .brand img { width: 126px; }
  .admin-link { font-size: 13px; }
  .login-layout { display: block; padding: 45px 0 50px; }
  .hero-copy h1 { font-size: 50px; }
  .hero-copy > p { font-size: 17px; }
  .trust-row { margin: 25px 0 35px; }
  .login-card { padding: 28px 23px; }
  .vote-header { display: block; margin: 30px 0 36px; }
  .vote-header h1 { font-size: 38px; }
  .candidate-grid { grid-template-columns: 1fr; }
  .candidate-card { min-height: 96px; padding: 12px 14px; }
  .candidate-card h3 { font-size: 16px; margin: 14px 0 2px; }
  .submit-bar { display: block; padding: 0; margin-top: 24px; }
  .submit-bar .primary-button { width: 100%; }
  .success-card, .admin-panel { padding: 32px 23px; }
  .success-card h1 { font-size: 31px; }
  .admin-row { grid-template-columns: 1fr; }
  .result-row { grid-template-columns: 30px 44px 1fr auto; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Authentication gate: the ballot is the home screen, never a second page. */
.vote-surface {
  transition: filter .32s ease, opacity .32s ease, transform .32s ease;
}

.vote-surface.locked {
  filter: blur(8px);
  opacity: .38;
  transform: scale(.985);
  pointer-events: none;
  user-select: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px 14px;
  overflow-y: auto;
  background: rgba(2, 10, 24, .32);
  backdrop-filter: blur(2px);
  transition: opacity .3s ease, visibility .3s ease;
}

.auth-overlay.unlocked {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-card {
  width: min(100%, 420px);
  padding: 27px 22px 21px;
  animation: auth-enter .42s cubic-bezier(.2, .8, .2, 1) both;
}

.auth-brandline {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--blue-600);
  font: 600 11px "Lexend", sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 17px 0 11px;
  font-size: clamp(34px, 10vw, 47px);
  line-height: 1.02;
}

.auth-card > p {
  margin: 0 0 23px;
  color: var(--slate-500);
  font-size: 16px;
  line-height: 1.5;
}

.auth-card .primary-button {
  width: 100%;
}

.auth-card .demo-note {
  margin-top: 14px !important;
  padding-top: 13px;
}

@keyframes auth-enter {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* Mobile-first ballot sizing. */
.app-shell { width: min(100% - 28px, 1240px); }
.site-header { width: min(100% - 28px, 1240px); height: 82px; }
.brand img { width: 122px; height: 62px; }
.vote-header { display: block; margin: 28px 0 34px; }
.vote-header h1 { font-size: 36px; line-height: 1.08; }
.vote-header p { font-size: 16px; line-height: 1.5; }
.candidate-grid { grid-template-columns: 1fr; }
.candidate-card { min-height: 96px; padding: 12px 14px; }
.candidate-card h3 { font-size: 16px; margin: 14px 0 2px; }
.submit-bar { display: block; padding: 0; margin-top: 24px; }
.submit-bar .primary-button { width: 100%; min-height: 56px; }

@media (min-width: 700px) {
  .auth-card { padding: 38px; }
  .site-header { height: 96px; }
  .brand img { width: 145px; height: 70px; }
  .vote-header { display: flex; margin: 36px 0 44px; }
  .candidate-grid { grid-template-columns: repeat(2, 1fr); }
  .submit-bar { display: flex; padding: 0; margin-top: 36px; }
  .submit-bar .primary-button { width: auto; min-height: 52px; }
}

@media (min-width: 1024px) {
  /* Side-by-side group layout */
  #groups-container {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 36px;
    align-items: start;
  }
  .group-section {
    margin-bottom: 0;
  }
  
  /* Left column: Năng lực (3 columns for cards) */
  [aria-labelledby="group-nang-luc"] .candidate-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 12px;
  }
  
  /* Right column: Nỗ lực (2 columns for cards) */
  [aria-labelledby="group-no-luc"] .candidate-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }

  /* Make header and margins compact on desktop to fit on 1 screen */
  .site-header {
    height: 70px;
  }
  .brand img {
    width: 120px;
    height: 55px;
  }
  .vote-header {
    margin: 16px 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .vote-header h1 {
    font-size: 26px;
    margin: 0;
  }
  .vote-header .eyebrow {
    font-size: 11px;
    margin-bottom: 2px;
  }
  .group-heading {
    margin-bottom: 14px;
    gap: 12px;
  }
  .group-index {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 13px;
  }
  .group-heading h2 {
    font-size: 18px;
  }
  .group-heading p {
    font-size: 13px;
    margin-top: 3px;
  }
  
  /* Compact cards for desktop */
  .candidate-card {
    min-height: 104px;
    padding: 12px 14px;
    border-radius: 12px;
  }
  .candidate-card h3 {
    font-size: 15px;
    margin: 14px 0 4px;
  }
  .candidate-card p {
    font-size: 12px;
  }
  .check {
    width: 20px;
    height: 20px;
  }
  .check svg {
    width: 11px;
  }
  .number {
    font-size: 11px;
  }
  .self-badge {
    margin-top: 6px;
    font-size: 11px;
  }
  
  /* Compact submit bar */
  .submit-bar {
    margin-top: 24px;
    margin-bottom: 20px;
  }
}

/* Detailed Votes Table Styling */
.votes-table th, .votes-table td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--slate-100);
}
.votes-table tbody tr:hover {
  background: var(--slate-50);
}
.table-responsive {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-100);
  padding: 8px;
}

.site-footer {
  text-align: center;
  padding: 40px 0 32px;
  color: var(--slate-500);
  font-size: 11px;
  font-family: "Lexend", sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}
.site-footer strong {
  color: var(--blue-500);
  font-weight: 700;
}

