/* ============================================================
   Panel de Encuestas – Uso y No Abuso de Tecnología
   Stylesheet – Dark Premium Design
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────── */
:root {
  --bg-base:       #0f172a;
  --bg-surface:    #1e293b;
  --bg-surface2:   #253248;
  --bg-elevated:   #2d3f57;
  --bg-hover:      #334155;
  --border:        rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);

  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;

  --accent:        #6366f1;
  --accent-hover:  #4f46e5;
  --accent-light:  rgba(99,102,241,0.15);
  --teal:          #14b8a6;
  --teal-light:    rgba(20,184,166,0.15);
  --orange:        #f97316;
  --orange-light:  rgba(249,115,22,0.15);
  --blue:          #0ea5e9;
  --blue-light:    rgba(14,165,233,0.15);
  --purple:        #8b5cf6;
  --purple-light:  rgba(139,92,246,0.15);
  --green:         #10b981;
  --green-light:   rgba(16,185,129,0.15);
  --red:           #ef4444;
  --red-light:     rgba(239,68,68,0.15);
  --yellow:        #f59e0b;

  --sidebar-w:     260px;
  --topbar-h:      68px;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 4px 24px rgba(0,0,0,0.35);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.2);
  --transition:    0.2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ── Layout ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  font-size: 1.75rem;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
}

.brand-text strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}
.brand-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.65rem 0.875rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: translateX(2px);
}

.nav-link.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-logout {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--red-light);
  color: var(--red);
  font-size: 1rem;
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover { background: var(--red); color: #fff; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.75rem;
  backdrop-filter: blur(12px);
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

.topbar-title h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.topbar-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ── Page Body ──────────────────────────────────────────── */
.page-body {
  padding: 1.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page-body-narrow {
  max-width: 800px;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.card-sm { padding: 0; }
.card-sm .card-body { padding: 1rem 1.25rem; }

.card-header {
  padding: 1rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 1.25rem 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); }

.card-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── KPI Cards ──────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.kpi-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.kpi-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

.kpi-card:hover::before { opacity: 1; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi-blue  { border-color: rgba(14,165,233,0.3);  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(14,165,233,0.08)); }
.kpi-purple{ border-color: rgba(139,92,246,0.3);  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(139,92,246,0.08)); }
.kpi-teal  { border-color: rgba(20,184,166,0.3);  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(20,184,166,0.08)); }
.kpi-orange{ border-color: rgba(249,115,22,0.3);  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(249,115,22,0.08)); }

.kpi-icon { font-size: 2rem; }

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

/* ── Section Grids ──────────────────────────────────────── */
.section-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.35); }

