/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:    #2563eb;
  --blue-dk: #1d4ed8;
  --green:   #16a34a;
  --red:     #dc2626;
  --gray-50: #f9fafb;
  --gray-100:#f3f4f6;
  --gray-200:#e5e7eb;
  --gray-400:#9ca3af;
  --gray-600:#4b5563;
  --gray-800:#1f2937;
  --white:   #ffffff;
  --radius:  8px;
  --shadow:  0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }

.main-content { flex: 1; padding: 2rem 1.25rem; }

/* ─── Header ────────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--blue);
  color: var(--white);
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo { display: flex; align-items: center; gap: .5rem; font-size: 1.35rem; font-weight: 700; }
.logo-icon { font-size: 1.5rem; }

.main-nav { display: flex; gap: .25rem; }

.nav-link {
  padding: .4rem .85rem;
  border-radius: var(--radius);
  font-size: .95rem;
  color: rgba(255,255,255,.85);
  transition: background .15s;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.15);
  color: var(--white);
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--gray-800);
  color: var(--gray-400);
  padding: 1rem 0;
  font-size: .85rem;
  text-align: center;
}

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.card-link {
  display: block;
  border: 2px solid transparent;
  transition: border-color .2s, transform .15s;
  cursor: pointer;
}
.card-link:hover { border-color: var(--blue); transform: translateY(-2px); }

.card-icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* ─── Hero ───────────────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 3rem 1rem; }
.hero h1 { font-size: 2rem; margin-bottom: .75rem; }
.hero-sub { color: var(--gray-600); font-size: 1.1rem; }

/* ─── Page header ────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.6rem; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--blue);  color: var(--white); }
.btn-primary:hover   { background: var(--blue-dk); }
.btn-success   { background: var(--green); color: var(--white); }
.btn-success:hover   { opacity: .9; }
.btn-danger    { background: var(--red);   color: var(--white); }
.btn-danger:hover    { opacity: .9; }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-200); opacity: .8; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--blue);
  color: var(--blue);
}
.btn-outline:hover { background: var(--blue); color: var(--white); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

/* ─── Form elements ──────────────────────────────────────────────────────────── */
.input-field {
  width: 100%;
  padding: .5rem .75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}
.input-field:focus { border-color: var(--blue); }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .35rem; font-weight: 600; font-size: .9rem; }
.form-check label { display: flex; align-items: center; gap: .5rem; font-weight: normal; cursor: pointer; }
.field-error { display: block; color: var(--red); font-size: .8rem; margin-top: .25rem; }

/* ─── Table ───────────────────────────────────────────────────────────────────── */
.table-toolbar {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.table-toolbar .input-field { max-width: 280px; }

.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.data-table th, .data-table td {
  padding: .65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}
.data-table th { background: var(--gray-50); font-weight: 700; color: var(--gray-600); white-space: nowrap; }
.data-table tr:hover td { background: var(--gray-50); }
.text-center { text-align: center; }

/* ─── Badge ───────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-gray    { background: var(--gray-200); color: var(--gray-600); }

/* ─── Poll panel ─────────────────────────────────────────────────────────────── */
.poll-panel { border: 2px solid var(--blue); }
.poll-actions { display: flex; gap: .75rem; margin: 1rem 0; }
.poll-progress { display: flex; align-items: center; gap: .5rem; color: var(--blue); }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2.5px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.poll-results { margin-top: 1rem; }
.poll-result-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .4rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: .9rem;
}

/* ─── Stats summary ───────────────────────────────────────────────────────────── */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--blue); }
.stat-label { font-size: .85rem; color: var(--gray-600); margin-top: .25rem; }

/* ─── Charts ─────────────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
}
.chart-full { grid-column: 1 / -1; }
.chart-wrapper { position: relative; height: 280px; }
.chart-wrapper--sm { height: 240px; }

/* ─── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%; max-width: 480px;
  padding: 1.75rem;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-header h2 { font-size: 1.25rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--gray-400); line-height: 1; }
.modal-close:hover { color: var(--gray-800); }
.modal-footer { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-inner { gap: .5rem; }
  .nav-link { padding: .35rem .55rem; font-size: .85rem; }
  .page-header { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .charts-grid { grid-template-columns: 1fr; }
}
