:root {
  --bg-color: #f9f9f8;
  --surface: #ffffff;
  --surface-low: #f3f4f3;
  --primary: #1B4332;
  --primary-light: #74C69D;
  --secondary: #0284c7;
  --secondary-light: #38bdf8;
  --primary-dim: rgba(27, 67, 50, 0.08);
  --text-main: #191c1c;
  --text-muted: #414844;
  --error: #ba1a1a;
  --error-bg: #ffdad6;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --success: #0e6c4a;
  --success-bg: #a0f4c8;
  --border-light: rgba(193, 200, 194, 0.3);

  --font-display: 'Manrope', sans-serif;
  --font-body: 'Inter', sans-serif;

  --glass-shadow: 0 12px 40px rgba(25, 28, 28, 0.04);
}

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

html, body {
  max-width: 100%;
  overflow-x: hidden;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-main);
  background-image: 
    radial-gradient(circle at top right, rgba(116, 198, 157, 0.1), transparent 40%),
    radial-gradient(circle at bottom left, rgba(27, 67, 50, 0.05), transparent 40%);
  background-attachment: fixed;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2, h3, h4, .display-title { font-family: var(--font-display); color: var(--primary); min-width: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.mt-4 { margin-top: 1rem; }
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }
.error-text { color: var(--error); }

/* Login Screen Styles */
/* Login - Mobile First */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  width: 100vw;
  background-image: url('https://images.unsplash.com/photo-1592982537447-6f2a6a0c5c1b?auto=format&fit=crop&w=1200&q=60');
  background-size: cover;
  background-position: center;
  position: relative;
  padding: 1rem;
}
.login-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(27, 67, 50, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1;
}
.login-glass-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 2rem 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-logo {
  max-width: 180px;
  height: auto;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}


/* Navigation & Layout */
/* Layout - Mobile First */
.app-wrapper { 
  display: block; 
  min-height: 100dvh; 
  width: 100%; 
  position: relative; 
}

/* Sidebar Drawer - Mobile First */
.sidebar {
  position: fixed;
  top: 0;
  left: -280px; /* Hidden by default */
  width: 280px;
  height: 100dvh;
  background: white;
  z-index: 2000;
  box-shadow: 10px 0 40px rgba(0,0,0,0.15);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
}
.sidebar.open { transform: translateX(280px); } /* Slide in */

.sidebar-header { margin-bottom: 2rem; padding: 0 0.5rem; }
.logo-container { display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
.brand-icon { font-size: 1.5rem; color: var(--primary-light); }
.sidebar-header h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 0.5rem; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.75rem 1rem; color: var(--text-muted); text-decoration: none;
  border-radius: 12px; font-weight: 500; font-size: 0.95rem; transition: all 0.2s ease;
}
.nav-item i { font-size: 1.2rem; }
.nav-item:hover { background: var(--surface-low); color: var(--primary); }
.nav-item.active { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(27, 67, 50, 0.2); }

