/* ==========================================================================
   A&F OBRA 4.0 - SISTEMA DE GESTIÓN Y OPERACIONES TÉCNICAS
   GRUPO A&F CONSTRUYE SAS
   Identidad visual: Barra lateral #111c2d, fondo corporativo #f4f6f9
   ========================================================================== */

:root {
  --primary-navy: #111c2d;
  --primary-navy-light: #1b2a41;
  --primary-accent: #0284c7;
  --primary-orange: #f97316;
  --primary-orange-hover: #ea580c;
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #3b82f6;
  --info-bg: #dbeafe;
  --dark: #0f172a;
  --gray-900: #1e293b;
  --gray-800: #334155;
  --gray-700: #475569;
  --gray-600: #64748b;
  --gray-500: #94a3b8;
  --gray-300: #cbd5e1;
  --gray-200: #e2e8f0;
  --gray-100: #f1f5f9;
  --bg-app: #f4f6f9;
  --white: #ffffff;
  --sidebar-width: 215px;
  --sidebar-collapsed-width: 60px;
  --topbar-height: 52px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 3px 6px -1px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 12px -2px rgba(0,0,0,0.09);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--gray-800);
  line-height: 1.4;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   LAYOUT DEL CENTRO DE MANDO
   ========================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* SIDEBAR CORPORATIVO (#111c2d) */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--primary-navy);
  color: #e2e8f0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.12);
}

/* REGLA ESTRICTA 1: LOGO OFICIAL */
.brand-logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
}

.brand-logo-img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  background: #ffffff;
  padding: 2px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  flex-shrink: 0;
}

.brand-title-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.62rem;
  text-transform: uppercase;
  color: var(--primary-orange);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
}

.nav-group-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  font-weight: 700;
  margin: 10px 8px 3px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.78rem;
  transition: var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
}

.nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(2, 132, 199, 0.9), rgba(2, 132, 199, 0.7));
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
  font-weight: 600;
}

.nav-link .nav-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-link .badge-counter {
  margin-left: auto;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.nav-link.active .badge-counter {
  background: #ffffff;
  color: var(--primary-accent);
  font-weight: 700;
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.user-compact {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-orange);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  overflow: hidden;
  line-height: 1.2;
}

.user-name {
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.78rem;
}

.user-role {
  font-size: 0.65rem;
  color: #94a3b8;
}

/* MAIN CONTENT AREA */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-page-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--dark);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--gray-200);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
}

.btn-icon:hover {
  background: var(--gray-100);
  color: var(--dark);
}

.btn-primary {
  background: var(--primary-accent);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.2);
  text-decoration: none;
}

.btn-primary:hover {
  background: #0369a1;
  box-shadow: 0 3px 6px rgba(2, 132, 199, 0.3);
}

.btn-orange {
  background: var(--primary-orange);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

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

.btn-success {
  background: #10b981;
  color: #ffffff;
  border: 1px solid #059669;
}
.btn-success:hover {
  background: #059669;
}

.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-outline:hover {
  background: var(--gray-100);
  color: var(--dark);
}

.content-body {
  padding: 14px 18px;
  flex: 1;
}

/* ==========================================================================
   TARJETAS KPI DASHBOARD (7 TARJETAS OFICIALES REALES - COMPACTAS)
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}

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

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
}

.kpi-card.prev-activo::before { background: #3b82f6; }
.kpi-card.prev-cerrado::before { background: #0284c7; }
.kpi-card.corr-activo::before { background: #f97316; }
.kpi-card.corr-cerrado::before { background: #10b981; }
.kpi-card.civil-activo::before { background: #8b5cf6; }
.kpi-card.civil-cerrado::before { background: #64748b; }
.kpi-card.nov-activo::before { background: #ef4444; }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gray-600);
  letter-spacing: 0.02em;
}

.kpi-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  text-transform: uppercase;
}

.kpi-card.prev-activo .kpi-badge { background: var(--info-bg); color: var(--info); }
.kpi-card.prev-cerrado .kpi-badge { background: #e0f2fe; color: #0284c7; }
.kpi-card.corr-activo .kpi-badge { background: var(--warning-bg); color: var(--primary-orange); }
.kpi-card.corr-cerrado .kpi-badge { background: var(--success-bg); color: var(--success); }
.kpi-card.civil-activo .kpi-badge { background: #ede9fe; color: #7c3aed; }
.kpi-card.civil-cerrado .kpi-badge { background: var(--gray-200); color: var(--gray-700); }
.kpi-card.nov-activo .kpi-badge { background: var(--danger-bg); color: var(--danger); }

.kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.1;
  margin-bottom: 2px;
}

.kpi-subtext {
  font-size: 0.68rem;
  color: var(--gray-500);
}

/* ==========================================================================
   FILTROS Y TABLA DE PROGRAMACIONES
   ========================================================================== */

.filter-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  margin-bottom: 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.form-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-700);
}

