* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: #1f2430;
}
h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
.subtitle { color: #6b7280; margin: 0 0 16px; }
.muted { color: #9ca3af; }
.small { font-size: 0.85rem; }

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card { width: 100%; max-width: 360px; }

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

label { display: block; font-size: 0.85rem; font-weight: 600; margin: 12px 0 4px; }
input[type="email"], input[type="password"], input[type="text"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  background: #fff;
}
textarea { resize: vertical; font-family: inherit; }

.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 8px 0; }
.checkbox-label input { width: auto; }

.radio-label { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 10px 0 4px; }
.radio-label input { width: auto; }
.audience-panel {
  margin: 4px 0 12px 26px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Una regla de clase con la misma especificidad que [hidden] le gana al
   atributo en la cascada (ambas 0-1-0, origen "autor" en los dos casos) --
   sin este selector mas especifico, el panel quedaba visible aunque
   `hidden` estuviera puesto (bug real, encontrado al verificar en vivo). */
.audience-panel[hidden] { display: none; }
.select-row { display: flex; gap: 8px; }
.select-row select { flex: 1; min-width: 0; }

.image-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 12px; }
.img-thumb { width: 96px; }
.img-thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid #e5e7eb; display: block; }
.img-thumb .btn { width: 100%; margin-top: 4px; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 0.82rem;
  font-weight: 600;
}
.chip button { border: none; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 4px; }

.search-results { border: 1px solid #e5e7eb; border-radius: 6px; max-height: 160px; overflow-y: auto; margin-top: 4px; }
.search-results:empty { border: none; }
.search-result-item { padding: 6px 10px; cursor: pointer; font-size: 0.88rem; }
.search-result-item:hover { background: #f9fafb; }

.btn {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; margin-top: 14px; }
.btn-link { border: none; background: none; color: #2563eb; text-decoration: none; padding: 4px 0; }
.btn-small { padding: 4px 10px; font-size: 0.82rem; }

.page { max-width: 960px; margin: 0 auto; padding: 24px 16px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.table-scroll { overflow-x: auto; }
.table { width: 100%; min-width: 480px; border-collapse: collapse; background: #fff; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eef0f2; font-size: 0.9rem; }
.table th { color: #6b7280; font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }
.row-clickable { cursor: pointer; }
.row-clickable:hover { background: #f9fafb; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef3c7; color: #92400e; }

.pagination { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.pagina-info { color: #6b7280; font-size: 0.85rem; }

.detail-grid { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin-bottom: 12px; }
.detail-grid dt { color: #6b7280; font-size: 0.85rem; }
.detail-grid dd { margin: 0; }

.banner { padding: 10px 12px; border-radius: 6px; font-size: 0.88rem; margin: 8px 0; }
.banner-error { background: #fee2e2; color: #991b1b; }
.banner-ok { background: #dcfce7; color: #166534; }

.loading { padding: 40px; text-align: center; color: #6b7280; }

/* ---- Shell: sidebar + topbar (ver ADR-011 "Quinta tanda") ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #111827;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
  padding: 6px 10px 20px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #4f46e5;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
}
.nav-item:hover { background: #1f2937; color: #fff; }
.nav-item-active { background: #4f46e5; color: #fff; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { color: #6b7280; font-size: 0.75rem; padding: 10px; border-top: 1px solid #1f2937; margin-top: 8px; }

.main { flex: 1; min-width: 0; }
.topbar-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1;
}
.page-title { font-size: 1.1rem; margin: 0; }

.user-box { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eef2ff;
  color: #4338ca;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.user-info { line-height: 1.25; }
.user-name { font-weight: 600; font-size: 0.85rem; }
.user-email { color: #6b7280; font-size: 0.75rem; }
.role-badge {
  background: #ecfdf5;
  color: #047857;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.btn-icon { padding: 6px; display: flex; align-items: center; justify-content: center; }
.btn-icon .nav-icon { width: 16px; height: 16px; }

.content { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* ---- Dashboard ---- */
.section-header { margin: 28px 0 12px; }
.section-header:first-child { margin-top: 0; }
.section-header h2 { margin-bottom: 2px; }
.section-header p { margin: 0; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.kpi-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
}
.kpi-value { font-size: 1.6rem; font-weight: 700; }
.kpi-label { color: #374151; font-size: 0.82rem; font-weight: 600; margin-top: 2px; }
.kpi-desc { color: #9ca3af; font-size: 0.74rem; margin-top: 6px; line-height: 1.35; }

.chart-desc { margin: -6px 0 12px; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 40% 1fr auto; align-items: center; gap: 10px; }
.bar-label { font-size: 0.83rem; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #f1f5f9; border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { background: #4f46e5; height: 100%; border-radius: 999px; }
.bar-value { font-size: 0.82rem; font-weight: 600; color: #374151; min-width: 20px; text-align: right; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 12px; overflow-x: auto; }
  .brand { padding: 0 12px 0 0; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .nav-item span { display: none; }
  .content { padding: 16px; }

  .topbar-shell { padding: 12px 16px; gap: 8px; }
  .page-title { font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-box { gap: 6px; flex-shrink: 0; }
  .user-info { display: none; }
  .role-badge { display: none; }
}
