/* ============================================================
   IMMAC — Asphalt360 | Sistema de Diseño Corporativo
   Basado en Manual de Imagen Corporativa IMMAC
   ============================================================

   PALETA OFICIAL
   ─────────────────────────────────────────────────────────
   Azul marino (Principal)   #181d2e  RGB(24, 29, 46)
   Verde (Secundario)        #a1c436  RGB(161, 196, 54)
   Azul intermedio (Sec.)    #005992  RGB(0, 89, 146)

   TIPOGRAFÍA OFICIAL
   ─────────────────────────────────────────────────────────
   Marca / Títulos mayores   → Montserrat (reemplaza Articulat CF en web)
   Sub-títulos / Cuerpo warm → Lato
   UI / Tablas / Labels      → Inter

   JERARQUÍA DE USO
   ─────────────────────────────────────────────────────────
   H1 – Page titles          Montserrat 700  1.1rem  #181d2e
   H2 – Section headings     Montserrat 600  .95rem  #181d2e
   H3 – Card headings        Lato 600        .88rem  #181d2e
   Body text                 Inter 400       .875rem #3a3f52
   Labels / Meta             Inter 400       .78rem  #6c757d
   KPI values                Montserrat 700  1.6rem  #181d2e
   ============================================================ */

/* ============================================================
   GOOGLE FONTS IMPORT
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&family=Lato:wght@300;400;700&family=Inter:wght@300;400;500;600&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES — Tokens del sistema
   ============================================================ */
:root {
  /* Paleta primaria */
  --navy:        #181d2e;
  --navy-90:     rgba(24, 29, 46, .90);
  --navy-70:     rgba(24, 29, 46, .70);
  --navy-12:     rgba(24, 29, 46, .12);
  --navy-06:     rgba(24, 29, 46, .06);

  /* Paleta secundaria */
  --green:       #a1c436;
  --green-dark:  #85a228;
  --green-light: #d4e89b;
  --green-bg:    #f2f7e2;

  --blue:        #005992;
  --blue-dark:   #004a7c;
  --blue-light:  #4d93bf;
  --blue-bg:     #e6f0f8;

  /* Neutros */
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --border:      #e0e5ee;
  --text:        #3a3f52;
  --text-muted:  #6c757d;
  --text-light:  #9aa3b2;

  /* Semánticos */
  --danger:      #d93025;
  --warning:     #f59e0b;
  --success:     var(--green);

  /* Espaciado */
  --sidebar-w:   238px;
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   14px;

  /* Sombras */
  --shadow-xs:   0 1px 4px rgba(24,29,46,.08);
  --shadow-sm:   0 2px 8px rgba(24,29,46,.09);
  --shadow-md:   0 4px 16px rgba(24,29,46,.12);
  --shadow-lg:   0 8px 32px rgba(24,29,46,.16);

  /* Tipografías */
  --font-brand:  'Montserrat', 'Arial', sans-serif;
  --font-body:   'Lato', 'Arial', sans-serif;
  --font-ui:     'Inter', 'Arial', sans-serif;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  font-family: var(--font-ui);
  font-size: .875rem;
  color: var(--text);
  line-height: 1.5;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar corporativa */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--navy-12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--navy-70); }

/* ============================================================
   TIPOGRAFÍA — Jerarquía visual
   ============================================================ */

/* Nivel 1 — Títulos de página */
.page-title {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--navy);
  letter-spacing: -.01em;
  margin-bottom: 1.1rem;
}

/* Nivel 2 — Encabezados de sección */
.section-title {
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: .95rem;
  color: var(--navy);
  letter-spacing: .01em;
}

/* Nivel 3 — Encabezados de tarjeta (Lato, más cálido) */
.card-title-sm {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: .88rem;
  color: var(--navy);
}