.sidebar-footer { padding-top: 1.5rem; border-top: 1px solid var(--border-light); }
.user-name { font-weight: 700; font-size: 0.9rem; color: var(--primary); }
.user-role-display { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.logout-btn { 
  margin-top: 1rem; width: 100%; padding: 0.6rem; 
  border-radius: 10px; border: 1px solid #fee2e2; background: #fff1f2; 
  color: #be123c; font-weight: 700; cursor: pointer; transition: 0.2s;
}
.logout-btn:hover { background: #fee2e2; }

.sidebar-overlay { 
  display: none; 
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,0.4); 
  backdrop-filter: blur(2px); 
  z-index: 1500; 
  opacity: 0; 
  transition: opacity 0.3s;
}
.sidebar-overlay.show { display: block; opacity: 1; pointer-events: auto; }

/* Mobile First Components */
.mobile-only { display: flex !important; }
.mobile-top-bar {
  display: flex; justify-content: space-between; align-items: center;
  height: 64px;
  padding: 0 1.2rem; background: white; border-bottom: 1px solid var(--border-light);
  position: sticky; top: 0; z-index: 1050;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.mobile-menu-btn {
  background: var(--surface-low); border: none; width: 44px; height: 44px; 
  border-radius: 12px; font-size: 1.8rem; color: var(--primary); 
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.sidebar-close-btn {
  background: var(--surface-low); border: none; width: 40px; height: 40px; 
  border-radius: 50%; color: var(--primary); font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}

.content-area { 
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 1rem;
  background: transparent;
  min-height: 100dvh;
}
.topbar {
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  padding: 1rem; 
  position: sticky; 
  top: 0; 
  z-index: 1001;
  background: white;
  border-bottom: 1px solid var(--border-light);
  gap: 8px;
  flex-wrap: wrap;
}
.search-bar {
  display: flex; align-items: center; gap: 0.5rem; background: var(--surface-low);
  padding: 0.5rem 1rem; border-radius: 99px; width: 100%;
  order: 2; /* Search bar at bottom on mobile */
}
.search-bar input { border: none; outline: none; background: transparent; width: 100%; font-family: inherit; font-size: 0.9rem; color: var(--text-main); }
.search-bar i { color: var(--text-muted); font-size: 1.1rem; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border-light);
  width: 44px; height: 44px; border-radius: 50%; display: flex; justify-content: center; align-items: center;
  cursor: pointer; box-shadow: var(--glass-shadow); position: relative; transition: transform 0.2s;
}
.icon-btn:hover { transform: translateY(-2px); }
.icon-btn i { font-size: 1.3rem; color: var(--primary); }
.badge-indicator {
  position: absolute; top: 10px; right: 12px;
  width: 8px; height: 8px; background: var(--error); border-radius: 50%; border: 2px solid white;
}

/* Tablets & Desk overrides */
@media (min-width: 992px) {
  .app-wrapper {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    position: sticky;
    left: 0;
    transition: none;
    box-shadow: none;
    border-right: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.95);
  }

  .content-area {
    padding: 2.5rem;
    overflow-y: auto;
  }

  .topbar {
    padding: 1.5rem 3rem;
    flex-wrap: nowrap;
    background: linear-gradient(to bottom, var(--bg-color) 40%, transparent);
    border: none;
  }

  .search-bar {
    width: 350px;
    order: 0;
    background: var(--surface);
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--border-light);
  }

  .views-container {
    padding: 0 3rem 3rem 3rem;
  }

  .mobile-only, .mobile-top-bar, .sidebar-close-btn {
    display: none !important;
  }
}

/* Views */
.views-container { padding: 0 1rem 1rem 1rem; }
.view { display: none; animation: fadeIn 0.4s ease; }
.view.active-view { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.section-header { margin-bottom: 2rem; }
.display-title { font-size: 2rem; letter-spacing: -0.03em; margin-bottom: 0.5rem; }
.subtitle { color: var(--text-muted); font-size: 1rem; }

/* Dashboard Grid - Mobile First */
.dashboard-grid { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 1rem; 
}
.dashboard-grid-kpi { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 1rem; 
  margin-bottom: 2rem; 
}
.dashboard-grid-charts { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 1.5rem; 
  margin-bottom: 2rem; 
}

@media (min-width: 768px) {
  .dashboard-grid-kpi { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1200px) {
  .dashboard-grid-kpi { grid-template-columns: repeat(4, 1fr); }
  .dashboard-grid-charts { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: repeat(3, 1fr); }
}

.col-span-2 { grid-column: span 1; }
@media (min-width: 1200px) {
  .col-span-2 { grid-column: span 2; }
}

.glass-card {
  background: rgba(255, 255, 255, 0.75); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-light); border-radius: 20px; padding: 1.5rem;
  box-shadow: var(--glass-shadow); display: flex; flex-direction: column; 
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.card-header h3 { font-size: 1.05rem; font-weight: 600; }
.trend.up { color: var(--success); font-weight: 600; font-size: 0.8rem; display: flex; align-items: center; gap: 4px; background: var(--success-bg); padding: 4px 10px; border-radius: 99px;}

.chart-container { position: relative; height: 230px; width: 100%; }

.rings-container { display: flex; justify-content: space-around; }
.ring-wrapper { position: relative; width: 80px; height: 80px; display: flex; justify-content: center; align-items: center; }
.ring-svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--surface-low); stroke-width: 8; }
.ring-progress { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s ease-in-out; }
.ring-value { position: absolute; font-weight: 700; font-size: 1rem; color: var(--primary); font-family: var(--font-display);}
.ring-label { text-align: center; font-size: 0.75rem; font-weight: 600; margin-top: 0.5rem; color: var(--text-muted); }

