/* ============================================
   DOCURIBE — ESTILOS GLOBALES
   ============================================ */

/* Variables CSS */
:root {
  --primary: #1a3a6b;
  --primary-dark: #0f2347;
  --primary-light: #2e5fa3;
  --accent: #1e7fc2;
  --accent-light: #e8f4fd;
  --zuma-1: #a8d8c8;
  --zuma-2: #f5c97a;
  --zuma-3: #f4a07a;

  --success: #22c55e;
  --success-bg: #dcfce7;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #3b82f6;
  --info-bg: #dbeafe;

  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --white: #ffffff;
  --sidebar-width: 260px;
  --sidebar-collapsed: 68px;
  --topbar-height: 60px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
  --transition: 0.22s ease;
  --font: 'Inter', system-ui, sans-serif;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }

/* Animación shake para modales protegidos */
@keyframes shake-modal {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(-8px); }
  30%  { transform: translateX(8px); }
  45%  { transform: translateX(-6px); }
  60%  { transform: translateX(6px); }
  75%  { transform: translateX(-3px); }
  90%  { transform: translateX(3px); }
  100% { transform: translateX(0); }
}
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; touch-action: manipulation; }
button { font-family: var(--font); cursor: pointer; border: none; outline: none; touch-action: manipulation; }
input, select, textarea { font-family: var(--font); font-size: 1rem; }
img { max-width: 100%; }

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
#app-layout {
  display: flex;
  height: 100vh;
  height: 100svh;  /* iOS Safari */
  height: 100dvh;  /* Chrome/Firefox tablet: dynamic viewport (descuenta barra browser) */
  overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
#sidebar {
  width: var(--sidebar-width);
  background: var(--primary-dark);
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  z-index: 100;
}
#sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--topbar-height);
}
.sidebar-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
  border-radius: 6px;
}
.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--transition), width var(--transition);
}
.sidebar-logo-text .app-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
  letter-spacing: 0.5px;
}
.sidebar-logo-text .app-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
}
#sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.nav-section {
  padding: 16px 12px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.3);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}
#sidebar.collapsed .nav-section { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-radius: 8px;
  margin: 2px 8px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
}
.nav-item.active {
  background: var(--accent);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(30,127,194,0.4);
}
.nav-item i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item-text {
  font-size: 0.88rem;
  font-weight: 500;
  transition: opacity var(--transition);
  overflow: hidden;
}
#sidebar.collapsed .nav-item-text { opacity: 0; width: 0; }
#sidebar.collapsed .nav-item { justify-content: center; padding: 10px; margin: 2px 6px; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  line-height: 1.2;
  transition: opacity var(--transition);
}
#sidebar.collapsed .nav-badge { display: none; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-toggle {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.8rem;
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.12); color: var(--white); }

/* ============================================
   CONTENIDO PRINCIPAL
   ============================================ */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================
   TOPBAR
   ============================================ */
#topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 50;
}
.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  flex: 1;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-btn {
  background: transparent;
  color: var(--gray-500);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.topbar-btn:hover { background: var(--gray-100); color: var(--primary); }
.topbar-btn .badge-count {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--danger);
  color: var(--white);
  font-size: 0.6rem;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
}
.topbar-user:hover { background: var(--gray-100); }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}
.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-700);
}
.user-role {
  font-size: 0.7rem;
  color: var(--gray-400);
  line-height: 1;
}

/* ============================================
   PÁGINA / VIEWS
   ============================================ */
#page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  padding-bottom: 80px;  /* espacio generoso al fondo — tablet/móvil con barra navegador */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; /* scroll suave en iOS/iPadOS */
  /* Asegurar que el contenedor NO tenga altura fija que bloquee el scroll */
  min-height: 0;
}
#page-content::-webkit-scrollbar { width: 5px; }
#page-content::-webkit-scrollbar-track { background: var(--gray-100); }
#page-content::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

.view { display: none; }
.view.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header-left h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}
.page-header-left p {
  font-size: 0.82rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 20px; }

/* ============================================
   STATS / MÉTRICAS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.15s, box-shadow 0.15s;
  min-width: 0;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; color: var(--info); }
.stat-icon.green  { background: var(--success-bg); color: var(--success); }
.stat-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red    { background: var(--danger-bg); color: var(--danger); }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.teal   { background: #ccfbf1; color: #0d9488; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.gray   { background: var(--gray-100); color: var(--gray-600); }
.stat-icon.info   { background: var(--info-bg); color: var(--info); }

.stat-data { flex: 1; min-width: 0; }
.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.15;
  /* Permite que valores monetarios largos se ajusten */
  word-break: break-word;
  overflow-wrap: break-word;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--gray-500);
  margin-top: 3px;
  line-height: 1.3;
  white-space: normal;
}
.stat-sub {
  font-size: 0.62rem;
  color: var(--gray-400);
  margin-top: 1px;
  font-style: italic;
}
/* Valores monetarios: fuente ligeramente más pequeña para que quepan */
.stat-value-money {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.2;
  word-break: break-all;
}

/* ============================================
   GRID LAYOUT
   ============================================ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* ============================================
   TABLAS
   ============================================ */
.table-responsive { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.table thead th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.12s;
}
.table tbody tr:hover { background: var(--gray-50); }
.table tbody td {
  padding: 10px 14px;
  color: var(--gray-700);
  vertical-align: middle;
}
.table tbody tr:last-child { border-bottom: none; }
.table-actions { display: flex; gap: 6px; align-items: center; }

/* ============================================
   BADGES / ETIQUETAS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: #16a34a; }
.badge-warning { background: var(--warning-bg); color: #d97706; }
.badge-danger { background: var(--danger-bg); color: #dc2626; }
.badge-info { background: var(--info-bg); color: #2563eb; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-purple { background: #ede9fe; color: #7c3aed; }
.badge-primary { background: #dbeafe; color: var(--primary); }

/* ============================================
   BOTONES
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: 1.5px solid transparent;
  line-height: 1.2;
}
.btn-sm { padding: 5px 11px; font-size: 0.78rem; border-radius: 6px; gap: 5px; }
.btn-xs { padding: 3px 8px; font-size: 0.72rem; border-radius: 5px; gap: 4px; }
.btn-lg { padding: 11px 22px; font-size: 0.95rem; }
.btn-icon { padding: 7px; }

.btn-primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }

.btn-info {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--info);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background var(--transition);
}
.btn-info:hover { background: var(--info); color: var(--white); }

.btn-accent {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
}
.btn-accent:hover { background: #1668a3; }

.btn-success {
  background: var(--success);
  color: var(--white);
  border-color: var(--success);
}
.btn-success:hover { background: #16a34a; }

.btn-danger {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; }

.btn-warning {
  background: var(--warning);
  color: var(--white);
  border-color: var(--warning);
}
.btn-warning:hover { background: #d97706; }

/* Botón Borrador — naranja suave */
.btn-draft {
  background: #fff7ed;
  color: #c2410c;
  border: 1.5px solid #fb923c;
  font-weight: 600;
}
.btn-draft:hover { background: #ffedd5; border-color: #ea580c; color: #9a3412; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: var(--white); }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: var(--gray-200);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-white {
  background: var(--white);
  color: var(--gray-700);
  border-color: var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.btn-white:hover { background: var(--gray-50); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ============================================
   FORMULARIOS
   ============================================ */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
}
.form-group label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30,127,194,0.12);
}
.form-control::placeholder { color: var(--gray-400); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 17px; height: 17px;
  cursor: pointer;
  accent-color: var(--accent);
}
.form-check label { font-size: 0.85rem; color: var(--gray-700); cursor: pointer; margin: 0; }

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .form-control { flex: 1; border-radius: 8px 0 0 8px; }
.input-group .btn { border-radius: 0 8px 8px 0; border-left: none; }
.input-prefix {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--gray-500);
  font-size: 0.88rem;
  white-space: nowrap;
}
.input-prefix + .form-control { border-radius: 0 8px 8px 0; }

/* ============================================
   MODALES
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;   /* nunca bloquear clics cuando está oculto */
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;   /* habilitado sólo cuando está visible */
}
/* Confirm modal siempre encima de cualquier otro modal */
#modal-confirm-overlay {
  z-index: 1100;
}
/* Modal genérico principal: siempre visible */
#modal-overlay {
  z-index: 1050;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  max-height: 90dvh; /* descuenta la barra del navegador en tablet/móvil */
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s;
  overflow: hidden;
}
.modal-overlay.show .modal { transform: scale(1) translateY(0); }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 1000px; }

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 9px;
}
.modal-close {
  background: var(--gray-100);
  color: var(--gray-500);
  width: 30px; height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* crítico: permite que flex + overflow-y funcione en todos los navegadores */
  -webkit-overflow-scrolling: touch;
}
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0; /* el footer NUNCA se encoge — siempre visible */
}

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
  gap: 0;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 18px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================
   ALERTAS
   ============================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.84rem;
  margin-bottom: 12px;
}
.alert i { margin-top: 1px; font-size: 0.95rem; flex-shrink: 0; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: var(--info-bg); color: #1e40af; border: 1px solid #93c5fd; }
.alert-success { background: var(--success-bg); color: #166534; border: 1px solid #86efac; }
.alert-title { font-weight: 700; }
.alert-body { margin-top: 2px; }

/* ============================================
   BÚSQUEDA / FILTROS
   ============================================ */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-input-wrap i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 0.9rem;
}
.search-input-wrap input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.85rem;
  background: var(--white);
  transition: border-color 0.15s;
}
.search-input-wrap input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ============================================
   PROGRESO / BARRAS
   ============================================ */
.progress-bar {
  height: 7px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 5px;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.progress-fill.green { background: var(--success); }
.progress-fill.yellow { background: var(--warning); }
.progress-fill.red { background: var(--danger); }
.progress-fill.blue { background: var(--accent); }

/* ============================================
   FINANCIAL PANEL (Trabajos)
   ============================================ */
.fin-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px;
  background: var(--gray-50);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.fin-item { text-align: center; }
.fin-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.fin-label {
  font-size: 0.7rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--gray-400);
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
  opacity: 0.4;
}
.empty-state h3 { font-size: 1rem; color: var(--gray-500); margin-bottom: 6px; }
.empty-state p { font-size: 0.82rem; }

/* ============================================
   LOADING
   ============================================ */
.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

/* ============================================
   WIZARD (Generador de documentos)
   ============================================ */
.wizard-steps {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
  gap: 0;
  position: relative;
}
.wizard-steps::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--gray-200);
  z-index: 0;
}
.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  position: relative;
  z-index: 1;
}
.step-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gray-400);
  transition: all 0.2s;
}
.wizard-step.done .step-circle { background: var(--success); border-color: var(--success); color: var(--white); }
.wizard-step.active .step-circle { background: var(--accent); border-color: var(--accent); color: var(--white); box-shadow: 0 0 0 4px rgba(30,127,194,0.2); }
.step-label { font-size: 0.7rem; color: var(--gray-400); text-align: center; }
.wizard-step.active .step-label { color: var(--accent); font-weight: 600; }
.wizard-step.done .step-label { color: var(--success); }

