/* app.css — Calefaltec v2 — Unified Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── DESIGN TOKENS ─────────────────────────────────────── */
:root {
  /* Colors — unified with PWA */
  --primary:    #2563EB;
  --primary-dk: #1D4ED8;
  --primary-lt: #3B82F6;
  --primary-bg: #EFF6FF;
  --orange:     #F97316;
  --orange-bg:  #FFF7ED;
  --green:      #16A34A;
  --green-bg:   #F0FDF4;
  --red:        #DC2626;
  --red-bg:     #FEF2F2;
  --yellow:     #CA8A04;
  --yellow-bg:  #FEFCE8;
  --purple:     #7C3AED;
  --purple-bg:  #EDE9FE;

  /* Neutrals */
  --bg:         #F8FAFC;
  --white:      #FFFFFF;
  --border:     #E2E8F0;
  --border-lt:  #F1F5F9;
  --text:       #1E293B;
  --text2:      #475569;
  --text3:      #94A3B8;

  /* Layout */
  --sidebar:    220px;
  --topbar:     56px;

  /* Shape */
  --r:          8px;
  --r-lg:       12px;

  /* Shadows */
  --sh:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --sh-md:      0 4px 12px rgba(0,0,0,.10);
  --sh-lg:      0 10px 30px rgba(0,0,0,.12);

  /* F3.3 → Centralización tokens semánticos huérfanos */
  --color-background-primary:   var(--white);
  --color-background-secondary: var(--border-lt);
  --color-background-info:      var(--primary-bg);
  --color-border-primary:       var(--border);
  --color-border-secondary:     var(--border-lt);
  --color-text-primary:         var(--text);
  --color-text-secondary:       var(--text2);
  --color-text-tertiary:        var(--text3);
  --color-text-info:            var(--primary);
  --danger:                     var(--red);
  --bg-sec:                     var(--border-lt);
}

/* ── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar);
  background: var(--white); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 50; overflow-y: hidden;
  transition: width 0.2s ease, transform .25s cubic-bezier(.4,0,.2,1);
}
.main { transition: margin-left 0.2s ease; }
.sidebar-nav { flex: 1; overflow-y: auto; }
.sidebar-logo {
  display: flex; align-items: center;
  padding: 14px 14px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-logo-inner { flex: 1; min-width: 0; }

/* Sidebar collapse toggle button */
.sidebar-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg);
  cursor: pointer; color: var(--text3); font-size: 15px;
  flex-shrink: 0; margin-left: auto; transition: all .12s;
}
.sidebar-collapse-btn:hover { color: var(--text); background: var(--border); }

/* ── SIDEBAR COLLAPSED STATE ─────────────────────────────── */
body.sidebar-collapsed { --sidebar: 52px; }
body.sidebar-collapsed .sidebar-logo-inner .logo-sub { display: none; }
body.sidebar-collapsed .nav-group-label { height: 0; margin: 0; overflow: hidden; opacity: 0; }
body.sidebar-collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; white-space: nowrap; }
body.sidebar-collapsed .sb-views { display: none; }
body.sidebar-collapsed .gs-trigger span,
body.sidebar-collapsed .gs-trigger kbd { display: none; }
body.sidebar-collapsed .sidebar-user .user-name,
body.sidebar-collapsed .sidebar-user .user-role { display: none; }
body.sidebar-collapsed .sidebar-collapse-btn { margin-left: 0; }

/* Suppress transitions on initial load */
body.sidebar-no-transition .sidebar,
body.sidebar-no-transition .main { transition: none !important; }
.logo-badge {
  background: linear-gradient(135deg, #2563EB, #1D4ED8);
  color: white; font-weight: 800; font-size: 12.5px; padding: 7px 12px;
  border-radius: 7px; display: inline-block; letter-spacing: -.2px;
}
.logo-sub { font-size: 10px; color: var(--text3); margin-top: 3px; padding-left: 2px; }
.sidebar-company-logo { max-width: 100%; max-height: 60px; object-fit: contain; width: auto; height: auto; }

.nav-group { padding: 10px 8px 2px; }
.nav-group-label {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text3); padding: 0 8px; margin-bottom: 3px; display: block;
}
/* Secciones plegables del sidebar (hoy Ayuda): la cabecera es clicable y el cuerpo se oculta.
   Plegada por defecto — se abre solo si el usuario la dejó abierta. */
