/* ============ Tema (claro/oscuro) ============ */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
}

[data-theme='dark'] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1a2234;
  --border: #283146;
  --text: #e5e9f0;
  --text-muted: #8a94a8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-soft: #1e2243;
  --danger: #f87171;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}

/* ============ Elementos base ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  width: 100%;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.input-group { margin-bottom: 18px; text-align: left; }
.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

input[type='email'],
input[type='password'],
input[type='text'],
input[type='number'],
input[type='date'] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

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

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

.error-msg {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 4px 0 12px;
}

/* ============ Toggle de tema ============ */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  transition: background 0.15s ease;
}
.theme-toggle:hover { background: var(--surface-2); }

/* ============ Login ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
  padding: 40px 36px;
  position: relative;
}

.login-card .theme-toggle { position: absolute; top: 16px; right: 16px; }

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 14px;
}

.login-card h1 { font-size: 22px; margin: 0 0 6px; }
.login-card .subtitle { color: var(--text-muted); font-size: 14px; margin: 0 0 26px; }

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

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
}

.sidebar .brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  font-weight: 700;
  font-size: 16px;
}
.sidebar .brand { width: 34px; height: 34px; font-size: 15px; margin: 0; border-radius: 9px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.nav .nav-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 16px 12px 6px;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.header {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.header .page-title { font-size: 16px; font-weight: 600; margin: 0; }

.header-actions { display: flex; align-items: center; gap: 14px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.user-chip .avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.user-chip .meta { line-height: 1.25; text-align: right; }
.user-chip .meta .name { font-weight: 600; }
.user-chip .meta .role { color: var(--text-muted); font-size: 11px; }

.content { padding: 26px; flex: 1; }
.content h2 { margin: 0 0 6px; font-size: 20px; }
.content .lead { color: var(--text-muted); font-size: 14px; margin: 0 0 22px; }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.grid-cards .card h3 { margin: 0 0 4px; font-size: 15px; }
.grid-cards .card p { margin: 0; color: var(--text-muted); font-size: 13px; }

/* ============ Módulos (Bloque 2) ============ */
select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 90px; }

.btn-auto { width: auto; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--border); }
.btn-danger:hover { background: var(--surface-2); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.toolbar input { max-width: 320px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.detail-grid .label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.detail-grid .value { font-size: 14px; font-weight: 500; }

.table-wrap { overflow-x: auto; }
.table a { color: var(--primary); text-decoration: none; font-weight: 500; }
.table a:hover { text-decoration: underline; }
.row-actions { display: flex; gap: 10px; white-space: nowrap; }
.row-actions .delete-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 0;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: rgba(34, 197, 94, 0.14);  color: #15803d; }
.badge-red    { background: rgba(239, 68, 68, 0.12);  color: #b91c1c; }
.badge-blue   { background: rgba(59, 130, 246, 0.12); color: #1d4ed8; }
.badge-cyan   { background: rgba(6, 182, 212, 0.12);  color: #0e7490; }
.badge-amber  { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.badge-purple { background: rgba(168, 85, 247, 0.12); color: #7e22ce; }
.badge-gray   { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
[data-theme='dark'] .badge-green  { color: #4ade80; }
[data-theme='dark'] .badge-red    { color: #f87171; }
[data-theme='dark'] .badge-blue   { color: #60a5fa; }
[data-theme='dark'] .badge-cyan   { color: #22d3ee; }
[data-theme='dark'] .badge-amber  { color: #fbbf24; }
[data-theme='dark'] .badge-purple { color: #c084fc; }

.empty-state { color: var(--text-muted); font-size: 14px; text-align: center; padding: 28px 0; }

/* ============ Dashboard y Reportes (Bloque 6) ============ */
.filters-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters-row .input-group { margin: 0; min-width: 150px; }
.filters-row .input-group label { font-size: 12px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-card { padding: 16px 18px; text-decoration: none; color: var(--text); display: block; }
.kpi-card .kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.kpi-card .kpi-value { font-size: 20px; font-weight: 700; }
.kpi-card .kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
a.kpi-card:hover { border-color: var(--primary); }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 6px 0 12px; }

.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.charts-grid .card h3 { margin: 0 0 14px; font-size: 15px; }

.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.bar-row .bar-label { width: 110px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
.bar-track { flex: 1; background: var(--surface-2); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; min-width: 2px; }
.bar-green { background: #22c55e; }
.bar-red { background: #ef4444; }
.bar-blue { background: var(--primary); }
.bar-amber { background: #f59e0b; }
.bar-row .bar-value { width: 95px; flex-shrink: 0; text-align: right; font-weight: 600; }
