/* ============================================================
   SISTEMA LATOUR - Estilos Base v2
   proyecto_jml/assets/css/latour.css
   Diseño: industrial refinado — preciso, limpio, funcional
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

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

/* ── VARIABLES ────────────────────────────────────────────── */
:root {
  /* Primario — verde Latour */
  --color-primary:        #1B9B72;
  --color-primary-dark:   #0E6E50;
  --color-primary-light:  #E0F4ED;
  --color-primary-text:   #074D38;
  --color-primary-mid:    #14B882;

  /* Semánticos */
  --color-danger:         #D94040;
  --color-danger-light:   #FBEAEA;
  --color-danger-text:    #6E1A1A;

  --color-warning:        #E8960D;
  --color-warning-light:  #FDF2DC;
  --color-warning-text:   #5C3600;

  --color-success:        #5A8F1A;
  --color-success-light:  #E8F4D8;
  --color-success-text:   #254008;

  --color-info:           #2E7FD4;
  --color-info-light:     #E4EFFA;
  --color-info-text:      #0A3D72;

  /* Superficies */
  --bg:           #F2F3F5;
  --bg-surface:   #FFFFFF;
  --bg-elevated:  #FAFAFA;
  --bg-sidebar:   #0A1E17;
  --bg-sidebar-2: #122A20;

  /* Texto */
  --text-primary:   #141414;
  --text-secondary: #4A4A4A;
  --text-muted:     #868686;
  --text-inverse:   #FFFFFF;

  /* Bordes */
  --border:       #DADADA;
  --border-light: #EFEFEF;
  --border-focus: rgba(27,155,114,.35);

  /* Layout */
  --sidebar-width:  228px;
  --header-height:  54px;

  /* Radios */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.06);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.08);
  --shadow-focus: 0 0 0 3px var(--border-focus);

  /* Tipografía */
  --font:      'DM Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'DM Mono', 'JetBrains Mono', monospace;

  /* Transiciones */
  --t-fast:   .12s ease;
  --t-base:   .18s ease;
  --t-slow:   .28s ease;
}

/* ── BASE ─────────────────────────────────────────────────── */
html, body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg);
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--color-primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LAYOUT ───────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 1.25rem 1.1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  position: relative;
}
.sidebar-logo::after {
  content: '';
  position: absolute;
  bottom: 0; left: 1.1rem; right: 1.1rem;
  height: 1px;
  background: linear-gradient(90deg, var(--color-primary-mid), transparent);
  opacity: .4;
}
.sidebar-logo .empresa {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.38);
  margin-bottom: 3px;
}
.sidebar-logo .sistema {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -.01em;
}

.sidebar-nav { flex: 1; padding: .6rem 0 .75rem; }

.nav-section {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.28);
  padding: .9rem 1.1rem .2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: .5rem 1.1rem;
  color: rgba(255,255,255,.62);
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  border-left: 2px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  text-decoration: none;
  margin: 1px 0;
}
.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.9);
  text-decoration: none;
}
.nav-item.active {
  background: rgba(27,155,114,.18);
  color: #fff;
  border-left-color: var(--color-primary-mid);
  font-weight: 500;
}
.nav-item .icon {
  font-size: 14px;
  width: 17px;
  text-align: center;
  flex-shrink: 0;
  opacity: .75;
}
.nav-item.active .icon { opacity: 1; }

.sidebar-footer {
  padding: .85rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11.5px;
  color: rgba(255,255,255,.38);
}
.sidebar-footer .user-name {
  color: rgba(255,255,255,.75);
  font-weight: 500;
  font-size: 12.5px;
  margin-bottom: 1px;
}

/* ── MAIN ─────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.topbar {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-xs);
}
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  letter-spacing: -.01em;
}
.topbar-actions { display: flex; gap: .5rem; align-items: center; }

/* ── PAGE CONTENT ─────────────────────────────────────────── */
.page-content { padding: .8rem 1rem; flex: 1; }

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: .5rem .85rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-header h2 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -.01em;
}
.card-body { padding: .7rem .85rem; }

/* ── STAT CARDS ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 7px;
  margin-bottom: .7rem;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: .5rem .7rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--t-base), transform var(--t-base);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-mid));
  opacity: 0;
  transition: opacity var(--t-base);
}
.stat-card:hover::before { opacity: 1; }
.stat-card .stat-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.stat-card .stat-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -.02em;
}
.stat-card .stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── TABLA ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
thead th {
  text-align: left;
  padding: .38rem .6rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--t-fast);
}
tbody tr:nth-child(even) { background: rgba(0,0,0,.012); }
tbody tr:hover { background: var(--color-primary-light); }
tbody td {
  padding: .4rem .6rem;
  color: var(--text-primary);
  vertical-align: middle;
}
tbody td.muted { color: var(--text-muted); font-size: 12px; }

/* ── BOTONES ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: .42rem .9rem;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
  letter-spacing: -.01em;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(27,155,114,.25), inset 0 1px 0 rgba(255,255,255,.1);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  box-shadow: 0 2px 6px rgba(27,155,114,.3);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg);
  border-color: #C0C0C0;
  color: var(--text-primary);
}

.btn-danger {
  background: var(--color-danger-light);
  color: var(--color-danger-text);
  border-color: #F0BBBB;
}
.btn-danger:hover { background: #F5C5C5; border-color: var(--color-danger); }

.btn-sm { padding: .28rem .6rem; font-size: 11.5px; border-radius: var(--radius-sm); }
.btn-icon { padding: .38rem; border-radius: var(--radius-md); }

/* ── FORMULARIOS ──────────────────────────────────────────── */
.form-group { margin-bottom: .9rem; }
.form-group label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  letter-spacing: .01em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .48rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: #BEBEBE; }
.form-group input.error,
.form-group select.error { border-color: var(--color-danger); box-shadow: 0 0 0 3px rgba(217,64,64,.12); }
.form-group .field-error { font-size: 11.5px; color: var(--color-danger); margin-top: 3px; }

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

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .01em;
}
.badge-success { background: var(--color-success-light); color: var(--color-success-text); }
.badge-danger  { background: var(--color-danger-light);  color: var(--color-danger-text); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning-text); }
.badge-info    { background: var(--color-info-light);    color: var(--color-info-text); }
.badge-neutral { background: var(--border-light);        color: var(--text-secondary); }

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,15,12,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  backdrop-filter: blur(2px);
  animation: fadeOverlay .15s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideModal .18s cubic-bezier(.34,1.2,.64,1);
  border: 1px solid rgba(255,255,255,.8);
}
@keyframes slideModal { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}
.modal-header::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: var(--radius-xl) 0 0 0;
}
.modal-header h3 {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  padding-left: .5rem;
}
.modal-close {
  background: none;
  border: none;
  font-size: 17px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
  line-height: 1;
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }
.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: .45rem;
  background: var(--bg);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ── ALERTS / TOAST ───────────────────────────────────────── */
