:root{
  --bg:#0b0f1a;
  --card: rgba(255,255,255,.05);
  --border: rgba(255,255,255,.10);
  --muted: rgba(233,238,252,.65);
  --text:#e9eefc;
  --primary1:#2f81ff;
  --primary2:#2363ff;
  --danger: rgba(255,60,60,.12);
  --dangerBorder: rgba(255,60,60,.25);
  --success: rgba(0,200,120,.12);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a{color:inherit}
.wrap{max-width:1100px; margin:40px auto; padding:0 16px;}
.card{
  background: var(--card);
  border:1px solid var(--border);
  border-radius:18px;
  padding:20px;
  box-shadow:0 10px 30px rgba(0,0,0,.35);
}
.topbar{
  display:flex; justify-content:space-between; align-items:center;
  padding:18px 20px;
}
.brand{font-weight:800; font-size:20px;}
.muted{color:var(--muted)}
hr{border:none;border-top:1px solid var(--border); margin:18px 0}

label{display:block; margin:10px 0 6px; color: rgba(233,238,252,.85);}
input,select{
  width:100%;
  padding:12px;
  border-radius:12px;
  background: rgba(0,0,0,.25);
  border:1px solid var(--border);
  color:#fff;
  outline:none;
}
input[type="file"]{padding:10px}
input[type="checkbox"]{width:auto}
button{font-family:inherit}

/* File input buttons */
input[type="file"]{
  padding:10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(0,0,0,.22);
  color: var(--muted);
}
input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button{
  background: linear-gradient(180deg,var(--primary1),var(--primary2));
  color:#fff;
  border:1px solid rgba(255,255,255,.18);
  border-radius:10px;
  padding:8px 12px;
  margin-right:10px;
  cursor:pointer;
}
input[type="file"]:hover::file-selector-button,
input[type="file"]:hover::-webkit-file-upload-button{
  filter:brightness(1.06);
}

.btn{
  display:inline-block;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  color: var(--text);
  text-decoration:none;
  background: rgba(255,255,255,.06);
  cursor:pointer;
}
.btn:hover{filter:brightness(1.06)}
.btn.primary{
  background: linear-gradient(180deg,var(--primary1),var(--primary2));
  border-color: rgba(255,255,255,.18);
}
.btn.danger{
  background: rgba(255,60,60,.15);
  border-color: rgba(255,80,80,.25);
}
.btn.danger:hover{filter:brightness(1.1)}
.pill{
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  border:1px solid var(--border);
  display:inline-block;
}
.pill.green{background:var(--success)}
.pill.red{background:var(--danger)}

.error{
  background: var(--danger);
  border:1px solid var(--dangerBorder);
  padding:10px 12px;
  border-radius:12px;
}
.success{
  background: var(--success);
  border:1px solid rgba(0,200,120,.25);
  padding:10px 12px;
  border-radius:12px;
}

.table{
  width:100%;
  border-collapse:collapse;
  margin-top:10px;
}
.table th,.table td{
  padding:12px;
  border-bottom:1px solid rgba(255,255,255,.08);
  text-align:left;
  vertical-align:top;
}
.row-actions .btn{margin-right:6px; margin-bottom:6px}
.actions{display:flex; gap:10px; flex-wrap:wrap; margin-bottom:12px}
.footer-actions{display:flex; gap:10px; margin-top:16px; flex-wrap:wrap}

.grid{
  display:grid;
  grid-template-columns: 2fr 1.5fr 1.5fr 1.5fr auto;
  gap:10px;
  align-items:end;
}
@media (max-width: 980px){
  .grid{grid-template-columns:1fr}
}
.candidate-row{
  margin:12px 0;
  padding:12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.18);
}
.thumb{
  width:44px; height:44px; object-fit:cover;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  margin-right:6px;
}

/* Ballot (acta) */
.ballot{margin-top:16px;}
.ballot-row{
  display:grid;
  grid-template-columns: 46px 76px 76px 1fr;
  gap:12px;
  align-items:center;
  padding:14px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  margin-bottom:10px;
  cursor:pointer;
  background: rgba(0,0,0,.12);
}
.ballot-row:hover{background: rgba(255,255,255,.04)}
.ballot-row input{
  width:26px;
  height:26px;
  appearance:none;
  -webkit-appearance:none;
  border:2px solid rgba(255,255,255,.6);
  border-radius:6px;
  background: rgba(0,0,0,.25);
  position:relative;
}
.ballot-row input:checked{
  border-color: var(--primary1);
  background: rgba(47,129,255,.18);
}
.ballot-row input:checked::after{
  content:'✕';
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  font-weight:700;
  font-size:16px;
}
.ballot-cell img{
  width:72px; height:72px; object-fit:cover;
  border-radius:10px;
  background: rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
}
.cand-name{font-weight:800}

/* Responsive ballot */
@media (max-width: 720px){
  .ballot-row{
    grid-template-columns: 42px 64px 64px 1fr;
    gap:10px;
    padding:12px;
  }
  .ballot-row input{
    width:22px; height:22px;
    border-radius:5px;
  }
  .ballot-row input:checked::after{font-size:14px;}
  .ballot-cell img{
    width:64px; height:64px;
    border-radius:8px;
  }
  h1{font-size:26px;}
  .wrap{padding:0 12px;}
  .card{padding:16px;}
  .copybox{flex-direction:column; align-items:flex-start;}
  .copybox .code{width:100%;}
  .copybox .btn{width:100%; text-align:center;}
}

@media (max-width: 520px){
  .ballot-row{
    grid-template-columns: 38px 56px 56px 1fr;
    gap:8px;
    padding:10px;
  }
  .ballot-row input{
    width:20px; height:20px;
  }
  .ballot-cell img{
    width:56px; height:56px;
  }
  .cand-name{font-size:15px;}
  .copybox .code{font-size:14px;}
}

/* Results */
.results .result-row{
  display:grid;
  grid-template-columns: 140px 1fr 110px;
  gap:12px;
  align-items:center;
  padding:12px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.r-left{display:flex; align-items:center; gap:6px}
.bar{
  height:12px;
  border-radius:999px;
  background: rgba(255,255,255,.08);
  overflow:hidden;
  margin-top:10px;
}
.bar-fill{
  height:100%;
  background: linear-gradient(90deg,#2f81ff,#6aa6ff);
}
.small{font-size:12px}
.copybox{
  display:flex; gap:10px; align-items:center; flex-wrap:wrap;
  padding:10px; border:1px solid rgba(255,255,255,.08); border-radius:12px;
  background: rgba(0,0,0,.14);
}
.code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  padding:6px 10px; border-radius:10px; background: rgba(0,0,0,.25);
  border:1px solid rgba(255,255,255,.08);
  word-break: break-word;
  overflow-wrap: anywhere;
}