/* Valores KPI — Montserrat bold */
.kpi-val,
.stat-val {
  font-family: var(--font-brand);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

/* Labels / meta */
.stat-label,
.meta-label {
  font-family: var(--font-ui);
  font-size: .76rem;
  color: var(--text-muted);
  margin-top: .3rem;
  letter-spacing: .02em;
}

/* ============================================================
   LAYOUT — Sidebar + Main
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy);
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 20px rgba(24,29,46,.22);
  overflow-y: auto;
  overflow-x: hidden;
}

.main-content {
  margin-left: var(--sidebar-w);
  padding: 1.5rem;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR — Marca
   ============================================================ */
.sidebar .brand {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-align: center;
  flex-shrink: 0;
}

.sidebar .brand img {
  max-width: 148px;
  max-height: 60px;
  object-fit: contain;
}

/* Logotipo textual cuando no hay imagen */
.sidebar .brand-text {
  display: block;
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: 1.35rem;
  color: #fff;
  letter-spacing: .1em;
  margin-top: .35rem;
}

/* Sub-brand / dominio */
.sidebar .brand-sub {
  display: block;
  font-family: var(--font-ui);
  font-size: .68rem;
  color: var(--green);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-top: .15rem;
}

/* ============================================================
   SIDEBAR — Navegación
   ============================================================ */

/* Separador de grupos */
.nav-section {
  font-family: var(--font-ui);
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.28);
  font-weight: 600;
  padding: .75rem 1rem .1rem;
  margin-top: .25rem;
  user-select: none;
}

.nav-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,.07);
  margin: .4rem .65rem;
}

