/* ============================================================
   STYLES.CSS — Stech CotizaR · Design System "Navy & Clean"
   ============================================================ */

/* ── 1. DESIGN TOKENS ───────────────────────────────────────────────────────── */
:root {
  /* Paleta navy */
  --primary:       #1B2B4B;
  --primary-hover: #162340;
  --primary-light: #2563EB;
  --primary-600:   #1D4ED8;
  --primary-50:    #EFF6FF;
  --primary-100:   #DBEAFE;

  /* Semánticos */
  --secondary: #475569;
  --success:   #059669;
  --warning:   #D97706;
  --danger:    #DC2626;
  --info:      #0284C7;

  /* Superficies */
  --bg:        #F8FAFC;
  --surface:   #FFFFFF;
  --surface-2: #F1F5F9;
  --border:    #E2E8F0;
  --border-2:  #CBD5E1;

  /* Texto */
  --text:      #0F172A;
  --text-2:    #334155;
  --text-muted:#64748B;

  /* Tipografía */
  --font:      'Inter', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

  /* Espaciado */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;
  --sp-4: 1rem;     --sp-6: 1.5rem;   --sp-8: 2rem;

  /* Radios */
  --radius-sm:   4px;
  --radius:      8px;
  --radius-md:  10px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full:9999px;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow:    0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);

  /* Transiciones */
  --t-fast: 0.10s ease;
  --t-base: 0.18s ease;
  --t-slow: 0.28s cubic-bezier(0.4,0,0.2,1);

  /* Layout */
  --sidebar-w: 252px;
  --header-h:  64px;

  /* Z-index */
  --z-dropdown:  50;
  --z-sticky:    60;
  --z-modal:    100;
  --z-toast:    200;
  --z-tooltip:  300;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar estilizada */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

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

/* ── 4. SIDEBAR ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1B2B4B 0%, #162038 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: var(--z-modal);
  box-shadow: 4px 0 16px rgba(0,0,0,0.18);
  transition: width var(--t-slow);
  overflow: visible;
}

/* Toggle button */
.sidebar-toggle-btn {
  position: absolute;
  top: 72px;
  right: -14px;
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 800;
  z-index: 110;
  box-shadow: 0 2px 10px rgba(37,99,235,0.4);
  transition: background var(--t-base), transform var(--t-slow);
  padding: 0;
}
.sidebar-toggle-btn:hover { background: var(--primary-600); transform: scale(1.12); }

#sidebar-toggle-icon {
  display: inline-block;
  transition: transform var(--t-slow);
  font-style: normal;
  font-size: 0.55rem;
}

/* Logo area */
.sidebar-logo {
  padding: 1.375rem 1.125rem 1.125rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  transition: padding var(--t-slow);
}

.sidebar-logo h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.sidebar-logo .subtitle {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.5);
  margin-top: 3px;
  letter-spacing: 0.02em;
}

.sidebar-logo-mini {
  display: none;
  font-size: 1.5rem;
  text-align: center;
  width: 100%;
}

/* Nav */
#sidebar-nav {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.625rem 0.625rem;
  scrollbar-width: none;
}
#sidebar-nav::-webkit-scrollbar { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  transition: background var(--t-base), color var(--t-base);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.95);
}

.nav-item.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #60A5FA;
}

.nav-icon  { font-size: 1.05rem; min-width: 20px; text-align: center; flex-shrink: 0; }
.nav-label { font-size: 0.875rem; transition: opacity var(--t-base), width var(--t-slow); white-space: nowrap; }

/* Footer */
.sidebar-footer {
  padding: 0.875rem 1.125rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 0.7rem;
  color: rgba(255,255,255,0.3);
  overflow: hidden;
  white-space: nowrap;
  transition: padding var(--t-slow);
  letter-spacing: 0.03em;
}
.footer-mini { display: none; }

/* ── ESTADO COLAPSADO ───────────────────────────────────────────────────────── */
body.sidebar-collapsed .sidebar { width: 68px; }

body.sidebar-collapsed .sidebar-logo-full  { display: none; }
body.sidebar-collapsed .sidebar-logo-mini  { display: block; }
body.sidebar-collapsed .sidebar-logo       { padding: 1rem 0; text-align: center; }
body.sidebar-collapsed .nav-label          { opacity: 0; width: 0; overflow: hidden; }
body.sidebar-collapsed .footer-full        { display: none; }
body.sidebar-collapsed .footer-mini        { display: block; }
body.sidebar-collapsed .sidebar-footer     { text-align: center; padding: 0.75rem 0; }
body.sidebar-collapsed #sidebar-nav        { padding: 0.625rem 0.375rem; }

body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0.625rem 0;
  box-shadow: none;
}

body.sidebar-collapsed .nav-item.active {
  background: rgba(255,255,255,0.15);
  box-shadow: inset 3px 0 0 #60A5FA;
}

body.sidebar-collapsed .nav-icon { font-size: 1.25rem; }
body.sidebar-collapsed #sidebar-toggle-icon { transform: rotate(180deg); }

/* Tooltip colapsado */
body.sidebar-collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: var(--text);
  color: #F1F5F9;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
  box-shadow: var(--shadow-md);
  z-index: var(--z-tooltip);
}
body.sidebar-collapsed .nav-item::before {
  content: '';
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  border: 5px solid transparent;
  border-right-color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
  z-index: var(--z-tooltip);
}
body.sidebar-collapsed .nav-item:hover::after,
body.sidebar-collapsed .nav-item:hover::before {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ── 5. MAIN WRAPPER + TOPBAR ───────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--t-slow);
}
body.sidebar-collapsed .main-wrapper { margin-left: 68px; }

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  box-shadow: 0 1px 0 var(--border), 0 2px 12px rgba(0,0,0,0.04);
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.01em;
}
.topbar-right { display: flex; align-items: center; gap: 0.875rem; }

.topbar-year {
  background: var(--primary-50);
  color: var(--primary-light);
  padding: 0.25rem 0.875rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--primary-100);
  letter-spacing: 0.03em;
}

/* User Badge */
.user-badge {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0.3125rem 0.75rem 0.3125rem 0.3125rem;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: default;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-light), var(--primary-600));
  color: #fff;
  font-size: 0.6875rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.user-info {
  display: flex; flex-direction: column; line-height: 1.25;
}
.user-name { font-size: 0.8125rem; font-weight: 600; color: var(--text); }
.user-role { font-size: 0.6875rem; color: var(--text-muted); text-transform: capitalize; }

#main-content {
  flex: 1;
  padding: 1.75rem;
  max-width: 1420px;
  width: 100%;
}

/* ── 6. PAGE HEADER ─────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: var(--sp-6);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
}

.page-header h1 {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.page-header .subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.header-actions { display: flex; align-items: center; gap: 0.625rem; }
.page-header-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* ── 7. KPI CARDS ───────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(188px, 1fr));
  gap: 1rem;
  margin-bottom: var(--sp-6);
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.375rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-top: 4px solid transparent;
  transition: transform var(--t-base), box-shadow var(--t-base);
  text-align: left;
}

.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-card.primary { border-top-color: var(--primary-light); }
.kpi-card.success { border-top-color: var(--success); }
.kpi-card.warning { border-top-color: var(--warning); }
.kpi-card.danger  { border-top-color: var(--danger); }
.kpi-card.info    { border-top-color: var(--info); }

.kpi-icon  { font-size: 1.625rem; margin-bottom: 0.625rem; display: block; }
.kpi-value { font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1.15; letter-spacing: -0.025em; }
.kpi-label { font-size: 0.71875rem; color: var(--text-muted); margin-top: 0.25rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── 8. BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.125rem;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-base);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-xs);
}

.btn:hover  { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-xs); }
.btn:disabled, .btn[disabled] { opacity: 0.48; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-primary   { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #3D4F63; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #B91C1C; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #B45309; }

.btn-outline {
  background: var(--surface);
  color: var(--text-2);
  border: 1.5px solid var(--border-2);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
  border-color: var(--primary-light);
  color: var(--primary-light);
  background: var(--primary-50);
}

.btn-sm  { padding: 0.3125rem 0.8125rem; font-size: 0.8125rem; }
.btn-xs  { padding: 0.1875rem 0.5625rem; font-size: 0.75rem; }

/* ── 9. FORMS ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 0.375rem;
  letter-spacing: 0.01em;
}

.form-control {
  width: 100%;
  padding: 0.5625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  font-family: var(--font);
  transition: border-color var(--t-base), box-shadow var(--t-base);
  outline: none;
  line-height: 1.5;
}
.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-control:hover:not(:focus):not([readonly]):not(:disabled) {
  border-color: var(--border-2);
}
.form-control[readonly]  { background: var(--surface-2); color: var(--text-muted); cursor: default; }
.form-control:disabled   { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; opacity: 0.7; }
textarea.form-control    { resize: vertical; min-height: 80px; }
select.form-control      { cursor: pointer; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

@media (max-width: 768px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ── 10. FORM SECTIONS (cards) ──────────────────────────────────────────────── */
.form-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.form-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--primary-50);
  display: flex; align-items: center; gap: var(--sp-2);
  letter-spacing: -0.01em;
}

.form-section h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-2);
  margin: var(--sp-4) 0 var(--sp-3);
}