.inventory-alerts .alert-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; padding: 0.5rem; border-radius: 8px; background: var(--error-bg); color: var(--error); font-weight: 500;}

.audits-container { display: flex; flex-direction: column; gap: 1.25rem; }
.audit-item .audit-title { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; }
.progress-track { width: 100%; height: 8px; background: var(--surface-low); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 1s ease; }

.rrhh-stats { gap: 1.5rem; justify-content: flex-start; }
.stat-circle { width: 90px; height: 90px; border-radius: 50%; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); color: white; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(116, 198, 157, 0.4);}
.stat-value { font-size: 1.6rem; font-family: var(--font-display); font-weight: 700; line-height: 1; margin-top:-5px;}
.stat-label { font-size: 0.7rem; opacity: 0.9; margin-top: 5px; }
.stat-details p { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; margin-bottom: 0.5rem; font-weight: 500; }

.forum-item { display: flex; gap: 0.8rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-light); margin-bottom: 1rem; }
.forum-item:last-child { border: none; margin: 0; padding: 0; }
.forum-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-dim); display: flex; justify-content: center; align-items: center; color: var(--primary); font-weight: bold;}
.forum-content h4 { font-size: 0.9rem; margin-bottom: 0.2rem; }
.forum-content p { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Universal Module Layouts */
.btn { border: none; padding: 0.6rem 1.25rem; border-radius: 12px; font-weight: 600; font-family: var(--font-body); cursor: pointer; display: inline-flex; align-items: center; gap: 0.5rem; transition: all 0.2s; font-size: 0.9rem; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; }
.btn-primary:hover { box-shadow: 0 4px 15px rgba(27, 67, 50, 0.3); transform: translateY(-1px); }

.crud-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.input-group { display: flex; flex-direction: column; gap: 0.4rem; }
.input-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-main); }
.input-control { 
  padding: 0.6rem 1rem; 
  border-radius: 10px; 
  border: 1px solid var(--border-light); 
  background: var(--surface); 
  color: var(--text-main); 
  font-family: inherit; 
  font-size: 0.9rem; 
  outline: none; 
  transition: all 0.2s; 
  -webkit-appearance: none; 
  -moz-appearance: none; 
  appearance: none;
}
.input-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 4px var(--primary-dim); }
.input-group.full-width { grid-column: span 2; }

.table-wrapper { 
  width: 100%;
  overflow-x: auto; 
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
}
.editorial-table { 
  width: 100%; 
  min-width: 800px; /* Force scroll on mobile */
  border-collapse: collapse; 
}
.editorial-table th { 
  text-align: left; padding: 1rem; font-size: 0.75rem; 
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); 
  font-weight: 600; border-bottom: 1px solid var(--border-light); 
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.editorial-table td { padding: 1rem; font-size: 0.9rem; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.editorial-table tr:hover td { background: var(--surface-low); }

/* Agrupación de Guías por Cliente (Carpetas) */
.guia-group-header td {
  padding: 0 !important;
  border: none !important;
  cursor: pointer;
}
.guia-group-header:hover td div {
  filter: brightness(1.1);
}
.guia-group-header i.ph-caret-down {
  transition: transform 0.3s ease;
}
.guia-group-header.collapsed i.ph-caret-down {
  transform: rotate(-90deg);
}
.guia-row-item {
  transition: all 0.3s ease;
}
.guia-row-item.hidden {
  display: none !important;
}

/* Sub-Carpetas Anidadas */
.guia-subgroup-header td {
  padding: 0 !important;
  border: none !important;
  cursor: pointer;
}
.guia-subgroup-header i.ph-caret-right {
  transition: transform 0.2s ease;
}
.guia-subgroup-header.expanded i.ph-caret-right {
  transform: rotate(90deg);
}

.folder-badge {
  background: rgba(255,255,255,0.2);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.7rem;
  margin-left: auto;
}

.folder-badge {
  background: rgba(255,255,255,0.25); 
  padding: 2px 10px; 
  border-radius: 12px; 
  font-size: 0.75rem; 
  margin-left: 0.8rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.pill { padding: 4px 10px; border-radius: 99px; font-size: 0.7rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.pill.success { background: var(--success-bg); color: var(--success); }
.pill.warning { background: var(--warning-bg); color: var(--warning); }
.pill.neutral { background: var(--surface-low); color: var(--text-muted); border: 1px solid var(--border-light); }


/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.3); backdrop-filter: blur(4px); z-index: 99; display: none; opacity: 0; transition: opacity 0.3s; }
.drawer-backdrop.show { display: block; opacity: 1; }
.alerts-drawer { position: fixed; right: 0; top: 0; bottom: 0; width: 400px; background: rgba(255,255,255,0.85); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: -10px 0 40px rgba(0,0,0,0.1); z-index: 100; transform: translateX(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); display: flex; flex-direction: column; }
.alerts-drawer.open { transform: translateX(0); }
.drawer-header { padding: 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-light); }
.drawer-header h3 { font-size: 1.15rem; }
.drawer-content { padding: 1.5rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 1rem; }