/* Enlace de navegación */
.sidebar .nav-link {
  font-family: var(--font-ui);
  font-size: .83rem;
  font-weight: 400;
  color: rgba(255,255,255,.65);
  padding: .48rem 1rem;
  border-radius: var(--radius-sm);
  margin: .08rem .6rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .55rem;
  transition: background .14s, color .14s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .nav-link i {
  font-size: .95rem;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.sidebar .nav-link:hover {
  background: rgba(255,255,255,.09);
  color: #fff;
}

.sidebar .nav-link.active {
  background: var(--green);
  color: var(--navy) !important;
  font-weight: 600;
}

.sidebar .nav-link.active i {
  color: var(--navy);
}

/* ============================================================
   SIDEBAR — User area
   ============================================================ */
.sidebar .user-area {
  padding: .85rem 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
  margin-top: auto;
  flex-shrink: 0;
}

.sidebar .user-name {
  font-family: var(--font-ui);
  font-size: .82rem;
  font-weight: 500;
  color: rgba(255,255,255,.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .user-role {
  font-size: .7rem;
  color: rgba(255,255,255,.4);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  margin-bottom: 0;
  transition: box-shadow .18s;
}

.card:hover { box-shadow: var(--shadow-sm); }

.card-header {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .03em;
  padding: .65rem 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.card-header.green  { background: var(--green); color: var(--navy); }
.card-header.blue   { background: var(--blue);  color: #fff; }
.card-header.light  { background: var(--bg);    color: var(--navy); border-bottom: 1px solid var(--border); }

/* ============================================================
   STAT CARDS — KPIs
   ============================================================ */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  transition: box-shadow .18s, transform .18s;
}

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

/* Icono de stat */
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-icon.navy  { background: var(--navy-06); color: var(--navy); }
.stat-icon.green { background: var(--green-bg); color: var(--green-dark); }
.stat-icon.blue  { background: var(--blue-bg);  color: var(--blue); }
.stat-icon.warn  { background: #fff8e1; color: #e65100; }
.stat-icon.danger{ background: #fce4ec; color: var(--danger); }

/* ============================================================
   CRM PIPELINE — Embudo visual
   ============================================================ */
.crm-pipeline {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding: .5rem 0 .75rem;
}

.pipeline-step {
  flex: 1;
  min-width: 118px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: .95rem .7rem .75rem;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform .14s, box-shadow .14s;
  position: relative;
  border-bottom: 3px solid transparent;
}

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

.pipeline-step.active-step {
  border-bottom-color: var(--green);
}

.pipeline-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  margin: 0 auto .5rem;
}

.pipeline-val {
  font-family: var(--font-brand);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.pipeline-lbl {
  font-family: var(--font-ui);
  font-size: .71rem;
  color: var(--text-muted);
  margin-top: .28rem;
  line-height: 1.25;
}

.pipeline-arrow {
  display: flex;
  align-items: center;
  padding: 0 .25rem;
  color: var(--border);
  font-size: 1.1rem;
  flex: 0 0 auto;
}

/* ============================================================
   TABLAS
   ============================================================ */
.table {
  font-family: var(--font-ui);
  font-size: .84rem;
  color: var(--text);
}

.table thead th {
  background: #eef1f6;
  font-size: .73rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--navy);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
  padding: .6rem .75rem;
}

.table td {
  vertical-align: middle;
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:hover td {
  background: var(--navy-06);
}

.table-sm td, .table-sm th {
  padding: .35rem .65rem;
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: .84rem;
  border-radius: var(--radius-sm);
  transition: all .14s;
}

/* Primario — verde corporativo (acción principal) */
.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: var(--navy);
  font-weight: 600;
}
.btn-success:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: var(--navy);
}

/* Secundario — azul intermedio */
.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #fff;
}

/* Dark — azul marino */
.btn-dark {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn-dark:hover {
  background: #0f1220;
  border-color: #0f1220;
}

/* Outline navy */
.btn-outline-navy {
  background: transparent;
  border: 1.5px solid var(--navy);
  color: var(--navy);
}
.btn-outline-navy:hover {
  background: var(--navy);
  color: #fff;
}

/* Micro botón de acción en tablas */
.btn-xs {
  background: transparent;
  border: none;
  padding: .18rem .35rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  transition: background .12s;
}
.btn-xs:hover { background: var(--navy-06); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  font-family: var(--font-ui);
  font-size: .71rem;
  font-weight: 600;
  padding: .28em .65em;
  border-radius: 20px;
  letter-spacing: .03em;
}

/* Override Bootstrap semánticos con paleta IMMAC */
.badge.bg-primary   { background: var(--blue)   !important; }
.badge.bg-success   { background: var(--green)  !important; color: var(--navy) !important; }
.badge.bg-dark      { background: var(--navy)   !important; }
.badge.bg-info      { background: var(--blue-light) !important; color: #fff !important; }
.badge.bg-warning   { background: var(--warning) !important; color: #fff !important; }
.badge.bg-danger    { background: var(--danger)  !important; }

/* Role badges */
.role-badge {
  color: #fff;
  padding: .25em .75em;
  border-radius: 20px;
  font-family: var(--font-ui);
  font-size: .73rem;
  font-weight: 600;
  letter-spacing: .04em;
}
.role-admin   { background: var(--navy);  color: #fff; }
.role-editor  { background: var(--blue);  color: #fff; }
.role-visor   { background: #6c757d;      color: #fff; }
.role-cliente { background: var(--green); color: var(--navy); }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-control,
.form-select {
  font-family: var(--font-ui);
  font-size: .86rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .42rem .7rem;
  transition: border-color .14s, box-shadow .14s;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,89,146,.12);
  outline: none;
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(217,48,37,.12);
}

.form-label {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: .82rem;
  color: var(--navy);
  margin-bottom: .3rem;
}

.form-text {
  font-size: .76rem;
  color: var(--text-muted);
}

.input-group-text {
  background: var(--bg);
  border: 1.5px solid var(--border);
  font-size: .84rem;
  color: var(--text-muted);
}

/* ============================================================
   MODALES
   ============================================================ */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  padding: .9rem 1.2rem;
}

.modal-header .modal-title {
  font-family: var(--font-brand);
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.modal-header .btn-close {
  filter: invert(1);
  opacity: .7;
}

.modal-header.green {
  background: var(--green);
  color: var(--navy);
}

.modal-header.green .btn-close {
  filter: none;
}

.modal-body {
  padding: 1.2rem;
  font-family: var(--font-ui);
  font-size: .86rem;
}

.modal-footer {
  padding: .8rem 1.2rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   ALERTAS Y FLASH
   ============================================================ */
#flashArea {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  min-width: 290px;
  max-width: 390px;
}

.alert {
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: .84rem;
  border: none;
  box-shadow: var(--shadow-md);
}

/* Panel de alertas en dashboard */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  margin-bottom: .5rem;
  font-size: .82rem;
  font-family: var(--font-ui);
}

.alert-item .alert-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
}

.alert-item .alert-text { flex: 1; }
.alert-item .alert-title {
  font-family: var(--font-ui);
  font-weight: 600;
  color: var(--navy);
  font-size: .82rem;
}
.alert-item .alert-sub {
  color: var(--text-muted);
  font-size: .76rem;
}

/* ============================================================
   SECCIÓN HEADERS Y FILTER BAR
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
  gap: .5rem;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.filter-bar .form-control,
.filter-bar .form-select {
  font-size: .81rem;
  min-width: 120px;
  padding: .35rem .6rem;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress {
  background: #eef1f6;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  background: var(--green);
  border-radius: 4px;
  transition: width .4s;
}

.progress-bar.bg-primary { background: var(--blue)  !important; }
.progress-bar.bg-success { background: var(--green) !important; }
.progress-bar.bg-warning { background: var(--warning) !important; }
.progress-bar.bg-danger  { background: var(--danger) !important; }

/* ============================================================
   CÓDIGO / MONOSPACE
   ============================================================ */
code {
  font-family: 'Fira Code', 'Consolas', monospace;
  background: var(--blue-bg);
  color: var(--blue);
  padding: .1em .4em;
  border-radius: 4px;
  font-size: .8rem;
}

/* ============================================================
   BÁSCULA — Widget de pesaje rápido
   ============================================================ */
.bascula-widget {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 1.2rem;
  border-top: 4px solid var(--navy);
}

.bascula-widget .peso-display {
  font-family: var(--font-brand);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--navy);
  text-align: center;
  letter-spacing: .05em;
}

.bascula-widget .peso-neto-display {
  font-family: var(--font-brand);
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--green-dark);
  text-align: center;
  letter-spacing: .05em;
}

.bascula-widget .peso-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  text-align: center;
  margin-top: .2rem;
}

/* ============================================================
   OBRA — Cards de estado
   ============================================================ */
.obra-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  border-top: 4px solid transparent;
  padding: 1rem 1.1rem;
  transition: box-shadow .18s, transform .18s;
}

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

.obra-card.activa     { border-top-color: var(--green); }
.obra-card.pausada    { border-top-color: var(--warning); }
.obra-card.completada { border-top-color: var(--blue-light); }
.obra-card.cancelada  { border-top-color: var(--danger); }
.obra-card.diseño     { border-top-color: var(--blue); }

/* ============================================================
   EQUIPOS — Tarjetas de estado
   ============================================================ */
.equipo-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  border-left: 4px solid transparent;
  padding: .9rem 1rem;
  transition: box-shadow .18s;
}

.equipo-card.operativo       { border-left-color: var(--green); }
.equipo-card.mantenimiento   { border-left-color: var(--warning); }
.equipo-card.fuera_servicio  { border-left-color: var(--danger); }

/* ============================================================
   LABORATORIO — Indicadores
   ============================================================ */
.lab-indicator {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--font-ui);
  font-size: .78rem;
  font-weight: 600;
  padding: .25em .65em;
  border-radius: 20px;
}

.lab-ok    { background: var(--green-bg); color: var(--green-dark); }
.lab-fail  { background: #fce4ec; color: var(--danger); }
.lab-pend  { background: #fff3e0; color: #e65100; }
.lab-nd    { background: var(--bg); color: var(--text-muted); }

/* ============================================================
   COTIZACIÓN — Tabla de ítems
   ============================================================ */
#cot-items-tbody td {
  padding: .35rem .5rem;
  vertical-align: middle;
}

#cot-items-tbody .form-control,
#cot-items-tbody .form-select {
  padding: .28rem .45rem;
  font-size: .8rem;
}

.cotizacion-totals {
  background: var(--navy-06);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin-top: .75rem;
}

.cotizacion-totals .total-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-ui);
  font-size: .85rem;
  padding: .2rem 0;
}

