:root {
  --c-primary: #e63946;
  --c-primary-2: #ff5a67;
  --c-bg: #f6f7fb;
  --c-card: #ffffff;
  --c-text: #1f2937;
  --c-muted: #6b7280;
  --c-border: #e5e7eb;
  --c-success: #10b981;
  --c-danger: #ef4444;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0,0,0,0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--c-bg); color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Segoe UI, Roboto, Arial, sans-serif; }
a { color: inherit; text-decoration: none; }

.page { min-height: 100vh; display: flex; flex-direction: column; }

.hero {
  background: linear-gradient(135deg, #ff8a92 0%, #e63946 55%, #a81824 100%);
  color: #fff; padding: 48px 20px 40px; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.2), transparent 40%),
              radial-gradient(circle at 80% 0%, rgba(255,255,255,0.15), transparent 40%);
}
.hero.small { padding: 24px 20px; }
.hero-inner { max-width: 1100px; margin: 0 auto; position: relative; z-index: 1; }
.hero h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: 1px; }
.hero .subtitle { margin: 0; opacity: 0.9; }

.status-bar {
  margin-top: 14px; display: inline-block; padding: 6px 12px;
  background: rgba(255,255,255,0.18); border-radius: 999px; font-size: 13px;
}
.status-bar.ok { background: rgba(16,185,129,0.25); }
.status-bar.warn { background: rgba(255,200,0,0.28); color:#3b2a00; }

main { flex: 1; padding: 24px 16px 48px; max-width: 1100px; margin: 0 auto; width: 100%; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }

.card { background: var(--c-card); border-radius: var(--radius); box-shadow: var(--shadow); }

.cand { overflow: hidden; display: flex; flex-direction: column; transition: transform .2s ease, box-shadow .2s ease; }
.cand:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0,0,0,0.12); }
.cand .photo { width: 100%; aspect-ratio: 4/3; background: #eef0f4 center/cover no-repeat; }
.cand .photo .placeholder {
  width: 100%; height: 100%; display:flex; align-items:center; justify-content:center;
  font-size: 64px; color: #c8ccd3; background: linear-gradient(135deg,#f4f6fa,#e6e9f0);
}
.cand .body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.cand .name-row { display:flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cand .name { font-size: 18px; font-weight: 700; }
.cand .votes { color: var(--c-primary); font-weight: 800; font-size: 16px; }
.cand .votes small { font-weight: 500; color: var(--c-muted); margin-left: 2px; font-size: 12px;}
.cand .bio { color: var(--c-muted); font-size: 14px; line-height: 1.6; min-height: 44px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cand .actions { margin-top: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--c-border); background: #fff;
  color: var(--c-text); font-size: 14px; cursor: pointer; transition: all .15s ease; font-weight: 600; }
.btn:hover { border-color: #d1d5db; background: #f9fafb; }
.btn.primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn.primary:hover { background: var(--c-primary-2); border-color: var(--c-primary-2); }
.btn.primary[disabled], .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--c-danger); }
.btn.danger:hover { background: #fff1f2; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.4); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,0.12); }
.btn.full { width: 100%; padding: 12px 14px; border-radius: 12px; }

.empty { padding: 40px; text-align: center; color: var(--c-muted); }

.foot { text-align: center; padding: 16px; color: var(--c-muted); font-size: 12px; }

/* Admin */
.admin-page .hero .hero-inner { display:flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.auth-info { font-size: 14px; opacity: .95; }
.login-box { max-width: 420px; margin: 40px auto; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-box h2 { margin: 0 0 6px; }
label { display: flex; flex-direction: column; font-size: 13px; color: var(--c-muted); gap: 6px; }
input[type=text], input[type=password], input[type=file], textarea {
  font-size: 14px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--c-border);
  background: #fff; color: var(--c-text); outline: none; width: 100%; font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(230,57,70,0.15); }
textarea { resize: vertical; }

.msg { font-size: 13px; min-height: 18px; }
.msg.err { color: var(--c-danger); }
.msg.ok { color: var(--c-success); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff;
  border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table thead th { background: #fafbff; font-size: 13px; color: var(--c-muted); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: none; }
.table td img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; background:#eef0f4; }
.table .ops { display: flex; gap: 8px; flex-wrap: wrap; }

/* 确保 [hidden] 属性不被 CSS 覆盖 */
[hidden] { display: none !important; }

.modal { position: fixed; inset: 0; z-index: 999; display:flex; align-items:center; justify-content:center; padding: 20px; }
.modal-mask { position: absolute; inset: 0; background: rgba(15,23,42,0.55); backdrop-filter: blur(2px); }
.modal-body { position: relative; width: 100%; max-width: 560px; padding: 22px; display: flex; flex-direction: column; gap: 14px; max-height: 90vh; overflow: auto; }
.modal-body h2 { margin: 0 0 4px; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.photo-preview { display:flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.photo-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: 10px; background:#eef0f4; border:1px solid var(--c-border); }
.photo-preview input { flex: 1; min-width: 180px; }
.modal-actions { display:flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 560px) {
  .hero h1 { font-size: 22px; }
  .table th, .table td { padding: 8px; font-size: 13px; }
  .table td img { width: 56px; height: 56px; }
}