.wizard-page { display: none; }
.wizard-page.active { display: block; }

/* Selector empresa */
.empresa-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 500px;
  margin: 20px auto;
}
.empresa-card {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--white);
}
.empresa-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.empresa-card.selected { border-color: var(--accent); background: var(--accent-light); }
.empresa-card img { height: 60px; object-fit: contain; margin-bottom: 10px; }
.empresa-card-name { font-weight: 700; color: var(--primary); font-size: 0.9rem; }

/* Tipo de documento */
.doc-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.doc-type-card {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--white);
}
.doc-type-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.doc-type-card.selected { border-color: var(--accent); background: var(--accent-light); }
.doc-type-card i { font-size: 2rem; color: var(--accent); margin-bottom: 10px; display: block; }
.doc-type-card-name { font-size: 0.82rem; font-weight: 600; color: var(--gray-700); }

/* ============================================
   ITEMS TABLE (Cotización)
   ============================================ */
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 10px;
}
.items-table thead th {
  background: var(--gray-50);
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-600);
  font-size: 0.75rem;
  text-transform: uppercase;
}
.items-table tbody td {
  border: 1px solid var(--gray-200);
  padding: 5px 8px;
}
.items-table tbody td input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.82rem;
  padding: 4px;
  outline: none;
  color: var(--gray-800);
}
.items-table tbody td input:focus { background: var(--accent-light); border-radius: 4px; }
.items-totals { text-align: right; padding: 10px 0; }
.items-totals .total-row { display: flex; justify-content: flex-end; gap: 20px; padding: 4px 0; font-size: 0.84rem; }
.items-totals .total-row.grand-total { font-size: 1rem; font-weight: 700; color: var(--primary); border-top: 2px solid var(--gray-200); padding-top: 8px; }

/* ============================================
   FOTOS
   ============================================ */
.photo-drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--gray-50);
}
.photo-drop-zone:hover, .photo-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.photo-drop-zone i { font-size: 2rem; color: var(--gray-400); margin-bottom: 8px; display: block; }
.photo-drop-zone p { font-size: 0.85rem; color: var(--gray-500); }
.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.photo-item {
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.photo-item img { width: 100%; height: 130px; object-fit: cover; }
.photo-item-footer { padding: 6px 8px; }
.photo-item-footer input {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 0.75rem;
  background: var(--white);
}
.photo-remove {
  position: absolute;
  top: 5px; right: 5px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  cursor: pointer;
}
.photo-item-wrap { position: relative; }

/* Imagen de presupuesto (paste) */
.paste-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  background: var(--gray-50);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.paste-zone:hover, .paste-zone.has-img { border-color: var(--accent); }
.paste-zone img { max-width: 100%; border-radius: 6px; }
.paste-zone i { font-size: 1.5rem; color: var(--gray-400); }
.paste-zone p { font-size: 0.8rem; color: var(--gray-500); }

/* ============================================
   VISTA PREVIA DE DOCUMENTOS (Print)
   ============================================ */

/* Paleta CONURIBE (por defecto) */
.doc-preview {
  --doc-primary:   #1a3a6b;
  --doc-secondary: #2255A4;
  --doc-accent:    #2A6DB5;
  --doc-border:    #1a3a6b;
  --doc-title-color: #1a3a6b;
  background: var(--white);
  max-width: 800px;
  margin: 0 auto;
  padding: 30px 35px;
  font-size: 0.85rem;
  color: var(--gray-800);
  line-height: 1.6;
}

/* Paleta ZUMA — basada en colores reales del logo */
/* Cian pastel #7ECFD4 · Dorado #E8C97A · Salmón #E8A898 · Negro #0D0D0D */
.doc-preview[data-empresa="ZUMA"] {
  --doc-primary:     #1A1A1A;   /* Negro tipografía — títulos y textos */
  --doc-secondary:   #7ECFD4;   /* Cian pastel — acento del ícono */
  --doc-accent:      #E8A898;   /* Salmón pastel — segundo acento */
  --doc-border:      #7ECFD4;   /* Cian en línea del header */
  --doc-title-color: #1A1A1A;
  --doc-thead-bg:    #2C2C2C;   /* Fondo encabezado tabla — negro elegante */
}

.doc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 3px solid var(--doc-border, var(--primary));
  padding-bottom: 16px;
  margin-bottom: 20px;
}
.doc-logo img { height: 75px; max-width: 300px; object-fit: contain; }
.doc-company-info { text-align: right; font-size: 0.75rem; color: var(--gray-600); line-height: 1.7; }
.doc-company-info .company-name { font-size: 1rem; font-weight: 700; color: var(--doc-primary, var(--primary)); }
.doc-title {
  text-align: center;
  margin-bottom: 20px;
}
.doc-title h2 { font-size: 1.1rem; font-weight: 700; color: var(--doc-primary, var(--primary)); text-transform: uppercase; letter-spacing: 1px; }
.doc-ref { font-size: 0.75rem; color: var(--gray-500); }
.doc-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
}
.doc-meta-item label { display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500); font-weight: 600; }
.doc-meta-item span { font-size: 0.82rem; color: var(--gray-800); font-weight: 500; }
.doc-section { margin-bottom: 18px; }
.doc-section h3 { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--doc-primary, var(--primary)); border-bottom: 1px solid var(--gray-200); padding-bottom: 5px; margin-bottom: 10px; }

/* Contenido rico generado por el RichEditor — preview en app y PDF */
.doc-rich-content {
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--gray-800);
}
.doc-rich-content p { margin-bottom: 4px; text-align: justify; }
.doc-rich-content div { margin-bottom: 3px; }

/* Listas con viñetas */
.doc-rich-content ul {
  list-style-type: disc;
  padding-left: 1.4em;
  margin: 4px 0 6px 0;
}
/* Listas numeradas */
.doc-rich-content ol {
  list-style-type: decimal;
  padding-left: 1.4em;
  margin: 4px 0 6px 0;
}
/* Ítems */
.doc-rich-content li {
  margin-bottom: 3px;
  padding-left: 2px;
  line-height: 1.65;
}
/* Listas anidadas */
.doc-rich-content ul ul,
.doc-rich-content ol ol,
.doc-rich-content ul ol,
.doc-rich-content ol ul {
  margin-top: 2px;
  margin-bottom: 2px;
  padding-left: 1.2em;
}
.doc-rich-content ul ul { list-style-type: circle; }
.doc-rich-content ul ul ul { list-style-type: square; }

/* Formatos inline */
.doc-rich-content b,
.doc-rich-content strong { font-weight: 700; }
.doc-rich-content i,
.doc-rich-content em    { font-style: italic; }
.doc-rich-content u     { text-decoration: underline; }
.doc-photos-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 10px; }
.doc-photo-item { border: 1px solid var(--gray-200); border-radius: 6px; overflow: hidden; }
/* Fotos: proporcionales, sin distorsión, sin nombre de archivo */
.doc-photo-item img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: var(--gray-50); display: block; }
.doc-photo-caption { padding: 5px 8px; font-size: 0.72rem; color: var(--gray-600); text-align: center; background: var(--gray-50); border-top: 1px solid var(--gray-200); }

/* ---- Sistema de firmas — bloque nombre/cargo ---- */
.doc-signature-section { margin-top: 36px; padding-top: 12px; }
.doc-signature-title { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-500); text-align: center; margin-bottom: 24px; }

/* Dos firmantes (actas y contratos) */
.doc-signature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 30px; }

/* Un solo firmante (cotizaciones, informes, mantenimiento) — centrado */
.doc-signature-solo .doc-signature-grid-solo { display: flex; justify-content: center; }
.doc-signature-solo .doc-sign-block { min-width: 240px; max-width: 300px; }

.doc-sign-block { text-align: center; }
.doc-sign-line-area { border-top: 1px solid var(--gray-600); width: 76%; margin: 0 auto 8px; padding-top: 36px; }
.doc-sign-name { font-size: 0.84rem; font-weight: 700; color: var(--gray-800); margin-bottom: 2px; }
.doc-sign-role { font-size: 0.72rem; color: var(--gray-500); line-height: 1.5; }

/* Aviso de envío en cotizaciones */
.doc-cot-aviso {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.78rem;
  color: #0369a1;
  margin: 14px 0 6px;
}
/* ZUMA: aviso con tono cian pastel */
.doc-preview[data-empresa="ZUMA"] .doc-cot-aviso {
  background: #f0fdfd;
  border-color: #a5e4e7;
  color: #0e7490;
}
.doc-cot-aviso-icon { font-size: 1rem; font-style: normal; flex-shrink: 0; }

/* Legado — mantener compatibilidad */
.doc-signature { display: grid; grid-template-columns: repeat(2, 1fr); gap: 30px; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--gray-200); }
.doc-sign-box { text-align: center; }
.doc-sign-line { border-top: 1px solid var(--gray-600); width: 80%; margin: 0 auto 6px; }

/* Ref row en títulos */
.doc-ref-row { display: flex; justify-content: center; gap: 14px; margin-top: 4px; flex-wrap: wrap; }
.doc-ref-row span { font-size: 0.75rem; color: var(--gray-500); }
.doc-subtitle { font-size: 0.88rem; font-weight: 700; color: var(--gray-700); text-transform: uppercase; margin-top: 4px; }

/* Condiciones grid en cotización */
.doc-conditions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.doc-footer-bar {
  margin-top: 24px;
  padding-top: 10px;
  border-top: 2px solid var(--primary);
  text-align: center;
  font-size: 0.72rem;
  color: var(--gray-500);
}

/* Items table inside preview */
.doc-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin: 8px 0;
}
.doc-items-table thead th {
  background: var(--doc-thead-bg, var(--primary));
  color: var(--white);
  padding: 7px 10px;
  text-align: left;
  font-size: 0.72rem;
}
.doc-items-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--gray-200);
}
.doc-items-table tbody tr:nth-child(even) { background: var(--gray-50); }
.doc-items-totals { margin-top: 8px; }
.doc-items-totals table { margin-left: auto; font-size: 0.8rem; }
.doc-items-totals td { padding: 3px 10px; }
.doc-items-totals .total-final { font-weight: 700; font-size: 0.9rem; color: var(--doc-primary, var(--primary)); border-top: 2px solid var(--doc-primary, var(--primary)); }
.doc-items-totals .descuento-row td { color: var(--success); font-weight: 500; }

/* ============================================
   TOOLTIPS
   ============================================ */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: var(--white);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.73rem;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
.toast {
  background: var(--gray-800);
  color: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  position: relative;
  overflow: hidden;
}
.toast::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  animation: toastBar 3.5s linear forwards;
}
.toast.success::after { background: var(--success); }
.toast.error::after { background: var(--danger); }
.toast.warning::after { background: var(--warning); }
.toast.info::after { background: var(--info); }
.toast i { font-size: 1rem; flex-shrink: 0; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast.info i { color: var(--info); }
@keyframes toastIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }
@keyframes toastBar { from { width: 100%; } to { width: 0%; } }

/* ============================================
   MISC
   ============================================ */
