/* ============================================================================
   CALIDAD DEL AGUA (K | H & M ASOCIADOS) - Hoja de Estilos Principal
   Colores corporativos: Púrpura (#523680), Verde (#376652 / #16a34a) y Color Dinámico del Cliente
   ============================================================================ */

:root {
  --bg-body: #f4f6f9;
  --bg-surface: #ffffff;
  --khm-purple: #523680;
  --khm-purple-dark: #3b255e;
  --khm-purple-tint: #f3effb;
  --khm-green: #376652;
  --khm-green-bright: #16a34a;
  --khm-green-tint: #ecfdf5;
  --client-color: #1b4332;
  --primary: #523680;
  --primary-hover: #3f2866;
  --accent: #376652;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding-top: 72px; /* Altura del Header Blanco Fijo */
}

.hidden {
  display: none !important;
}

/* ============================================================================
   1. HEADER SUPERIOR FIJO (LIMPIO: LOGOS, TÍTULO CALIDAD DEL AGUA Y SESIÓN)
   ============================================================================ */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: #ffffff;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 1000;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
  gap: 1rem;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-divider {
  width: 1px;
  height: 36px;
  background: #e2e8f0;
}

.corp-logo {
  height: 42px;
  width: auto;
  max-width: 235px;
  object-fit: contain;
  display: block;
}

.brand-meta {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.2px;
  color: var(--khm-purple);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.74rem;
  color: var(--khm-green);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.monitoring-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0.38rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--khm-green-bright);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2);
}

.client-logo-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 46px;
}

.client-logo {
  height: 36px;
  width: auto;
  max-width: 155px;
  object-fit: contain;
  display: block;
}

.header-user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-text-stack {
  display: flex;
  flex-direction: column;
  text-align: right;
  line-height: 1.2;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
}

.user-role-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--khm-green-bright);
}

.user-avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-logout-clean {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.42rem 0.78rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-logout-clean:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* ============================================================================
   2. ESTRUCTURA CON MENÚ LATERAL IZQUIERDO (SIDEBAR) Y CONTENIDO PRINCIPAL
   ============================================================================ */
.app-shell {
  display: flex;
  min-height: calc(100vh - 72px);
}

.app-sidebar {
  width: 248px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  padding: 1.25rem 0.85rem;
  position: fixed;
  top: 72px;
  bottom: 0;
  left: 0;
  z-index: 950;
  overflow-y: auto;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 1.1rem 0.85rem 0.4rem;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  background: transparent;
  color: #475569;
  border: none;
  padding: 0.75rem 0.95rem;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
}

.tab-btn .nav-icon {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
}

.tab-btn:hover {
  background: var(--khm-purple-tint);
  color: var(--khm-purple);
}

.tab-btn.active {
  background: var(--khm-green-tint);
  color: var(--khm-green-bright);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--khm-green-bright);
}

/* ============================================================================
   3. ÁREA DE CONTENIDO PRINCIPAL Y BARRA DE CLIENTE DEBAJO DEL ENCABEZADO
   ============================================================================ */
.app-main {
  flex: 1;
  margin-left: 248px;
  padding: 1.35rem 1.65rem;
  max-width: calc(100vw - 248px);
}

/* Tarjeta Superior de Título de Vista y Exportación Rápida */
.top-system-bar {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.95rem 1.35rem;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.top-system-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.system-title-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--khm-green-tint);
  color: var(--khm-green-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.top-system-title h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #1e293b;
}

.top-system-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-export-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.48rem 0.95rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  cursor: pointer;
  transition: all 0.16s ease;
}

.btn-export-pill:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* Barra de Cliente y Corte de Datos DEBAJO del Encabezado */
.client-subbar {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-left: 5px solid var(--client-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.35rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.client-subbar-left,
.client-subbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.client-building-icon {
  color: var(--khm-green-bright);
  font-size: 1.05rem;
}

.client-subbar-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #334155;
}

.client-selector-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.client-subbar-select {
  min-width: 270px;
  padding: 0.45rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #0f172a;
  background: #ffffff;
  cursor: pointer;
}

.client-subbar-select:focus {
  outline: none;
  border-color: var(--khm-purple);
  box-shadow: 0 0 0 3px rgba(82, 54, 128, 0.14);
}

.btn-client-new {
  background: var(--khm-purple);
  color: #ffffff;
  border: none;
  padding: 0.42rem 0.75rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.btn-client-new:hover {
  background: var(--khm-purple-dark);
}

.client-fixed-name {
  font-size: 0.95rem;
  color: var(--client-color);
  font-weight: 800;
}

.client-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--client-color);
  display: inline-block;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #cbd5e1;
}