.alert-card { padding: 1.25rem; border-radius: 16px; background: var(--surface); border: 1px solid var(--border-light); box-shadow: 0 4px 12px rgba(0,0,0,0.02); display: flex; gap: 1rem; position: relative; overflow: hidden; }
.alert-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.alert-card.critical::before { background: var(--error); }
.alert-card.warning::before { background: var(--warning); }
.alert-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
.alert-card.critical .alert-icon { background: var(--error-bg); color: var(--error); }
.alert-card.warning .alert-icon { background: var(--warning-bg); color: var(--warning); }
.alert-details h4 { font-size: 0.95rem; margin-bottom: 0.25rem; color: var(--text-main); }
.alert-details p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.alert-time { font-size: 0.7rem; color: var(--text-muted); position: absolute; top: 1.25rem; right: 1.25rem; }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.8rem; border-radius: 8px; border: 1px solid var(--border-light); background: var(--surface-low); cursor: pointer; font-weight: 600; border:none; }
.btn-small:hover { background: var(--border-light); }

/* --- PREMIUM PROPOSAL & PDF ENGINE --- */
.formal-proposal {
    line-height: 1.6;
    color: #1e293b;
    background: white !important;
}

.formal-proposal h1, .formal-proposal h2, .formal-proposal h3, .formal-proposal h4 {
    font-family: 'Manrope', sans-serif;
    color: #081c15;
}

.section-divider {
    height: 4px;
    width: 80px;
    background: var(--primary);
    margin: 1rem 0;
    border-radius: 10px;
}

