/* ============================================================
   PAN Reporteador — Design System v2
   Moderno institucional: azul PAN, tipografía jerárquica,
   sombras en capas, micro-interacciones sutiles.
   ============================================================ */

:root {
  /* Marca */
  --color-primary: #0057B8;
  --color-primary-dark: #003B7A;
  --color-primary-deep: #062B54;
  --color-primary-bright: #1E7BE8;
  --color-primary-light: #EAF3FE;

  /* Neutros (slate) */
  --color-white: #FFFFFF;
  --color-background: #F4F6FB;
  --color-surface: #FFFFFF;
  --color-border: #E2E8F1;
  --color-border-strong: #CBD5E1;

  --color-text: #0F172A;
  --color-text-secondary: #64748B;
  --color-text-faint: #94A3B8;

  /* Semánticos */
  --color-success: #16A34A;
  --color-warning: #F59E0B;
  --color-error: #DC2626;
  --color-info: #2563EB;

  --font-primary: "Inter", "Montserrat", Arial, sans-serif;
  --font-display: "Montserrat", "Inter", Arial, sans-serif;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Sombras en capas */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.05);
  --shadow-hover: 0 2px 4px rgba(16, 24, 40, 0.05), 0 10px 28px rgba(16, 24, 40, 0.09);
  --shadow-focus: 0 0 0 3px rgba(0, 87, 184, 0.16);

  --ease: cubic-bezier(0.25, 0.6, 0.35, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-primary);
  background: var(--color-background);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(0, 87, 184, 0.18); }

/* Scrollbars discretos */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: 999px;
  border: 2px solid var(--color-background);
}
::-webkit-scrollbar-thumb:hover { background: var(--color-text-faint); }

/* ---------- Layout global ---------- */

.app {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
}

.main {
  padding: 30px 36px 48px;
  min-width: 0;
  animation: page-in .3s var(--ease) both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: linear-gradient(180deg, var(--color-primary-deep) 0%, #041C38 100%);
  color: var(--color-white);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-color: transparent;
}

.sidebar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
  margin-bottom: 22px;
  padding: 4px 8px;
}
.sidebar .brand small {
  display: block;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-top: 3px;
}
.sidebar .brand img {
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.sidebar nav { flex: 1; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.sidebar nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity .16s var(--ease);
}
.sidebar nav a:hover {
  background: rgba(255,255,255,0.07);
  color: var(--color-white);
}
.sidebar nav a:hover svg { opacity: 1; }
.sidebar nav a.active {
  background: linear-gradient(90deg, rgba(30,123,232,0.28), rgba(30,123,232,0.10));
  border-left-color: var(--color-primary-bright);
  color: var(--color-white);
  font-weight: 600;
}
.sidebar nav a.active svg { opacity: 1; }

.nav-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
  color: rgba(255,255,255,0.38);
  padding: 16px 12px 6px;
  margin-top: 4px;
}

/* Bloque de usuario en sidebar */
.sidebar-user {
  margin-top: 20px;
  padding: 14px 10px 6px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 13px;
  display: flex;
  flex-direction: column;
}
.sidebar-user .su-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-user .su-name::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34D399;
  box-shadow: 0 0 0 3px rgba(52,211,153,0.22);
  flex-shrink: 0;
}
.sidebar-user .su-meta {
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  margin: 4px 0 10px;
  line-height: 1.4;
}
.sidebar-user .su-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fff;
  text-decoration: none;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.sidebar-user .su-logout:hover {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.28);
}

/* ---------- Encabezado de página ---------- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--color-text);
}
.page-header p {
  margin: 5px 0 0;
  color: var(--color-text-secondary);
  font-size: 14px;
}

/* ---------- Cards ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 18px;
  transition: box-shadow .2s var(--ease);
}
.card h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}

.cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .cards-2 { grid-template-columns: 1fr; } }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              box-shadow .16s var(--ease), transform .1s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.btn-primary {
  background: linear-gradient(180deg, var(--color-primary-bright) -40%, var(--color-primary) 60%);
  color: var(--color-white);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--color-primary) -40%, var(--color-primary-dark) 90%);
  box-shadow: 0 3px 10px rgba(0, 87, 184, 0.28);
}

.btn-secondary {
  background: var(--color-white);
  border-color: var(--color-border-strong);
  color: var(--color-primary);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.btn-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  cursor: pointer;
  background: var(--color-white);
  color: var(--color-text);
  box-shadow: var(--shadow-xs);
  transition: background .14s var(--ease), border-color .14s var(--ease);
}
.btn-mini:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
}

/* ---------- Formularios ---------- */

.field { display: block; margin-bottom: 14px; }
.field label {
  font-size: 12.5px;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
  color: var(--color-text);
  letter-spacing: 0.1px;
}

.input, select.input {
  width: 100%;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-white);
  box-shadow: var(--shadow-xs);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input:hover { border-color: var(--color-text-faint); }
.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}
select.input { cursor: pointer; }

.chip-radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  background: var(--color-white);
  box-shadow: var(--shadow-xs);
  transition: border-color .14s var(--ease), background .14s var(--ease);
}
.chip-radio:hover { border-color: var(--color-primary); }
.chip-radio input { margin: 0; accent-color: var(--color-primary); }
.chip-radio input:checked + span { font-weight: 600; color: var(--color-primary); }
.chip-radio:has(input:checked) {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.dropzone {
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  text-align: center;
  background: linear-gradient(180deg, #F8FBFF, var(--color-primary-light));
  color: var(--color-primary-dark);
  font-weight: 500;
  cursor: pointer;
  transition: border-color .16s var(--ease), background .16s var(--ease), box-shadow .16s var(--ease);
}
.dropzone:hover,
.dropzone.is-drag {
  border-color: var(--color-primary);
  background: #DFECFC;
  box-shadow: inset 0 0 0 1px rgba(0,87,184,0.10);
}
.dropzone .small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-secondary);
}