.form-control {
  height: 32px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 0.8rem;
  color: var(--gray-800);
  background: var(--white);
  outline: none;
  transition: var(--transition);
  width: 100%;
}

.form-control:focus {
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.table-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  margin-bottom: 24px;
}

.table-header-bar {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
  background: #fafbfc;
}

.table-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-responsive {
  overflow-x: auto;
  min-height: 200px;
}

/* ==========================================================================
   TABLAS LIMPIAS Y ESPACIOSAS (UI REESTRUCTURADA - RESPIRO VISUAL)
   ========================================================================== */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  color: var(--gray-700);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-800);
  font-size: 0.84rem;
  vertical-align: middle;
  line-height: 1.45;
}

.data-table tbody tr {
  height: 48px;
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
  background: #f1f5f9;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

.badge-status.activo {
  background: var(--warning-bg);
  color: #b45309;
}

.badge-status.cerrado {
  background: var(--success-bg);
  color: #065f46;
}

.badge-tipo {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
}

.badge-tipo.correctivo { background: #fee2e2; color: #b91c1c; }
.badge-tipo.preventivo { background: #dbeafe; color: #1e40af; }
.badge-tipo.civiles { background: #ede9fe; color: #6d28d9; }

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  border-top: 1px solid var(--gray-200);
  background: #fafbfc;
  font-size: 0.75rem;
}

/* MODAL Y DETALLE */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--white);
  border-radius: var(--radius-md);
  max-width: 820px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 10;
}

.modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--dark);
}

.modal-body {
  padding: 14px 16px;
  flex: 1;
}

.modal-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #fafbfc;
}

/* ==========================================================================
   ACTA PDF EJECUTIVO CON MEMBRETE OFICIAL A&F CONSTRUYE SAS
   ========================================================================== */

.acta-documento {
  background: #ffffff;
  padding: 30px;
  border: 1px solid #d1d5db;
  color: #111827;
  font-family: Arial, sans-serif;
  margin-bottom: 20px;
}

.acta-membrete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px double #111c2d;
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.acta-logo {
  height: 60px;
  object-fit: contain;
}

.acta-empresa-info {
  text-align: right;
  line-height: 1.3;
}

.acta-empresa-info h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: #111c2d;
  margin-bottom: 2px;
}

.acta-empresa-info p {
  font-size: 0.78rem;
  color: #4b5563;
}

.acta-titulo-orden {
  text-align: center;
  margin: 18px 0;
  padding: 8px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}

.acta-titulo-orden h3 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #111c2d;
}

.acta-grid-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.acta-item-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  border-radius: 4px;
}

.acta-item-box span.lbl {
  font-weight: 700;
  font-size: 0.75rem;
  color: #6b7280;
  display: block;
}

.acta-item-box span.val {
  font-size: 0.88rem;
  font-weight: 600;
  color: #111827;
}

.acta-seccion {
  margin-bottom: 18px;
}

.acta-seccion-titulo {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  background: #111c2d;
  color: #ffffff;
  padding: 4px 10px;
  margin-bottom: 8px;
}

.acta-seccion-content {
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 8px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  min-height: 48px;
}

.acta-evidencias-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.acta-foto-card {
  border: 1px solid #d1d5db;
  border-radius: 4px;
  overflow: hidden;
  background: #f9fafb;
}

.acta-foto-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.acta-foto-meta {
  padding: 6px 8px;
  font-size: 0.7rem;
  background: #111c2d;
  color: #ffffff;
  line-height: 1.3;
}

.acta-firmas-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-top: 28px;
  padding-top: 10px;
}

.acta-firma-box {
  text-align: center;
  border-top: 1px solid #111827;
  padding-top: 8px;
}

.acta-firma-img {
  height: 65px;
  max-width: 180px;
  object-fit: contain;
  margin-bottom: 6px;
}

/* ==========================================================================
   APP MÓVIL ESTILOS TÉCNICO EN TERRENO (app-movil.html)
   ========================================================================== */