.spec-mini-badge {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.22rem 0.6rem;
  border-radius: 6px;
  background: var(--khm-purple-tint);
  color: var(--khm-purple);
  border: 1px solid rgba(82, 54, 128, 0.2);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.22s ease-out;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card,
.toolbar-card,
.chart-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

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

.toolbar-card h2,
.card-header h2 {
  font-size: 1.15rem;
  color: var(--text-main);
}

.toolbar-card p,
.card-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.control-inline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ============================================================================
   4. KPI GRID Y MOTOR DE GRÁFICOS CANVAS
   ============================================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.kpi-card.kpi-ok {
  border-left-color: var(--success);
}

.kpi-card.kpi-alert {
  border-left-color: var(--danger);
  background: #fff5f5;
}

.kpi-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 700;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0.2rem 0;
}

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

.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.chart-header h3 {
  font-size: 1.05rem;
  color: #0b2545;
}

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

.chart-legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-normal-ph {
  background: #0284c7;
}

.dot-normal-cloro {
  background: #0d9488;
}

.dot-alert {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.line-dash {
  width: 18px;
  height: 0;
  border-top: 2px dashed #dc2626;
  display: inline-block;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 0.5rem;
}

.canvas-wrapper canvas {
  width: 100%;
  height: 330px;
  display: block;
  cursor: crosshair;
}

.canvas-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(148, 163, 184, 0.3);
  z-index: 50;
  min-width: 210px;
  transition: opacity 0.1s ease;
}

.canvas-tooltip .tt-title {
  font-weight: 700;
  color: #38bdf8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 0.25rem;
  margin-bottom: 0.3rem;
}

.canvas-tooltip.tt-alert {
  border-color: #ef4444;
}

.canvas-tooltip.tt-alert .tt-title {
  color: #fca5a5;
}

/* ============================================================================
   5. FORMULARIOS, SEMAFORIZACIÓN METROLÓGICA Y VALIDACIÓN EN VIVO
   ============================================================================ */
.split-layout {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 1.25rem;
}

.card-header {
  margin-bottom: 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-color);
}

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text-main);
  background: #ffffff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.16);
}

.input-readonly {
  background: #f1f5f9 !important;
  color: #475569 !important;
  cursor: not-allowed;
}

.input-out-of-spec {
  border-color: var(--danger) !important;
  background: #fef2f2 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2) !important;
}

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

.form-row-5 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.85rem;
}

.equipo-select-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.metro-badge {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.metro-vigente {
  background: var(--success-bg);
  color: #15803d;
  border: 1px solid #86efac;
}

.metro-proximo {
  background: var(--warning-bg);
  color: #b45309;
  border: 1px solid #fcd34d;
}

.metro-vencido {
  background: var(--danger-bg);
  color: #b91c1c;
  border: 1px solid #fca5a5;
  animation: pulseAlert 1.6s infinite;
}

@keyframes pulseAlert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(220, 38, 38, 0); }
}