.cotizacion-totals .total-final {
  font-family: var(--font-brand);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  border-top: 2px solid var(--navy-12);
  margin-top: .3rem;
  padding-top: .4rem;
}

/* ============================================================
   REPORTES — Tablas de resumen
   ============================================================ */
.rep-summary-card {
  background: linear-gradient(135deg, var(--navy) 0%, #2a3352 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.1rem;
  text-align: center;
}

.rep-summary-card .rep-val {
  font-family: var(--font-brand);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
}

.rep-summary-card .rep-lbl {
  font-size: .75rem;
  opacity: .65;
  margin-top: .3rem;
  letter-spacing: .05em;
}

/* ============================================================
   PORTAL CLIENTES
   ============================================================ */
.portal-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.2rem;
}

.portal-header h4 {
  font-family: var(--font-brand);
  font-weight: 700;
  margin: 0;
}

.portal-header p {
  font-family: var(--font-ui);
  font-size: .85rem;
  opacity: .8;
  margin: .25rem 0 0;
}

/* ============================================================
   DIVIDERS & SPACERS
   ============================================================ */
hr.immac {
  border: none;
  border-top: 2px solid var(--green);
  width: 48px;
  margin: .75rem 0;
  opacity: 1;
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .sidebar, .btn, #flashArea, .modal-backdrop,
  .section-header .btn, nav { display: none !important; }
  .main-content { margin-left: 0 !important; padding: .5cm; }
  .card { box-shadow: none !important; border: 1px solid #ddd; }
  .table thead th { background: #eee !important; color: #000 !important; }
  body { font-size: 10pt; }
}

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    width: 100%;
    min-height: auto;
    position: relative;
    z-index: auto;
  }
  .main-content { margin-left: 0; padding: 1rem; }
  .crm-pipeline { flex-wrap: nowrap; }
  .pipeline-step { min-width: 95px; padding: .75rem .5rem; }
  .pipeline-val { font-size: 1.15rem; }
}