.mobile-body {
  background: #f1f5f9;
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  box-shadow: 0 0 20px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  position: relative;
}

.mobile-header {
  background: var(--primary-navy);
  color: #ffffff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.mobile-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-header-logo {
  width: 36px;
  height: 36px;
  background: #ffffff;
  padding: 2px;
  border-radius: 6px;
  object-fit: contain;
}

.mobile-header-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
}

.mobile-nav-tabs {
  display: flex;
  background: var(--primary-navy-light);
  border-top: 1px solid rgba(255,255,255,0.1);
}

.mobile-tab-btn {
  flex: 1;
  padding: 10px 4px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.mobile-tab-btn.active {
  color: #ffffff;
  background: rgba(2, 132, 199, 0.4);
  border-bottom: 3px solid var(--primary-orange);
}

.mobile-content {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.mobile-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

.mobile-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-order-item {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  border-left: 3px solid var(--primary-orange);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
}

.mobile-order-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.mobile-order-item.cerrado {
  border-left-color: var(--success);
  opacity: 0.85;
}

/* CANVAS DE FIRMA TÁCTIL */
.signature-box {
  background: #ffffff;
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-sm);
  position: relative;
  touch-action: none;
  margin: 10px 0;
}

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

.signature-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

/* MARCA DE AGUA FOTOGRÁFICA */
.camera-preview-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.camera-preview-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--gray-300);
  background: #000;
}

.camera-preview-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.camera-preview-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 0.62rem;
  padding: 3px 6px;
  line-height: 1.2;
}

/* TOAST NOTIFICACIONES */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--dark);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  min-width: 280px;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   SEGURIDAD (FIREBASE AUTH) - PANTALLAS DE LOGIN
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #111c2d 0%, #0f172a 100%);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 420px;
  width: 100%;
  padding: 32px 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
  position: relative;
}

.auth-card-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin: 0 auto 14px;
  background: #ffffff;
  padding: 4px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.auth-notice {
  background: #f8fafc;
  border-left: 3px solid var(--primary-orange);
  padding: 10px 12px;
  font-size: 0.75rem;
  color: #475569;
  text-align: left;
  border-radius: 4px;
  margin: 16px 0;
  line-height: 1.4;
}

.auth-init-alert {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-left: 4px solid #d97706;
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0 16px;
  text-align: left;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.08);
}

.auth-init-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #b45309;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.auth-init-desc {
  font-size: 0.75rem;
  color: #78350f;
  line-height: 1.4;
  margin-bottom: 6px;
}

.auth-init-warning {
  display: inline-block;
  background: #fee2e2;
  border: 1px solid #f87171;
  color: #991b1b;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  margin-top: 4px;
  width: 100%;
  box-sizing: border-box;
}

/* ==========================================================================
   AUTOMATIZACIÓN DE TIEMPOS (HORA INICIO / FIN BLOQUEADA)
   ========================================================================== */
.time-tracker-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.time-tracker-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
}

