/* =============================================================
   HALALina - Theme
   White & green LMS-style design
   Primary green: #16a34a (Tailwind green-600)
   ============================================================= */

:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-darker: #166534;
  --primary-light: #dcfce7;
  --primary-lighter: #f0fdf4;
  --accent: #65a30d;
  --bg: #ffffff;
  --bg-soft: #f7faf8;
  --bg-card: #ffffff;
  --text: #0f172a;
  --text-soft: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --warning: #d97706;
  --info: #0ea5e9;
  --info-bg: #f0f9ff;
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.10), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-sm: 6px;
  --transition: 150ms ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg-soft);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

a { color: var(--primary-dark); text-decoration: none; }
a:hover { color: var(--primary-darker); text-decoration: underline; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 50%, #ecfdf5 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  top: -120px; right: -120px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(22,163,74,0.08) 0%, transparent 70%);
}
.login-page::after {
  content: '';
  position: absolute;
  bottom: -120px; left: -120px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(22,163,74,0.06) 0%, transparent 70%);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 40px;
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 1;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  /* Logo is a circular badge (PNG with transparent corners) so we
     don't tint the background. A subtle white border helps it pop
     on the soft-green login background. */
  background: white;
  border: 2px solid var(--primary-light);
  object-fit: contain;
  padding: 2px;
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.18);
  /* Override the old text-based styling (font-weight, color: white)
     since we're now using an <img> element. */
  font-weight: 400;
  color: inherit;
  display: inline-block;
}
.brand-mark-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 2px;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.15);
}
.login-brand h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand-subtitle {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.login-tagline {
  margin-bottom: 24px;
  padding: 12px 16px;
  background: var(--primary-lighter);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  color: var(--primary-darker);
  font-size: 13.5px;
  line-height: 1.5;
}

form label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text-soft);
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
form input[type="text"],
form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  margin-bottom: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
  letter-spacing: 0.05em;
}
form input[type="text"]:focus,
form input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-top: 8px;
}

.login-help {
  margin-top: 24px;
  padding: 16px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
}
.login-help strong {
  color: var(--text);
  font-size: 13px;
}
.login-help ul {
  margin: 8px 0 12px;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-soft);
  font-family: 'Courier New', monospace;
  list-style: square;
}
.login-help ul li { margin-bottom: 3px; }
.login-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.login-footer {
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  max-width: 460px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.btn-outline {
  background: transparent;
  color: var(--primary-dark);
  border-color: var(--primary);
}
.btn-outline:hover:not(:disabled) {
  background: var(--primary-lighter);
}
.btn-secondary {
  background: white;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-soft);
}
.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-title {
  display: block;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-subtitle {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 14px;
  transition: all var(--transition);
}
.nav-link:hover {
  background: var(--primary-lighter);
  color: var(--primary-darker);
  text-decoration: none;
}
.nav-link.active {
  background: var(--primary);
  color: white;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-info { text-align: right; }
.user-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.user-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.tab-content {
  display: none;
  padding: 24px 32px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}
.tab-content.active { display: block; }

.page-header { margin-bottom: 24px; }
.page-header h2 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.page-header p {
  margin: 0;
  color: var(--text-soft);
  font-size: 14.5px;
  max-width: 880px;
}

/* ============================================================
   ELECTION STATUS BANNER
   ============================================================ */
.election-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary-lighter);
  border: 1px solid var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 12px 18px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--primary-darker);
  font-weight: 500;
}
.election-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0.1); }
}

/* ============================================================
   CALLOUTS
   ============================================================ */