.divider { height: 1px; background: var(--gray-200); margin: 16px 0; }
.text-muted { color: var(--gray-500); font-size: 0.82rem; }
.text-small { font-size: 0.78rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.monospace { font-family: monospace; }
.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }
.color-primary { color: var(--primary); }
.color-success { color: var(--success); }
.color-danger { color: var(--danger); }
.color-warning { color: var(--warning); }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

/* Ficha cliente tabs */
.client-tabs-content { margin-top: 4px; }
.client-header-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--white);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.client-avatar {
  width: 60px; height: 60px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
}
.client-info h2 { font-size: 1.2rem; font-weight: 700; }
.client-info p { font-size: 0.82rem; opacity: 0.8; }
.client-badges { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* Abonos / historial pagos */
.abono-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--white);
  gap: 12px;
  transition: box-shadow var(--transition);
}
.abono-item:hover { box-shadow: var(--shadow-sm); }

/* Botón abono en tabla: mostrar texto en pantallas anchas */
@media (min-width: 1200px) {
  .abono-label { display: inline !important; }
}

/* Icono de método de pago */
.abono-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--success-bg);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.abono-valor {
  font-size: 1rem;
  font-weight: 700;
  color: var(--success);
  line-height: 1.2;
}
.abono-meta {
  font-size: 0.73rem;
  color: var(--gray-500);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 3px;
}

/* ============================================
   TRAZABILIDAD — Banner obra vinculada
   ============================================ */
.traz-obra-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--accent-light) 0%, #e0f2fe 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.traz-obra-banner > i {
  font-size: 1.4rem;
  color: var(--accent);
  flex-shrink: 0;
}
.traz-obra-banner > div { flex: 1; min-width: 0; }
.btn-white {
  background: var(--white);
  border: 1px solid var(--gray-200);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}
.btn-white:hover { background: var(--gray-50); }

/* Indicador auto-sync en tabla trazabilidad */
.traz-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.65rem;
  color: var(--success);
  font-weight: 600;
}

/* ============================================
   MÓDULO OBRAS — Sub-tabs y estilos
   ============================================ */
.obras-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.obras-tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 8px;
  border: 2px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.obras-tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.obras-tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(26,58,107,0.25);
}

/* Panel avance vs cobro */
.obras-avance-panel {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 16px;
}
.obras-alerta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--warning-bg);
  color: #92400e;
  border: 1px solid var(--warning);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 8px;
}

/* ============================================
   DOCUMENTOS EN OBRAS — Componentes
   ============================================ */

/* Ítem de documento en la lista de la obra */
.doc-item-obra {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--white);
  transition: box-shadow var(--transition);
}
.doc-item-obra:hover { box-shadow: var(--shadow-sm); }

.doc-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.doc-item-icon.pdf     { background: #fee2e2; color: var(--danger); }
.doc-item-icon.sistema { background: var(--info-bg); color: var(--info); }
.doc-item-icon.ref     { background: var(--gray-100); color: var(--gray-500); }

.doc-item-info {
  flex: 1;
  min-width: 0;
}
.doc-item-titulo {
  font-weight: 600;
  color: var(--gray-800);
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--gray-500);
  align-items: center;
}
.doc-item-acciones {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

/* Badge de tipo de documento */
.badge-doc-tipo {
  background: var(--gray-100);
  color: var(--gray-600);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Zona de carga de PDF */
.pdf-upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  background: var(--gray-50);
  transition: all var(--transition);
}
.pdf-upload-zone:hover {
  border-color: var(--primary);
  background: rgba(26,58,107,0.04);
}

/* Tabs mini del formulario doc */
.btn-tab-mini {
  transition: all var(--transition);
}
.btn-tab-mini:hover {
  opacity: 0.85;
}

/* ── Celda de fechas en tabla de obras ── */
.obra-fechas-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 150px;
}
.obra-fecha-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.75rem;
}
.obra-fecha-lbl {
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 62px;
}
.obra-fecha-lbl.inicio  { color: #16a34a; }
.obra-fecha-lbl.prevista { color: #f59e0b; }
.obra-fecha-lbl.prevista.vencida { color: var(--danger); }
.obra-fecha-lbl.real    { color: #22c55e; }
.obra-fecha-val {
  font-size: 0.77rem;
  color: var(--gray-700);
}
.obra-fecha-val.vencida {
  color: var(--danger);
  font-weight: 600;
}
.obra-fecha-real .obra-fecha-val {
  color: var(--success);
  font-weight: 700;
}
.obra-fechas-dias {
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--gray-400);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Tabla obras — ocultar columnas en móvil */
@media (max-width: 900px) {
  .obras-table th:nth-child(4),
  .obras-table td:nth-child(4),
  .obras-table th:nth-child(8),
  .obras-table td:nth-child(8) { display: none; }
}
@media (max-width: 680px) {
  .obras-table th:nth-child(2),
  .obras-table td:nth-child(2),
  .obras-table th:nth-child(6),
  .obras-table td:nth-child(6) { display: none; }
}

/* ============================================
   RESPONSIVE MEJORADO
   ============================================ */
@media (max-width: 900px) {
  /* ── Sidebar colapsado en tablet ── */
  #sidebar { width: var(--sidebar-collapsed); }
  #sidebar .sidebar-logo-text,
  #sidebar .nav-item-text,
  #sidebar .nav-section,
  #sidebar .nav-badge { display: none; }
  #sidebar .nav-item { justify-content: center; padding: 12px; }

  /* ── Layout principal: asegurar scroll vertical ── */
  #page-content {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
    padding-bottom: 100px; /* espacio para barra de navegador en tablet */
    min-height: 0;
  }

  /* ── Grid del Dashboard: 1 columna en tablet ── */
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 12px; }

  /* ── Stats: 3 columnas en tablet horizontal, 2 en vertical ── */
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }

  /* ── Formularios: 1 columna ── */
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .doc-meta { grid-template-columns: repeat(2, 1fr); }

  /* ── Page header: wrap en tablet ── */
  .page-header { flex-wrap: wrap; gap: 10px; }
  .page-header div[style*="display:flex"] { flex-wrap: wrap; gap: 6px; }
  /* Botones del header más compactos en tablet */
  .page-header .btn { font-size: 0.78rem; padding: 6px 10px; }
  .page-header .btn-sm { font-size: 0.72rem; padding: 4px 8px; }

  /* ── Accesos rápidos: 3 por fila en tablet ── */
  .doc-type-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .doc-type-card { padding: 14px 10px; }
  .doc-type-card i { font-size: 1.6rem; margin-bottom: 6px; }

  /* ── Topbar compacto ── */
  .topbar-user .user-role { display: none; }

  /* ── Modales: más anchos en tablet, altura dinámica ── */
  .modal {
    max-width: 92vw;
    max-height: 85dvh;
    max-height: 85svh;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .modal-header { flex-shrink: 0; }
  .modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0; /* crítico para que flex + overflow-y funcione */
  }
  .modal-footer {
    flex-shrink: 0;
    padding: 12px 18px;
  }

  /* ── Overlay: ocupa exactamente el viewport visible (sin barra browser) ── */
  .modal-overlay {
    padding: 12px;
    align-items: center;
    justify-content: center;
  }
}
@media (max-width: 700px) {
  /* Móvil grande: 2 columnas */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px 14px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; font-size: 1rem; border-radius: 9px; }
  .stat-value { font-size: 1.05rem; }
  .stat-label { font-size: 0.68rem; }
  /* Topbar muy compacto */
  #topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 0.95rem; }
  #btn-alerts .badge-count { display: flex; }
  .topbar-user .user-name { font-size: 0.75rem; }
}
@media (max-width: 600px) {
  #page-content { padding: 10px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  /* Móvil estándar: 2 columnas compactas */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
  .stat-card { padding: 11px 12px; gap: 9px; border-radius: 10px; }
  .stat-icon { width: 34px; height: 34px; font-size: 0.95rem; border-radius: 8px; }
  .stat-value { font-size: 1rem; }
  .stat-label { font-size: 0.67rem; }
  /* Modales: pantalla completa en móvil */
  .modal {
    max-width: 100% !important;
    max-height: 96dvh !important;
    max-height: 96svh !important;
    max-height: 96vh !important;
    border-radius: 16px 16px 0 0;
    width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
  }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: none;
  }
  /* Tabs scrollables en móvil */
  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .tabs::-webkit-scrollbar { height: 3px; }
  .tabs::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; }
  /* Page header apilado en móvil */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header h1 { font-size: 1.1rem; }
  /* Barra de búsqueda scroll horizontal en móvil */
  .search-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; gap: 6px; }
  .search-bar::-webkit-scrollbar { height: 3px; }
  .search-bar select { min-width: 120px; }
  /* Botones de acción en tabla más pequeños */
  .table-actions { gap: 2px; }
  .btn-xs { padding: 3px 5px; font-size: 0.7rem; }
  /* Obras tabs apilados */
  .obras-tabs { gap: 4px; }
  .obras-tab-btn { padding: 8px 12px; font-size: 0.8rem; }
  .empresa-selector { grid-template-columns: 1fr; }
  .doc-type-grid { grid-template-columns: repeat(2, 1fr); }
  /* Gráficas más compactas en móvil */
  .grid-2 { grid-template-columns: 1fr; }
  .card { padding: 14px; }
}
@media (max-width: 400px) {
  /* Móvil pequeño: tarjetas más verticales */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .stat-card { padding: 10px; gap: 8px; flex-direction: column; align-items: flex-start; }
  .stat-icon { width: 30px; height: 30px; font-size: 0.85rem; }
  .stat-value { font-size: 0.95rem; }
  .stat-label { font-size: 0.65rem; }
}

/* ============================================
   RICH EDITOR — Editor de texto enriquecido
   ============================================ */
.re-wrap {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
.re-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,58,107,0.1);
}
.re-wrap.re-expanded {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(26,58,107,0.15);
}

/* Barra de herramientas */
.re-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
  min-height: 36px;
}
.re-toolbar-group {
  display: flex;
  align-items: center;
  gap: 1px;
}
.re-toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--gray-300);
  margin: 0 4px;
}

/* Botones de la barra */
.re-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--gray-600);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
  padding: 0;
}
.re-btn:hover {
  background: var(--gray-200);
  color: var(--primary);
}
.re-btn.active {
  background: var(--primary);
  color: var(--white);
}
.re-expand-btn {
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
  color: var(--gray-400);
}
.re-expand-btn:hover {
  background: var(--gray-200);
  color: var(--primary);
}

/* Área editable */
.re-content {
  padding: 10px 14px;
  outline: none;
  font-size: 0.9rem;
  color: var(--gray-800);
  line-height: 1.6;
  overflow-y: auto;
  resize: vertical;
  transition: min-height var(--transition);
  word-wrap: break-word;
}
/* Placeholder */
.re-content:empty::before {
  content: attr(data-placeholder);
  color: var(--gray-400);
  pointer-events: none;
  font-style: italic;
}
/* Listas dentro del editor */
.re-content ul,
.re-content ol {
  padding-left: 1.6em;
  margin: 4px 0;
}
.re-content li {
  margin-bottom: 2px;
}
/* Estilos inline */
.re-content b, .re-content strong { font-weight: 700; }
.re-content i, .re-content em     { font-style: italic; }
.re-content u                      { text-decoration: underline; }