/* ============================================================
   UTILITARIOS CORPORATIVOS
   ============================================================ */
.text-navy  { color: var(--navy)  !important; }
.text-green { color: var(--green) !important; }
.text-blue  { color: var(--blue)  !important; }
.bg-navy    { background: var(--navy)  !important; color: #fff; }
.bg-green   { background: var(--green) !important; color: var(--navy); }
.bg-blue    { background: var(--blue)  !important; color: #fff; }
.border-navy  { border-color: var(--navy)  !important; }
.border-green { border-color: var(--green) !important; }

/* Montserrat para títulos aislados */
.font-brand { font-family: var(--font-brand) !important; }
.font-body  { font-family: var(--font-body)  !important; }
.font-ui    { font-family: var(--font-ui)    !important; }

/* Lema corporativo */
.tagline {
  font-family: var(--font-body);
  font-style: italic;
  font-size: .78rem;
  color: var(--text-muted);
  letter-spacing: .03em;
}

/* ============================================================
   RESPONSIVE — Mobile-first completo
   Breakpoints: xs <576  sm 576  md 768  lg 992  xl 1200
   ============================================================ */

/* ── Topbar móvil (visible solo en <992px) ─────────────────── */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--navy);
  z-index: 300;
  align-items: center;
  gap: .75rem;
  padding: 0 1rem;
  box-shadow: 0 2px 8px rgba(24,29,46,.25);
}

.btn-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.btn-hamburger span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .22s, opacity .22s;
}

/* Animate to X when open */
body.sidebar-open .btn-hamburger span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
body.sidebar-open .btn-hamburger span:nth-child(2) {
  opacity: 0;
}
body.sidebar-open .btn-hamburger span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

.mobile-brand {
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
  letter-spacing: .08em;
  flex-shrink: 0;
}

.mobile-section-name {
  font-family: var(--font-ui);
  font-size: .8rem;
  color: rgba(255,255,255,.55);
  flex: 1;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Sidebar close button (inside sidebar, mobile only) ─────── */
.btn-sidebar-close {
  position: absolute;
  top: .6rem;
  right: .6rem;
  background: rgba(255,255,255,.1);
  border: none;
  color: rgba(255,255,255,.7);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: background .14s;
}
.btn-sidebar-close:hover {
  background: rgba(255,255,255,.2);
  color: #fff;
}

/* ── Overlay ────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Large screens: sidebar always visible ──────────────────── */
@media (min-width: 992px) {
  .mobile-topbar { display: none !important; }
  .btn-sidebar-close { display: none !important; }
  .sidebar {
    transform: none !important;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
  }
  .main-content {
    margin-left: var(--sidebar-w);
    margin-top: 0;
  }
}

/* ── Small/medium screens: sidebar slides in ────────────────── */
@media (max-width: 991.98px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4,0,.2,1);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 260px;
    z-index: 200;
    overflow-y: auto;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(24,29,46,.35);
  }
  .main-content {
    margin-left: 0;
    margin-top: 52px; /* topbar height */
    padding: 1rem;
  }
  /* Prevent body scroll when sidebar open */
  body.sidebar-open { overflow: hidden; }
}