.callout {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  border-left: 4px solid;
}
.callout h3 { margin: 0 0 6px; font-size: 16px; }
.callout p { margin: 0; font-size: 14px; }
.callout-info { background: var(--info-bg); border-color: var(--info); color: #0c4a6e; }
.callout-success { background: var(--primary-lighter); border-color: var(--success); color: var(--primary-darker); }
.callout-error { background: var(--danger-bg); border-color: var(--danger); color: #991b1b; }
.callout-warning { background: #fffbeb; border-color: var(--warning); color: #92400e; }

/* ============================================================
   BALLOT / VOTING PANEL
   ============================================================ */
.position-group {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.position-group-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.position-group-header .position-info {
  font-weight: 500;
  font-size: 13px;
  opacity: 0.9;
}
.candidate-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  padding: 18px;
}

.candidate-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  background: white;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.candidate-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.candidate-card.selected {
  border-color: var(--primary);
  background: var(--primary-lighter);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
}
.candidate-card.selected::after {
  content: '✓ Selected';
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--primary);
  color: white;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.candidate-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.candidate-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--avatar-color, var(--primary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}
.candidate-info {
  flex: 1;
  min-width: 0;
}
.candidate-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 2px;
}
.candidate-party {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-darker);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
}
.candidate-program {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
}
.candidate-platform {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.55;
  padding-left: 14px;
  border-left: 2px solid var(--primary-light);
}
.candidate-platform ul {
  margin: 0;
  padding-left: 18px;
}

/* ============================================================
   VOTE ACTIONS
   ============================================================ */
.vote-actions {
  margin-top: 28px;
  padding: 24px;
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.vote-action-hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
  font-weight: 700;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg-soft); }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.receipt-box {
  background: var(--primary-lighter);
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  text-align: center;
}
.receipt-code {
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-darker);
  letter-spacing: 0.05em;
  word-break: break-all;
  margin: 8px 0;
}
.receipt-label {
  font-size: 12px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.receipt-rows {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.receipt-rows strong { color: var(--text); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.receipt-rows .mono {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  word-break: break-all;
}

.receipt-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
}

/* ============================================================
   CANDIDATES GRID
   All cards in the same row have EQUAL HEIGHT. This is achieved
   with CSS grid (grid-auto-rows: 1fr makes each row's height
   equal to the tallest card in that row) + flexbox (each card is
   a flex column where the credentials list grows to fill the
   remaining space, so cards with shorter credential lists still
   stretch to match the tallest one in the row).
   ============================================================ */
.candidates-grid {
  display: grid;
  /* 3 columns at desktop, 2 at medium, 1 at mobile - all rows equal height */
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: stretch;       /* cards stretch to fill row height */
}

@media (max-width: 1100px) {
  .candidates-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .candidates-grid { grid-template-columns: 1fr; }
}

.candidate-full-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  /* height: 100% lets the card stretch to the row height set by the grid */
  height: 100%;
}
.candidate-full-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Header: fixed-height so the section titles below align across cards */
.candidate-full-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-height: 110px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;             /* header takes its natural height, doesn't grow */
}
.candidate-full-header > .candidate-avatar {
  flex: 0 0 60px;          /* fixed width */
  width: 60px;
  height: 60px;
  font-size: 22px;
}
.candidate-full-header > div {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.candidate-full-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
  line-height: 1.3;
  /* Allow up to 2 lines for long names - fixed height so the
     position/party line below is at the same y on every card. */
  min-height: 44px;          /* ~2 lines at 17px / 1.3 line-height */
}
.candidate-full-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 4px;
  /* Give it a fixed min-height so 2-line party/position text doesn't
     push the rest of the card down. */
  min-height: 36px;          /* ~2 lines at 13px / 1.4 line-height */
  line-height: 1.4;
}
.candidate-program {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 6px;
}

/* Section titles - pinned so all cards' "Platform" titles align */
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 14px 0 6px;
  flex: 0 0 auto;
}
.section-title-platform {
  margin-top: 4px;
}
.section-title-credentials {
  margin-top: 14px;
}

.platform-list, .credentials-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.6;
  /* The credentials list grows to fill the remaining space so cards
     in the same row end up the same height even when their content
     lengths differ. */
  flex: 1 1 auto;
}
.platform-list {
  /* Platform list always has 3 items - give it a FIXED height (not just
     min-height) so the "Credentials" section title sits at exactly the
     same offset on every card. flex: 0 0 160px means the list takes
     exactly 160px (it doesn't grow or shrink), which fits up to 6
     wrapped lines at 13.5px / 1.6 line-height. If a platform item
     needs more room, it overflows gracefully. */
  flex: 0 0 160px;
  overflow: hidden;
}
.credentials-list {
  /* min-height so very short lists still give the card some height.
     100px fits ~5 lines at 13.5px / 1.6 line-height. */
  min-height: 100px;
}
.platform-list li, .credentials-list li { margin-bottom: 4px; }

.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--primary);
  color: white;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
  align-self: flex-start;
  max-width: 100%;
}

/* ============================================================
   AUDIT & LIVE TALLY
   ============================================================ */
.audit-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-soft);
}
.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.card-body { padding: 18px 20px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-green {
  background: var(--primary-light);
  color: var(--primary-darker);
  border-color: var(--primary-light);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat-block {
  background: var(--bg-soft);
  padding: 14px;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
}
.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 4px;
}
.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-darker);
  line-height: 1;
}

.tally-position {
  margin-bottom: 16px;
}
.tally-position-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.tally-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.tally-row-name {
  flex: 0 0 38%;
  color: var(--text-soft);
  font-weight: 500;
}
.tally-row-bar {
  flex: 1;
  height: 22px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.tally-row-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 4px;
  transition: width 0.5s ease;
  min-width: 2px;
}
.tally-row-count {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.tally-row-pct {
  flex: 0 0 50px;
  text-align: right;
  font-weight: 600;
  color: var(--text);
  font-size: 12.5px;
}

.tally-footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: right;
}