/* ── Utilidades de tarjeta ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
}
.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .875rem;
}
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }

/* ---- TABLES ---- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--surface);
}

.data-table thead th {
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

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

.data-table tbody tr:hover { background: rgba(37,99,235,0.03); }
.data-table tfoot td { padding: 0.75rem 1rem; border-top: 2px solid var(--border); }

.data-table.sm thead th, .data-table.sm tbody td { padding: 0.4rem 0.6rem; font-size: 0.8rem; }

.total-row { background: #f8fafc !important; font-weight: 600; }
.section-header-row { background: #eef2ff !important; }
/* Input con addon (ej: campo % con símbolo al final) */
.input-group { display: flex; gap: 0; }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); flex: 1; }
.input-addon {
  display: flex; align-items: center; justify-content: center;
  padding: 0 0.6rem;
  background: #f1f5f9; border: 1px solid #cbd5e1;
  border-left: none; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.85rem; color: #64748b; white-space: nowrap;
}

/* Encabezados de sección de costo (categorías (-) del P&L) */
tr.cost-section td {
  background: #fef2f2 !important;
  color: #991b1b;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  padding: 0.3rem 0.75rem;
}
.income-row { background: #ecfdf5 !important; }
.cost-row { }
.contrib-row { background: #fff7ed !important; font-weight: 600; }
.final-good { background: #ecfdf5 !important; font-weight: 700; color: var(--success); }
.final-medium { background: #fff7ed !important; font-weight: 700; color: var(--warning); }
.final-bad { background: #fef2f2 !important; font-weight: 700; color: var(--danger); }

/* ── 11. BADGES ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.71875rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-success   { background: #DCFCE7; color: #15803D; }
.badge-warning   { background: #FEF9C3; color: #854D0E; }
.badge-danger    { background: #FEE2E2; color: #B91C1C; }
.badge-info      { background: #E0F2FE; color: #0369A1; }
.badge-primary   { background: #EEF2FF; color: #3730A3; }
.badge-secondary { background: #F1F5F9; color: #475569; }

/* ── 12. WIZARD ─────────────────────────────────────────────────────────────── */
.wizard-steps {
  display: flex;
  align-items: center;
  margin-bottom: var(--sp-4);
  background: var(--surface);
  padding: 1.25rem 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
  overflow-x: auto;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  min-width: 100px;
  transition: all var(--t-base);
}

.wizard-step:hover .step-circle {
  border-color: var(--primary-light);
  color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}

.step-circle {
  width: 38px; height: 38px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  transition: all var(--t-base);
  box-shadow: var(--shadow-xs);
}

.wizard-step.active .step-circle {
  border-color: var(--primary-light);
  background: var(--primary-light);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.18);
}

.wizard-step.done .step-circle {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.step-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  text-align: center;
  white-space: nowrap;
  font-weight: 500;
}

.wizard-step.active .step-label { color: var(--primary-light); font-weight: 600; }
.wizard-step.done .step-label   { color: var(--success); }

.step-connector {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--border-2), var(--border));
  min-width: 20px;
  margin-bottom: 1.125rem; /* alinear con centro del círculo */
}

.wizard-step.done + .step-connector { background: var(--success); }

.wizard-body { margin-bottom: var(--sp-4); }

.wizard-nav {
  display: flex;
  justify-content: space-between;
  padding: var(--sp-4) 0;
}

/* ---- SERVICIO CARD ---- */
.servicio-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.servicio-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.servicio-num { font-weight: 700; color: var(--primary); }
.servicio-header .btn { margin-left: auto; }

.servicio-resultados {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5rem;
}

.result-item {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border-radius: 4px;
  font-size: 0.85rem;
}

.result-item.highlight {
  background: #e0e7ff;
  font-weight: 600;
}

.result-item span { color: var(--text-muted); }
.result-item strong { color: var(--text); }

/* ---- RESUMEN ECONÓMICO ---- */
.resumen-header {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.resumen-kpi {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  text-align: center;
  min-width: 150px;
  border: 2px solid var(--border);
}

.resumen-kpi.good { border-color: var(--success); background: #ecfdf5; }
.resumen-kpi.medium { border-color: var(--warning); background: #fffbeb; }
.resumen-kpi.bad { border-color: var(--danger); background: #fef2f2; }

.resumen-table { font-size: 0.83rem; }
.resumen-table td { padding: 0.5rem 0.75rem; }
.text-right { text-align: right; }

/* ---- SALARIAL ---- */
.sal-resultado { margin-top: 1rem; }
.sal-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.sal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-light);
}

.sal-card h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.highlight-card { border-left-color: var(--success); background: #f0fdf4; }

/* ---- CHARTS ---- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.chart-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
}

/* ── 13. MODALS ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 1rem;
  animation: fadeIn var(--t-slow) ease forwards;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp var(--t-slow) ease forwards;
}

.modal-lg { max-width: 960px; }
.modal-sm { max-width: 480px; }

@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-header h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.01em;
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--t-base);
  flex-shrink: 0;
}

.modal-close:hover { background: var(--danger); color: #fff; }

.modal-body { padding: var(--sp-6); }

.modal-footer {
  padding: 1rem var(--sp-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ── 14. EMPTY STATE ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  color: var(--text-muted);
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
}

.empty-state.small { padding: 2rem 1rem; }

.empty-icon { font-size: 3rem; margin-bottom: var(--sp-4); opacity: 0.4; display: block; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-2); margin-bottom: 0.4rem; }
.empty-state p  { font-size: 0.875rem; margin-bottom: var(--sp-4); max-width: 360px; line-height: 1.6; }

/* ---- SECTION TOOLBAR ---- */
.section-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.5rem 0 1rem;
}

.section-header h2 { font-size: 1.1rem; font-weight: 700; color: var(--primary); }

/* ---- INNER TABS ---- */
.tabs-inner {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab-inner {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.tab-inner.active {
  background: var(--primary-light);
  color: #fff;
  border-color: var(--primary-light);
}

.inner-tab-content { animation: fadeIn 0.15s; }

/* ---- COMERCIALES ---- */
.comercial-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.comercial-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--primary-light);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  flex-shrink: 0;
}

.comercial-info { flex: 1; }
.comercial-info h4 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.2rem; }
.comercial-info p { font-size: 0.8rem; color: var(--text-muted); }
.comercial-actions { display: flex; gap: 0.5rem; }

/* ---- MAPA ---- */
.mapa-filtros {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.mapa-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.mapa-summary .kpi-card {
  flex: 1;
  min-width: 150px;
  padding: 1rem;
}

.mapa-table { font-size: 0.78em; }
.mapa-table thead th { padding: 0.5rem 0.6rem; }
.mapa-table tbody td { padding: 0.4rem 0.6rem; }

/* ── 16. UTILITIES ──────────────────────────────────────────────────────────── */
/* Texto */
.text-xs    { font-size: 0.75rem; }
.text-sm    { font-size: 0.875rem; }
.text-base  { font-size: 0.9375rem; }
.text-lg    { font-size: 1.125rem; }
.text-xl    { font-size: 1.25rem; }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-info    { color: var(--info); }
.text-primary { color: var(--primary-light); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-left    { text-align: left; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

/* Espaciado */
.mt-1 { margin-top: var(--sp-1); }  .mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }  .mt-4 { margin-top: var(--sp-4); }
.mb-1 { margin-bottom: var(--sp-1); } .mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); }
.gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.d-flex { display: flex; } .align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--primary-light);
  border: 1px solid var(--border);
}

/* ---- TABLA EDITABLE DE MODALIDADES ---- */
.modalidades-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.modalidades-header h3 {
  border-bottom: none;
  margin-bottom: 0.25rem;
  padding-bottom: 0;
}

.mod-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 560px;
  line-height: 1.5;
}

.modalidades-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  align-items: flex-start;
}

/* Tabla de modalidades: inputs dentro de celdas */
.modalidades-table { font-size: 0.82rem; }

.modalidades-table thead th {
  background: #1e3a5f;
  color: #fff;
  padding: 0.6rem 0.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

.modalidades-table tbody td {
  padding: 0.3rem 0.35rem;
  vertical-align: middle;
  border-bottom: 1px solid #e2e8f0;
}

.mod-row:hover { background: #f8faff; }

.mod-input {
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  border-radius: 5px;
  height: 34px;
}

/* Resaltar filas con salario propio */
.mod-row:has(input[id^="mod-salario-"]:not([value="0"])) {
  background: #f0fff4;
}

/* Barra de guardado */
.mod-save-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding-top: 1rem;
  margin-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.mod-status-msg {
  font-size: 0.82rem;
  font-weight: 500;
  min-width: 220px;
  text-align: right;
}

.mod-status-ok { color: var(--success); }
.mod-status-pending { color: var(--warning); }

/* Tooltip visual en encabezado */
.modalidades-table thead th[title] { cursor: help; text-decoration: underline dotted rgba(255,255,255,0.5); }

/* ---- GRID FORMULARIO SERVICIO ---- */
.srv-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

/* Campos de solo lectura (horas autocalculadas) */
.form-control.srv-readonly {
  background: #f1f5f9;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: default;
  border-color: #e2e8f0;
}

/* Fila AyS informativa */
.srv-ays-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}

.srv-ays-label { font-weight: 600; color: var(--text); }
.srv-ays-hint  { color: var(--text-muted); font-style: italic; font-size: 0.78rem; }

/* ---- TABLA DE COSTOS POR LÍNEA ---- */
.srv-costos-tabla {
  overflow-x: auto;
}

.srv-costos-head,
.srv-costos-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  min-width: 900px;
}