.colored-box {
    background: #f8fafc;
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.page-break {
    page-break-after: always;
    clear: both;
    display: block;
    height: 0;
}

@media print {
    .no-print { display: none !important; }
    .proposal-body { padding: 0 !important; background: white !important; }
    .formal-proposal { box-shadow: none !important; padding: 0 !important; margin: 0 !important; width: 100% !important; }
    .page-break { page-break-after: always !important; }
}

.total-premium-box {
    background: #081c15;
    color: white;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(8,28,21,0.2);
}

.client-box-formal {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-premium {
    font-size: 1rem !important;
    padding: 1rem 2rem !important;
    border-radius: 50px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 800 !important;
}

/* Logic for Modals/Drawers on Mobile */
@media (max-width: 991px) {
  .alerts-drawer { width: 100%; z-index: 3000; }
  .drawer-content { padding: 1rem; }
}

/* ---------------------------------
   Impresión de Cotización Simple (Productos)
----------------------------------- */
.simple-quote {
  font-family: 'Arial', sans-serif;
  color: #333;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px;
  background: white;
  line-height: 1.5;
  font-size: 14px;
}
.simple-header { display: flex; justify-content: space-between; border-bottom: 2px solid var(--primary); padding-bottom: 20px; margin-bottom: 20px; }
.simple-company { font-size: 12px; line-height: 1.6; }
.simple-company strong { font-size: 16px; color: var(--primary); }
.simple-meta { text-align: right; }
.simple-meta h1 { font-family: var(--font-display); font-size: 24px; color: var(--primary); margin: 0 0 10px 0; }
.simple-client { border: 1px solid #ddd; padding: 15px; background: #fcfcfc; border-radius: 5px; margin-bottom: 30px; font-size: 13px; }
.simple-client h3 { margin-top: 0; color: var(--primary); font-size: 15px; margin-bottom: 10px; border-bottom: 1px solid #eee; padding-bottom: 5px; }
.simple-table { width: 100%; border-collapse: collapse; margin-bottom: 30px; }
.simple-table th { background: var(--primary); color: white; padding: 10px; font-size: 13px; text-align: left; border: 1px solid var(--primary);}
.simple-table td { border-bottom: 1px solid #ddd; padding: 10px; font-size: 14px; }
.simple-totals { width: 300px; margin-left: auto; border: 1px solid #ddd; border-radius: 5px; padding: 15px; margin-bottom: 40px;}
.simple-totals-row { display: flex; justify-content: space-between; padding: 5px 0; }
.simple-totals-row strong { color: var(--primary); }
.simple-footer { margin-top: 50px; text-align: center; color: #555; }

/* ---------------------------------
   Impresión y Generación de Presupuesto Técnico (PDF/A4)
----------------------------------- */
.formal-proposal {
  font-family: 'Arial', 'Inter', sans-serif;
  color: #333;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px;
  background: white;
  background-color: white;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  line-height: 1.5;
  font-size: 13px;
  text-align: justify;
}

.formal-header {
  text-align: center;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 15px;
  margin-bottom: 30px;
  font-size: 12px;
  color: var(--primary);
  line-height: 1.4;
}

.formal-header strong { font-size: 14px; }

.formal-header img {
  max-width: 220px;
  margin-bottom: 5px;
}

.formal-date { text-align: right; margin-bottom: 30px; }

.client-block { margin-bottom: 30px; line-height: 1.6; }
.client-block p { margin: 0; }

.formal-proposal h1, .formal-proposal h2, .formal-proposal h3 {
  color: #1b4332; /* Forest Green */
  margin-top: 25px;
  margin-bottom: 15px;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.formal-proposal h2 { 
  font-size: 16px; 
  border-bottom: 2px solid #1b4332; 
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.formal-proposal h3 { 
  font-size: 14px; 
  margin-top: 20px; 
  color: #2d6a4f;
}
.formal-proposal p { 
  margin-bottom: 14px; 
  line-height: 1.6;
  color: #333;
}

.formal-table {
  width: 100%;
  border-collapse: collapse;
  margin: 25px 0;
  border-radius: 8px;
  overflow: hidden;
}
.formal-table th, .formal-table td {
  border: 1px solid #e0e0e0;
  padding: 12px 15px;
  font-size: 13px;
}
.formal-table th { 
  background: #f8faf9; 
  color: #1b4332;
  font-weight: 700; 
  text-align:left;
  border-bottom: 2px solid #1b4332;
}
.formal-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.acceptance-block {
  margin-top: 50px;
  border: 2px dashed #1b4332;
  padding: 25px;
  background: #f8faf9;
  border-radius: 12px;
}

.page-break { 
  page-break-before: always; 
  break-before: page;
  height: 0 !important; 
  margin: 0 !important; 
  padding: 0 !important;
  overflow: hidden !important;
  display: block;
}

/* --- Enhanced Budget UI & PDF Styles --- */
.status-pill-aprobada { background: #dcfce7 !important; color: #166534 !important; border: 1px solid #bbf7d0 !important; }
.status-pill-generada { background: #fef9c3 !important; color: #854d0e !important; border: 1px solid #fef08a !important; }
.status-pill-rechazada { background: #fee2e2 !important; color: #991b1b !important; border: 1px solid #fecaca !important; }

.budget-row-highlight { border-left: 5px solid var(--primary-light) !important; }

/* Enhanced Doc Styles for PDF */
.formal-proposal {
  border: 1px solid #eee;
  border-top: 10px solid var(--primary);
  border-radius: 0 0 12px 12px;
}

.premium-header {
  background: linear-gradient(135deg, var(--primary) 0%, #2d6a4f 100%);
  color: white;
  padding: 30px;
  margin: -40px -40px 40px -40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.premium-header-info { text-align: right; font-size: 11px; line-height: 1.4; opacity: 0.9; }
.premium-header img { filter: brightness(0) invert(1); max-width: 180px; }

.section-divider {
  height: 3px;
  background: linear-gradient(to right, var(--primary), var(--primary-light), transparent);
  margin: 1.5rem 0;
  border-radius: 2px;
}

.colored-box {
  background: #f8faf9;
  border: 1px solid #e2e8f0;
  border-left: 6px solid var(--primary);
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 25px;
}

.total-premium-box {
  background: var(--primary);
  color: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}


/* --- PREMIUM PROPOSAL VIEWER MODAL --- */
#print-view {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 28, 21, 0.95); /* Agro Darker Transparent */
  backdrop-filter: blur(12px);
  z-index: 100000;
  overflow-y: auto;
  display: none;
  padding: 40px 10px;
  animation: fadeInModal 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInModal {
  from { opacity: 0; transform: scale(1.05); }
  to { opacity: 1; transform: scale(1); }
}

.total-premium-box span { opacity: 0.8; font-size: 0.9rem; }
.total-premium-box strong { font-size: 1.5rem; display: block; margin-top: 5px; }


@page {
  size: A4;
  margin: 10mm;
}

#print-view {
  background: #f3f4f6;
  padding: 0;
}

#print-view .pdf-page,
#print-view .pdf-content {
  width: 190mm;
  min-height: auto;
  margin: 0 auto 8mm auto;
  background: #fff;
  box-sizing: border-box;
  overflow: visible;
}

#print-view .pdf-content,
#print-view .report-body,
#print-view .section-block,
#print-view #ag-capture-area {
  display: block !important;
  position: static !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  transform: none !important;
}

#print-view .avoid-break,
#print-view table,
#print-view .signature-box,
#print-view .kpi-grid {
  break-inside: avoid;
  page-break-inside: avoid;
}

#print-view p,
#print-view li,
#print-view .long-text {
  orphans: 3;
  widows: 3;
}

#print-view .page-break {
  break-before: page;
  page-break-before: always;
}

@media print {
  body * {
    visibility: hidden;
  }

  #print-view,
  #print-view * {
    visibility: visible;
  }

  #print-view {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: white;
  }

  .no-print {
    display: none !important;
  }
}


/* ==========================================================================
   AGRO-GROUPS SIDEBAR STYLING (v12.1.2)
   ========================================================================== */

.sidebar-category {
  margin-top: 0.5rem;
  border-radius: 12px;
}

.category-header {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  background: rgba(0,0,0,0.02);
  border-radius: 12px;
  margin-bottom: 2px;
}

.category-header:hover {
  background: var(--primary-dim);
  color: var(--primary);
}

.category-header i {
  font-size: 0.8rem;
  transition: transform 0.3s ease;
}

.sidebar-category.collapsed .category-content {
  display: none !important;
}

.sidebar-category.collapsed i.ph-caret-down {
  transform: rotate(-90deg);
}

.category-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.2rem 0 0.5rem 0.5rem;
  border-left: 2px solid var(--border-light);
  margin-left: 0.8rem;
}

.nav-item {
  margin-bottom: 2px;
  font-size: 0.9rem;
}

.nav-item i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.sidebar-nav {
  padding-bottom: 2rem;
}

/* --- SMART SEARCHABLE SELECT (IA) --- */
.smart-search-wrapper {
  position: relative;
  width: 100%;
}
.smart-search-input-container {
  position: relative;
  display: flex;
  align-items: center;
}
.smart-search-input-container i {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}
.smart-search-input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.5rem !important;
  border-radius: 12px !important;
  border: 1px solid var(--border-light) !important;
  background: white !important;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.smart-search-input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px var(--primary-dim) !important;
  outline: none;
}
.smart-search-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: white;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  border: 1px solid var(--border-light);
  max-height: 300px;
  overflow-y: auto;
  z-index: 5000;
  display: none;
  animation: slideDownFade 0.2s ease-out;
}
.smart-search-dropdown.show {
  display: block;
}
@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.smart-search-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.2s;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}
.smart-search-item:last-child { border-bottom: none; }
.smart-search-item:hover, .smart-search-item.selected {
  background: var(--primary-dim);
}
.smart-search-item .client-name {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}
.smart-search-item .client-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}
.smart-search-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}
.smart-search-highlight {
  background: #fef08a;
  color: #854d0e;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 700;
}