/* Pie del editor */
.re-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  gap: 8px;
  flex-wrap: wrap;
}
.re-char-count {
  font-size: 0.7rem;
  color: var(--gray-400);
}

/* Responsive: ocultar hint en móvil */
@media (max-width: 600px) {
  .re-footer span:last-child { display: none; }
  .re-btn { width: 26px; height: 26px; }
}

/* ============================================
   PLANIFICACIÓN DE PERSONAL
   Sub-tabs Personal / Planificación
   ============================================ */

/* Sub-tabs barra */
.personal-subtabs {
  display: flex;
  gap: 0;
  background: var(--white);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--gray-200);
  border-bottom: none;
  overflow: hidden;
  margin-bottom: 0;
}
.personal-subtab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  background: var(--gray-50);
  border: none;
  border-right: 1px solid var(--gray-200);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-500);
  transition: all var(--transition);
}
.personal-subtab-btn:last-child { border-right: none; }
.personal-subtab-btn.active {
  background: var(--white);
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}
.personal-subtab-btn:hover:not(.active) {
  background: var(--gray-100);
  color: var(--gray-700);
}

/* ── Toolbar de planificación ── */
.plan-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.plan-tabs {
  display: flex;
  gap: 4px;
}
.plan-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  color: var(--gray-500);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.plan-tab-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.plan-tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.plan-nav-semana {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Kanban ── */
.plan-kanban-wrap {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
}
.plan-kanban-wrap::-webkit-scrollbar { height: 6px; }
.plan-kanban-wrap::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

.plan-col {
  min-width: 200px;
  max-width: 220px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition), box-shadow var(--transition);
  flex-shrink: 0;
}
.plan-col-sinasignar { min-width: 200px; max-width: 220px; }
.plan-col-drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,58,107,0.2);
}

.plan-col-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.8rem;
  font-weight: 700;
  min-height: 52px;
}
.plan-col-sinasignar .plan-col-header { background: var(--gray-200); color: var(--gray-600); }
.plan-col-count {
  margin-left: auto;
  background: rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.plan-col-sinasignar .plan-col-count { background: var(--gray-300); color: var(--gray-600); }

.plan-col-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 80px;
}

/* ── Tarjeta de persona ── */
.plan-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: grab;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
}
.plan-card:hover { box-shadow: var(--shadow); }
.plan-card:active { cursor: grabbing; }
.plan-card-dragging { opacity: 0.5; }
.plan-card-alerta { border-left: 3px solid var(--warning); }

.plan-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.plan-avatar-sm {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

.plan-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity var(--transition);
}
.plan-card:hover .plan-card-actions { opacity: 1; }

/* ── Vista semana ── */
.plan-semana-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: var(--white);
  -webkit-overflow-scrolling: touch;
}
.plan-semana-table {
  border-collapse: collapse;
  min-width: 820px;
  width: 100%;
}
.plan-semana-table th,
.plan-semana-table td { border: 1px solid var(--gray-200); }