.time-tracker-val {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 800;
  color: #0284c7;
  background: #ffffff;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

/* ==========================================================================
   FIRMA EN PANTALLA GRANDE (FULL-SCREEN / 95% VIEWPORT)
   ========================================================================== */
.modal-firma-fs {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  z-index: 10000;
  display: none;
  flex-direction: column;
  padding: 14px;
}

.modal-firma-fs.active {
  display: flex;
}

.modal-firma-fs-box {
  background: #ffffff;
  border-radius: var(--radius-md);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.modal-firma-fs-header {
  padding: 12px 18px;
  background: var(--primary-navy);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-firma-fs-body {
  flex: 1;
  position: relative;
  background: #ffffff;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-fullscreen {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.modal-firma-fs-footer {
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ==========================================================================
   AGENTE IA DE SOPORTE TÉCNICO (BOTÓN FLOTANTE & CHAT)
   ========================================================================== */
.btn-flotante-ia {
  position: fixed;
  bottom: 24px;
  right: 20px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #ffffff;
  border: none;
  border-radius: 30px;
  padding: 12px 20px;
  font-weight: 800;
  font-size: 0.88rem;
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.45);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  z-index: 999;
  transition: var(--transition);
}

.btn-flotante-ia:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 22px rgba(249, 115, 22, 0.6);
}

.chat-ia-overlay {
  position: fixed;
  bottom: 84px;
  right: 20px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.25);
  display: none;
  flex-direction: column;
  z-index: 1000;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  animation: slideUp 0.25s ease;
}

.chat-ia-overlay.active {
  display: flex;
}

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

.chat-ia-header {
  background: var(--primary-navy);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-ia-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.chat-msg.agent {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.chat-msg.user {
  background: var(--primary-orange);
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.chat-ia-footer {
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   ASISTENTE IA CORPORATIVA VALERIA (VALE) - AVATAR TRANSPARENTE OFICIAL
   ========================================================================== */
.valeria-btn-flotante {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(17, 28, 45, 0.94);
  color: #ffffff;
  border: 2px solid rgba(2, 132, 199, 0.4);
  border-radius: 40px;
  padding: 6px 16px 6px 6px;
  font-weight: 700;
  font-size: 0.84rem;
  box-shadow: 0 8px 24px rgba(17, 28, 45, 0.35), 0 0 15px rgba(2, 132, 199, 0.25);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  z-index: 999;
  backdrop-filter: blur(8px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.valeria-btn-flotante:hover {
  background: var(--primary-navy);
  border-color: #38bdf8;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 28px rgba(17, 28, 45, 0.45), 0 0 20px rgba(56, 189, 248, 0.4);
}

.valeria-avatar-img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #0284c7;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.valeria-btn-flotante:hover .valeria-avatar-img {
  transform: scale(1.08);
}

.valeria-btn-label {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}

.valeria-btn-label-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: #ffffff;
}

.valeria-btn-label-sub {
  font-size: 0.65rem;
  color: #38bdf8;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.valeria-pulse-dot {
  width: 9px;
  height: 9px;
  background: #10b981;
  border-radius: 50%;
  position: absolute;
  top: 6px;
  left: 36px;
  box-shadow: 0 0 0 2px #111c2d, 0 0 8px #10b981;
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.valeria-avatar-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: #ffffff;
  border: 1.5px solid #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.valeria-chat-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==========================================================================
   BADGES Y COMPONENTES ZERO-TRUST & TRANSACCIONAL
   ========================================================================== */
.badge-status.inactivo {
  background: var(--danger-bg);
  color: #991b1b;
  font-weight: 700;
}

.badge-status.pendiente-firma {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
  font-weight: 700;
}

.badge-status.recibido {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-weight: 700;
}

/* Selector rápido de cuadrilla en hover de tabla */
.select-cuadrilla-rapida {
  font-size: 0.76rem;
  padding: 4px 8px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: #ffffff;
  color: var(--gray-800);
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.select-cuadrilla-rapida:hover,
.select-cuadrilla-rapida:focus {
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

/* Dropzone Carga Masiva IA Gemini */
.dropzone-ia {
  border: 2px dashed #93c5fd;
  background: #f8fafc;
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone-ia:hover,
.dropzone-ia.dragover {
  border-color: var(--primary-accent);
  background: #eff6ff;
  transform: translateY(-1px);
}

.valeria-chat-overlay {
  position: fixed;
  bottom: 74px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 36px);
  height: 540px;
  max-height: calc(100vh - 100px);
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  display: none;
  flex-direction: column;
  z-index: 1000;
  border: 1px solid var(--gray-300);
  overflow: hidden;
  animation: slideUp 0.2s ease;
}

.valeria-chat-overlay.active {
  display: flex;
}

.valeria-chat-header {
  background: var(--primary-navy);
  color: #ffffff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.valeria-quick-questions {
  background: #f1f5f9;
  border-bottom: 1px solid var(--gray-200);
  padding: 10px 12px;
}

.valeria-quick-btn {
  background: #ffffff;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: var(--gray-800);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  width: 100%;
}

.valeria-quick-btn:hover {
  background: #f8fafc;
  border-color: var(--primary-accent);
  color: var(--primary-accent);
}

.valeria-chat-messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
}

.valeria-chat-footer {
  padding: 8px 12px;
  background: #ffffff;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 6px;
}

/* PRINT MEDIA */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .sidebar, .topbar, .modal-header button, .modal-footer, .filter-card, .table-card, .btn, .no-print, .btn-flotante-ia, .chat-ia-overlay, .valeria-btn-flotante, .valeria-chat-overlay {
    display: none !important;
  }
  .modal-overlay {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    display: block !important;
  }
  .modal-box {
    box-shadow: none !important;
    max-width: 100% !important;
    max-height: none !important;
    border: none !important;
  }
  .acta-documento {
    border: none !important;
    padding: 0 !important;
  }
}

/* Supresión global de controles de incremento en inputs numéricos */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