/* Audit trail */
.audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}
.audit-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-soft);
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  margin: 0;
}
.audit-filters select {
  padding: 6px 10px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: white;
  color: var(--text);
  font-family: inherit;
}

.audit-log-list {
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.audit-log-entry {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 160px 200px 1fr;
  gap: 12px;
  align-items: start;
  font-size: 12.5px;
}
.audit-log-entry:last-child { border-bottom: none; }
.audit-log-entry:hover { background: white; }
.audit-log-time {
  color: var(--text-muted);
  font-family: 'Courier New', monospace;
  font-size: 11.5px;
}
.audit-log-action {
  font-weight: 600;
  font-size: 12px;
}
.audit-log-actor {
  color: var(--text-soft);
  font-family: 'Courier New', monospace;
  font-size: 11.5px;
}
.audit-log-details {
  color: var(--text-soft);
  font-size: 12px;
  word-break: break-all;
}

.action-LOGIN_SUCCESS { color: var(--success); }
.action-LOGIN_FAILED { color: var(--danger); }
.action-LOGIN_REJECTED_ALREADY_VOTED { color: var(--warning); }
.action-LOGOUT { color: var(--text-muted); }
.action-VOTE_CAST { color: var(--primary-darker); font-weight: 700; }
.action-VOTE_VERIFIED { color: var(--info); }
.action-VOTE_NOT_FOUND { color: var(--warning); }
.action-BLOCKCHAIN_VALID { color: var(--success); }
.action-BLOCKCHAIN_INVALID { color: var(--danger); }
.action-SYSTEM_ACTION { color: var(--text-muted); }

/* Blockchain list */
.blockchain-list {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.blockchain-block {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: white;
}
.blockchain-block:last-child { border-bottom: none; }
.blockchain-block.genesis {
  background: var(--primary-lighter);
}
.block-row { display: flex; gap: 14px; padding: 3px 0; }
.block-label {
  width: 130px;
  color: var(--text-muted);
  font-weight: 600;
}
.block-value {
  flex: 1;
  color: var(--text);
  word-break: break-all;
}
.block-hash { color: var(--primary-darker); font-weight: 700; }

/* ============================================================
   VERIFY VOTE TAB
   ============================================================ */
.verify-result { margin-top: 12px; font-size: 13.5px; color: var(--text-soft); }
.verify-result strong { color: var(--text); }

#verify-form { display: grid; grid-template-columns: 1fr; gap: 12px; max-width: 600px; }
#verify-form label { display: block; margin-bottom: 6px; }
#verify-form button { width: 100%; }

/* ============================================================
   SIS / SQL INFO PANEL (audit tab)
   ============================================================ */
.sis-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 14px 0;
}
.sis-info-stat {
  background: var(--bg-soft);
  padding: 12px;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
}
.sis-info-stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 4px;
}
.sis-info-stat-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-darker);
  line-height: 1;
}
.sis-info-sql-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.sis-info-sql-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.55;
  overflow-x: auto;
  margin: 0;
}
.sis-info-sql-block code,
.sis-info-sql-block .kw { color: #86efac; }
.sis-info-sql-block .com { color: #94a3b8; }

@media (max-width: 720px) {
  .sis-info-grid { grid-template-columns: repeat(2, 1fr); }
}

.verify-success-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  font-size: 13px;
}
.verify-success-row strong {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.verify-success-row .mono { font-family: 'Courier New', monospace; word-break: break-all; }

/* ============================================================
   APP FOOTER
   ============================================================ */
.app-footer {
  background: white;
  border-top: 1px solid var(--border);
  padding: 16px 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}
.app-footer p { margin: 2px 0; }
.footer-links {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.85;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  z-index: 1000;
  max-width: 360px;
  transition: opacity 200ms ease, transform 200ms ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
.toast.hidden { opacity: 0; transform: translateY(10px); pointer-events: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 980px) {
  .audit-layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .topbar-nav { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; }
  .user-info { display: none; }
}
@media (max-width: 720px) {
  .tab-content { padding: 16px; }
  .login-card { padding: 28px 22px; }
  .stats-row { grid-template-columns: 1fr; }
  .audit-log-entry { grid-template-columns: 1fr; }
  .verify-success-row { grid-template-columns: 1fr; }
  #verify-form { grid-template-columns: 1fr; }
  .candidate-list { grid-template-columns: 1fr; }
  /* .candidates-grid already set to 1 column at <=720px above */
}

/* ============================================================
   ROLE BADGE (topbar)
   ============================================================ */
.role-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
  margin-right: 8px;
}
.role-badge.role-student {
  background: var(--primary-light);
  color: var(--primary-darker);
  border-color: var(--primary-light);
}
.role-badge.role-admin {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

/* ============================================================
   ADMIN TAG (used on cards/sections that are admin-only)
   ============================================================ */
.admin-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ============================================================
   LOGIN HELP HINTS
   ============================================================ */
.login-help-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}
.login-help code {
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11.5px;
  color: var(--primary-darker);
  border: 1px solid var(--border);
}

/* ============================================================
   AUDIT TRAIL - STUDENT NOTE + SYSTEM TAG
   ============================================================ */
.audit-filters-admin-note {
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--info-bg);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: #0c4a6e;
  line-height: 1.5;
}
.audit-filters-admin-note.hidden { display: none; }
.audit-filters-admin-note strong { color: #075985; }

.audit-log-sys-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  vertical-align: middle;
  text-transform: uppercase;
}

/* Cursor hint for blockchain stats badge (hover for explanation) */
#blockchain-stats {
  cursor: help;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  text-decoration-color: var(--text-muted);
}