.alert {
  padding: .65rem 1rem;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 3px solid;
}
.alert-success { background: var(--color-success-light); color: var(--color-success-text); border-color: var(--color-success); }
.alert-danger  { background: var(--color-danger-light);  color: var(--color-danger-text);  border-color: var(--color-danger); }
.alert-warning { background: var(--color-warning-light); color: var(--color-warning-text); border-color: var(--color-warning); }
.alert-info    { background: var(--color-info-light);    color: var(--color-info-text);    border-color: var(--color-info); }

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.toast {
  background: var(--bg-sidebar);
  color: rgba(255,255,255,.9);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: .7rem 1.1rem .7rem .9rem;
  font-size: 13px;
  min-width: 220px;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: .6rem;
  animation: toastIn .2s cubic-bezier(.34,1.2,.64,1);
}
.toast::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.toast.success::before { background: var(--color-primary-mid); box-shadow: 0 0 6px var(--color-primary-mid); }
.toast.error::before   { background: #FF6B6B; box-shadow: 0 0 6px #FF6B6B; }
.toast.info::before    { background: #6BB8FF; box-shadow: 0 0 6px #6BB8FF; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px) scale(.95); } to { opacity: 1; transform: none; } }

/* ── BÚSQUEDA / FILTROS ───────────────────────────────────── */
.toolbar {
  display: flex;
  gap: .65rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-box input {
  width: 100%;
  padding: .45rem .75rem .45rem 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  outline: none;
  background: var(--bg-surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-box input:focus { border-color: var(--color-primary); box-shadow: var(--shadow-focus); }
.search-box::before {
  content: '🔍';
  font-size: 11px;
  position: absolute;
  left: .6rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: .5;
}

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 32px; margin-bottom: .65rem; opacity: .5; }
.empty-state p { font-size: 13px; }

/* ── SPINNER ──────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── AVATAR ───────────────────────────────────────────────── */
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── UTILIDADES ───────────────────────────────────────────── */
.hidden   { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.flex       { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-sm { gap: .5rem; }
.gap-md { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.w-full { width: 100%; }

/* ── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #B8B8B8; }

/* ── SELECTS custom arrow ─────────────────────────────────── */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23868686'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .65rem center;
  padding-right: 2rem !important;
  cursor: pointer;
}


/* ============================================================
   SIDEBAR JERÁRQUICO (subgrupos Compras/Ventas dentro de Gestión)
   ============================================================ */

.nav-section-group {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  padding: .55rem 1.1rem .2rem;
  margin-top: .25rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-section-group .icon {
  font-size: 12px;
  opacity: .75;
}

.nav-item.sub {
  padding-left: 2.1rem;
  font-size: 12.5px;
}
.nav-item.sub .icon {
  font-size: 12.5px;
  width: 15px;
  opacity: .65;
}
/* ── RESPONSIVE / CELULAR — versión intermedia (2026-10-13) ── */
/* Menú off-canvas + hamburguesa + densidad moderada. SIN forzar columnas de tabla. */
.menu-toggle { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 82vw; max-width: 300px;
    box-shadow: 0 0 40px rgba(0,0,0,.45);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 7px; left: 8px; z-index: 101;
    width: 40px; height: 40px; border: none; border-radius: 9px;
    background: var(--bg-sidebar); color: #fff;
    font-size: 19px; line-height: 1; cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
  }
  .topbar { padding-left: 58px; }
  .topbar-title { font-size: 14px; }
  .sidebar-backdrop.open {
    display: block; position: fixed; inset: 0; z-index: 99;
    background: rgba(10,22,18,.45);
  }
  .page-content { padding: .9rem .7rem; }
  .card-header { padding: .55rem .8rem; }
  .card-body   { padding: .7rem .8rem; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 7px; margin-bottom: .8rem; }
  .stat-card { padding: .5rem .6rem; }
  .stat-card .stat-value { font-size: 17px; line-height: 1.1; }
  table { font-size: 12px; }
  thead th { padding: .4rem .55rem; font-size: 9.5px; }
  tbody td { padding: .42rem .55rem; }
}

@media (max-width: 480px) {
  .page-content { padding: .7rem .55rem; }
  .topbar-title { font-size: 13.5px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 6px; }
}