.nav-group-collapsible .nav-item { display: none; }
.nav-group-collapsible.open .nav-item { display: flex; }
.nav-group-toggle { cursor: pointer; display: flex !important; align-items: center; justify-content: space-between; user-select: none; }
.nav-group-toggle:hover { color: var(--text2); }
.nav-grp-caret { transition: transform .15s; opacity: .6; }
.nav-group-collapsible.open .nav-grp-caret { transform: rotate(180deg); }

.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--text2); cursor: pointer;
  transition: all .12s; margin-bottom: 1px; text-decoration: none;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.nav-item .ni { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item.disabled { opacity: .4; pointer-events: none; }
.nav-badge { margin-left: auto; background: #ef4444; color: white; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
/* ── Lucide icons — global contextual sizing ── */
i[data-lucide] { display: inline-block; flex-shrink: 0; stroke-width: 1.75; vertical-align: -3px; }
.tab-btn i[data-lucide], .stab i[data-lucide] { width: 15px; height: 15px; vertical-align: -3px; }
.btn i[data-lucide], button i[data-lucide], .topbar-btn i[data-lucide], .action-btn i[data-lucide], .action-menu-item i[data-lucide] { width: 15px; height: 15px; vertical-align: -3px; }
td i[data-lucide], .btn-sm i[data-lucide] { width: 13px; height: 13px; vertical-align: -2px; }
.btn-lg i[data-lucide] { width: 18px; height: 18px; vertical-align: -4px; }
h3 i[data-lucide], h4 i[data-lucide], .section-title i[data-lucide] { width: 16px; height: 16px; vertical-align: -3px; }

/* ── Mis Vistas sidebar section ── */
.sb-views {
  border-left: 2.5px solid #E8A020;
  margin: 6px 8px 4px;
  padding: 4px 0 2px;
}
.sb-views-title {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px;
  color: #9A7010; padding: 0 8px; margin-bottom: 3px; display: block;
}
.sb-view-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
  font-size: 12.5px; font-weight: 500; color: var(--text2);
  transition: background .12s; position: relative;
}
.sb-view-item:hover { background: var(--bg); color: var(--text); }
.sb-view-item > span:first-child { color: #E8A020; font-size: 11px; flex-shrink: 0; }
.sb-view-item > span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-view-del {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text3); font-size: 14px; line-height: 1; padding: 0 2px;
  border-radius: 3px; flex-shrink: 0;
}
.sb-view-del:hover { color: #dc2626; background: #fee2e2; }
.sb-view-item:hover .sb-view-del { display: block; }
.sb-views-add {
  font-size: 11.5px; color: #9A7010; cursor: pointer;
  padding: 4px 8px; border-radius: 5px; margin-top: 1px;
  transition: background .12s;
}
.sb-views-add:hover { background: #fef3c7; color: #78600a; }

.sidebar-user {
  padding: 10px 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 9px;
}
.user-av {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dk));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
}
.user-name { font-size: 12px; font-weight: 600; }
.user-role { font-size: 10.5px; color: var(--text3); }
.logout-btn {
  margin-left: auto; padding: 5px 9px; border: 1px solid var(--border);
  border-radius: 6px; background: none; font-size: 12px; color: var(--text3);
  cursor: pointer; transition: all .12s; min-height: 32px;
}
.logout-btn:hover { background: var(--red-bg); color: var(--red); border-color: #FCA5A5; }

/* ── SIDEBAR OVERLAY (mobile) ─────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 49; cursor: pointer;
}
.sidebar-overlay.open { display: block; }

/* ── HAMBURGER ────────────────────────────────────────── */
.hamburger {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border);
  background: none; font-size: 18px; cursor: pointer; color: var(--text2);
  flex-shrink: 0; transition: all .12s;
}
.hamburger:hover { background: var(--bg); }

/* ── LAYOUT ─────────────────────────────────────────────── */
.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; background: var(--white);
  border-bottom: 1px solid var(--border); padding: 0 22px;
  height: var(--topbar); display: flex; align-items: center; gap: 10px;
}
.topbar-title { font-size: 15px; font-weight: 700; color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.page { flex: 1; padding: 20px 22px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: var(--r); border: none; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s; white-space: nowrap;
  min-height: 38px; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(37,99,235,.25); }
.btn-primary:hover { background: var(--primary-dk); }
.btn-orange { background: var(--orange); color: white; box-shadow: 0 2px 8px rgba(249,115,22,.2); }
.btn-orange:hover { background: #EA6C0A; }
.btn-green { background: var(--green); color: white; box-shadow: 0 2px 8px rgba(22,163,74,.2); }
.btn-green:hover { background: #15803D; }
.btn-out { background: var(--white); color: var(--text2); border: 1px solid var(--border); }
.btn-out:hover { background: var(--bg); border-color: #CBD5E1; }
.btn-ghost { background: none; color: var(--text3); border: none; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 11px; font-size: 12px; min-height: 32px; }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid #FCA5A5; }
.btn-danger:hover { background: var(--red); color: white; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-full { width: 100%; justify-content: center; }

/* ── FAB (Floating Action Button, mobile only) ───────── */
.fab {
  display: none;
  position: fixed; bottom: 24px; right: 20px; z-index: 80;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: white;
  border: none; font-size: 26px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,.4);
  align-items: center; justify-content: center;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { background: var(--primary-dk); box-shadow: 0 6px 20px rgba(37,99,235,.5); }
.fab:active { transform: scale(.93); }

/* ── STATUS BADGES ───────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 12px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.b-gray   { background: #F1F5F9; color: #64748B; }
.b-blue   { background: var(--primary-bg); color: var(--primary); }
.b-green  { background: var(--green-bg); color: var(--green); }
.b-red    { background: var(--red-bg); color: var(--red); }
.b-orange { background: var(--orange-bg); color: var(--orange); }
.b-amber  { background: #FEF3C7; color: #B45309; }
.b-yellow { background: var(--yellow-bg); color: var(--yellow); }
.b-purple { background: var(--purple-bg); color: var(--purple); }

/* ── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh);
}
.card-pad { padding: 16px 18px; }

/* ── STAT PILLS ──────────────────────────────────────── */
.stat-row {
  display: flex; gap: 8px; overflow-x: auto; margin-bottom: 16px;
  padding-bottom: 2px; scrollbar-width: none;
}
.stat-row::-webkit-scrollbar { display: none; }
.stat-pill {
  flex-shrink: 0; background: var(--white); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 10px 16px; cursor: pointer; transition: all .15s;
  min-width: 120px;
}
.stat-pill:hover { border-color: var(--primary-lt); box-shadow: var(--sh); }
.stat-pill.active { border-color: var(--primary); background: var(--primary-bg); }
.stat-pill .sp-label { font-size: 11px; font-weight: 600; color: var(--text3); margin-bottom: 2px; }
.stat-pill .sp-count { font-size: 20px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-pill .sp-amt { font-size: 10.5px; color: var(--text3); margin-top: 2px; }
.stat-pill.active .sp-label,
.stat-pill.active .sp-amt { color: var(--primary); }
.stat-pill.active .sp-count { color: var(--primary); }

/* ── TABLE ───────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Tables with visible tfoot: scroll internally so tfoot stays pinned at bottom */
.tbl-wrap:has(tfoot:not(.tfoot-hidden)) {
  overflow: auto;
  max-height: calc(100vh - var(--topbar) - var(--tbl-above, 180px));
}
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 9px 12px; text-align: left; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; color: var(--text3);
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--white);
  position: sticky; top: 0; z-index: 3;
}
/* ── TFOOT STICKY ─────────────────────────────────────── */
tfoot:not(.tfoot-hidden) { position: sticky; bottom: 0; z-index: 3; }
tfoot td, tfoot th {
  background: var(--border-lt) !important;
  border-top: 1px solid var(--border);
  font-weight: 600; font-size: 12px; padding: 8px 12px;
}
.tfoot-hidden { display: none !important; }
tbody tr { border-bottom: 1px solid var(--border-lt); transition: background .1s; }
tbody tr:hover { background: #FAFBFF; cursor: pointer; }
tbody tr:nth-child(even) { background: #FAFBFC; }
tbody tr:nth-child(even):hover { background: #FAFBFF; }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 10px 12px; font-size: 13px; }
.td-muted { color: var(--text3); font-size: 12px; }

/* ── FILTERS ─────────────────────────────────────────── */
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r);
  font-size: 13px; outline: none; background: var(--white); color: var(--text);
  transition: border-color .15s; min-height: 38px;
}
.filter-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.filter-search { min-width: 200px; }

/* ── KPI GRID ────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--sh);
  transition: box-shadow .15s;
}
.kpi:hover { box-shadow: var(--sh-md); }
.kpi-icon { font-size: 22px; float: right; }
.kpi-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text3); margin-bottom: 6px;
}
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.5px; color: var(--text); }
.kpi-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── LOADING STATE ───────────────────────────────────── */
.loading-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  background: linear-gradient(90deg, var(--border-lt) 25%, #e8edf2 50%, var(--border-lt) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.4s infinite;
  border-radius: 4px; display: inline-block;
}
@keyframes skeleton { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── MODAL ───────────────────────────────────────────── */
/* z-index 700: por encima de panel detalle slide-in OT (600) — soluciona bug arqueológico
   latente desde 10/04/2026 (modal mini productPicker quedaba detrás del panel detalle OT
   en partes.html, fix 09/05/2026). Por debajo de dropdowns inline z-index:9000 (catPicker,
   admDd, prod-dd, etc.) que viven DENTRO de modales y deben superarlos. AI chat btn (900)
   y panel (750) son flotantes que coexisten con el modal sin tapar el área central. */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 700;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  overflow-y: auto; /* scroll the overlay when modal taller than viewport */
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white); border-radius: var(--r-lg); width: 100%;
  max-height: 85vh;
  display: flex; flex-direction: column; /* head/body/foot stack, body scrolls */
  box-shadow: var(--sh-lg);
  transform: translateY(8px); transition: transform .18s;
  flex-shrink: 0; /* don't let overlay flex crush the modal */
}
.overlay.open .modal { transform: translateY(0); }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 1;
  background: var(--white); border-radius: var(--r-lg) var(--r-lg) 0 0;
  flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border);
  background: none; cursor: pointer; font-size: 15px; color: var(--text3);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px; background: var(--bg);
  position: sticky; bottom: 0; z-index: 1;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  flex-shrink: 0;
}

/* ── FORM ────────────────────────────────────────────── */
.form-grid   { display: grid; grid-template-columns: 1fr 1fr;      gap: 10px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr;  gap: 10px; }
.form-1      { grid-template-columns: 1fr; }
.fg { display: flex; flex-direction: column; gap: 3px; }
.fg.full  { grid-column: 1/-1; }
.fg.span2 { grid-column: span 2; }
.fg label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text3);
}
.fc {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--r);
  font-size: 13px; color: var(--text); outline: none; background: var(--white);
  transition: border-color .15s; min-height: 34px;
}
.fc:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea.fc { resize: vertical; min-height: 60px; }
select.fc { appearance: none; -webkit-appearance: none; cursor: pointer; }