/* Hide elements with .hidden (override) - keep !important from .hidden */
.hidden { display: none !important; }

/* ============================================================
   ADMIN CANDIDATES TOOL (candidates tab, admin only)
   ============================================================ */
.add-candidate-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 14px;
  margin-bottom: 14px;
}
@media (max-width: 720px) {
  .add-candidate-grid { grid-template-columns: 1fr; }
}
.add-candidate-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}
.add-candidate-grid label.full-width {
  grid-column: 1 / -1;
}
.add-candidate-grid input,
.add-candidate-grid select,
.add-candidate-grid textarea {
  padding: 8px 10px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color 150ms ease;
}
.add-candidate-grid input:focus,
.add-candidate-grid select:focus,
.add-candidate-grid textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15);
}
.add-candidate-grid textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  line-height: 1.5;
}
.add-candidate-grid .req {
  color: var(--danger);
  font-weight: 700;
}
.add-candidate-grid .field-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-muted);
  font-size: 11px;
  font-style: italic;
}

.add-candidate-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.add-candidate-status {
  font-size: 13px;
  color: var(--text-muted);
}
.add-candidate-status.success { color: var(--success); font-weight: 600; }
.add-candidate-status.error { color: var(--danger); font-weight: 600; }

.added-candidates-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.added-candidates-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.added-candidate-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.added-candidate-row .added-candidate-name {
  font-weight: 600;
  color: var(--text);
}
.added-candidate-row .added-candidate-meta {
  color: var(--text-muted);
  font-size: 12px;
}
.added-candidate-row .added-candidate-remove {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all 150ms ease;
}
.added-candidate-row .added-candidate-remove:hover {
  background: var(--danger);
  color: white;
}

/* ============================================================
   ADMIN TESTING PANEL (audit tab, admin only)
   ============================================================ */
.admin-test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.admin-test-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-test-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-test-tag {
  display: inline-block;
  padding: 1px 6px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-test-card p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.55;
  flex: 1;
}

.admin-test-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-test-result {
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  background: var(--info-bg);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
  font-size: 13.5px;
  color: var(--text);
}
.admin-test-result.test-success { border-left-color: var(--success); background: var(--primary-lighter); }
.admin-test-result.test-fail { border-left-color: var(--danger); background: var(--danger-bg); }

.admin-test-result-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.admin-test-result-desc {
  color: var(--text-soft);
  margin-bottom: 10px;
  line-height: 1.55;
}
.admin-test-result-rows {
  font-size: 12.5px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-strong);
}
.admin-test-result-rows strong {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 2px;
}
.admin-test-result-rows .mono {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--text);
}

.admin-test-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-test-restore-status {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Validation result display */
.validation-result {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}
.validation-result.valid {
  background: var(--primary-lighter);
  border-color: var(--primary-light);
  border-left: 4px solid var(--success);
  color: var(--primary-darker);
}
.validation-result.invalid {
  background: var(--danger-bg);
  border-color: #fecaca;
  border-left: 4px solid var(--danger);
  color: #991b1b;
}
.validation-result-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}
.validation-result-failures {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed currentColor;
}
.validation-failure {
  font-family: 'Courier New', monospace;
  font-size: 11.5px;
  margin-bottom: 4px;
  word-break: break-word;
}
.validation-failure-tag {
  display: inline-block;
  padding: 1px 5px;
  background: rgba(220, 38, 38, 0.15);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  margin-right: 4px;
  text-transform: uppercase;
}