.plan-fila-pers-header {
  background: var(--primary-dark);
  color: #fff;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 130px;
  max-width: 150px;
  position: sticky;
  left: 0;
  z-index: 2;
}
.plan-hoy {
  background: #eff6ff !important;
}
.plan-semana-table th.plan-hoy { background: var(--primary) !important; color: #fff !important; }

.plan-fila-pers {
  background: var(--gray-50);
  padding: 8px 10px;
  font-size: 0.78rem;
  vertical-align: top;
  min-width: 130px;
  max-width: 150px;
  position: sticky;
  left: 0;
  z-index: 1;
}
.plan-pers-alerta { background: #fffbeb !important; }

.plan-celda {
  padding: 6px;
  vertical-align: top;
  min-height: 60px;
  min-width: 100px;
  cursor: pointer;
  transition: background var(--transition);
}
.plan-celda:hover { background: var(--gray-50); }
.plan-celda-libre {
  background: var(--white);
  position: relative;
}
.plan-celda-libre:hover { background: #f0f9ff; }

.plan-celda-add {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  color: var(--gray-300);
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity var(--transition);
}
.plan-celda-libre:hover .plan-celda-add { opacity: 1; color: var(--primary); }

.plan-celda-add-sm {
  display: block;
  text-align: center;
  color: var(--gray-300);
  font-size: 0.7rem;
  margin-top: 2px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition);
}
.plan-celda:hover .plan-celda-add-sm { opacity: 1; color: var(--primary); }

.plan-celda-tag {
  background: var(--gray-50);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 3px 5px;
  margin-bottom: 3px;
  font-size: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: relative;
  line-height: 1.3;
}
/* Botones de acción dentro del tag (editar + eliminar) */
.plan-celda-tag > div:last-child {
  /* el div que contiene plan-tag-edit + plan-tag-del */
  opacity: 0;
  transition: opacity var(--transition);
}
.plan-celda-tag:hover > div:last-child { opacity: 1; }

.plan-tag-del,
.plan-tag-edit {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.6rem;
  border-radius: 3px;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}
.plan-tag-del {
  color: var(--danger);
}
.plan-tag-del:hover {
  background: var(--danger-bg);
}
.plan-tag-edit {
  color: var(--accent);
}
.plan-tag-edit:hover {
  background: var(--accent-light);
}
.plan-celda-tag:hover .plan-tag-del { color: var(--danger); }
.plan-celda-tag:hover .plan-tag-edit { color: var(--accent); }

/* ── Vista mes ── */
.plan-mes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.plan-mes-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.plan-mes-card:hover { box-shadow: var(--shadow); }
.plan-mes-card-actual { border-color: var(--primary); }
.plan-mes-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.82rem;
  gap: 8px;
  flex-wrap: wrap;
}
.plan-mes-card-actual .plan-mes-card-header { background: #eff6ff; }
.plan-mes-filas { padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.plan-mes-fila {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--gray-50);
  transition: background var(--transition);
}
.plan-mes-fila:hover { background: var(--gray-100); }
.plan-mes-fila.plan-pers-alerta { background: #fffbeb; }

/* ── Mapa del día ── */
.plan-mapa-dia {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.plan-mapa-obra {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.plan-mapa-obra-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.85rem;
  font-weight: 700;
}
.plan-mapa-libres .plan-mapa-obra-header {
  background: #fef3c7;
  border-bottom-color: #fcd34d;
}
.plan-mapa-turnos {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plan-mapa-turno-label {
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.plan-mapa-personas {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.plan-mapa-persona-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--white);
  font-size: 0.82rem;
  min-width: 180px;
  flex: 1 1 180px;
  max-width: 260px;
}

/* ── Tag de hora extra en mapa ── */
.plan-mapa-tag-extra {
  border-color: #fca5a5 !important;
  background: #fff7f7 !important;
}

/* ── Leyenda de horas al pie de la vista semana ── */
.plan-leyenda-horas {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.75rem;
}
.plan-leyenda-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

/* ── Supervisor card styles ── */
.plan-card-supervisor {
  border-left: 3px solid #7c3aed !important;
  background: linear-gradient(135deg, #faf5ff, #f5f3ff) !important;
}
.plan-avatar-supervisor {
  background: linear-gradient(135deg, #7c3aed, #6d28d9) !important;
  color: #fff !important;
  box-shadow: 0 0 0 2px #c4b5fd !important;
}

/* ══════════════════════════════════════════════════════
   KANBAN MOSAICO — plan-kmosaico-*
   ══════════════════════════════════════════════════════ */

/* Contenedor principal: grid responsivo — compacto */
.plan-kmosaico-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 240px));
  gap: 10px;
  align-items: start;
  padding: 4px 0;
  justify-content: start;
}

/* Layout dos paneles: aside Sin Asignar + grid obras */
.plan-kanban-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 4px 0;
}

/* Panel lateral — Sin Asignar */
.plan-kanban-aside {
  flex: 0 0 220px;
  max-width: 220px;
  position: sticky;
  top: 0;
}
.plan-kanban-aside .plan-kmosaico-col {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

/* Grid de obras — lado derecho */
.plan-kanban-obras {
  flex: 1 1 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  align-items: start;
}

/* Tarjeta de obra/sede/cap */
.plan-kmosaico-col {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}
.plan-kmosaico-col:hover {
  box-shadow: var(--shadow);
}
.plan-kmosaico-col.plan-col-drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: var(--accent-light);
}

/* Cabecera de la tarjeta */
.plan-kmosaico-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px 8px;
}
.plan-kmosaico-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.plan-kmosaico-header-info {
  flex: 1 1 0;
  min-width: 0;
}
.plan-kmosaico-nombre {
  font-weight: 700;
  font-size: 0.80rem;
  line-height: 1.25;
  word-break: break-word;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.plan-kmosaico-ubicacion {
  font-size: 0.67rem;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badges de la cabecera */
.plan-kmosaico-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.plan-kmosaico-badge-alerta {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

/* Contador de empleados */
.plan-kmosaico-counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  background: rgba(0,0,0,0.08);
  border-radius: 8px;
  flex-shrink: 0;
  gap: 0;
}
.plan-kmosaico-counter-num {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}
.plan-kmosaico-counter-lbl {
  font-size: 0.53rem;
  font-weight: 600;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Zona de chips */
.plan-kmosaico-chips {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 8px;
  min-height: 36px;
  flex: 1;
}
.plan-kmosaico-empty {
  padding: 14px 8px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Footer con botón asignar */
.plan-kmosaico-footer {
  padding: 5px 8px 8px;
  border-top: 1px solid var(--gray-100);
}

/* Chip de persona */
.plan-kchip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  user-select: none;
}
.plan-kchip:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}
.plan-kchip-alerta {
  border-color: #fcd34d;
  background: #fffbeb;
}
.plan-kchip-alerta:hover {
  border-color: #f59e0b;
  background: #fef3c7;
}
.plan-kchip-superv {
  border-color: #c4b5fd;
  background: #faf5ff;
}
.plan-kchip-superv:hover {
  background: #f5f3ff;
  border-color: #a78bfa;
}
.plan-kchip-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}
.plan-kchip-info {
  flex: 1;
  min-width: 0;
}
.plan-kchip-nombre {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-kchip-sub {
  font-size: 0.62rem;
  color: var(--gray-500);
  margin-top: 1px;
}

/* Tag de capacitación en celda semana */
.plan-celda-tag-cap {
  background: linear-gradient(135deg, #faf5ff, #f5f3ff) !important;
}

/* Columna Sin Asignar */
.plan-kmosaico-sin .plan-kmosaico-counter {
  background: rgba(0,0,0,0.06);
  color: var(--gray-600);
}

/* Responsive */
@media (max-width: 900px) {
  .plan-kmosaico-wrap { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
}
@media (max-width: 600px) {
  .plan-kmosaico-wrap { grid-template-columns: 1fr 1fr; gap: 8px; }
  .plan-kmosaico-nombre { font-size: 0.8rem; }
  .plan-kmosaico-counter { min-width: 36px; height: 36px; }
  .plan-kmosaico-counter-num { font-size: 1rem; }
}

/* ══════════════════════════════════════════════════════
   HISTORIAL CON FILTROS — Vista plan-historial-*
   ══════════════════════════════════════════════════════ */

/* Contenedor principal del historial */
.plan-historial-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 4px 0;
}

/* Panel de filtros */
.plan-historial-filtros {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.plan-historial-filtros h4 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* Grid de inputs de filtro */
.plan-historial-filtros-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px 14px;
  align-items: end;
}
.plan-historial-filtros-grid label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.plan-historial-filtros-grid select,
.plan-historial-filtros-grid input[type="date"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  font-size: 0.82rem;
  color: var(--gray-800);
  background: var(--gray-50);
  transition: border-color var(--transition);
}
.plan-historial-filtros-grid select:focus,
.plan-historial-filtros-grid input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--white);
}
/* Fila de botones de acción del filtro */
.plan-historial-filtros-acciones {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

/* Barra de resumen global */
.plan-hist-resumen {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.plan-hist-resumen-label {
  width: 100%;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.70);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
}

/* Tarjeta individual de métrica */
.plan-hist-resumen-item {
  flex: 1 1 110px;
  min-width: 100px;
  background: rgba(255,255,255,0.13);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 9px;
  padding: 10px 14px;
  text-align: center;
  backdrop-filter: blur(4px);
  transition: background var(--transition);
}
.plan-hist-resumen-item:hover {
  background: rgba(255,255,255,0.22);
}
.plan-hist-resumen-item .hist-metric-val {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
  margin-bottom: 3px;
}
.plan-hist-resumen-item .hist-metric-lbl {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(255,255,255,0.80);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Contenedor de grupos de resultados */
.plan-hist-grupos {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Tarjeta de grupo (persona / obra / semana) */
.plan-hist-grupo {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.plan-hist-grupo:hover {
  box-shadow: var(--shadow);
}

/* Cabecera expandible del grupo */
.plan-hist-grupo-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  cursor: pointer;
  user-select: none;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  transition: background var(--transition);
}
.plan-hist-grupo-header:hover {
  background: var(--gray-100);
}
.plan-hist-grupo-header .hist-grupo-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}
.plan-hist-grupo-header .hist-grupo-icon.obra {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  border-radius: 9px;
}
.plan-hist-grupo-header .hist-grupo-icon.sede {
  background: linear-gradient(135deg, #1a3a6b, #2e5fa3);
  border-radius: 9px;
}
.plan-hist-grupo-header .hist-grupo-icon.fecha {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  border-radius: 9px;
}
.plan-hist-grupo-info {
  flex: 1 1 0;
  min-width: 0;
}
.plan-hist-grupo-info .hist-grupo-titulo {
  font-size: 0.93rem;
  font-weight: 700;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-hist-grupo-info .hist-grupo-subtitulo {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 1px;
}

/* Pills de resumen dentro de la cabecera */
.plan-hist-grupo-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.hist-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.hist-pill-dias   { background: #dbeafe; color: #1d4ed8; }
.hist-pill-ord    { background: #dcfce7; color: #15803d; }
.hist-pill-extra  { background: #fef3c7; color: #92400e; }
.hist-pill-costo  { background: #f3e8ff; color: #6b21a8; }

/* Chevron de toggle */
.plan-hist-grupo-header .hist-chevron {
  font-size: 0.75rem;
  color: var(--gray-400);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.plan-hist-grupo-header.expanded .hist-chevron {
  transform: rotate(180deg);
}

/* Cuerpo del grupo (tabla de detalles) */
.plan-hist-grupo-body {
  padding: 0 18px 14px;
  display: none;
}
.plan-hist-grupo-body.visible {
  display: block;
}
.plan-hist-detalle-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.8rem;
}
.plan-hist-detalle-table th {
  padding: 6px 10px;
  text-align: left;
  font-size: 0.71rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  background: var(--gray-50);
}
.plan-hist-detalle-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}
.plan-hist-detalle-table tr:last-child td {
  border-bottom: none;
}
.plan-hist-detalle-table tr:hover td {
  background: var(--gray-50);
}

/* Chip de cargo dentro de la tabla */
.hist-cargo-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hist-cargo-chip.supervisor { background: #f3e8ff; color: #7c3aed; }
.hist-cargo-chip.oficial    { background: #dbeafe; color: #1d4ed8; }
.hist-cargo-chip.ayudante   { background: #dcfce7; color: #16a34a; }

/* Botón eliminar en tabla historial */
.hist-btn-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
  font-size: 0.85rem;
  padding: 3px 6px;
  border-radius: 5px;
  opacity: 0.6;
  transition: opacity var(--transition), background var(--transition);
}
.hist-btn-del:hover {
  opacity: 1;
  background: var(--danger-bg);
}

/* Estado vacío historial */
.plan-hist-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  gap: 10px;
  color: var(--gray-400);
  background: var(--white);
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius);
  text-align: center;
}
.plan-hist-empty i {
  font-size: 2.5rem;
  opacity: 0.5;
}
.plan-hist-empty p {
  font-size: 0.88rem;
  font-weight: 600;
}
.plan-hist-empty small {
  font-size: 0.78rem;
  color: var(--gray-400);
}

/* ══════════════════════════════════════════════════════
   VISTA POR OBRA — po-chip
   ══════════════════════════════════════════════════════ */

/* Chip de persona en la celda por-obra */
.po-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
}
.po-chip:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,58,107,0.12);
}
.po-chip-on {
  background: #dbeafe;
  border-color: #1a3a6b;
}
.po-chip-on:hover {
  background: #bfdbfe;
}
.po-chip-draft {
  box-shadow: 0 0 0 2px #f59e0b55;
}

/* Tabla principal por-obra: hover de fila */
.por-obra-table tbody tr:hover td {
  background-color: #f0f9ff !important;
}

/* ── Responsive: en pantallas pequeñas reducir ancho mínimo de columnas */
@media (max-width: 768px) {
  .po-chip span { max-width: 60px !important; }
}

/* ── Cards móviles de Por Obra (solo visible en ≤ 600px) ── */
.po-mobile-cards { display: none; } /* oculto por defecto, CSS móvil lo activa */

.po-obra-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.po-obra-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--primary-dark);
  color: #fff;
  gap: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.po-obra-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.po-obra-card-sub {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
}
.po-obra-card-toggle {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.po-obra-card.collapsed .po-obra-card-toggle { transform: rotate(-90deg); }
.po-obra-card-body {
  padding: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.po-obra-card.collapsed .po-obra-card-body { max-height: 0 !important; }

/* Cada día dentro de la card */
.po-dia-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--gray-100);
}
.po-dia-row:last-child { border-bottom: none; }
.po-dia-label {
  min-width: 58px;
  flex-shrink: 0;
  text-align: center;
}
.po-dia-label .dia-num  { font-size: 1.1rem; font-weight: 800; color: var(--primary); line-height: 1; }
.po-dia-label .dia-nom  { font-size: 0.62rem; color: var(--gray-500); text-transform: capitalize; }
.po-dia-label .dia-mes  { font-size: 0.6rem;  color: var(--gray-400); }
.po-dia-label.hoy .dia-num  { color: var(--white); }
.po-dia-label.hoy       { background: var(--primary); border-radius: 8px; padding: 4px 6px; }
.po-dia-label.finde     { background: var(--warning-bg); border-radius: 8px; padding: 4px 6px; }
.po-dia-label.finde .dia-num { color: var(--warning); }
.po-dia-chips {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  min-height: 28px;
}
.po-dia-empty {
  font-size: 0.72rem;
  color: var(--gray-300);
  font-style: italic;
}


/* ── Responsive tablet: kanban scroll, mes 1 columna ── */
@media (max-width: 900px) {
  .plan-mes-grid { grid-template-columns: 1fr; }
  .plan-toolbar { gap: 8px; }
  .plan-tabs .plan-tab-btn { padding: 5px 10px; font-size: 0.78rem; }
  .personal-subtab-btn { padding: 9px 12px; font-size: 0.8rem; }
}
@media (max-width: 600px) {
  .plan-kanban-wrap { gap: 8px; }
  .plan-col { min-width: 170px; max-width: 190px; }
  .plan-mes-grid { grid-template-columns: 1fr; }
  .plan-toolbar { flex-wrap: wrap; gap: 6px; }
  .personal-subtab-btn { padding: 8px 10px; font-size: 0.75rem; }
  .plan-mapa-persona-tag { min-width: 140px; max-width: 100%; }
  /* Historial responsive */
  .plan-historial-filtros-grid { grid-template-columns: 1fr 1fr; }
  .plan-hist-resumen { gap: 6px; padding: 12px 14px; }
  .plan-hist-resumen-item { flex: 1 1 80px; padding: 8px 10px; }
  .plan-hist-resumen-item .hist-metric-val { font-size: 1.15rem; }
  .plan-hist-grupo-header { padding: 10px 12px; gap: 8px; }
  .plan-hist-grupo-pills { display: none; }
  .plan-hist-grupo-body { padding: 0 12px 10px; }
  .plan-hist-detalle-table th,
  .plan-hist-detalle-table td { padding: 5px 7px; }
}

/* ──────────────────────────────────────────────────────
   MOBILE — PLANIFICACIÓN: toolbar y vistas compactas
   Aplica exclusivamente en ≤ 600px portrait
   ────────────────────────────────────────────────────── */
@media (max-width: 600px) {

  /* ── Toolbar: 2 filas bien definidas ── */
  .plan-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 10px 8px;
  }

  /* Fila 1: tabs con scroll horizontal, sin texto en móvil */
  .plan-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    /* ocultar scrollbar visual */
    scrollbar-width: none;
  }
  .plan-tabs::-webkit-scrollbar { display: none; }
  .plan-tab-btn {
    flex-shrink: 0;
    padding: 7px 10px;
    font-size: 0.75rem;
    gap: 5px;
    white-space: nowrap;
  }

  /* Fila 2: nav-semana ocupa ancho completo y centrado */
  .plan-nav-semana {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }
  #plan-semana-label {
    font-size: 0.8rem;
    text-align: center;
    flex: 1;
  }

  /* Fila 3: botones de acción — alineados en fila con scroll */
  .plan-toolbar > div[style*="margin-left:auto"],
  .plan-toolbar > div[style*="margin-left: auto"] {
    margin-left: 0 !important;
    display: flex !important;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    scrollbar-width: none;
  }
  .plan-toolbar > div[style*="margin-left:auto"]::-webkit-scrollbar,
  .plan-toolbar > div[style*="margin-left: auto"]::-webkit-scrollbar { display: none; }

  /* Botones de acción: solo icono en móvil */
  .plan-toolbar .btn-outline.btn-sm .btn-text,
  .plan-toolbar .btn-outline.btn-sm > span:not(.fas):not(.far):not(.fab) {
    display: none;
  }
  .plan-toolbar .btn-sm {
    flex-shrink: 0;
    padding: 6px 9px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* ── Vista SEMANA: scroll horizontal con tabla fija ── */
  .plan-semana-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
  }
  .plan-semana-table {
    min-width: 560px; /* permite scroll manteniendo legibilidad */
    font-size: 0.75rem;
  }
  .plan-semana-table th,
  .plan-semana-table td { padding: 6px 4px; }

  /* ── Vista KANBAN: scroll horizontal ── */
  .plan-kanban-layout {
    flex-direction: column !important;
    gap: 10px;
  }
  .plan-kanban-aside {
    width: 100% !important;
    max-height: 220px;
    overflow-y: auto;
  }
  .plan-kanban-obras {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Vista POR OBRA: ocultar tabla, mostrar cards ── */
  .por-obra-table-wrap { display: none !important; }
  .po-mobile-cards    { display: block !important; }

  /* ── Draft banner compacto en móvil ── */
  #plan-draft-banner {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  #plan-draft-banner span {
    font-size: 0.78rem;
    flex: 1 1 100%;
  }
  #plan-draft-banner button {
    flex: 1;
    justify-content: center;
    font-size: 0.78rem;
    padding: 6px 10px;
  }

  /* ── Historial filtros en 1 columna ── */
  .plan-historial-filtros-grid { grid-template-columns: 1fr !important; }
}

/* ============================================
   MOBILE — NAVEGACIÓN INFERIOR + DRAWER
   Breakpoint: <= 600px (portrait smartphone)
   ============================================ */
@media (max-width: 600px) {

  /* ── 1. OCULTAR SIDEBAR LATERAL completamente ── */
  #sidebar { display: none !important; }

  /* ── 2. TOPBAR MÓVIL: ultra-compacto ── */
  #topbar {
    height: 52px;
    padding: 0 10px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 200;
  }
  .topbar-title { font-size: 0.9rem; font-weight: 600; }
  .topbar-user   { display: none !important; }   /* avatar/nombre oculto */
  #btn-hamburger { display: flex !important; }    /* activar botón hamburguesa */
  #btn-new-doc   { display: none !important; }    /* mover al bottom nav */

  /* ── 3. CONTENIDO PRINCIPAL sin topbar duplicado ── */
  #main-content { padding-bottom: 0; }
  #page-content {
    padding: 10px 10px 80px; /* 80px = alto barra inferior + aire */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  /* ── 4. BOTTOM NAV BAR ── */
  #mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 58px;
    background: var(--primary-dark);
    border-top: 1px solid rgba(255,255,255,0.1);
    z-index: 300;
    align-items: stretch;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
    /* safe-area para iPhone con notch inferior */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mob-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    border-radius: 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .mob-nav-item:active  { background: rgba(255,255,255,0.06); }
  .mob-nav-item.active  { color: var(--white); }
  .mob-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
  }
  .mob-nav-item i    { font-size: 1.1rem; line-height: 1; }
  .mob-nav-item span { font-size: 0.58rem; font-weight: 500; letter-spacing: 0.2px; line-height: 1; }
  .mob-nav-badge {
    position: absolute;
    top: 6px; right: calc(50% - 16px);
    background: var(--danger);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 8px;
    line-height: 1.3;
    min-width: 14px;
    text-align: center;
  }

  /* ── 5. DRAWER LATERAL (menú completo en móvil) ── */
  #mobile-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 400;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  #mobile-drawer-overlay.open { display: block; }
  #mobile-drawer {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 270px;
    background: var(--primary-dark);
    z-index: 500;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }
  #mobile-drawer.open  { transform: translateX(0); }
  #mobile-drawer .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.09);
    flex-shrink: 0;
  }
  #mobile-drawer .drawer-logo {
    display: flex; align-items: center; gap: 10px;
  }
  #mobile-drawer .drawer-logo img {
    width: 32px; height: 32px; object-fit: contain;
    filter: brightness(0) invert(1); border-radius: 6px;
  }
  #mobile-drawer .drawer-logo .app-name {
    font-size: 1rem; font-weight: 700; color: #fff; letter-spacing: 0.4px;
  }
  #mobile-drawer .drawer-logo .app-sub {
    font-size: 0.65rem; color: rgba(255,255,255,0.45); display: block;
  }
  #mobile-drawer .drawer-close {
    background: rgba(255,255,255,0.08);
    border: none; color: rgba(255,255,255,0.6);
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; cursor: pointer; flex-shrink: 0;
  }
  #mobile-drawer .drawer-close:active { background: rgba(255,255,255,0.16); }
  #mobile-drawer .drawer-nav {
    flex: 1; overflow-y: auto; padding: 8px 0;
    -webkit-overflow-scrolling: touch;
  }
  #mobile-drawer .drawer-nav::-webkit-scrollbar { width: 2px; }
  #mobile-drawer .drawer-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
  #mobile-drawer .drawer-section {
    padding: 14px 14px 3px;
    font-size: 0.62rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    color: rgba(255,255,255,0.28);
  }
  #mobile-drawer .drawer-item {
    display: flex; align-items: center; gap: 13px;
    padding: 11px 16px;
    color: rgba(255,255,255,0.65);
    cursor: pointer; border-radius: 8px;
    margin: 2px 8px;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  #mobile-drawer .drawer-item:active  { background: rgba(255,255,255,0.06); }
  #mobile-drawer .drawer-item.active  { background: var(--accent); color: #fff; }
  #mobile-drawer .drawer-item i {
    font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0;
  }
  #mobile-drawer .drawer-item span  { font-size: 0.87rem; font-weight: 500; }
  #mobile-drawer .drawer-item .d-badge {
    margin-left: auto; background: var(--danger); color: #fff;
    font-size: 0.6rem; font-weight: 700; padding: 2px 5px;
    border-radius: 8px; line-height: 1.2;
  }
  #mobile-drawer .drawer-footer {
    padding: 10px 12px; border-top: 1px solid rgba(255,255,255,0.08);
  }
  #mobile-drawer .drawer-footer button {
    width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; color: rgba(255,255,255,0.38);
    background: transparent; border: none; border-radius: 8px;
    font-size: 0.75rem; cursor: pointer;
  }
  #mobile-drawer .drawer-footer button:active {
    background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.6);
  }

  /* ── 6. CARDS COMPACTAS en tablas ── */
  /* Obras: ocultar columnas pesadas, mostrar solo esenciales */
  .obras-table thead { display: none; }
  .obras-table tbody tr {
    display: flex; flex-direction: column;
    background: var(--white); border-radius: 10px;
    margin-bottom: 10px; padding: 12px 14px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
    gap: 4px;
  }
  .obras-table tbody td {
    display: flex; align-items: center; gap: 6px;
    border: none; padding: 2px 0; font-size: 0.82rem;
  }
  .obras-table tbody td::before {
    content: attr(data-label);
    font-size: 0.68rem; font-weight: 600;
    color: var(--gray-500); min-width: 80px; flex-shrink: 0;
    text-transform: uppercase; letter-spacing: 0.3px;
  }
  /* Trazabilidad */
  .traz-table thead { display: none; }
  .traz-table tbody tr {
    display: flex; flex-direction: column;
    background: var(--white); border-radius: 10px;
    margin-bottom: 10px; padding: 12px 14px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
    gap: 3px;
  }
  .traz-table tbody td {
    display: flex; align-items: center; gap: 6px;
    border: none; padding: 2px 0; font-size: 0.82rem;
  }

  /* ── 7. FORMULARIOS 1 COLUMNA ESTRICTO ── */
  .form-row, .form-row-3, .form-row-4, .grid-2, .grid-3 {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
  .doc-meta { grid-template-columns: 1fr !important; }

  /* ── 8. CARDS más compactas ── */
  .card { padding: 12px 14px; border-radius: 10px; }
  .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-header h1 { font-size: 1.05rem; }
  .page-header > div { flex-wrap: wrap; gap: 6px; }

  /* ── 9. SEARCH BAR apilada ── */
  .search-bar {
    flex-direction: column; align-items: stretch; gap: 8px;
  }
  .search-bar input, .search-bar select { width: 100%; }

  /* ── 10. FIN-PANEL (tarjetas financieras) en 2 columnas ── */
  .fin-panel { grid-template-columns: repeat(2,1fr) !important; gap: 8px; }
  .fin-item  { padding: 10px 8px; }
  .fin-value { font-size: 0.92rem; }
  .fin-label { font-size: 0.65rem; }

  /* ── 11. Tabs con scroll horizontal ── */
  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { height: 2px; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; font-size: 0.8rem; padding: 7px 12px; }

  /* ── 12. Botones de acción en header: solo icono ── */
  .page-header .btn .btn-text { display: none; }
  .page-header .btn { padding: 7px 9px; }

  /* ── 13. MODALES: hoja completa desde abajo ── */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100% !important; width: 100%;
    max-height: 94dvh !important; max-height: 94svh !important; max-height: 94vh !important;
    border-radius: 18px 18px 0 0;
    margin: 0;
    display: flex; flex-direction: column;
  }
  .modal-header { padding: 14px 16px; flex-shrink: 0; }
  .modal-header::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--gray-300); border-radius: 2px;
    margin: 0 auto 10px;
  }
  .modal-body  { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px; }
  .modal-footer{ flex-shrink: 0; padding: 10px 16px; gap: 8px; }
  .modal-footer .btn { flex: 1; justify-content: center; }

  /* ── 14. PAGE-HEADER: botones secundarios comprimidos ── */
  /* Ocultar texto de botones Exportar / Importar, dejar solo icono */
  .page-header .btn-success.btn-sm span:not(.fas):not(.far),
  .page-header .btn-outline.btn-sm span:not(.fas):not(.far) { display: none; }
  /* El botón primary principal mantiene texto pero más corto */
  .page-header .btn-primary { font-size: 0.78rem; padding: 7px 10px; }
  /* Contenedor de botones del header siempre en fila scrollable */
  .page-header > div,
  .page-header > div[style] {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  /* ── 15. SEARCH-BAR: inputs y selects width 100% en columna ── */
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar .search-input-wrap { min-width: unset; width: 100%; }
  .search-bar select { width: 100% !important; min-width: unset; }

  /* ── 16. STATS-GRID: siempre 2 columnas en móvil ── */
  .stats-grid { grid-template-columns: repeat(2,1fr) !important; gap: 8px; }

  /* ── 17. TABLA TRAZABILIDAD: scroll horizontal + ocultar columnas extras ── */
  #trazabilidad-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Ocultar columnas de baja prioridad */
  .traz-table th:nth-child(4),
  .traz-table td:nth-child(4),
  .traz-table th:nth-child(7),
  .traz-table td:nth-child(7),
  .traz-table th:nth-child(8),
  .traz-table td:nth-child(8),
  .traz-table th:nth-child(9),
  .traz-table td:nth-child(9) { display: none; }

  /* ── 18. TABLA INVENTARIO: scroll horizontal ── */
  #inv-view-catalogo .card,
  #inv-view-alertas  .card { overflow-x: auto; }

  /* ── 19. FIN-PANEL en modales: 2×2 ── */
  .modal-body .fin-panel { grid-template-columns: repeat(2,1fr) !important; }

  /* ── 20. ABONO FORM compacto en móvil ── */
  #modal-obra-body .form-row { grid-template-columns: 1fr !important; }

  /* ── 21. CHIPS de por-obra más pequeños ── */
  .po-chip { padding: 3px 6px; font-size: 0.68rem; }
  .po-chip span { max-width: 55px !important; }

  /* ── 22. CARD-HEADER con múltiples botones ── */
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-header > div,
  .card-header > span { flex-wrap: wrap; gap: 6px; }

  /* ── 23. GENERADOR DE DOCUMENTOS — Wizard: barra de acciones FIJA en móvil ──
     Soluciona el problema reportado: el botón "Imprimir / PDF" y otras acciones
     quedaban fuera del viewport visible al final del Paso 5 (Vista Previa),
     sin forma de hacer scroll para alcanzarlos. Se usa position:fixed (no
     sticky) porque .card tiene overflow:hidden y rompería el efecto sticky.
     La barra queda anclada por encima del bottom-nav durante todo el scroll
     de la vista previa, así el usuario siempre puede llegar a "Imprimir/PDF". */
  .wizard-preview-toolbar { margin-bottom: 10px !important; }
  .wizard-preview-toolbar h3 { font-size: 0.98rem; width: 100%; }

  /* Reserva de espacio para que el contenido no quede tapado por la barra fija */
  #wp-3, #wp-4, #wp-5 { padding-bottom: 130px; }

  .wizard-actions {
    position: fixed !important;
    left: 0; right: 0;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    z-index: 250;
    background: var(--white);
    margin: 0 !important;
    padding: 10px 12px;
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.10);
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
  }
  .wizard-actions > .btn { flex: 1 1 48%; }
  .wizard-actions-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1 1 100%;
  }
  .wizard-actions-group > .btn { flex: 1 1 48%; }
  /* Paso 3 y 4: "Atrás" ocupa toda la fila superior, el grupo la inferior */
  #wp-3 .wizard-actions > .btn.btn-ghost,
  #wp-4 .wizard-actions > .btn.btn-ghost { flex: 1 1 100%; }

  .wizard-actions .btn {
    justify-content: center;
    font-size: 0.8rem;
    padding: 11px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Botón principal de impresión: destacado para ubicarlo rápido */
  #wp-5 .wizard-actions .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 700;
  }

  /* Área de vista previa: aire suficiente para no chocar con la barra fija */
  #doc-preview-area { margin-bottom: 12px; }

  /* ── 24. MODAL "Ver/Imprimir" documento (Mis Documentos) — footer con
     múltiples botones (Cerrar, Continuar Editando, Clonar, Imprimir, Eliminar).
     El footer ya es flex-shrink:0 (siempre visible), pero se ordena en
     cuadrícula 2 columnas para que ningún botón quede aplastado o cortado,
     y "Imprimir" quede siempre legible y accesible al tacto. ── */
  #modal-doc .modal-footer {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  #modal-doc .modal-footer .btn {
    flex: none;
    width: 100%;
    margin-left: 0 !important;
    justify-content: center;
    font-size: 0.8rem;
    padding: 10px 8px;
  }
  /* Botón Eliminar ocupa fila completa al final, para evitar toques accidentales */
  #modal-doc .modal-footer .btn[style*="color:#dc2626"] {
    grid-column: 1 / 3;
  }
  /* Imprimir destacado */
  #modal-doc .modal-footer .btn-primary { font-weight: 700; }
}

