:root {
  --primary: #315efb;
  --primary-dark: #2449d8;
  --primary-soft: #edf2ff;
  --ink: #18223b;
  --text: #35415c;
  --muted: #7b8499;
  --line: #e6eaf2;
  --surface: #ffffff;
  --background: #f5f7fb;
  --success: #0d9f75;
  --success-soft: #e9f8f2;
  --warning: #d97706;
  --danger: #d84848;
  --shadow: 0 16px 48px rgba(30, 48, 93, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--background); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 750; letter-spacing: .16em; margin-bottom: 10px; }
.eyebrow.light { color: rgba(255,255,255,.65); }

.button { min-height: 44px; border: 0; border-radius: 11px; padding: 0 20px; font-weight: 650; transition: transform .18s, background .18s, box-shadow .18s; }
.button:not(:disabled):active { transform: translateY(1px); }
.button-primary { color: white; background: var(--primary); box-shadow: 0 8px 20px rgba(49,94,251,.2); }
.button-primary:not(:disabled):hover { background: var(--primary-dark); }
.button-secondary { color: var(--text); background: #f0f2f7; }
.button-danger { color: white; background: var(--danger); }
.button-block { width: 100%; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--muted); }
.icon-button svg { width: 21px; height: 21px; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(400px, 1.05fr) minmax(480px, .95fr); background: white; }
.login-brand { min-height: 100vh; position: relative; overflow: hidden; padding: clamp(48px, 8vw, 110px); color: white; background: linear-gradient(145deg, #183aab 0%, #315efb 55%, #5278ff 100%); display: flex; flex-direction: column; justify-content: center; }
.brand-mark { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; color: white; background: var(--primary); border-radius: 12px; font-size: 19px; font-weight: 800; }
.brand-mark-large { width: 62px; height: 62px; margin-bottom: 48px; color: white; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.28); border-radius: 18px; }
.brand-mark-large svg { width: 34px; height: 34px; }
.login-brand h1 { position: relative; z-index: 1; font-size: clamp(42px, 5vw, 68px); line-height: 1.25; letter-spacing: -.04em; }
.brand-description { position: relative; z-index: 1; margin-top: 26px; color: rgba(255,255,255,.77); line-height: 1.9; font-size: 16px; }
.brand-features { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 38px; }
.brand-features span { padding: 8px 14px; border: 1px solid rgba(255,255,255,.22); border-radius: 99px; color: rgba(255,255,255,.9); background: rgba(255,255,255,.08); font-size: 13px; }
.brand-decoration { position: absolute; width: 520px; height: 520px; right: -240px; bottom: -230px; border: 80px solid rgba(255,255,255,.055); border-radius: 50%; }
.brand-decoration::before { content: ""; position: absolute; width: 220px; height: 220px; left: -240px; top: -280px; border: 1px solid rgba(255,255,255,.09); border-radius: 50%; }
.login-panel { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(420px, 100%); }
.login-card h2 { color: var(--ink); font-size: 30px; letter-spacing: -.03em; }
.login-card form { margin-top: 24px; }
.login-intro { margin-top: 12px; font-size: 14px; line-height: 1.75; }
.mobile-brand { display: none; }
.segmented { display: inline-flex; gap: 4px; padding: 4px; background: #f0f2f7; border-radius: 11px; }
.segmented button { min-height: 34px; padding: 0 16px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 600; }
.segmented button.active { color: var(--primary); background: white; box-shadow: 0 2px 8px rgba(30,48,93,.08); }
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; margin-bottom: 8px; color: var(--text); font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; min-height: 46px; padding: 11px 13px; color: var(--ink); background: white; border: 1px solid #dce1eb; border-radius: 10px; outline: none; transition: border .18s, box-shadow .18s; }
.field textarea { min-height: 86px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(49,94,251,.1); }
.field input::placeholder, .field textarea::placeholder { color: #a5adbd; }
.privacy-note { margin-top: 20px; color: #9aa2b3; font-size: 11px; line-height: 1.7; text-align: center; }

.app-header { position: sticky; z-index: 20; top: 0; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.app-header-inner { max-width: 1180px; height: 70px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; }
.app-brand { display: flex; align-items: center; gap: 11px; }
.app-brand > div:last-child { display: flex; flex-direction: column; gap: 2px; }
.app-brand strong { color: var(--ink); font-size: 15px; }
.app-brand span { color: var(--muted); font-size: 10px; letter-spacing: .12em; }
.header-actions { display: flex; align-items: center; gap: 18px; }
.status-pill, .live-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--success); background: var(--success-soft); border-radius: 99px; padding: 6px 11px; font-size: 12px; font-weight: 650; }
.status-pill i, .live-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(13,159,117,.12); }
.status-pill.closed { color: var(--muted); background: #f0f2f5; }
.status-pill.closed i { background: var(--muted); box-shadow: none; }
.user-summary { display: flex; align-items: center; gap: 9px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 34px; color: var(--primary); background: var(--primary-soft); border-radius: 50%; font-size: 13px; font-weight: 750; }
.user-summary > div { display: flex; flex-direction: column; gap: 2px; }
.user-summary strong { color: var(--ink); font-size: 13px; }
.user-summary div span { color: var(--muted); font-size: 11px; }
.employee-main { max-width: 1180px; min-height: calc(100vh - 160px); margin: 0 auto; padding: 36px 24px 130px; }
.election-hero { display: flex; align-items: center; justify-content: space-between; gap: 32px; padding: 36px 40px; color: white; border-radius: 22px; background: linear-gradient(120deg, #2148c8, #3e67f4); box-shadow: 0 18px 45px rgba(36,73,216,.16); overflow: hidden; position: relative; }
.election-hero::after { content: ""; position: absolute; right: 28%; bottom: -110px; width: 240px; height: 240px; border: 50px solid rgba(255,255,255,.045); border-radius: 50%; }
.election-hero h1 { font-size: clamp(26px, 3.4vw, 38px); letter-spacing: -.025em; }
.election-hero > div:first-child > p:last-child { margin-top: 12px; color: rgba(255,255,255,.72); font-size: 14px; }
.hero-dept-card { min-width: 220px; position: relative; z-index: 1; padding: 20px 24px; border: 1px solid rgba(255,255,255,.18); border-radius: 15px; background: rgba(255,255,255,.1); backdrop-filter: blur(8px); }
.hero-dept-card span, .hero-dept-card small { display: block; color: rgba(255,255,255,.68); font-size: 11px; }
.hero-dept-card strong { display: block; margin: 7px 0; font-size: 21px; }
.rule-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 26px 0 40px; border: 1px solid var(--line); border-radius: 15px; background: var(--line); overflow: hidden; }
.rule-strip > div { display: flex; align-items: center; gap: 13px; padding: 18px 22px; background: white; }
.rule-number { color: #b7c4ec; font-size: 23px; font-weight: 800; letter-spacing: -.04em; }
.rule-strip p { display: flex; flex-direction: column; gap: 5px; }
.rule-strip strong { color: var(--ink); font-size: 13px; }
.rule-strip small { color: var(--muted); font-size: 11px; }
.section-heading, .results-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2, .results-heading h2 { color: var(--ink); font-size: 23px; letter-spacing: -.02em; }
.section-heading .muted, .results-heading .muted { margin-top: 8px; font-size: 13px; }
.quota-badge { display: flex; align-items: center; gap: 15px; padding: 10px 14px; background: var(--primary-soft); border-radius: 12px; }
.quota-badge > span { color: #6574a0; font-size: 11px; }
.quota-badge strong { color: var(--primary); font-size: 15px; }
.quota-badge b { font-weight: 750; }
.candidate-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.candidate-card { position: relative; min-height: 205px; padding: 22px; text-align: left; color: var(--text); background: white; border: 1.5px solid var(--line); border-radius: var(--radius); transition: border .18s, transform .18s, box-shadow .18s; }
.candidate-card:not(:disabled):hover { transform: translateY(-2px); border-color: #aebded; box-shadow: var(--shadow); }
.candidate-card.selected { border-color: var(--primary); background: linear-gradient(180deg, #fff, #f8faff); box-shadow: 0 10px 30px rgba(49,94,251,.1); }
.candidate-card:disabled { opacity: 1; cursor: default; }
.candidate-check { position: absolute; top: 18px; right: 18px; width: 23px; height: 23px; display: grid; place-items: center; color: transparent; border: 1.5px solid #d4dae6; border-radius: 7px; }
.candidate-check svg { width: 15px; height: 15px; }
.candidate-card.selected .candidate-check { color: white; background: var(--primary); border-color: var(--primary); }
.candidate-person { display: flex; align-items: center; gap: 13px; padding-right: 24px; }
.candidate-avatar { width: 48px; height: 48px; display: grid; place-items: center; flex: 0 0 48px; color: var(--primary-dark); background: #e8eeff; border-radius: 14px; font-size: 18px; font-weight: 750; }
.candidate-person h3 { color: var(--ink); font-size: 18px; }
.candidate-person p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.candidate-bio { margin-top: 19px; color: #68748b; font-size: 13px; line-height: 1.75; }
.candidate-footer { margin-top: 16px; padding-top: 13px; border-top: 1px dashed var(--line); color: #9aa3b5; font-size: 11px; }
.empty-state { padding: 45px; text-align: center; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state strong { color: var(--ink); }
.empty-state p { margin-top: 10px; font-size: 13px; }
.vote-bar { position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; padding: 12px 24px calc(12px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.95); border-top: 1px solid var(--line); box-shadow: 0 -8px 30px rgba(30,48,93,.06); backdrop-filter: blur(16px); }
.vote-bar-inner { max-width: 800px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.vote-bar-inner > div { display: flex; flex-direction: column; gap: 3px; }
.vote-bar-inner span { color: var(--muted); font-size: 11px; }
.vote-bar-inner strong { color: var(--ink); font-size: 15px; }
.vote-bar-inner strong b:first-child { color: var(--primary); font-size: 22px; }
.vote-bar .button { min-width: 210px; }
.app-footer { padding: 0 20px 30px; color: #a0a8b8; font-size: 11px; text-align: center; }
#results-section { padding-top: 8px; }
.results-heading { align-items: center; margin-top: 12px; }
.live-pill i { animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(13,159,117,0); } }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.metric-card { padding: 22px 24px; background: white; border: 1px solid var(--line); border-radius: 15px; }
.metric-card > span { color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin: 9px 0 5px; color: var(--ink); font-size: 30px; line-height: 1; }
.metric-card small { color: #a1a9b8; font-size: 11px; }
.metric-card.accent { border-color: #c9d5ff; background: linear-gradient(135deg, #f7f9ff, #edf2ff); }
.metric-card.accent strong { color: var(--primary); }
.results-card { padding: 24px; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.results-card-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 25px; }
.chart-legend { display: flex; justify-content: space-between; padding: 0 2px 12px; color: #9aa3b5; font-size: 10px; }
.result-row { display: grid; grid-template-columns: 145px 1fr 90px; align-items: center; gap: 18px; padding: 15px 0; border-top: 1px solid #f0f2f6; }
.result-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.result-person .avatar { width: 32px; height: 32px; flex-basis: 32px; }
.result-person div { min-width: 0; }
.result-person strong { display: block; color: var(--ink); font-size: 13px; }
.result-person small { color: var(--muted); font-size: 10px; }
.result-track { height: 9px; background: #edf0f6; border-radius: 99px; overflow: hidden; }
.result-fill { height: 100%; min-width: 2px; background: linear-gradient(90deg, #7895fb, var(--primary)); border-radius: 99px; transition: width .5s ease; }
.result-value { text-align: right; }
.result-value strong { color: var(--primary); font-size: 19px; }
.result-value span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.rank-badge { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 7px; color: #8a95aa; background: #f0f2f6; border-radius: 6px; font-size: 10px; }
.rank-badge.top { color: #a86400; background: #fff1d6; }
.results-footnote { margin: 14px 6px 0; color: #9ba4b5; font-size: 11px; line-height: 1.7; }
.ballot-list-header, .ballot-item { display: grid; grid-template-columns: 150px 1fr 150px; gap: 20px; align-items: center; }
.ballot-list-header { padding: 0 10px 12px; color: #9aa3b5; font-size: 11px; }
.ballot-item { padding: 15px 10px; border-top: 1px solid #f0f2f6; font-size: 12px; }
.ballot-item.mine { margin: 0 -8px; padding-left: 18px; padding-right: 18px; background: var(--primary-soft); border-radius: 10px; }
.ballot-person strong { display: block; color: var(--ink); }
.ballot-person small { color: var(--muted); }
.ballot-choices { color: var(--text); line-height: 1.6; }
.ballot-time { color: var(--muted); text-align: right; font-size: 11px; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(15,25,48,.5); backdrop-filter: blur(5px); }
.modal-card { width: min(460px, 100%); padding: 30px; background: white; border-radius: 20px; box-shadow: 0 30px 80px rgba(10,25,60,.24); }
.modal-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 18px; color: var(--primary); background: var(--primary-soft); border-radius: 14px; }
.modal-icon svg { width: 27px; height: 27px; }
.modal-card h3 { color: var(--ink); font-size: 22px; }
.modal-card > p { margin-top: 10px; font-size: 13px; line-height: 1.7; }
.confirm-candidates { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.confirm-candidates span { padding: 8px 12px; color: var(--primary-dark); background: var(--primary-soft); border-radius: 8px; font-size: 13px; font-weight: 650; }
.modal-warning { padding: 12px 14px; color: #916012; background: #fff8e9; border-radius: 9px; font-size: 11px; line-height: 1.7; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.toast { position: fixed; z-index: 200; left: 50%; top: 24px; max-width: min(440px, calc(100% - 32px)); padding: 12px 18px; color: white; background: #25314b; border-radius: 11px; box-shadow: 0 12px 35px rgba(15,25,48,.2); font-size: 13px; line-height: 1.5; opacity: 0; transform: translate(-50%, -15px); pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #c73f48; }
.toast.success { background: #07845f; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr 1fr; }
  .login-brand { padding: 45px; }
  .login-brand h1 { font-size: 42px; }
  .candidate-grid { grid-template-columns: repeat(2, 1fr); }
  .election-hero { padding: 30px; }
}

@media (max-width: 700px) {
  .login-shell { display: block; background: var(--background); padding: 28px 18px; }
  .login-brand { display: none; }
  .login-panel { min-height: calc(100vh - 56px); padding: 0; align-items: center; }
  .login-card { padding: 26px 22px; background: white; border-radius: 18px; box-shadow: var(--shadow); }
  .mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; color: var(--ink); font-weight: 700; }
  .app-header-inner { height: 62px; padding: 0 16px; }
  .app-brand .brand-mark { width: 34px; height: 34px; flex-basis: 34px; border-radius: 10px; font-size: 16px; }
  .app-brand > div:last-child span, .user-summary > div, .status-pill { display: none; }
  .header-actions { gap: 10px; }
  .employee-main { padding: 18px 14px 130px; }
  .election-hero { display: block; padding: 24px 22px; border-radius: 18px; }
  .election-hero h1 { font-size: 25px; line-height: 1.4; }
  .election-hero > div:first-child > p:last-child { font-size: 12px; line-height: 1.7; }
  .hero-dept-card { min-width: 0; margin-top: 22px; padding: 14px 16px; }
  .hero-dept-card strong { font-size: 18px; }
  .rule-strip { grid-template-columns: 1fr; margin: 18px 0 28px; }
  .rule-strip > div { padding: 13px 17px; }
  .rule-number { font-size: 20px; }
  .section-heading { align-items: center; }
  .section-heading h2, .results-heading h2 { font-size: 20px; }
  .section-heading .eyebrow, .results-heading .eyebrow { margin-bottom: 7px; }
  .quota-badge { flex-direction: column; gap: 3px; padding: 9px 12px; }
  .candidate-grid { grid-template-columns: 1fr; gap: 12px; }
  .candidate-card { min-height: 0; padding: 18px; }
  .candidate-bio { margin-top: 14px; }
  .vote-bar { padding-left: 16px; padding-right: 16px; }
  .vote-bar .button { min-width: 0; padding: 0 18px; font-size: 13px; }
  .metric-grid { gap: 8px; }
  .metric-card { padding: 16px 12px; }
  .metric-card strong { font-size: 25px; }
  .metric-card small { display: none; }
  .results-heading { align-items: flex-start; }
  .results-heading .live-pill { flex-shrink: 0; margin-top: 3px; }
  .results-card { padding: 16px 12px; }
  .results-card-header { align-items: flex-start; flex-direction: column; margin-bottom: 18px; }
  .result-row { grid-template-columns: 105px 1fr 58px; gap: 9px; }
  .result-person { gap: 6px; }
  .result-person .avatar { display: none; }
  .result-value strong { font-size: 17px; }
  .ballot-list-header { display: none; }
  .ballot-item { grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px 6px; }
  .ballot-choices { grid-column: 1 / -1; grid-row: 2; }
  .ballot-time { grid-column: 2; grid-row: 1; }
  .modal-card { padding: 24px 20px; }
}

@media (max-width: 380px) {
  .result-row { grid-template-columns: 90px 1fr 52px; }
  .segmented button { padding: 0 11px; }
}