/* ── Extra small: tighter padding ──────────────────────────── */
@media (max-width: 575.98px) {
  .main-content { padding: .75rem; }
  .page-title { font-size: .95rem; }
  .stat-card { padding: .75rem; flex-direction: row; align-items: center; }
  .stat-val, .kpi-val { font-size: 1.35rem; }
  .pipeline-step { min-width: 90px; padding: .65rem .4rem; }
  .pipeline-val { font-size: 1.1rem; }
  .pipeline-lbl { font-size: .65rem; }
  .pipeline-arrow { display: none; } /* hide arrows, save space */
  .card-header { font-size: .78rem; padding: .55rem .85rem; }
}

/* ── Tables: always scroll horizontally ────────────────────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

/* ── Modals: full-screen on mobile ─────────────────────────── */
@media (max-width: 575.98px) {
  .modal-dialog {
    margin: 0;
    max-width: 100%;
    height: 100vh;
  }
  .modal-content {
    border-radius: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .modal-body { overflow-y: auto; flex: 1; }
  .modal-dialog.modal-lg,
  .modal-dialog.modal-xl { max-width: 100%; }
}

/* ── Grid columns responsive ────────────────────────────────── */
@media (max-width: 767.98px) {
  /* Force single-column on small screens for main grids */
  .row.g-3 > [class*="col-md"] { flex: 0 0 100%; max-width: 100%; }
  /* except col-6 which stays 2-up */
  .row.g-3 > .col-6 { flex: 0 0 50%; max-width: 50%; }
  /* KPI stat cards: 2 per row */
  .row.g-2 > [class*="col-md-3"] { flex: 0 0 50%; max-width: 50%; }
  /* Obra cards: 1 per row on phone */
  #obras-cards > [class*="col-md-4"] { flex: 0 0 100%; max-width: 100%; }
  /* Equipo cards: 2 per row on tablet, 1 on phone */
  #equipos-cards > [class*="col-md-3"] { flex: 0 0 50%; max-width: 50%; }
}
@media (max-width: 575.98px) {
  .row.g-2 > [class*="col-md-3"] { flex: 0 0 50%; max-width: 50%; }
  #equipos-cards > [class*="col-md-3"] { flex: 0 0 100%; max-width: 100%; }
}

/* ── Filter bars: stack vertically on mobile ────────────────── */
@media (max-width: 767.98px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control,
  .filter-bar .form-select,
  .filter-bar .btn { width: 100%; }
  .section-header { flex-direction: column; align-items: stretch; }
  .section-header .btn { width: 100%; margin-top: .25rem; }
}

/* ── CRM Pipeline: scroll on mobile ────────────────────────── */
@media (max-width: 767.98px) {
  .crm-pipeline {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: .5rem;
  }
  .pipeline-step { flex: 0 0 100px; }
}

/* ── Modal forms: single column on xs ──────────────────────── */
@media (max-width: 575.98px) {
  .modal-body .row > [class*="col-md"] { 
    flex: 0 0 100%; 
    max-width: 100%; 
  }
}

/* ── Bascula widget: stack on mobile ────────────────────────── */
@media (max-width: 767.98px) {
  .bascula-widget .row > .col-md-3,
  .bascula-widget .row > .col-md-4,
  .bascula-widget .row > .col-md-6 {
    flex: 0 0 100%;
    max-width: 100%;
    margin-bottom: .5rem;
  }
  .bascula-widget .peso-neto-display { font-size: 2rem; }
}

/* ── Login page (index.html) responsive ─────────────────────── */
.login-card {
  width: 100%;
  max-width: 400px;
  margin: auto;
}
@media (max-width: 575.98px) {
  .login-card { max-width: 100%; border-radius: 0; box-shadow: none; }
  body.login-body { background: #fff; }
}

/* ── Touch targets: minimum 44px ───────────────────────────── */
@media (max-width: 991.98px) {
  .btn { min-height: 38px; }
  .nav-link { min-height: 40px; }
  .form-control, .form-select { min-height: 40px; }
  .btn-xs { min-height: 32px; min-width: 32px; }
}

/* ── Print always desktop layout ───────────────────────────── */
@media print {
  .mobile-topbar, .btn-hamburger, .sidebar-overlay,
  .btn, #flashArea, .modal-backdrop { display: none !important; }
  .main-content { margin: 0 !important; padding: .5cm !important; }
  .sidebar { display: none !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd; }
}