.btn-secondary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.btn-secondary:hover { opacity: 0.9; color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover { opacity: 0.85; color: #fff; }

.btn-full { width: 100%; justify-content: center; }
.btn-sm   { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all var(--transition);
  text-decoration: none;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }
.btn-icon.btn-danger:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.55rem 0.875rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.form-input::placeholder { color: var(--text-muted); }

.form-textarea { resize: vertical; min-height: 80px; }
.form-input-sm { width: 80px; text-align: center; }
.form-select-sm { width: auto; padding: 0.3rem 0.5rem; font-size: 0.8rem; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.3rem; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.input-with-toggle {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-toggle .form-input { padding-right: 2.5rem; }

.toggle-password {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 0;
  transition: color var(--transition);
}
.toggle-password:hover { color: var(--text-primary); }

/* ── Filters ────────────────────────────────────────────── */
.filters-card .card-body,
.filters-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  padding: 1rem 1.5rem;
}

.filter-group { flex: 1; min-width: 160px; }

.filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding-bottom: 0.05rem;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: var(--bg-elevated); }
.data-table tbody tr:last-child td { border-bottom: none; }

.sort-link { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.sort-link:hover { color: var(--accent); }

.actions-cell {
  white-space: nowrap;
  vertical-align: middle;
}
.actions-cell .btn-icon {
  margin-right: 4px;
  vertical-align: middle;
}
.actions-cell .btn-icon:last-child {
  margin-right: 0;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem;
  font-style: italic;
}

.respuesta-cell { max-width: 320px; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-province {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-success { color: var(--green); }
.badge-warning { color: var(--yellow); }
.badge-danger  { color: var(--red); }

.badge-you {
  background: var(--green-light);
  color: var(--green);
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
}

.nota-badge, .pct-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
}

.text-success { color: var(--green) !important; }
.text-warning { color: var(--yellow) !important; }
.text-danger  { color: var(--red) !important; }
.text-muted   { color: var(--text-muted) !important; }
.nowrap       { white-space: nowrap; }

.cat-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Progress Bars ──────────────────────────────────────── */
.question-bar-wrap {
  margin-bottom: 1.25rem;
}

.question-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.question-bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
}

.bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 100px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s ease;
}

.bar-green { background: linear-gradient(90deg, var(--green), #34d399); }

.bar-pct {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}

.question-counts {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
}

.count-si  { color: var(--green); }
.count-no  { color: var(--red); }
.count-total { color: var(--text-muted); }

/* ── School rows in dashboard ────────────────────────────── */
.school-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.school-row:last-child { border-bottom: none; }

.school-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.school-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.school-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.school-nota {
  font-size: 1rem;
  font-weight: 800;
}

.school-partic {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.school-name-sm {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Chart wrap ─────────────────────────────────────────── */
.chart-wrap {
  position: relative;
}

/* ── Flash messages ─────────────────────────────────────── */
.flash {
  margin: 0 1.75rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideDown 0.3s ease;
  border-left: 4px solid;
}

.flash-success { background: var(--green-light);  color: var(--green);  border-color: var(--green); }
.flash-error   { background: var(--red-light);    color: var(--red);    border-color: var(--red); }
.flash-info    { background: var(--blue-light);   color: var(--blue);   border-color: var(--blue); }
.flash-warning { background: var(--orange-light); color: var(--orange); border-color: var(--orange); }

.flash ul { margin: 0.5rem 0 0 1.25rem; }

@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-width: 380px;
  max-width: 520px;
  width: 90%;
  box-shadow: var(--shadow);
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  font-weight: 700;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 1.25rem 1.5rem;
  color: var(--text-secondary);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  padding: 1rem 1.5rem;
  justify-content: center;
}

.pg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: all var(--transition);
  text-decoration: none;
}

.pg-btn:hover:not(.disabled):not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.pg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pg-btn.disabled { opacity: 0.3; pointer-events: none; }

/* ── Side layout (respuestas) ────────────────────────────── */
.side-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.side-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1.5rem; }
.side-sidebar { width: 280px; flex-shrink: 0; position: sticky; top: calc(var(--topbar-h) + 1rem); }

/* Category frequency sidebar */
.cat-freq-row { margin-bottom: 0.75rem; }

.cat-freq-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.cat-freq-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cat-freq-num { font-size: 0.78rem; font-weight: 700; color: var(--text-primary); min-width: 24px; text-align: right; }

/* ── Category preview ────────────────────────────────────── */
.cat-preview {
  display: inline-flex;
  padding: 0.35rem 0.75rem;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.5rem;
  transition: all var(--transition);
}

/* ── Question edit rows ──────────────────────────────────── */
.question-edit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.question-edit-row:last-child { border-bottom: none; }

.question-edit-label {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.question-edit-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── Export cards ────────────────────────────────────────── */
.export-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.export-card {
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition);
}

.export-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.export-icon {
  font-size: 2.5rem;
  padding: 1.5rem 1.5rem 0;
}

.export-card .card-body { flex: 1; }
.export-desc { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 1rem; }

/* ── Instructions list ──────────────────────────────────── */
.instructions-list {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.7;
}

/* ── Login ───────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.12) 0%, transparent 50%),
    var(--bg-base);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow);
}

.login-header { text-align: center; margin-bottom: 2rem; }

.login-logo {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  animation: pulse 3s ease infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.05); }
}

.login-title {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.login-subtitle { color: var(--text-muted); font-size: 0.875rem; }

.login-form { display: flex; flex-direction: column; gap: 0; }

.login-hint {
  margin-top: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.login-hint code {
  background: var(--bg-elevated);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  color: var(--accent);
}

/* ── User management ────────────────────────────────────── */
.user-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.role-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
}

.role-badge.admin  { background: rgba(99,102,241,0.2);  color: var(--accent); }
.role-badge.editor { background: rgba(20,184,166,0.2);  color: var(--teal); }
.role-badge.viewer { background: rgba(100,116,139,0.2); color: var(--text-muted); }

.admin-role  { color: var(--accent); }
.editor-role { color: var(--teal); }
.viewer-role { color: var(--text-muted); }

.roles-legend { display: flex; flex-direction: column; gap: 0.6rem; }
.role-item { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; color: var(--text-secondary); }

/* ── Activity log ────────────────────────────────────────── */
.action-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--accent-light);
  color: var(--accent);
}

/* ── Legend ──────────────────────────────────────────────── */
.legend-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.8;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1200px) {
  .export-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .section-grid-2 { grid-template-columns: 1fr; }
  .side-layout { flex-direction: column; }
  .side-sidebar { width: 100%; position: static; }
  .kpi-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .export-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-toggle { display: flex; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-grid-3 { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 1rem; }
  .page-body { padding: 1rem; }
  .filters-form { flex-direction: column; }
  .filter-group { min-width: 100%; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .login-card { padding: 1.5rem; }
}
