:root {
  --ink: #16234F;
  --ink-soft: #3B4A7A;
  --royal: #3457D5;
  --royal-soft: #E4E9FB;
  --paper: #FFFFFF;
  --bg: #F4F6FD;
  --line: #D7DEF3;
  --green: #1E6E4E;
  --green-bg: #E3F3EC;
  --red: #B0362E;
  --muted: #6B7590;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--royal); text-decoration: none; }

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow {
  max-width: 460px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Top bar */
.topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar .back {
  color: var(--royal);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar .divider {
  width: 1px; height: 20px; background: var(--line);
}
.topbar .title { font-weight: 700; font-size: 15px; color: var(--ink); }
.topbar .subtitle { font-size: 12px; color: var(--muted); }
.topbar-logout {
  margin-left: auto; font-weight: 700; font-size: 13px;
  color: var(--red); white-space: nowrap;
}

/* Hero / landing */
.hero { text-align: center; padding: 56px 20px 30px; }
.hero-logo {
  width: 88px; height: 88px; object-fit: contain;
  margin: 0 auto 16px; display: block;
}
.seal {
  width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--royal); color: var(--royal);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; margin: 0 auto 16px;
  background: var(--paper);
}
.hero h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 30px; color: var(--ink); margin: 0 0 8px;
}
.hero p { color: var(--ink-soft); margin: 0; font-size: 15px; }

.portal-grid {
  display: grid; gap: 16px; grid-template-columns: 1fr;
  max-width: 900px; margin: 0 auto; padding: 0 20px 40px;
}
@media (min-width: 700px) {
  .portal-grid { grid-template-columns: repeat(3, 1fr); }
}
.portal-card {
  background: var(--paper); border: 1.5px solid var(--line);
  border-radius: 16px; padding: 20px; text-align: left;
  cursor: pointer; font: inherit; color: inherit;
}
.portal-card:hover { border-color: var(--royal); }
.portal-card .icon { color: var(--royal); font-size: 22px; }
.portal-card .name { font-weight: 700; margin-top: 12px; color: var(--ink); }
.portal-card .desc { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Ballot card (code entry) */
.ballot-wrap { max-width: 420px; margin: 24px auto 32px; padding: 0 12px; }
.ballot-card {
  position: relative;
  background: var(--paper);
  border: 1.5px dashed var(--line);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 1px 3px rgba(22,35,79,0.08);
}
.ballot-card::before, .ballot-card::after {
  content: ""; position: absolute; width: 22px; height: 22px;
  border-radius: 50%; background: var(--bg); border: 1.5px dashed var(--line);
  top: 50%; transform: translateY(-50%);
}
.ballot-card::before { left: -12px; }
.ballot-card::after { right: -12px; }

.field { display: block; margin-bottom: 14px; }
.field .label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; color: var(--ink); background: var(--paper);
  font-family: inherit;
}
.field input.code-input {
  text-align: center; font-family: 'Courier New', monospace;
  letter-spacing: 0.15em; font-weight: 700; text-transform: uppercase;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; padding: 11px 18px; font-weight: 700; font-size: 14px;
  border: none; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--royal); color: #fff; width: 100%; }
.btn-primary:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn-secondary { background: var(--paper); color: var(--royal); border: 1px solid var(--line); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-danger-outline { background: transparent; color: var(--red); border: none; cursor: pointer; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 12px; }

.error-text {
  color: var(--red); font-size: 12px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}

/* Status badges */
.badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
}
.badge-muted { background: var(--bg); color: var(--muted); }
.badge-royal { background: var(--royal-soft); color: var(--royal); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-dark { background: var(--ink); color: #fff; }

/* Generic panel / card */
.panel {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px; margin-bottom: 20px;
}
.row-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.row-card .r-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.row-card .r-sub { font-size: 12px; color: var(--muted); }

/* Voting container (parent page) */
.voting-container {
  background: var(--paper); border: 1.5px dashed var(--royal);
  border-radius: 18px; padding: 20px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(22,35,79,0.08);
}
.voting-container .kind { font-size: 12px; font-weight: 700; color: var(--royal); margin-bottom: 4px; }
.voting-container .title { font-family: Georgia, serif; font-size: 17px; font-weight: 700; color: var(--ink); margin-bottom: 12px; }

.nominee-option {
  width: 100%; text-align: left; border-radius: 12px; padding: 12px 16px;
  font-size: 14px; font-weight: 600; color: var(--ink);
  border: 1.5px solid var(--line); background: var(--paper);
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; margin-bottom: 8px; font-family: inherit;
}
.nominee-option.selected { border-color: var(--royal); background: var(--royal-soft); }
.nominee-option:disabled { opacity: 0.55; cursor: not-allowed; }

.status-row {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.status-row .note-done { color: var(--green); font-size: 12px; }
.status-row .note-pending { color: var(--muted); font-size: 12px; }

/* Admin tab nav */
.tabbar { display: flex; gap: 6px; overflow-x: auto; padding: 16px 0; }
.tabbar a {
  display: flex; align-items: center; gap: 6px; padding: 9px 14px;
  border-radius: 10px; font-size: 13px; font-weight: 600; white-space: nowrap;
  color: var(--ink-soft);
}
.tabbar a.active { background: var(--royal); color: #fff; }

.grade-pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.grade-pill {
  padding: 7px 14px; border-radius: 10px; font-size: 12px; font-weight: 600;
  background: var(--bg); color: var(--ink-soft); border: none; cursor: pointer; font-family: inherit;
}
.grade-pill.active { background: var(--royal); color: #fff; }

.bar-row { margin-bottom: 10px; }
.bar-row .bar-labels { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.bar-track { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--ink); }
.bar-fill.highlight { background: var(--royal); }

.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 4px; }
.form-row .field { flex: 1; min-width: 140px; margin-bottom: 0; }

.helper-text { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

.lock-note { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }

table.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
table.plain th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
table.plain td { padding: 8px; border-bottom: 1px solid var(--line); }

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