/* safe-area iPhone X+ para bottom nav */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 600px) {
    #mobile-bottom-nav {
      padding-bottom: env(safe-area-inset-bottom);
      height: calc(58px + env(safe-area-inset-bottom));
    }
    #page-content { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  body { overflow: visible; background: white; }
  #app-layout { display: block; height: auto; }
  #sidebar, #topbar, .no-print, .btn, .search-bar, .tabs, .page-header { display: none !important; }
  #main-content { display: block; }
  #page-content { overflow: visible; padding: 0; }
  .view { display: block !important; }
  .view:not(.print-active) { display: none !important; }
  #print-area { display: block !important; }
  .doc-preview { padding: 15mm 20mm; font-size: 10pt; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .modal-overlay { position: static; background: none; opacity: 1; visibility: visible; padding: 0; }
  .modal { box-shadow: none; max-height: none; transform: none; }

  /* Listas y texto enriquecido en impresión directa desde la app */
  .doc-rich-content ul { list-style-type: disc !important; padding-left: 1.4em !important; margin: 4pt 0 6pt !important; }
  .doc-rich-content ol { list-style-type: decimal !important; padding-left: 1.4em !important; margin: 4pt 0 6pt !important; }
  .doc-rich-content li { margin-bottom: 3pt !important; line-height: 1.65 !important; display: list-item !important; }
  .doc-rich-content ul ul { list-style-type: circle !important; }
  .doc-rich-content ul ul ul { list-style-type: square !important; }
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* ============================================
   MÓDULO INVENTARIO — Herramientas y Equipos
   Fase 1 — Escalable para migración futura
   ============================================ */

/* Grid de estadísticas */
.inv-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 1100px) { .inv-stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 680px)  { .inv-stats-grid { grid-template-columns: repeat(2, 1fr); } }