/* ── TOAST ───────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  padding: 12px 18px; border-radius: 10px; font-size: 13px;
  font-weight: 600; color: white; box-shadow: var(--sh-md);
  animation: tIn .2s ease; max-width: 320px;
}
@keyframes tIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

/* ── UTILS ───────────────────────────────────────────── */
.tr { text-align: right; }
.tc { text-align: center; }
.fw7 { font-weight: 700; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text3); }
.empty-state { text-align: center; padding: 52px 24px; color: var(--text3); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-size: 14px; font-weight: 700; color: var(--text2); margin-bottom: 6px; }
.hidden { display: none !important; }

/* ── SCROLLBAR ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── TABLET (≤1024px) ────────────────────────────────── */
@media(max-width:1024px) {
  :root { --sidebar: 200px; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
}

/* ── MOBILE (≤767px) ─────────────────────────────────── */
@media(max-width:767px) {
  /* Sidebar: slide-in drawer */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 50;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .main { margin-left: 0; }
  .hamburger { display: flex; }

  /* Topbar */
  .topbar { padding: 0 14px; gap: 8px; height: 52px; }
  .topbar-title { font-size: 14px; }
  .topbar-right { gap: 5px; }
  /* Hide text labels in topbar buttons, keep icons only via span.btn-label-hide */
  .btn-label-hide { display: none; }

  /* Buttons */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; padding: 6px 12px; }

  /* Inputs */
  .fc, .filter-input { min-height: 44px; font-size: 14px; }

  /* KPI */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 20px; }

  /* Filters */
  .filters { flex-direction: column; gap: 8px; }
  .filter-search { min-width: 0; width: 100%; }
  .filter-input { width: 100%; }

  /* Stat pills smaller */
  .stat-pill { min-width: 100px; padding: 8px 12px; }
  .stat-pill .sp-count { font-size: 17px; }

  /* Form */
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 0; max-height: 95vh; }
  .overlay .modal { border-radius: 16px 16px 0 0; }
  .modal-head { border-radius: 16px 16px 0 0; }
  .modal-foot { border-radius: 0; }

  /* Tables */
  tbody td { padding: 8px 10px; font-size: 12.5px; }
  thead th { padding: 7px 10px; }

  /* Page padding */
  .page { padding: 14px 14px; }

  /* Two-col dashboard */
  .two-col { grid-template-columns: 1fr !important; }

  /* FAB visible */
  .fab { display: flex; }

  /* Toast bottom safe area */
  .toast { bottom: 16px; right: 14px; left: 14px; max-width: none; text-align: center; }
}