.srv-costos-head {
  background: #1e3a5f;
  border-radius: 6px 6px 0 0;
}

.srv-costos-head span {
  padding: 0.45rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  border-right: 1px solid rgba(255,255,255,0.12);
}

.srv-costos-head span:last-child { border-right: none; }

.srv-costos-row {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 6px 6px;
}

.srv-costos-row span {
  padding: 0.55rem 0.6rem;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  border-right: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.srv-costos-row span:last-child { border-right: none; }

.srv-costos-row .val-muted   { color: #94a3b8; font-style: italic; font-weight: 400; }
.srv-costos-row .val-seguro  { color: #15803d; }
.srv-costos-row .val-subtotal { background: #eff6ff; color: #1d4ed8; }
.srv-costos-row .val-aiu     { background: #fffbeb; color: #b45309; }
.srv-costos-row .val-iva     { background: #fef3c7; color: #92400e; }
.srv-costos-row .val-siniva  { background: #f0fdf4; color: #166534; font-weight: 700; }
.srv-costos-row .val-coniva  {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #064e3b;
  font-weight: 800;
  font-size: 0.9rem;
}

/* ---- RESUMEN HORAS DE TURNO ---- */
.turno-horas-resumen {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

.turno-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.turno-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
}

.turno-tag strong { font-weight: 700; }

.turno-total  { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.turno-dia    { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.turno-noche  { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.turno-legal  { background: #f0fdf4; color: #166534; border: 1px solid #86efac; font-style: italic; }

/* ---- SEGURO DE VIDA — CONFIGURACIÓN ---- */
.seguro-config-box {
  background: #f8faff;
  border: 1px solid #dbeafe;
  border-radius: var(--radius);
  padding: 1.25rem;
}

.seguro-toggle-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.seguro-toggle-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

/* Botón toggle pill */
.seguro-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem 0.4rem 0.4rem;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  background: #e2e8f0;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  letter-spacing: 0.04em;
  min-width: 150px;
}

.seguro-toggle.activo {
  background: #d1fae5;
  border-color: var(--success);
  color: #065f46;
}

.seguro-toggle-knob {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #94a3b8;
  transition: background 0.2s;
  flex-shrink: 0;
}

.seguro-toggle.activo .seguro-toggle-knob {
  background: var(--success);
}

.seguro-valor-row {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.seguro-info {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
  color: #78350f;
  max-width: 380px;
  line-height: 1.4;
  margin-top: 1.5rem;
}

/* Celda prima en desglose de precio por línea */
.precio-linea-item.seguro-vida {
  background: #f0fdf4;
  border-left: 3px solid var(--success);
}

.precio-linea-item.seguro-vida span { color: #166534; }
.precio-linea-item.seguro-vida strong { color: #15803d; }

.precio-linea-item.seguro-vida.sin-seguro {
  background: #f8fafc;
  border-left: 3px solid #cbd5e1;
}

.precio-linea-item.seguro-vida.sin-seguro span { color: var(--text-muted); }
.precio-linea-item.seguro-vida.sin-seguro strong {
  color: #94a3b8;
  font-style: italic;
  font-weight: 500;
}

/* ---- TARIFA BANNER (Circular Supervigilancia) ---- */
.tarifa-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tarifa-banner-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tarifa-banner-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.tarifa-banner-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tarifa-banner-sub {
  font-size: 0.78rem;
  opacity: 0.82;
  margin-top: 2px;
}

.tarifa-banner-right {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.tarifa-banner-right .form-control {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  font-weight: 600;
  font-size: 0.82rem;
}

.tarifa-banner-right .form-control option {
  background: #1e3a5f;
  color: #fff;
}

/* ---- PRECIO POR LÍNEA (desglose tarifa mínima por servicio) ---- */
.precio-linea {
  background: #f8faff;
  border: 1px solid #dbeafe;
  border-radius: 6px;
  margin-top: 0.75rem;
  overflow: hidden;
}

.precio-linea-titulo {
  background: #eff6ff;
  border-bottom: 1px solid #dbeafe;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e40af;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.precio-linea-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0;
}

.precio-linea-item {
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.75rem;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  gap: 2px;
}

.precio-linea-item:last-child {
  border-right: none;
}

.precio-linea-item span {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.precio-linea-item strong {
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 700;
}

/* Variantes de precio-linea-item */
.precio-linea-item.resaltado {
  background: #eff6ff;
}

.precio-linea-item.resaltado strong {
  color: #2563eb;
}

.precio-linea-item.resaltado-fuerte {
  background: #dbeafe;
}

.precio-linea-item.resaltado-fuerte strong {
  color: #1d4ed8;
  font-size: 0.95rem;
}

.precio-linea-item.aiu {
  background: #fffbeb;
  border-left: 3px solid var(--warning);
}

.precio-linea-item.aiu span {
  color: #92400e;
}

.precio-linea-item.aiu strong {
  color: #b45309;
  font-size: 0.9rem;
}

.precio-linea-item.separador {
  background: #f1f5f9;
  border-left: 3px solid var(--secondary);
}

.precio-linea-item.separador strong {
  color: var(--secondary);
  font-size: 1rem;
}

.precio-linea-item.total-linea {
  background: #ecfdf5;
}

.precio-linea-item.total-linea strong {
  color: #059669;
  font-size: 0.9rem;
}

.precio-linea-item.total-linea-final {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  grid-column: span 2;
}

.precio-linea-item.total-linea-final span {
  color: #065f46;
  font-size: 0.78rem;
}

.precio-linea-item.total-linea-final strong {
  color: #064e3b;
  font-size: 1.05rem;
  font-weight: 800;
}

/* ---- BARRA TOTAL DE SERVICIOS ---- */
.total-servicios-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  background: var(--primary);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 1rem;
  box-shadow: var(--shadow-md);
}

.total-servicios-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 1.1rem;
  flex: 1;
  min-width: 160px;
  border-right: 1px solid rgba(255,255,255,0.12);
}

.total-servicios-item:last-child { border-right: none; }

.ts-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.72);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.ts-value {
  font-size: 0.95rem;
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
}

.total-servicios-item.highlight-total {
  background: rgba(16, 185, 129, 0.22);
  border-left: 3px solid var(--success);
}

.total-servicios-item.highlight-total .ts-label {
  color: #a7f3d0;
}

.ts-grande {
  font-size: 1.05rem;
  color: #6ee7b7;
  font-weight: 800;
}

/* ---- INDICADOR AUTO-GUARDADO ---- */
.autosave-indicator {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
  flex: 1;
  text-align: center;
  pointer-events: none;
}

.autosave-indicator.visible {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   SERVICIOS COMPUESTOS — Tramos
   ═══════════════════════════════════════════════════════════════ */

/* Tarjeta de servicio compuesto: borde izquierdo dorado */
.servicio-card.servicio-compuesto {
  border-left: 4px solid #f59e0b;
}

/* Botón extra-pequeño para acciones dentro de tramos */
.btn-xs {
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.4;
}
.btn-xs.btn-danger  { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.btn-xs.btn-secondary { background: #e2e8f0; color: #475569; border-color: #cbd5e1; }
.btn-xs.btn-warning { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

/* Contenedor de todos los tramos de una línea compuesta */
.tramos-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0.75rem 0;
}

/* Tarjeta individual de tramo */
.tramo-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #6366f1;
  border-radius: 8px;
  padding: 0.85rem 1rem;
}

.tramo-card:nth-child(2) { border-left-color: #f59e0b; }
.tramo-card:nth-child(3) { border-left-color: #10b981; }
.tramo-card:nth-child(4) { border-left-color: #ec4899; }

/* Encabezado del tramo */
.tramo-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.tramo-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: #334155;
  flex: 1 1 auto;
}

/* Grid de campos del tramo (reutiliza srv-form-grid pero más compacto) */
.tramo-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}

/* Tabla de costos dentro del tramo */
.tramo-costos {
  margin-top: 0.65rem;
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.78rem;
  border: 1px solid #e2e8f0;
}

/* Cabecera de la tabla de costos del tramo */
.tramo-costos .srv-costos-head {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  gap: 0.25rem;
  font-size: 0.72rem;
  text-align: right;
}
.tramo-costos .srv-costos-head span:first-child { text-align: left; }

/* Fila de valores del tramo */
.tramo-costos-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  padding: 0.35rem 0.6rem;
  gap: 0.25rem;
  background: #fff;
  font-size: 0.76rem;
  text-align: right;
  border-top: 1px solid #e2e8f0;
}
.tramo-costos-row span:first-child { text-align: left; }

/* ═══════════════════════════════════════════════════════════════
   RESUMEN DE SERVICIOS — Tabla exportable
   ═══════════════════════════════════════════════════════════════ */

.resumen-servicios-section {
  margin-top: 2rem;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #1e3a5f;
  background: #fff;
  box-shadow: 0 4px 24px rgba(30,58,95,0.10);
}

/* Cabecera de la sección */
.rs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5986 100%);
  flex-wrap: wrap;
}

.rs-titulo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rs-icono { font-size: 1.6rem; }

.rs-titulo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}

.rs-titulo-sub {
  font-size: 0.78rem;
  color: #93c5fd;
  margin-top: 2px;
}

/* Botones exportar */
.rs-acciones { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.btn-refresh-resumen {
  background: #0ea5e9;
  color: #fff;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-refresh-resumen:hover { background: #0284c7; }

.btn-export-excel {
  background: #16a34a;
  color: #fff;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-export-excel:hover { background: #15803d; }

.btn-export-pdf {
  background: #dc2626;
  color: #fff;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-export-pdf:hover { background: #b91c1c; }

/* Scroll horizontal para tabla ancha */
.rs-tabla-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Tabla principal */
.rs-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
  white-space: nowrap;
  min-width: 1400px;
}

/* Cabeceras de grupo (primera fila de thead) */
.rs-head-grupo th {
  background: #1e3a5f;
  color: #e0f2fe;
  padding: 6px 8px;
  text-align: center;
  border: 1px solid #2d5986;
  font-size: 0.72rem;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Grupo "horas turno" */
.rs-th-grupo-horas { background: #0f4c81 !important; color: #bae6fd !important; }
/* Grupo "costo unitario" */
.rs-th-grupo-costos { background: #065f46 !important; color: #a7f3d0 !important; }
/* Grupo "IVA sobre AIU" */
.rs-th-grupo-iva { background: #78350f !important; color: #fde68a !important; }
/* Grupo "total mensual" */
.rs-th-grupo-total { background: #1e1b4b !important; color: #c7d2fe !important; }

/* Sub-cabeceras (segunda fila de thead) */
.rs-head-sub th {
  background: #334155;
  color: #e2e8f0;
  padding: 5px 7px;
  text-align: center;
  border: 1px solid #475569;
  font-size: 0.70rem;
  font-weight: 600;
}

/* Celdas de datos */
.rs-tabla td {
  padding: 5px 8px;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  vertical-align: middle;
  white-space: nowrap;
}

/* Filas alternas */
.rs-tabla tbody tr:nth-child(even) td { background: #f8fafc; }
.rs-tabla tbody tr:nth-child(odd)  td { background: #fff; }

/* Fila de línea simple */
.rs-linea td { font-weight: 500; }

/* Fila de sub-tramo: ligeramente sangrada y más suave */
.rs-subtramo td {
  background: #eff6ff !important;
  color: #334155;
  font-size: 0.74rem;
  padding-left: 14px;
}

/* Columna línea */
.rs-td-linea  { text-align: center; font-weight: 700; color: #1e3a5f; min-width: 40px; }
/* Números */
.rs-td-num    { text-align: right; font-variant-numeric: tabular-nums; }
/* Centr */
.rs-td-center { text-align: center; }
/* Texto largo */
.rs-td-ubicacion { max-width: 180px; white-space: normal; word-break: break-word; }
/* Modalidad pequeña */
.rs-td-small  { font-size: 0.70rem; }
/* Precio unitario x puesto */
.rs-td-sub    { background: #f0fdf4 !important; font-weight: 600; }
/* Sin IVA */
.rs-td-siniva { background: #fefce8 !important; font-weight: 600; }
/* Con IVA */
.rs-td-coniva { background: #eff6ff !important; color: #1e40af; }
/* Total contrato */
.rs-td-contrato { background: #ecfdf5 !important; color: #065f46; font-weight: 700; }

/* Badge sector residencial / PH */
.badge-residencial {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Badge tramo dentro de celda */
.rs-badge-tramo {
  display: inline-block;
  font-size: 0.65rem;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 4px;
  padding: 1px 5px;
  margin-top: 2px;
  font-weight: 500;
}

/* Badges de tipo de medio */
.rs-badge-medio {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.70rem;
  font-weight: 600;
}
.rs-medio-sin_arma  { background: #dbeafe; color: #1d4ed8; }
.rs-medio-con_arma  { background: #fee2e2; color: #b91c1c; }
.rs-medio-con_canino { background: #fef9c3; color: #92400e; }

/* Fila de totales en tfoot */
.rs-total-row td {
  background: #1e3a5f !important;
  color: #fff !important;
  font-weight: 700;
  font-size: 0.80rem;
  border-color: #2d5986;
}
.rs-total-label { text-align: right; font-size: 0.82rem; letter-spacing: 0.05em; }
.rs-total-row .rs-td-siniva   { background: #fbbf24 !important; color: #1e293b !important; }
.rs-total-row .rs-td-coniva   { background: #3b82f6 !important; color: #fff    !important; }
.rs-total-row .rs-td-contrato { background: #10b981 !important; color: #fff    !important; }

/* KPIs debajo de la tabla */
.rs-kpis {
  display: flex;
  gap: 0;
  border-top: 2px solid #e2e8f0;
}

.rs-kpi {
  flex: 1;
  padding: 0.85rem 1rem;
  text-align: center;
  border-right: 1px solid #e2e8f0;
}
.rs-kpi:last-child { border-right: none; }

.rs-kpi-label {
  font-size: 0.70rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 4px;
}

.rs-kpi-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
}

.rs-kpi-iva .rs-kpi-value,
.rs-kpi-value.rs-kpi-iva  { color: #92400e; }

.rs-kpi-highlight {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
}
.rs-kpi-highlight .rs-kpi-value { color: #1e40af; font-size: 1.15rem; }

.rs-kpi-contrato { color: #065f46 !important; }

/* ====================================================
   DETALLE NÓMINA & PRESTACIONES (por servicio)
   ==================================================== */

/* Barra del toggle */
.nomina-toggle-bar {
  border-top: 1px dashed #cbd5e1;
  padding: 0.5rem 1rem;
  background: #f8fafc;
  border-radius: 0 0 10px 10px;
  text-align: left;
}

.btn-nomina-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.9rem;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-nomina-toggle:hover { background: #dbeafe; }

/* Panel detalle nómina */
.nomina-detalle-panel {
  border-top: 2px solid #2563eb;
  background: #f8fafc;
  padding: 1rem;
}

.nomina-detalle-wrap { display: flex; flex-direction: column; gap: 1rem; }

/* Grid 4 bloques */
.nomina-det-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}
@media (max-width: 1100px) { .nomina-det-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .nomina-det-grid { grid-template-columns: 1fr; } }

.nomina-bloque {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.nomina-bloque-title {
  background: #1e293b;
  color: #fff;
  font-size: 0.73rem;
  font-weight: 700;
  padding: 0.38rem 0.75rem;
  letter-spacing: 0.04em;
}

.nomina-tabla { width: 100%; border-collapse: collapse; font-size: 0.77rem; }
.nomina-tabla td {
  padding: 0.28rem 0.6rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}
.nomina-tabla tr:last-child td { border-bottom: none; }

.nd-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
}
.nd-bono      { color: #7c3aed; }
.nd-sub       { color: #16a34a; }
.nd-ded       { color: #dc2626; }
.nd-na        { color: #94a3b8; font-size: 0.7rem; font-style: italic; }
.nd-na-inline { color: #94a3b8; font-size: 0.72rem; font-style: italic; text-align: right; }

/* Badge de exoneración Ley 1607/2012 (ICBF, SENA, salud empleador) */
.nd-exo {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.05rem 0.35rem;
  margin-left: 0.3rem;
  vertical-align: middle;
  white-space: nowrap;
}
/* Aviso en el header del bloque parafiscales */
.nd-exo-header {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: #92400e;
  background: #fef9c3;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  margin-top: 0.25rem;
}
/* Nota al pie del módulo Cálculo Salarial */
.sal-exo-nota {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  color: #92400e;
  background: #fef9c3;
  border-left: 3px solid #fcd34d;
  padding: 0.3rem 0.6rem;
  border-radius: 0 4px 4px 0;
}
.nd-rule      { font-size: 0.65rem; color: #94a3b8; font-weight: 400;
                background: #f1f5f9; padding: 0.1rem 0.35rem;
                border-radius: 3px; margin-left: 0.3rem; }
.nd-subtotal td { background: #f1f5f9; border-top: 1px solid #cbd5e1; }
.nd-neto-val   { color: #16a34a !important; font-size: 0.84rem !important; }

/* ── Dotación con selectividad por ítem (Paso 3) ─────────── */

/* Checkbox integrado en la celda de nombre */
.dot-item-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin: 0;
  font-weight: normal;
}

/* Fila desmarcada — atenuada visualmente */
tr.dot-item-off td {
  opacity: 0.38;
  color: var(--text-muted);
}

/* Inputs de la tabla "Otros" — evitar desbordamiento */
#dot-otros-tabla input.form-control.sm {
  min-width: 0;
}

/* Banner de total dotación en Paso 3 */
.dot-total-banner {
  margin-top: 1rem;
  padding: 0.75rem 1.2rem;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #93c5fd;
  border-left: 4px solid #2563eb;
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: #1e3a5f;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: center;
}

/* Barra resumen costo laboral */
.nomina-resumen-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: #1e293b;
  border-radius: 8px;
  padding: 0.55rem 1rem;
}

.nomina-res-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
  padding: 0.28rem 0.65rem;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
}

.nomina-res-label {
  font-size: 0.65rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.nomina-res-val {
  font-size: 0.86rem;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
}

.nomina-res-sep { font-size: 1rem; color: #64748b; padding: 0 0.2rem; }

.nomina-res-puesto .nomina-res-val { color: #60a5fa; font-size: 0.93rem; }
.nomina-res-tarifa .nomina-res-val { color: #4ade80; }

.nomina-res-ok    { background: rgba(22,163,74,0.18); }
.nomina-res-warn  { background: rgba(217,119,6,0.20); }
.nomina-res-alert { background: rgba(220,38,38,0.22); }
.nomina-res-ok    .nomina-res-val { color: #4ade80 !important; }
.nomina-res-warn  .nomina-res-val { color: #fbbf24 !important; }
.nomina-res-alert .nomina-res-val { color: #f87171 !important; }

/* ====================================================
   HOJA COMPARATIVA — Costos Laborales vs Tarifa
   ==================================================== */

.comp-tarifas-section {
  margin-top: 1.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Header */
.comp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.comp-titulo   { font-size: 0.97rem; font-weight: 700; color: #f1f5f9; }
.comp-subtitulo { font-size: 0.73rem; color: #94a3b8; margin-top: 0.12rem; }

.comp-acciones { display: flex; gap: 0.5rem; }

.btn-export-comp {
  padding: 0.35rem 0.85rem;
  border: none; border-radius: 5px;
  font-size: 0.77rem; font-weight: 600;
  cursor: pointer;
  background: #16a34a; color: #fff;
  transition: background 0.15s;
}
.btn-export-comp:hover { background: #15803d; }
.btn-comp-pdf          { background: #0ea5e9; }
.btn-comp-pdf:hover    { background: #0284c7; }

/* Tabla comparativa */
.comp-tabla-scroll { overflow-x: auto; }

.comp-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.77rem;
}

/* Headers grupos */
.comp-head-grupo-row th {
  padding: 0.42rem 0.55rem;
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.comp-th-srv  { background: #1e293b; color: #f1f5f9; text-align: left; min-width: 170px; }
.comp-th-num  { background: #1e293b; color: #94a3b8; text-align: center; width: 46px; }
.comp-th-bar  { background: #1e293b; color: #94a3b8; min-width: 130px; }

.comp-grp-nomina  { background: #1e40af; color: #dbeafe; }
.comp-grp-tarifa  { background: #065f46; color: #d1fae5; }
.comp-grp-analisis{ background: #7c2d12; color: #fed7aa; }

/* Sub-headers */
.comp-head-sub-row th {
  padding: 0.38rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.3;
  background: #334155;
  color: #e2e8f0;
  text-align: right;
}

/* Filas datos */
.comp-row {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}
.comp-row:hover       { background: #f8fafc; }
.comp-row-alert       { background: #fef2f2; }
.comp-row-alert:hover { background: #fee2e2; }
.comp-row-warn        { background: #fffbeb; }
.comp-row-warn:hover  { background: #fef3c7; }

.comp-td-srv { padding: 0.48rem 0.75rem; vertical-align: top; }

.comp-srv-nombre {
  font-weight: 600;
  color: #0f172a;
  font-size: 0.77rem;
  line-height: 1.3;
}

.comp-srv-nota {
  display: inline-block;
  margin-top: 0.18rem;
  font-size: 0.66rem;
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.08rem 0.38rem;
  border-radius: 3px;
}

.comp-srv-ubic {
  font-size: 0.66rem;
  color: #64748b;
  margin-top: 0.12rem;
}

.comp-td-num {
  padding: 0.4rem 0.5rem;
  text-align: center;
  color: #334155;
  font-weight: 600;
}

.comp-td-nomina {
  padding: 0.38rem 0.55rem;
  text-align: right;
  color: #1e40af;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.comp-td-tarifa {
  padding: 0.38rem 0.55rem;
  text-align: right;
  color: #065f46;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.comp-td-hl { font-weight: 700; font-size: 0.8rem; }

.comp-td-pct {
  padding: 0.38rem 0.55rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
}

.pct-ok    { color: #16a34a; background: #f0fdf4; }
.pct-warn  { color: #d97706; background: #fffbeb; }
.pct-alert { color: #dc2626; background: #fef2f2; }

.comp-td-margen {
  padding: 0.38rem 0.55rem;
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

.margen-pos { color: #16a34a; }
.margen-neg { color: #dc2626; }

/* Barra de distribución visual */
.comp-td-bar { padding: 0.4rem 0.6rem; min-width: 130px; }

.comp-bar-wrap { display: flex; flex-direction: column; gap: 0.2rem; }

.comp-bar {
  display: flex;
  height: 11px;
  border-radius: 6px;
  overflow: hidden;
  background: #e2e8f0;
}

.comp-bar-nomina { background: #3b82f6; transition: width 0.35s; }
.comp-bar-ays    { background: #10b981; transition: width 0.35s; }
.comp-bar-other  { background: #f59e0b; transition: width 0.35s; }

.comp-bar-leyenda { display: flex; gap: 0.4rem; font-size: 0.63rem; }
.comp-leg-n { color: #3b82f6; font-weight: 600; }
.comp-leg-a { color: #10b981; font-weight: 600; }

/* Fila total */
.comp-total-row td {
  background: #0f172a;
  color: #f1f5f9;
  padding: 0.48rem 0.6rem;
  font-weight: 700;
  font-size: 0.78rem;
}

.comp-total-label { text-align: left; letter-spacing: 0.03em; padding-left: 0.75rem !important; }
.comp-total-val   { font-size: 0.85rem; }

/* Leyenda inferior */
.comp-leyenda-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  padding: 0.55rem 1rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 0.7rem;
  align-items: center;
}

.comp-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #475569;
}

.comp-leg-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
}

.dot-nomina { background: #3b82f6; }
.dot-ays    { background: #10b981; }
.dot-other  { background: #f59e0b; }

.comp-semaforo-item { font-weight: 600; }
.comp-sem-ok    { color: #16a34a; }
.comp-sem-warn  { color: #d97706; }
.comp-sem-alert { color: #dc2626; }

/* ====================================================
   MÓDULO CATÁLOGOS — Configuración
   ==================================================== */

.cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cat-header h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
}

.cat-header p {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: #64748b;
}

/* Tabs */
.cat-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 1rem;
  padding-bottom: 0;
}

.cat-tab {
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.cat-tab:hover {
  background: #e2e8f0;
  color: #334155;
}

.cat-tab.active {
  background: #fff;
  color: #2563eb;
  border-color: #e2e8f0;
  border-bottom-color: #fff;
  margin-bottom: -2px;
  z-index: 1;
  position: relative;
}

/* Panels */
.cat-panel {
  display: none;
}

.cat-panel.active {
  display: block;
}

.cat-panel-desc {
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 0.75rem;
  background: #f1f5f9;
  border-left: 3px solid #94a3b8;
  padding: 0.4rem 0.75rem;
  border-radius: 0 4px 4px 0;
}

/* Tabla editable */
.cat-table-wrap {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.cat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.cat-table thead tr {
  background: #1e293b;
  color: #fff;
}

.cat-table thead th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.cat-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}

.cat-table tbody tr:hover {
  background: #f8fafc;
}

.cat-table tbody tr:last-child {
  border-bottom: none;
}

.cat-table td {
  padding: 0.35rem 0.5rem;
  vertical-align: middle;
}

/* Columna numérica (ancho fijo) */
.cat-td-num {
  width: 40px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.75rem;
}

/* Columna acciones */
.cat-td-acc {
  width: 48px;
  text-align: center;
}

/* Inputs en tabla */
.cat-input-txt {
  width: 100%;
  min-width: 120px;
  padding: 0.3rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.78rem;
  background: #fff;
  color: #1e293b;
  transition: border-color 0.15s;
}

.cat-input-txt:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.cat-input-num {
  width: 100%;
  min-width: 80px;
  max-width: 120px;
  padding: 0.3rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.78rem;
  background: #fff;
  color: #1e293b;
  text-align: right;
  transition: border-color 0.15s;
}

.cat-input-num:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Hint de valor formateado debajo del input */
.cat-val-hint {
  display: block;
  font-size: 0.68rem;
  color: #22c55e;
  margin-top: 1px;
  text-align: right;
}

/* Botón eliminar fila */
.btn-cat-del {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #ef4444;
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: background 0.15s;
}

.btn-cat-del:hover {
  background: #fee2e2;
}

/* Fila "Agregar nuevo" */
.cat-add-row {
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-top: 1px dashed #e2e8f0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-cat-add {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-cat-add:hover {
  background: #dbeafe;
}

/* Barra de guardar/restaurar */
.cat-save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-cat-save {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 1rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-cat-save:hover {
  background: #1d4ed8;
}

.btn-cat-restore {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  background: #fff;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-cat-restore:hover {
  background: #fee2e2;
}

/* Mensaje de estado */
.cat-status-msg {
  font-size: 0.78rem;
  color: #64748b;
  min-width: 120px;
}

.cat-status-msg.ok {
  color: #16a34a;
  font-weight: 600;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  /* En móvil: forzar colapsado */
  .sidebar { width: 64px; }
  .sidebar-logo-full, .nav-label, .footer-full { display: none; }
  .sidebar-logo-mini { display: block; }
  .footer-mini { display: block; }
  .main-wrapper { margin-left: 64px; }
  .nav-item { justify-content: center; padding: 0.75rem 0; }
  .sidebar-toggle-btn { display: none; } /* Ocultar en móvil */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  #main-content { padding: 1rem; }
  .wizard-steps { padding: 0.75rem; }
  .step-label { display: none; }
}

/* ══════════════════════════════════════════════════════════════════
   CÁLCULO SALARIAL – Barra AyS automático
   ══════════════════════════════════════════════════════════════════ */

/* Contenedor de la barra informativa de AyS */
.sal-ays-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #f0f4ff;
  border: 1px solid #c7d4f0;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

/* Etiqueta fija "AyS detectado:" */
.sal-ays-etiqueta {
  font-size: 0.78rem;
  font-weight: 600;
  color: #4a5568;
  white-space: nowrap;
}

/* Badge pill que indica el tipo de servicio */
.sal-ays-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* Variantes de color por tipo de medio */
.sal-ays-badge.sal-ays-sin_arma {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}
.sal-ays-badge.sal-ays-con_arma {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}
.sal-ays-badge.sal-ays-con_canino {
  background: #fef9c3;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* Texto de la regla "aplica X%" */
.sal-ays-regla {
  font-size: 0.75rem;
  color: #6b7280;
  flex: 1;
  min-width: 100px;
}

/* Control: input + hint "editable" */
.sal-ays-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

/* Input numérico del % AyS (editable manualmente) */
.sal-margen-input {
  width: 72px;
  padding: 0.3rem 0.5rem;
  border: 1px solid #a0aec0;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: right;
  color: #1a202c;
  background: #fff;
  transition: border-color 0.2s;
}
.sal-margen-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102,126,234,0.2);
}

/* Hint "✎ editable" junto al input */
.sal-ays-override-hint {
  font-size: 0.7rem;
  color: #9ca3af;
  white-space: nowrap;
}

/* ── Badge pequeño reutilizable en tarjetas de resultado ── */
.sal-medio-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.sal-medio-badge.sal-ays-sin_arma {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}
.sal-medio-badge.sal-ays-con_arma {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}
.sal-medio-badge.sal-ays-con_canino {
  background: #fef9c3;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* Fila de AyS en la tarjeta de precio */
.sal-ays-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.5rem;
  background: #f8faff;
  border-left: 3px solid #667eea;
  border-radius: 0 4px 4px 0;
  margin: 0.1rem 0;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Valor monetario destacado en la fila de AyS */
.sal-ays-valor {
  font-weight: 700;
  color: #1d4ed8;
  font-size: 0.9rem;
}

/* Badge más pequeño (alias) */
.sal-badge-sm {
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
}

/* ── Bloqueo de campos derivados de Modalidad ─────────────────────── */

/* Botón 🔒/🔓 inline junto al label de Modalidad */
.btn-bloqueo {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72rem;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.5;
  color: #555;
  transition: border-color 0.15s, background 0.15s;
}
.btn-bloqueo:hover {
  border-color: #6b7280;
  background: #f3f4f6;
}
.btn-bloqueo.bloqueado {
  border-color: #d97706;
  background: #fffbeb;
  color: #92400e;
  font-weight: 600;
}

/* Campos en modo solo-lectura (derivados de Modalidad cuando bloqueado) */
select.campo-bloqueado,
input[type="time"].campo-bloqueado {
  background: #f3f4f6 !important;
  color: #6b7280 !important;
  cursor: not-allowed !important;
  opacity: 0.8;
  border-color: #e5e7eb !important;
}

/* ── Módulo de Usuarios ────────────────────────────────────────────────── */
.role-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-admin  { background: #fee2e2; color: #991b1b; }
.badge-user   { background: #dbeafe; color: #1e40af; }
.badge-viewer { background: #f3f4f6; color: #374151; }

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.dot-active   { background: #22c55e; }
.dot-inactive { background: #d1d5db; }

.row-inactive td { color: #9ca3af; }
.row-inactive strong { font-weight: 400; }

.btn-warning {
  background: #f59e0b;
  color: #fff;
  border: none;
}
.btn-warning:hover { background: #d97706; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  border-left: 4px solid;
  font-size: 0.875rem;
  margin-bottom: var(--sp-4);
  line-height: 1.5;
}
.alert-danger   { background: #FEF2F2; border-color: var(--danger);  color: #991B1B; }
.alert-success  { background: #F0FDF4; border-color: var(--success); color: #166534; }
.alert-warning  { background: #FFFBEB; border-color: var(--warning); color: #92400E; }
.alert-info     { background: #EFF6FF; border-color: var(--info);    color: #1E40AF; }

/* ── Módulo Reportes ──────────────────────────────────────────────────────── */

.rpt-filtros-card { margin-bottom: 1.25rem; }

.rpt-filtros-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.rpt-filtros-row .form-group { flex: 1; min-width: 130px; margin-bottom: 0; }
.rpt-btn-group { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* KPI grid con 6 columnas en la sección de reportes */
.rpt-kpi-grid {
  grid-template-columns: repeat(6, 1fr);
  margin-bottom: 1.25rem;
}
@media (max-width: 1100px) { .rpt-kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .rpt-kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* Grid de gráficas */
.rpt-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 768px) { .rpt-charts-grid { grid-template-columns: 1fr; } }

/* Gráfica de barras horizontal (vanilla CSS/HTML) */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0.25rem 0;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
}
.bar-label {
  width: 130px;
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.bar-track {
  flex: 1;
  background: var(--bg-secondary, #f1f5f9);
  border-radius: 4px;
  height: 22px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 4px;
}
.bar-value {
  width: 30px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary, #475569);
  flex-shrink: 0;
}

/* Card header dentro de reportes */
.rpt-charts-grid .card-header,
.rpt-filtros-card .card-header {
  font-weight: 600;
  padding: 0.65rem 1rem;
  background: var(--bg-secondary, #f8fafc);
  border-bottom: 1px solid var(--border, #e2e8f0);
  border-radius: 8px 8px 0 0;
}
.rpt-charts-grid .card-body { padding: 0.9rem 1rem; }

/* ── Nómina compuesta (servicios con tramos) ──────────────────────────────── */

.nomina-compuesto-wrap { padding: 0; }

.nomina-compuesto-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.1rem;
  background: linear-gradient(90deg, #eff6ff 0%, #f0fdf4 100%);
  border-bottom: 2px solid #bfdbfe;
  border-radius: 8px 8px 0 0;
  flex-wrap: wrap;
}
.nomina-compuesto-badge {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1e40af;
}

/* Cada bloque de tramo */
.tramo-nomina-bloque {
  border-bottom: 1px solid var(--border, #e2e8f0);
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
}
.tramo-nomina-bloque:last-of-type { border-bottom: none; }

.tramo-nomina-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1.1rem 0.3rem;
  background: #f8fafc;
  border-left: 4px solid #3b82f6;
  margin-bottom: 0.5rem;
}
.tramo-nomina-bloque:nth-child(2) .tramo-nomina-header { border-left-color: #10b981; }
.tramo-nomina-bloque:nth-child(3) .tramo-nomina-header { border-left-color: #f59e0b; }
.tramo-nomina-bloque:nth-child(4) .tramo-nomina-header { border-left-color: #8b5cf6; }

.tramo-nomina-label {
  font-size: 0.92rem;
  color: #1e293b;
}
.tramo-nomina-meta {
  font-size: 0.8rem;
  color: #64748b;
}

/* Grid de bloques dentro del tramo (3 columnas en tramo) */
.nomina-tramo-grid {
  padding: 0 0.75rem;
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 900px) { .nomina-tramo-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .nomina-tramo-grid { grid-template-columns: 1fr; } }

/* Footer resumen de cada tramo */
.tramo-nomina-footer {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.5rem 1.1rem;
  background: #f0fdf4;
  font-size: 0.82rem;
}
.tramo-footer-item { text-align: center; }
.tramo-footer-label { display: block; color: #64748b; font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.03em; }
.tramo-footer-val   { display: block; font-weight: 700; color: #1e293b; font-size: 0.9rem; }
.tramo-footer-sep   { color: #94a3b8; font-weight: 700; font-size: 1rem; }
.tramo-footer-total .tramo-footer-val { color: #166534; font-size: 1rem; }

/* Barra consolidada final */
.nomina-compuesto-total {
  background: linear-gradient(90deg, #ecfdf5 0%, #eff6ff 100%);
  border-top: 2px solid #10b981;
  margin-top: 0;
  padding: 0.75rem 1.1rem;
  font-size: 0.9rem;
  border-radius: 0 0 8px 8px;
}
.nomina-compuesto-total .nomina-res-val { font-size: 1.05rem; }

/* ── Configuración umbrales semáforo de nómina ───────────────────────────── */

.umbrales-semaforo-grid {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.umbral-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  flex: 1;
  min-width: 160px;
  border: 1px solid transparent;
}
.umbral-verde   { background: rgba(22,163,74,0.08);  border-color: rgba(22,163,74,0.25);  }
.umbral-naranja { background: rgba(217,119,6,0.08);  border-color: rgba(217,119,6,0.25);  }
.umbral-rojo    { background: rgba(220,38,38,0.08);  border-color: rgba(220,38,38,0.25);  }
.umbral-icono   { font-size: 1.4rem; flex-shrink: 0; }
.umbral-label   { font-weight: 600; font-size: 0.85rem; color: var(--text-primary, #1e293b); }
.umbral-rango   { font-size: 0.78rem; color: var(--text-secondary, #64748b); margin-top: 1px; }

/* Barra de vista previa */
.umbral-preview { width: 100%; }
.umbral-preview-label { font-size: 0.78rem; color: var(--text-secondary, #64748b); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.umbral-preview-barra {
  display: flex;
  height: 18px;
  border-radius: 9px;
  overflow: hidden;
  background: #f1f5f9;
}
.umbral-preview-seg { display: block; height: 100%; transition: width 0.25s ease; }
.seg-verde    { background: #4ade80; }
.seg-amarillo { background: #fbbf24; }
.seg-rojo     { background: #f87171; }
.umbral-preview-pcts { font-size: 0.75rem; color: var(--text-secondary, #64748b); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   WORKFLOW DE APROBACIÓN DE COTIZACIONES
   ============================================================ */

/* Badges de nivel en tarjetas de Comerciales */
.badge-nivel-solicitante  { background: #6c757d; color: #fff; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; display: inline-block; margin-top: 4px; }
.badge-nivel-coordinador  { background: #ffc107; color: #000; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; display: inline-block; margin-top: 4px; }
.badge-nivel-director     { background: #fd7e14; color: #fff; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; display: inline-block; margin-top: 4px; }
.badge-nivel-gerente      { background: #dc3545; color: #fff; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; display: inline-block; margin-top: 4px; }

/* Semáforo de aprobación en Paso 6 */
.aprobacion-semaforo {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-radius: 8px;
  margin-top: 1.25rem;
  border-left: 5px solid transparent;
}
.aprobacion-semaforo-icon { font-size: 2rem; flex-shrink: 0; }
.aprobacion-semaforo-info { display: flex; flex-direction: column; gap: 2px; }
.aprobacion-semaforo-info strong { font-size: 1rem; }
.aprobacion-semaforo-info span   { font-size: 0.82rem; color: #555; }

.aprobacion-verde    { border-left-color: #28a745; background: #d4edda; }
.aprobacion-amarillo { border-left-color: #ffc107; background: #fff3cd; }
.aprobacion-rojo     { border-left-color: #dc3545; background: #f8d7da; }

/* Header de modal de aprobación con color según nivel */
.aprobacion-header-amarillo { background: #fff3cd !important; border-bottom: 2px solid #ffc107 !important; }
.aprobacion-header-rojo     { background: #f8d7da !important; border-bottom: 2px solid #dc3545 !important; }

/* Vista previa de umbrales en Configuración */
.aprobacion-preview-cfg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.8rem;
}
.aprobacion-preview-fila {
  padding: 6px 12px;
  font-weight: 500;
}
.aprobacion-preview-fila.aprobacion-verde    { background: #d4edda; color: #155724; }
.aprobacion-preview-fila.aprobacion-amarillo { background: #fff3cd; color: #856404; }
.aprobacion-preview-fila.aprobacion-rojo     { background: #f8d7da; color: #721c24; }

/* Badges de estado de aprobación en la tabla de cotizaciones */
.aprobacion-badge {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
}
.aprobacion-badge-verde     { background: #d4edda; color: #155724; }
.aprobacion-badge-amarillo  { background: #fff3cd; color: #856404; }
.aprobacion-badge-aprobado  { background: #d4edda; color: #155724; }
.aprobacion-badge-rechazado { background: #f8d7da; color: #721c24; }

/* Panel de cotizaciones pendientes en lista */
.panel-pendientes {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.panel-pendiente-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.75rem;
  background: rgba(255,255,255,0.6);
  border-radius: 6px;
}
.panel-pendiente-item em { color: #856404; font-size: 0.82rem; }

/* Badge rojo en nav item */
.nav-badge {
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1.4;
  animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

/* ── 15. TOASTS ─────────────────────────────────────────────────────────────── */
.toast-notif {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: var(--z-toast);
  min-width: 280px;
  max-width: 380px;
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-lg);
  border-left: 4px solid;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(12px) translateX(8px);
  transition: opacity var(--t-slow), transform var(--t-slow);
  pointer-events: none;
}
.toast-notif.toast-visible { opacity: 1; transform: translateY(0) translateX(0); }
.toast-success { background: #F0FDF4; border-color: var(--success); color: #14532D; }
.toast-danger  { background: #FFF1F2; border-color: var(--danger);  color: #881337; }
.toast-warning { background: #FFFBEB; border-color: var(--warning); color: #78350F; }
.toast-info    { background: #F0F9FF; border-color: var(--info);    color: #0C4A6E; }

/* ============================================================
   WHITE-LABEL / IDENTIDAD DE MARCA
   ============================================================ */

/* Sección de marca blanca en Configuración */
.wb-section h3 { color: var(--primary); }

.wb-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 700px) {
  .wb-grid { grid-template-columns: 1fr; }
}

.wb-col-logo { text-align: center; }
.wb-logo-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem;
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-light, #f8fafc);
  min-height: 120px;
  justify-content: center;
}
.wb-logo-upload img { border-radius: 6px; }
.wb-logo-btn {
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
}

/* Color picker row */
.wb-colores .form-group label { font-size: 0.85rem; }
.wb-color-hex {
  font-family: monospace;
  font-size: 0.85rem;
  color: #64748b;
  min-width: 70px;
}

/* Sidebar logo image */
#sidebar-logo {
  display: block;
  max-height: 48px;
  max-width: 140px;
  object-fit: contain;
  margin: 0 auto 0.35rem auto;
  border-radius: 4px;
}

/* ── Carga de RUT ───────────────────────────────────────────────────────── */
.rut-upload-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #f0f9ff;
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}
.rut-upload-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.rut-upload-icon { font-size: 1.8rem; line-height: 1; }
.rut-upload-info strong { display: block; font-size: 0.9rem; color: #1e40af; }
.rut-upload-info small  { color: #64748b; font-size: 0.78rem; }
.rut-upload-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.btn-rut {
  background: #eff6ff;
  border: 1.5px solid #3b82f6;
  color: #1d4ed8;
  font-weight: 600;
  white-space: nowrap;
}
.btn-rut:hover { background: #dbeafe; }
.btn-rut:disabled { opacity: 0.6; cursor: not-allowed; }

.rut-status { font-size: 0.82rem; font-weight: 500; }
.rut-status-loading { color: #92400e; }
.rut-status-ok      { color: #065f46; }
.rut-status-error   { color: #991b1b; }

/* ──────────────────────────────────────────────────────────────────────────────
   ESTADO FIRMADA — Cotizaciones bloqueadas / inmutables
   ────────────────────────────────────────────────────────────────────────────── */

/* Badge especial para el estado FIRMADA en la tabla */
.badge.badge-firmada {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: 0 1px 3px rgba(91,33,182,0.4);
}

/* Ícono candado junto al código */
.badge-firmada-lock {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.8rem;
  vertical-align: middle;
  opacity: 0.7;
}

/* Fila de cotización FIRMADA en la tabla */
tr.cot-firmada-row {
  background: #f5f3ff !important;
  opacity: 0.92;
}
tr.cot-firmada-row:hover { background: #ede9fe !important; }
tr.cot-firmada-row td    { color: #4c1d95; }

/* Botón Firmar */
.btn-firmar {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  color: #fff;
  font-weight: 700;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  white-space: nowrap;
  transition: opacity .15s;
}
.btn-firmar:hover { opacity: 0.85; }

/* Columna de acciones en lista cotizaciones — sin salto de línea */
td.acciones-col {
  white-space: nowrap;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
}

/* ──────────────────────────────────────────────────────────────────────────────
   TIMELINE DE AUDITORÍA
   ────────────────────────────────────────────────────────────────────────────── */

.audit-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.5rem 0;
}

.audit-event {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
}
.audit-event:last-child { border-bottom: none; }

/* Línea vertical de la timeline */
.audit-event::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 48px;
  width: 2px;
  height: calc(100% - 28px);
  background: #e2e8f0;
}
.audit-event:last-child::before { display: none; }

.audit-event-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  z-index: 1;
}

.audit-event-content { flex: 1; min-width: 0; }

.audit-event-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.audit-accion {
  font-weight: 700;
  font-size: 0.9rem;
}

.audit-meta {
  font-size: 0.8rem;
  color: #64748b;
}

.audit-detalles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.audit-detalle-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
  color: #475569;
}

/* Spinner pequeño para loading del historial */
.spinner-sm {
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary, #1e3a5f);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cabecera de página con acciones múltiples ──────────────────────────────── */
.page-header-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Informe de Clientes ────────────────────────────────────────────────────── */
.informe-clientes-table {
  font-size: 0.82rem;
  white-space: nowrap;
}
.informe-clientes-table th {
  background: #1e3a5f;
  color: #fff;
  font-size: 0.78rem;
  padding: .5rem .6rem;
  position: sticky;
  top: 0;
  z-index: 1;
}
.informe-clientes-table td {
  padding: .4rem .6rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.informe-clientes-table tr:hover td {
  background: #f8fafc;
}

/* Barras de estadísticas en el informe */
.informe-bar-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .45rem;
}
.informe-bar-label {
  flex: 0 0 130px;
  font-size: .82rem;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.informe-bar-track {
  flex: 1;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.informe-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1e3a5f, #2563eb);
  border-radius: 999px;
  transition: width .4s ease;
}
.informe-bar-fill-alt {
  background: linear-gradient(90deg, #0891b2, #06b6d4);
}
.informe-bar-count {
  flex: 0 0 28px;
  text-align: right;
  font-size: .82rem;
  font-weight: 600;
  color: #1e293b;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ICONS — SVG Lucide-style inline icon system
   ═══════════════════════════════════════════════════════════════════════════ */

/* Base icon — inline, stroke-based, vertically centred */
.icon {
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
  line-height: 1;
  pointer-events: none;
  /* Inherit stroke color from parent text color */
  color: inherit;
}

/* Nav icons — block-centred inside .nav-icon span */
.nav-icon .icon {
  display: block;
  margin: 0 auto;
  vertical-align: initial;
}

/* Sidebar collapsed: hide label, show only icon */
.sidebar-collapsed .nav-icon .icon {
  margin: 0 auto;
}

/* Sidebar toggle chevron rotates 180° when sidebar is collapsed */
.sidebar-collapsed #sidebar-toggle-icon .icon {
  transform: rotate(180deg);
  transition: transform var(--t-base);
}
#sidebar-toggle-icon .icon {
  transition: transform var(--t-base);
}

/* Shield icon in sidebar mini (centered) */
.sidebar-logo-mini .icon {
  display: block;
  margin: 0 auto;
  opacity: 0.9;
}

/* Spinning loader animation */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.spin-anim {
  animation: spin 1.1s linear infinite;
}

/* Button icons — slightly tighter gap */
.btn .icon {
  vertical-align: -0.2em;
  margin-right: 0.1em;
}

/* Table / card action button icons */
.btn-icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}
.btn-icon-only .icon {
  vertical-align: initial;
  margin: 0;
}

/* Form section title icons */
.form-section h3 .icon {
  vertical-align: -0.2em;
  opacity: 0.75;
}

/* Toast / alert leading icons */
.toast-icon .icon,
.alert-icon .icon {
  flex-shrink: 0;
  vertical-align: initial;
}

/* ═══════════════════════════════════════════════════════════════════════════
   AGENTE OCR · GEMINI VISION — Panel de captura automática de datos
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Panel contenedor ──────────────────────────────────────────────────── */
.capture-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 0.25rem;
  box-shadow: var(--shadow-xs);
}
.capture-panel-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.capture-panel-header strong { color: var(--text-primary); font-weight: 600; }
.capture-panel-sub { margin-left: auto; font-size: 0.72rem; color: var(--text-muted); }

/* ── Las dos opciones (RUT + OCR) ──────────────────────────────────────── */
.capture-panel-options {
  display: flex;
  align-items: stretch;
}
.capture-opt {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.9rem;
  transition: background var(--t-base);
}
.capture-opt:hover { background: var(--surface-2); }

/* Icono de opción */
.capture-opt-icon {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-50);
  color: var(--primary-light);
}
/* Icono OCR — degradado Gemini */
.ocr-opt-icon {
  position: relative;
  background: linear-gradient(135deg,#4F46E5 0%,#7C3AED 50%,#EC4899 100%);
  color: #fff;
}
/* Badge "IA" sobre el icono */
.ocr-gem-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: #F59E0B;
  color: #fff;
  font-size: 0.52rem; font-weight: 800; letter-spacing: 0.03em; line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  border: 1.5px solid var(--surface);
}

/* Textos */
.capture-opt-body   { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.capture-opt-title  { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }
.capture-opt-desc   { font-size: 0.71rem; color: var(--text-muted); }

/* Área botón */
.capture-opt-action {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem;
}

/* Divisor vertical "ó" */
.capture-divider-v {
  flex-shrink: 0;
  width: 1px;
  background: var(--border);
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.capture-divider-v span {
  position: absolute;
  background: var(--surface);
  padding: 0.3rem 0;
  font-size: 0.68rem; color: var(--text-muted); font-weight: 500;
}

/* ── Botón OCR ─────────────────────────────────────────────────────────── */
.btn-ocr {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.32rem 0.8rem;
  font-size: 0.775rem; font-weight: 600;
  border-radius: var(--radius-full);
  border: none; cursor: pointer;
  background: linear-gradient(135deg,#4F46E5,#7C3AED);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,.28);
  transition: all var(--t-base);
}
.btn-ocr:hover     { background: linear-gradient(135deg,#4338CA,#6D28D9); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,70,229,.38); }
.btn-ocr:active    { transform: translateY(0); }
.btn-ocr:disabled  { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* Pulso mientras procesa */
.capture-opt-ocr.ocr-processing .ocr-opt-icon {
  animation: ocr-pulse-icon 1.2s ease-in-out infinite;
}
@keyframes ocr-pulse-icon {
  0%,100% { box-shadow: 0 0 0 0   rgba(124,58,237,.4); }
  50%     { box-shadow: 0 0 0 8px rgba(124,58,237,0); }
}

/* Status messages */
.ocr-status {
  font-size: 0.71rem; font-weight: 500;
  max-width: 155px; text-align: right; line-height: 1.3;
}
.ocr-status-loading { color: var(--primary-light); }
.ocr-status-ok      { color: var(--success); }
.ocr-status-error   { color: var(--danger); }

/* ── Preview de imagen ─────────────────────────────────────────────────── */
.ocr-img-preview {
  padding: 0.6rem 0.9rem;
  border-top: 1px solid var(--border);
  background: #0F172A;
}
.ocr-preview-wrap {
  position: relative;
  display: block;
  max-height: 175px;
  overflow: hidden;
  border-radius: var(--radius-md);
}
.ocr-preview-img {
  width: 100%; max-height: 175px;
  object-fit: contain; display: block;
  border-radius: var(--radius-md);
  opacity: 0.82;
}

/* ── Overlay de scanning ───────────────────────────────────────────────── */
.ocr-scanning-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  padding-bottom: 0.5rem;
  background: linear-gradient(to bottom, transparent 45%, rgba(15,23,42,.65));
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: opacity .4s ease;
}
/* Línea que recorre la imagen */
.ocr-scan-line {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg,transparent,#7C3AED,#EC4899,#7C3AED,transparent);
  box-shadow: 0 0 10px 2px rgba(124,58,237,.65);
  animation: ocr-scan-anim 1.8s ease-in-out infinite;
}
@keyframes ocr-scan-anim {
  0%   { top:0%;  opacity:1; }
  48%  { top:95%; opacity:1; }
  50%  { top:95%; opacity:0; }
  52%  { top:0%;  opacity:0; }
  54%  { top:0%;  opacity:1; }
  100% { top:95%; opacity:1; }
}
.ocr-scanning-label {
  display: flex; align-items: center; gap: 0.3rem;
  color: #fff; font-size: 0.74rem; font-weight: 600;
  background: rgba(79,70,229,.82);
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-full);
  backdrop-filter: blur(4px);
  letter-spacing: .02em;
}

/* ── Flash de campo rellenado por OCR ─────────────────────────────────── */
@keyframes ocr-fill-flash {
  0%   { background-color: var(--surface);            box-shadow: none; }
  15%  { background-color: rgba(79,70,229,.13); box-shadow: 0 0 0 2px rgba(79,70,229,.32); }
  70%  { background-color: rgba(79,70,229,.07); box-shadow: 0 0 0 2px rgba(79,70,229,.15); }
  100% { background-color: var(--surface);            box-shadow: none; }
}
.ocr-filled { animation: ocr-fill-flash 2.8s ease forwards; }

/* ── Preview de PDF ────────────────────────────────────────────────────── */
.ocr-pdf-wrap {
  background: #1E293B;
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  min-height: 72px;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.ocr-pdf-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #94A3B8;
  flex: 1;
  z-index: 1;
}
.ocr-pdf-card .icon   { color: #F87171; flex-shrink: 0; }
.ocr-pdf-info         { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.ocr-pdf-name {
  font-size: 0.8rem; font-weight: 600; color: #E2E8F0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 260px;
}
.ocr-pdf-size { font-size: 0.69rem; color: #64748B; }

/* ── Modo de extracción badge ─────────────────────────────────────────────── */
.ocr-mode-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-size: 0.68rem; font-weight: 600;
  vertical-align: middle;
  letter-spacing: 0.01em;
}
.ocr-mode-texto  { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }
.ocr-mode-vision { background: #EEF2FF; color: #4338CA; border: 1px solid #C7D2FE; }

/* Responsive */
@media (max-width: 600px) {
  .capture-panel-options { flex-direction: column; }
  .capture-divider-v { width: 100%; height: 1px; }
  .capture-divider-v span { writing-mode: horizontal-tb; }
  .capture-panel-sub { display: none; }
}