.inv-stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--gray-100);
  transition: box-shadow var(--transition);
}
.inv-stat-card:hover { box-shadow: var(--shadow); }

.inv-stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.inv-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-800);
  line-height: 1;
}
.inv-stat-label {
  font-size: 0.72rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* Pestañas del módulo */
.inv-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
}
.inv-tab {
  padding: 7px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.inv-tab:hover  { color: var(--primary); background: rgba(26,58,107,0.07); }
.inv-tab.active { background: var(--surface); color: var(--primary); font-weight: 700;
                  box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* Botones de cambio de vista (catálogo / movimientos) */
.inv-view-btn       { transition: all var(--transition); }
.inv-view-btn.active { background: var(--primary) !important; color: #fff !important;
                       border-color: var(--primary) !important; }

/* Icono de categoría */
.inv-cat-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.inv-cat-herramienta-manual    { background: #fef9c3; color: #854d0e; }
.inv-cat-herramienta-electrica { background: #fef3c7; color: #d97706; }
.inv-cat-equipo-de-altura      { background: #fee2e2; color: #dc2626; }
.inv-cat-equipo-mayor          { background: #e0f2fe; color: #0369a1; }
.inv-cat-epp                   { background: #dcfce7; color: #16a34a; }
.inv-cat-medicion              { background: #f3e8ff; color: #7e22ce; }
.inv-cat-otro                  { background: var(--gray-100); color: var(--gray-500); }

/* Barra de stock */
.inv-stock-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
}
.inv-stock-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease;
}
.inv-stock-ok  { background: #22c55e; }
.inv-stock-mid { background: #f59e0b; }
.inv-stock-low { background: #ef4444; }

/* Badges de movimiento */
.inv-mov-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.inv-mov-out  { background: #fff7ed; color: #ea580c; }
.inv-mov-in   { background: #f0fdf4; color: #16a34a; }
.inv-mov-mid  { background: #eff6ff; color: #2563eb; }
.inv-mov-baja { background: #fef2f2; color: #dc2626; }

/* Panel de alertas */
.inv-alerta {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.84rem;
  line-height: 1.5;
}
.inv-alerta i { margin-top: 2px; flex-shrink: 0; font-size: 0.9rem; }
.inv-alerta-danger  { background: #fef2f2; color: #991b1b; border-left: 3px solid #ef4444; }
.inv-alerta-warning { background: #fffbeb; color: #92400e; border-left: 3px solid #f59e0b; }
.inv-alerta-info    { background: #eff6ff; color: #1e40af; border-left: 3px solid #3b82f6; }

/* Responsive tabla inventario */
@media (max-width: 900px) {
  .inv-stats-grid { grid-template-columns: repeat(3, 1fr); }
  #inv-table-body tr td:nth-child(7) { display: none; }
}
@media (max-width: 680px) {
  .inv-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .inv-tabs { overflow-x: auto; width: 100%; }
  #inv-table-body tr td:nth-child(3),
  #inv-table-body tr td:nth-child(6) { display: none; }
}

/* ============================================
   PANEL DE ALMACENAMIENTO — Mis Documentos
   ============================================ */
.stor-panel {
  background: var(--surface, #fff);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}
.stor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.stor-titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--gray-700);
}
.stor-titulo i { color: var(--primary); }
.stor-estado {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 99px;
}
.stor-ok        { background: #dcfce7; color: #15803d; }
.stor-precaucion{ background: #fef3c7; color: #92400e; }
.stor-critico   { background: #fee2e2; color: #991b1b; }

.stor-nums {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--gray-500);
}
.stor-usado { font-size: 1.1rem; font-weight: 800; color: var(--gray-800); }
.stor-sep   { font-size: 0.78rem; }
.stor-max   { font-size: 0.78rem; color: var(--gray-400); }
.stor-docs  { font-size: 0.75rem; color: var(--gray-400); }

/* Barra de progreso */
.stor-bar-wrap { margin-bottom: 6px; }
.stor-bar-track {
  position: relative;
  height: 10px;
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 4px;
}
.stor-bar-saludable {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: rgba(34,197,94,0.12);
  border-right: 1.5px dashed #22c55e;
  border-radius: 0;
  pointer-events: none;
}
.stor-bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 99px;
  transition: width 0.6s ease, background 0.4s ease;
}
.stor-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--gray-400);
  padding: 0 2px;
}

/* Tip de consejo */
.stor-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: #92400e;
  margin-top: 8px;
}
.stor-tip i { color: #f59e0b; margin-top: 1px; flex-shrink: 0; }

/* Lista de documentos pesados */
.stor-heavy-list {
  margin-top: 10px;
  border-top: 1px solid var(--gray-100);
  padding-top: 8px;
}
.stor-heavy-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stor-heavy-title i { color: var(--warning); }
.stor-heavy-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 0.8rem;
  transition: background 0.15s;
}
.stor-heavy-item:hover { background: var(--gray-50); }
.stor-heavy-tipo {
  color: var(--gray-500);
  font-size: 0.75rem;
  min-width: 110px;
  white-space: nowrap;
}
.stor-heavy-nombre {
  flex: 1;
  color: var(--gray-700);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stor-heavy-fecha {
  font-size: 0.72rem;
  color: var(--gray-400);
  white-space: nowrap;
}

/* Badges de peso por fila */
.peso-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.peso-ok      { background: #dcfce7; color: #15803d; }
.peso-medio   { background: #fef9c3; color: #854d0e; }
.peso-alto    { background: #fef3c7; color: #92400e; }
.peso-critico { background: #fee2e2; color: #991b1b; }

@media (max-width: 900px) {
  .stor-header { flex-direction: column; align-items: flex-start; }
  .stor-heavy-fecha { display: none; }
}

/* ============================================
   VISTA GANTT — Obras (avance físico vs anticipo)
   ============================================ */
.gantt-swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  background: #3b82f6;
  margin-right: 4px;
  vertical-align: middle;
}
.gantt-swatch-marker {
  background: transparent;
  border-left: 2px dashed #64748b;
  width: 0; height: 12px;
  border-radius: 0;
}
.gantt-row {
  padding: 12px 4px;
  border-bottom: 1px solid var(--gray-100);
}
.gantt-row:last-child { border-bottom: none; }
.gantt-row-alert {
  background: #fef2f2;
  border-radius: 8px;
  padding: 12px 10px;
  margin: 4px 0;
}
.gantt-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.gantt-row-title {
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--gray-800);
}
.gantt-row-cliente {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-left: 8px;
}
.gantt-row-fechas {
  font-size: 0.74rem;
  color: var(--gray-500);
  white-space: nowrap;
}
.gantt-bar-track {
  position: relative;
  height: 16px;
  background: var(--gray-100);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 6px;
}
.gantt-bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 8px;
  transition: width 0.4s ease;
}
.gantt-bar-marker {
  position: absolute;
  top: -2px; bottom: -2px;
  width: 0;
  border-left: 2px dashed #1e293b;
  z-index: 2;
}
.gantt-row-foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--gray-600);
}
.gantt-sin-anticipo {
  color: var(--gray-400);
  font-style: italic;
}
.gantt-alert-msg {
  margin-top: 8px;
  font-size: 0.78rem;
  color: #991b1b;
  background: #fee2e2;
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
@media (max-width: 700px) {
  .gantt-row-head { flex-direction: column; align-items: flex-start; }
  .gantt-row-cliente { margin-left: 0; display: block; }
  #obras-gantt-wrap .card-body { padding: 6px 10px 12px !important; }
  #obras-gantt-wrap .card-header { padding: 12px 12px !important; }
  #obras-gantt-wrap .card-header > div:last-child { font-size: 0.68rem; gap: 10px; }
  .gantt-row-fechas { font-size: 0.68rem; white-space: normal; }
}

/* ============================================
   TRAZABILIDAD CONTABLE — Selector Ambas/CONURIBE/ZUMA
   ============================================ */
.traz-scope-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.traz-scope-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.traz-scope-btn:hover { background: var(--gray-50); }
.traz-scope-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.traz-scope-btn[data-scope="CONURIBE"].active { background: #1a3a6b; border-color: #1a3a6b; }
.traz-scope-btn[data-scope="ZUMA"].active      { background: #7c3aed; border-color: #7c3aed; }

@media (max-width: 700px) {
  .traz-scope-toggle { gap: 6px; }
  .traz-scope-btn { flex: 1; justify-content: center; font-size: 0.76rem; padding: 9px 8px; white-space: nowrap; }
}
@media (max-width: 400px) {
  .traz-scope-btn i { display: none; }
}

/* ============================================
   CALENDARIO ADMINISTRATIVO
   ============================================ */
.cadmin-leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.cadmin-leyenda-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--gray-600);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  padding: 4px 12px;
}
.cadmin-leyenda-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.cadmin-table-wrap {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.cadmin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}
.cadmin-table th, .cadmin-table td {
  border: 1px solid var(--gray-100);
  padding: 8px;
  vertical-align: top;
}
.cadmin-table thead th {
  background: var(--gray-50);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--gray-500);
  font-weight: 700;
  text-align: center;
  padding: 10px 6px;
}
.cadmin-table thead th.cadmin-th-hoy {
  color: var(--primary);
  background: #eff6ff;
}
.cadmin-persona-cell {
  min-width: 150px;
  background: var(--gray-50);
  vertical-align: middle;
}
.cadmin-persona-nombre {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}
.cadmin-persona-cargo {
  font-size: 0.72rem;
  color: var(--gray-500);
  margin-top: 2px;
}
.cadmin-persona-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}
.cadmin-btn-editar {
  margin-top: 6px;
  font-size: 0.68rem;
  padding: 3px 9px;
}

/* Navegador de semana (arriba de la grilla) */
.cadmin-nav-card { margin-bottom: 16px; }
.cadmin-nav-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
}
.cadmin-nav-btn { flex-shrink: 0; white-space: nowrap; }
.cadmin-rango-semana {
  font-weight: 700;
  color: var(--gray-800);
  font-size: 1rem;
  text-align: center;
  flex: 1;
  min-width: 140px;
}

/* Botonera de vistas en encabezado de Obras (Kanban / Gantt) */
.obras-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.obras-vista-switch { display: flex; gap: 6px; }

/* Tarjetas móviles del Calendario Administrativo (ocultas por defecto, activadas ≤600px) */
.cadmin-mobile-cards { display: none; }
.cadmin-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.cadmin-card-editing { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,58,107,0.15); }
.cadmin-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}
.cadmin-card-nombre { font-weight: 700; font-size: 0.86rem; color: var(--gray-800); }
.cadmin-card-dias {
  display: flex;
  flex-direction: column;
}
.cadmin-card-dia {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--gray-100);
}
.cadmin-card-dia:last-child { border-bottom: none; }
.cadmin-card-dia-hoy { background: #f0f9ff; }
.cadmin-card-dia-label {
  min-width: 52px;
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: capitalize;
  padding-top: 4px;
}
.cadmin-card-dia-editing { flex-direction: column; background: #fffbeb; }
.cadmin-card-dia-editing .cadmin-card-dia-label { min-width: auto; padding-top: 0; margin-bottom: 4px; }
.cadmin-card-dia .cadmin-chip { flex: 1; }
.cadmin-card-edit-actions {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.cadmin-day-cell {
  min-width: 150px;
  max-width: 190px;
  cursor: default;
  vertical-align: top;
}
.cadmin-day-cell.cadmin-col-hoy { background: #f0f9ff; }
.cadmin-day-cell.cadmin-editing { background: #fffbeb; min-width: 210px; }
.cadmin-chip-list { display: flex; flex-direction: column; gap: 5px; }
.cadmin-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.72rem;
  line-height: 1.3;
  min-height: 40px;
}
.cadmin-chip-label {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cadmin-chip-detalle {
  color: rgba(0,0,0,0.55);
  font-size: 0.7rem;
  white-space: normal;
  word-break: break-word;
}
.cadmin-chip-empty {
  color: var(--gray-300);
  font-size: 0.7rem;
  text-align: center;
  padding: 8px 0;
}
/* Selector de categoría en modo edición (dentro de la celda del día) */
.cadmin-edit-select {
  width: 100%;
  font-size: 0.72rem;
  padding: 4px 4px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  margin-bottom: 4px;
}
.cadmin-edit-input {
  width: 100%;
  font-size: 0.7rem;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  margin-bottom: 3px;
}

/* Botonera rápida "todo el día" (Oficina / Casa / Libre / etc.) dentro del editor */
.cadmin-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.cadmin-quick-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.66rem;
  font-weight: 600;
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}
.cadmin-quick-btn:hover { filter: brightness(0.96); }

/* Lista de bloques/actividades agregados para el día */
.cadmin-bloques-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.cadmin-bloque-row {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-left-width: 3px;
  border-radius: 6px;
  padding: 6px 8px;
}
.cadmin-bloque-row-top { display: flex; gap: 4px; align-items: center; }
.cadmin-bloque-row-top .cadmin-edit-select { flex: 1; margin-bottom: 0; }
.cadmin-bloque-remove {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  padding: 3px 6px;
  font-size: 0.72rem;
  border-radius: 4px;
}
.cadmin-bloque-remove:hover { color: #dc2626; background: #fef2f2; }
.cadmin-bloque-horas { display: flex; gap: 6px; margin-top: 3px; }
.cadmin-bloque-hora-label {
  flex: 1;
  font-size: 0.62rem;
  color: var(--gray-500);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cadmin-bloque-hora-label .cadmin-edit-input { margin-bottom: 0; }
.cadmin-bloque-hint { font-size: 0.62rem; color: var(--gray-400); margin-top: 2px; font-style: italic; }

/* Botón "Agregar actividad" */
.cadmin-add-bloque-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  background: #eff6ff;
  border: 1px dashed #bfdbfe;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
}
.cadmin-add-bloque-btn:hover { background: #dbeafe; }

/* Editor dentro de la tarjeta móvil */
.cadmin-card-dia-editor { flex: 1; min-width: 0; }
/* Responsive: tabla en tablet/desktop; tarjetas apiladas en móvil ≤700px */
@media (max-width: 900px) {
  .cadmin-table { min-width: 680px; }
}
@media (max-width: 700px) {
  /* Ocultar tabla con scroll horizontal, mostrar tarjetas verticales (mismo patrón que Planificación · Por Obra) */
  .cadmin-table-wrap { display: none !important; }
  .cadmin-mobile-cards { display: block !important; }

  /* Navegador de semana: botones con solo ícono para ahorrar espacio */
  .cadmin-nav-body { padding: 10px 12px; gap: 8px; }
  .cadmin-nav-btn-text { display: none; }
  .cadmin-nav-btn { padding: 8px 10px; }
  .cadmin-rango-semana { font-size: 0.82rem; order: -1; flex: 1 1 100%; margin-bottom: 4px; }

  /* Leyenda: chips más compactos */
  .cadmin-leyenda-item { font-size: 0.72rem; padding: 3px 9px; }

  /* Encabezado de Obras: ocultar texto de botones secundarios, dejar solo íconos */
  .obras-btn-text { display: none; }
  .obras-header-actions { width: 100%; justify-content: flex-start; }
  .obras-vista-switch { flex-shrink: 0; }
}
@media (max-width: 400px) {
  .cadmin-card-header { padding: 9px 10px; gap: 8px; }
  .cadmin-card-dia { padding: 8px 10px; }
}

/* En tarjetas móviles, agrandar los controles de edición para mejor uso táctil
   (allí sí hay espacio de sobra, a diferencia de la celda estrecha de la tabla) */
@media (max-width: 700px) {
  .cadmin-card-dia-editing { flex-direction: column; }
  .cadmin-card-dia-editing .cadmin-edit-select,
  .cadmin-card-dia-editing .cadmin-edit-input {
    font-size: 0.85rem;
    padding: 9px 10px;
    margin-bottom: 6px;
  }
  .cadmin-card-dia-editing input[type="time"] { padding: 8px 8px; }

  /* Botones rápidos: más grandes y fáciles de tocar en celular */
  .cadmin-quick-btn {
    font-size: 0.72rem;
    padding: 7px 11px;
  }

  /* Bloques de actividad: más aire y controles táctiles más grandes */
  .cadmin-bloque-row { padding: 9px 10px; }
  .cadmin-bloque-remove { padding: 6px 10px; font-size: 0.85rem; }
  .cadmin-bloque-hora-label { font-size: 0.7rem; }
  .cadmin-add-bloque-btn { font-size: 0.8rem; padding: 9px 10px; }
}

/* Tablet: la celda de edición de la tabla necesita más ancho para los bloques,
   pero seguimos usando la tabla (>700px) hasta el breakpoint de tarjetas */
@media (max-width: 900px) and (min-width: 701px) {
  .cadmin-day-cell.cadmin-editing { min-width: 230px; }
  .cadmin-quick-btn-label { display: none; }
}