/* ── HIGHLIGHT AFTER SAVE ────────────────────────────── */
.highlight-new {
  animation: highlightFade 2s ease-out;
}
@keyframes highlightFade {
  0%   { background-color: #fef9c3; }
  100% { background-color: transparent; }
}


/* ── SORT HEADERS ─────────────────────────────────────── */
/* Sub-Sprint Ajustes Stepper D — flechas más visibles + columna activa señalada. */
th[data-col] { cursor: pointer; user-select: none; transition: background-color .12s; }
th[data-col]:hover { background: var(--border-lt, #f1f5f9); }
.sort-arrow {
  margin-left: 4px; opacity: 0.55; font-size: 11px;
  color: var(--text2, #475569); font-weight: 600;
}
th.sort-active {
  background-color: #eff6ff !important;   /* fondo azul muy sutil */
  font-weight: 700;
  color: var(--primary, #2563eb);
  border-bottom: 2px solid var(--primary, #2563eb);
}
th.sort-active .sort-arrow {
  opacity: 1;
  color: var(--primary, #2563eb);
  font-size: 12px;
}

/* ── Remove number input spinners ── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance:none; margin:0; }
input[type=number] { -moz-appearance:textfield; }

/* ── PUNTO NUEVA VERSIÓN SIDEBAR ────────────────────── */
@keyframes clfVerPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.3); }
}
#clfVerDot {
  position: relative;
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22C55E;
  margin-left: 6px;
  vertical-align: middle;
  cursor: default;
  animation: clfVerPulse 2s ease-in-out infinite;
}
#clfVerDot::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 5px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 9999;
}
#clfVerDot:hover::after { opacity: 1; }

/* ── BOTÓN LIMPIAR FILTROS — estándar global ─────────── */
.clf-reset-btn {
  display: none;
  padding: 6px 14px;
  border: 1px solid #DC2626;
  border-radius: 999px;
  background: #fff;
  color: #DC2626;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  align-items: center;
  gap: 4px;
}
.clf-reset-btn.visible { display: inline-flex; }
.clf-reset-btn:hover { background: #FEF2F2; }

/* ── ICONS C4: badges dot + text color helpers ─────────────────────── */
.badge-dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:currentColor;margin-right:5px;vertical-align:1px;flex-shrink:0}
.text-green{color:#059669}
.text-amber{color:#d97706}
.text-red{color:#dc2626}

/* ── Leaflet: confinar stacking context para no tapar modales overlay ── */
.leaflet-container { z-index: 1; }

/* ── ICONS C5: Lucide dentro de pills ClfFilters ─────────────────── */
.clf2-pill i[data-lucide]{width:11px;height:11px;vertical-align:-1px;stroke-width:2;margin-right:3px}

/* ── ICONS C6: empty states Lucide ─────────────────────────────────── */
.empty-icon-lucide{width:48px;height:48px;color:var(--text3,#9ca3af);stroke-width:1.25;display:block;margin:0 auto 12px}

/* ── ICONS C7: tooltips / menús / doc-preview ──────────────────────── */
.tooltip-row i[data-lucide],.clf-tooltip i[data-lucide]{width:13px;height:13px;vertical-align:-2px;stroke-width:1.75;color:var(--text3,#9ca3af);margin-right:4px}
.context-menu-item i[data-lucide]{width:14px;height:14px;vertical-align:-3px;stroke-width:1.75;margin-right:6px}
.doc-preview-actions i[data-lucide]{width:15px;height:15px;vertical-align:-3px}

/* ══════════════════════ ASISTENTE IA ════════════════════════════════════ */
.ai-chat-btn{position:fixed;bottom:24px;right:88px;width:48px;height:48px;border-radius:50%;background:linear-gradient(135deg,#1a2e4a,#2d4a7a);color:white;border:none;cursor:pointer;box-shadow:0 4px 16px rgba(26,46,74,.4);z-index:900;display:flex;align-items:center;justify-content:center;transition:transform .2s,box-shadow .2s}
.ai-chat-btn:hover{transform:scale(1.08);box-shadow:0 6px 20px rgba(26,46,74,.5)}
.ai-chat-btn i[data-lucide]{width:22px;height:22px}

.ai-chat-panel{position:fixed;top:0;right:-440px;width:420px;max-width:100vw;height:100vh;background:var(--white);border-left:1px solid var(--border);box-shadow:-4px 0 20px rgba(0,0,0,.1);z-index:750;display:flex;flex-direction:column;transition:right .3s ease}
.ai-chat-panel.open{right:0}
.ai-chat-header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;background:linear-gradient(135deg,#1a2e4a,#2d4a7a);color:white;flex-shrink:0}
.ai-chat-title{display:flex;align-items:center;gap:8px;font-weight:600;font-size:15px}
.ai-chat-title i[data-lucide]{width:18px;height:18px}
.ai-chat-close{background:none;border:none;color:white;cursor:pointer;padding:4px;display:flex;align-items:center;justify-content:center;border-radius:6px;transition:background .15s}
.ai-chat-close:hover{background:rgba(255,255,255,.15)}
.ai-chat-close i[data-lucide]{width:20px;height:20px}

.ai-chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px;background:#fafbfc}
.ai-msg{max-width:88%}
.ai-msg-bot{align-self:flex-start}
.ai-msg-user{align-self:flex-end}
.ai-msg-content{padding:10px 14px;border-radius:12px;font-size:13px;line-height:1.5;word-wrap:break-word}
.ai-msg-bot .ai-msg-content{background:var(--white);color:var(--text);border:1px solid var(--border-lt);border-bottom-left-radius:4px}
.ai-msg-user .ai-msg-content{background:#1a2e4a;color:white;border-bottom-right-radius:4px}
.ai-msg-thinking .ai-msg-content{background:var(--white);color:var(--text3);font-style:italic;border:1px solid var(--border-lt)}
.ai-thinking-dots::after{content:'...';animation:aiDots 1.5s infinite}
@keyframes aiDots{0%,20%{content:'.'}40%{content:'..'}60%,100%{content:'...'}}

.ai-suggestions{padding:8px 12px;display:flex;flex-wrap:wrap;gap:6px;border-top:1px solid var(--border-lt);background:var(--white);flex-shrink:0}
.ai-suggestions button{font-size:11px;padding:5px 10px;border:1px solid var(--border);border-radius:14px;background:white;color:var(--text2);cursor:pointer;transition:all .15s;font-family:inherit}
.ai-suggestions button:hover{background:#1a2e4a;color:white;border-color:#1a2e4a}

.ai-chat-input{padding:12px 14px;border-top:1px solid var(--border);display:flex;gap:8px;align-items:flex-end;background:var(--white);flex-shrink:0}
.ai-chat-input textarea{flex:1;border:1px solid var(--border);border-radius:10px;padding:9px 12px;font-size:13px;resize:none;max-height:120px;outline:none;font-family:inherit;line-height:1.4}
.ai-chat-input textarea:focus{border-color:#1a2e4a}
.ai-chat-input button{background:#1a2e4a;color:white;border:none;width:38px;height:38px;border-radius:10px;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background .15s}
.ai-chat-input button:hover:not(:disabled){background:#2d4a7a}
.ai-chat-input button:disabled{opacity:.5;cursor:not-allowed}
.ai-chat-input button i[data-lucide]{width:16px;height:16px}

/* ── ClfRowKebab — dropdown kebab acciones por fila ──────── */
.clf-kebab-menu {
  position: fixed;
  z-index: 1000;
  min-width: 200px;
  background: var(--white, #fff);
  border: 1px solid var(--border, #E2E8F0);
  border-radius: var(--r, 8px);
  box-shadow: var(--sh-md, 0 4px 12px rgba(0,0,0,.10));
  padding: 4px 0;
  font-size: 13px;
}
.clf-kebab-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 14px;
  background: none; border: none;
  font-size: 13px; color: var(--text, #1E293B);
  cursor: pointer; text-align: left;
  transition: background .12s;
}
.clf-kebab-item:hover { background: var(--border-lt, #F1F5F9); }
.clf-kebab-item.danger { color: var(--red, #DC2626); }
.clf-kebab-item.danger:hover { background: var(--red-bg, #FEF2F2); }
.clf-kebab-item.primary { color: var(--primary, #2563EB); }
.clf-kebab-item.primary:hover { background: var(--primary-bg, #EFF6FF); }
.clf-kebab-item i[data-lucide],
.clf-kebab-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.clf-kebab-divider {
  border: none;
  border-top: 1px solid var(--border-lt, #F1F5F9);
  margin: 4px 0;
}

/* ─── Sprint STEPPER+FIX B3 — Stepper accionable OT ────────────────── */
.ot-stepper {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 6px 0;
  overflow-x: auto; overflow-y: visible;
  scrollbar-width: thin;
}
.ot-stepper::-webkit-scrollbar { height: 4px; }
.ot-stepper-actions { display: flex; gap: 4px; flex-shrink: 0; }
.ot-stepper-zone { display: flex; gap: 4px; flex-shrink: 0; align-items: center; }
.ot-stepper-divider { width: 1px; height: 28px; background: var(--border, #cbd5e1); margin: 0 4px; flex-shrink: 0; }
.step-action {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; font-size: 11px; font-weight: 500;
  border-radius: 6px; cursor: pointer;
  background: var(--surface, #fff); border: 1px solid var(--border, #cbd5e1);
  color: var(--text2, #475569);
  transition: background .12s, border-color .12s;
}
.step-action:hover { background: #f1f5f9; border-color: #94a3b8; }
/* Sprint Sub-Stepper A — especificidad reforzada (.ot-stepper .step) + bg explícito
   para vencer user-agent default de <button> (ButtonFace). Antes pasos superados
   se veían pálidos por background-color: ButtonFace pisando is-done. */
.ot-stepper .step {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 78px; min-height: 40px; padding: 4px 10px;
  font-size: 11px; font-weight: 500;
  border-radius: 6px; border: 1.5px solid;
  cursor: pointer; transition: background-color .12s, border-color .12s, color .12s;
  white-space: nowrap; line-height: 1.2;
  background-color: #fff;   /* Vincent 11/07 — pastillas con fondo blanco (pending); color solo en actual/hecho/terminal */
  color: #64748b; border-color: #cbd5e1;
  font-family: inherit;
  box-sizing: border-box;
}
.ot-stepper .step-action { min-height: 40px; box-sizing: border-box; }
.ot-stepper .step-label { font-size: 11px; }
.ot-stepper .step-date  { font-size: 9px; opacity: .75; margin-top: 1px; min-height: 11px; color:#64748b; }  /* gris uniforme del texto de fecha en TODOS los pasos/documentos (antes heredaba el color del estado: verde/ámbar/gris) */
.ot-stepper .step.is-pending  { background-color:#fff !important; color:#64748b !important; border-color:#cbd5e1 !important; cursor: default; }
.ot-stepper .step.is-current  { background-color:#fef3c7 !important; color:#a16207 !important; border-color:#fcd34d !important; box-shadow: 0 0 0 2px rgba(252,211,77,.25); }
.ot-stepper .step.is-done     { background-color:#dcfce7 !important; color:#15803d !important; border-color:#86efac !important; }
.ot-stepper .step.is-done:hover { background-color:#bbf7d0 !important; }
.ot-stepper .step.is-revising { border-style: dashed !important; }
.ot-stepper .step.is-cancelled { background-color:#fee2e2 !important; color:#991b1b !important; border-color:#fca5a5 !important; }
.ot-stepper .step.is-invoiced  { background-color:#ede9fe !important; color:#5b21b6 !important; border-color:#c4b5fd !important; cursor: default; }
.ot-stepper .step.is-invoiced .step-date a { color: #5b21b6; font-weight: 600; text-decoration: underline; }
@media (max-width: 768px) {
  .ot-stepper { padding: 4px 0; }
  .step { min-width: 64px; padding: 3px 6px; }
  .step-label { font-size: 10px; }
  .step-date  { font-size: 8px; }
}

/* ─── Sub-Sprint Arreglos 3 — Homogeneizar barra acciones con stepper ───
   Vincent: dimensiones de la línea 2 (Guardar / PDF / Email / WhatsApp / ...)
   deben igualar las del stepper (línea 1) para coherencia visual. Aplica
   solo a botones dentro de `.dp-actions-top` para no alterar el resto de
   la app que usa `.btn` / `.btn-sm` con sus dimensiones estándar. */
/* Layout de la fila de acciones — compartido OT + editor (antes solo en el <style> de partes.html,
   por eso el editor no lo heredaba y el indicador de guardado se veía como barra a todo el ancho). */
.dp-actions-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--border, #e2e8f0); background: var(--white, #fff); flex-shrink: 0; }
.dp-actions-top .btn,
.dp-actions-top .btn.btn-sm {
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  min-height: 40px;
  border-radius: 6px;
  gap: 5px;
}
/* Botones de la fila de acciones en blanco/outline (como los btn-out de la OT); Guardar (orange)
   y btn-primary conservan su relleno. El border-color inline de los botones de color gana. */
.dp-actions-top .btn:not(.btn-orange):not(.btn-primary) { background: var(--white, #fff); border: 1px solid var(--border, #e2e8f0); }
.dp-actions-top .btn:not(.btn-orange):not(.btn-primary):hover { background: var(--bg, #f9fafb); }
.dp-actions-top .btn i[data-lucide],
.dp-actions-top .btn.btn-sm i[data-lucide] {
  width: 13px; height: 13px;
}


/* ── PLACEHOLDERS (23/08/2026) — un ejemplo no puede vestir igual que un dato. El amigo
   de Vincent dio por rellenado el municipio porque «La Nucia» (placeholder) se pintaba
   como texto real. Cursiva + gris claro: el convenio universal de «esto es un ejemplo».
   opacity 1 porque Firefox atenua por opacidad y el color dejaria de mandar. ── */
::placeholder { color: #b3bfce; font-style: italic; opacity: 1; }