.limit-pill {
  font-size: 0.73rem;
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

.live-validation {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.live-validation.ok {
  color: var(--text-muted);
}

.live-validation.conforme {
  background: var(--success-bg);
  color: #15803d;
}

.live-validation.fuera {
  background: var(--danger-bg);
  color: #b91c1c;
}

/* ============================================================================
   6. BOTONES Y ALERTAS
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.58rem 1.05rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-xs {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.72rem 1.35rem;
  font-size: 0.95rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #334155;
  color: #ffffff;
}

.btn-accent {
  background: var(--accent);
  color: #0b2545;
  font-weight: 700;
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger-soft {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-danger-soft:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-outline {
  background: transparent;
  border-color: #cbd5e1;
  color: var(--text-main);
}

.btn-outline:hover {
  background: #f1f5f9;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert-danger {
  background: var(--danger-bg);
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.alert-warning {
  background: var(--warning-bg);
  color: #92400e;
  border: 1px solid #fcd34d;
}

/* ============================================================================
   7. TABLAS DE DATOS Y AUDITORÍA
   ============================================================================ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.qms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.qms-table th,
.qms-table td {
  padding: 0.72rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.qms-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.qms-table tbody tr:hover {
  background: #f8fafc;
}

.qms-table tr.row-out-spec {
  background: #fff1f2;
}

.qms-table tr.row-out-spec:hover {
  background: #ffe4e6;
}

.cell-out-spec {
  color: var(--danger);
  font-weight: 800;
}

.audit-pill {
  display: inline-block;
  font-size: 0.73rem;
  background: #fef3c7;
  color: #92400e;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #fde68a;
}

/* ============================================================================
   8. PANEL DE REPORTES Y FILTROS
   ============================================================================ */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  align-items: end;
  margin-bottom: 1rem;
}

.filter-buttons {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.stats-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-box span {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
}

.stat-box strong {
  font-size: 0.95rem;
  color: #0b2545;
}

.export-buttons {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* ============================================================================
   9. LISTAS RÁPIDAS Y MODALES
   ============================================================================ */
.recent-list,
.mini-equipos-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.recent-item {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.recent-item.recent-alert {
  border-left: 4px solid var(--danger);
  background: #fff1f2;
}

.recent-item.recent-ok {
  border-left: 4px solid var(--success);
}

.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1rem 0;
}

/* ============================================================================
   PORTADA DE INICIO DE SESIÓN (ESTILO CORPORATIVO K | H & M ASOCIADOS)
   ============================================================================ */
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #523680 0%, #414e6e 50%, #376652 100%);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.login-card {
  background: rgba(209, 213, 222, 0.94);
  backdrop-filter: blur(8px);
  width: 100%;
  max-width: 445px;
  border-radius: 16px;
  padding: 2.35rem 2.25rem 2.45rem;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.32);
}

.login-brand-khm {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.15rem;
}

.khm-logo-img {
  width: 100%;
  max-width: 375px;
  height: auto;
  object-fit: contain;
  display: block;
}

.khm-svg-fallback {
  width: 100%;
  max-width: 375px;
  height: auto;
  display: block;
}

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

.login-module-title {
  font-size: 2.15rem;
  font-weight: 800;
  color: #6d28d9;
  line-height: 1.15;
  margin-bottom: 0.35rem;
  letter-spacing: -0.3px;
}

.login-module-subtitle {
  font-size: 0.94rem;
  color: #64748b;
  font-weight: 400;
}

.login-field-group {
  margin-bottom: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}

.login-field-group label {
  font-size: 0.92rem;
  font-weight: 500;
  color: #334155;
}

.login-input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-field-icon {
  position: absolute;
  left: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

.login-input-icon-wrap select,
.login-input-icon-wrap input[type="password"] {
  width: 100%;
  height: 48px;
  padding: 0.55rem 0.95rem 0.55rem 2.65rem;
  background: #ffffff;
  border: 1px solid rgba(203, 213, 225, 0.7);
  border-radius: 10px;
  font-size: 0.96rem;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.login-input-icon-wrap select:focus,
.login-input-icon-wrap input[type="password"]:focus {
  outline: none;
  border-color: #6d28d9;
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.16);
}

.btn-login-submit {
  width: 100%;
  height: 48px;
  margin-top: 0.5rem;
  background: #4ca354;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.1s ease;
  box-shadow: 0 2px 6px rgba(76, 163, 84, 0.3);
}

.btn-login-submit:hover {
  background: #418f48;
}

.btn-login-submit:active {
  transform: translateY(1px);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: #ffffff;
  width: 100%;
  max-width: 540px;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1rem;
}

.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 2500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--accent);
  animation: fadeIn 0.2s ease-out;
}

.toast.toast-error {
  border-left-color: var(--danger);
}

.toast.toast-success {
  border-left-color: var(--success);
}

/* ============================================================================
   10. RESPONSIVE MEDIA QUERIES
   ============================================================================ */
@media (max-width: 992px) {
  body {
    padding-top: 72px;
  }
  .app-shell {
    flex-direction: column;
  }
  .app-sidebar {
    position: static;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-section-label {
    display: none;
  }
  .tab-btn {
    width: auto;
    padding: 0.5rem 0.85rem;
  }
  .app-main {
    margin-left: 0;
    max-width: 100%;
    padding: 1rem;
  }
  .split-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .monitoring-pill {
    display: none;
  }
}

/* ============================================================================
   11. ENCABEZADO CON LOGOS, RESUMEN Y GRÁFICAS EN EL INFORME DE CALIDAD
   ============================================================================ */
.report-doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1rem 1.25rem;
  margin-bottom: 0.85rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
}

.report-doc-logo {
  height: 48px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  background: #ffffff;
  padding: 4px 8px;
}

.report-doc-title-block {
  text-align: center;
  flex: 1;
}

.report-doc-title-block h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--khm-purple);
  margin-bottom: 0.15rem;
}

.report-doc-title-block p {
  font-size: 0.86rem;
  color: #475569;
  font-weight: 600;
}

.report-resumen-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-left: 4px solid var(--khm-green);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.1rem;
  margin-bottom: 1rem;
  font-size: 0.86rem;
  color: #1e293b;
}

.report-resumen-box strong {
  color: var(--khm-purple);
  margin-right: 0.4rem;
}

.report-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.report-chart-box {
  background: #ffffff;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.report-chart-img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 900px) {
  .report-doc-header {
    flex-direction: column;
  }
  .report-charts-grid {
    grid-template-columns: 1fr;
  }
}