/* ---------- KPIs ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 16px;
  margin-bottom: 20px;
}
/* Dentro de una card angosta (p.ej. cards-2) los KPIs se acomodan solos */
.card .kpis {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.kpi {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--color-primary-bright), var(--color-primary));
  border-radius: 4px 0 0 4px;
}
.kpi:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.kpi .label {
  font-size: 11px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.7px;
}
.kpi .value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 6px;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.kpi.success::before { background: linear-gradient(180deg, #4ADE80, var(--color-success)); }
.kpi.success .value  { color: var(--color-success); }
.kpi.error::before   { background: linear-gradient(180deg, #F87171, var(--color-error)); }
.kpi.error .value    { color: var(--color-error); }
.kpi.warn::before    { background: linear-gradient(180deg, #FBBF24, var(--color-warning)); }
.kpi.warn .value     { color: #B45309; }
.kpi.muted::before   { background: var(--color-border-strong); }
.kpi.muted .value    { color: var(--color-text-secondary); }
.kpi-help { cursor: help; }

/* ---------- Tablas ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--color-border);
}
.table th {
  background: #F8FAFD;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--color-border-strong);
  white-space: nowrap;
}
.table tbody tr {
  transition: background .12s var(--ease);
}
.table tbody tr:hover { background: #F3F8FE; }
.table td { font-variant-numeric: tabular-nums; }

/* ---------- Chips / alerts ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip.success { background: #E7F9EE; color: #15803D; border-color: #BBF0CE; }
.chip.error   { background: #FDECEC; color: #B91C1C; border-color: #F8CBCB; }
.chip.warn    { background: #FEF5DC; color: #B45309; border-color: #F7E1A8; }
.chip.info    { background: var(--color-primary-light); color: var(--color-primary-dark); border-color: #C3DCF8; }

.alert {
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  border-left-width: 4px;
  box-shadow: var(--shadow-xs);
}
.alert.success { background: #EFFBF3; border-color: #BBF0CE; border-left-color: var(--color-success); color: #14532D; }
.alert.error   { background: #FDF1F1; border-color: #F8CBCB; border-left-color: var(--color-error);   color: #7F1D1D; }
.alert.info    { background: #F2F8FF; border-color: #C3DCF8; border-left-color: var(--color-primary); color: var(--color-primary-dark); }

/* ---------- Utilidades ---------- */

.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--color-text-secondary); }
.mono {
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.hint { border-bottom: 1px dotted var(--color-text-faint); cursor: help; }
.hint:hover { border-bottom-color: var(--color-primary); }

/* ---------- Barras horizontales (pirámide) ---------- */

.bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 110px;
  gap: 12px;
  align-items: center;
  margin: 7px 0;
}
.bar-row .lbl { font-size: 13px; font-weight: 600; color: var(--color-text-secondary); }
.bar-row .val {
  font-size: 13px;
  color: var(--color-text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.bar {
  position: relative;
  height: 20px;
  background: #EDF2F9;
  border-radius: 999px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary-bright), var(--color-primary-dark));
  border-radius: 999px;
  min-width: 4px;
  animation: bar-grow .7s var(--ease) both;
  transform-origin: left center;
}
@keyframes bar-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ---------- Insight ("Lectura del consultor") ---------- */

.insight {
  position: relative;
  background: linear-gradient(135deg, #F2F8FF 0%, var(--color-primary-light) 100%);
  border: 1px solid #C3DCF8;
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
}
.insight h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-primary-dark);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 7px;
}
.insight h3::before { content: "💡"; font-size: 14px; }
.insight ul { margin: 0; padding-left: 18px; }
.insight li { margin-bottom: 5px; line-height: 1.55; font-size: 13.5px; }

/* ---------- Auth (login / setup) ---------- */

.auth-screen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.auth-side {
  position: relative;
  background:
    radial-gradient(1100px 500px at -10% -10%, rgba(30,123,232,0.35), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(0,59,122,0.8), transparent 60%),
    linear-gradient(160deg, var(--color-primary-deep) 0%, #041C38 100%);
  color: #fff;
  padding: 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.auth-side::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }
.auth-side h2 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  line-height: 1.2;
}
.auth-side p {
  color: rgba(255,255,255,0.82);
  font-size: 15px;
  line-height: 1.6;
  max-width: 440px;
}
.auth-side .brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.5px;
}
.auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--color-background);
}
.auth-form {
  width: 100%;
  max-width: 400px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-hover);
  padding: 36px 34px;
}
.auth-form h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.auth-form .muted { margin-bottom: 24px; font-size: 14px; }
.auth-form .btn { width: 100%; justify-content: center; padding: 12px 18px; }

@media (max-width: 800px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-side { padding: 28px; }
  .auth-form { padding: 26px 22px; }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 12px 18px;
  }
  .sidebar .brand { margin-bottom: 0; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar nav a { padding: 6px 10px; font-size: 13px; border-left: none; }
  .nav-group-label { display: none; }
  .sidebar-user { margin-top: 0; padding: 0; border-top: none; }
  .main { padding: 20px 16px 40px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
