:root {
  --teal: #008C95;
  --teal-dark: #006e76;
  --teal-light: #e6f4f5;
  --gray-dark: #75787B;
  --gray-mid: #D0D0CE;
  --gray-light: #f5f5f5;
  --white: #ffffff;
  --text: #2c2e30;
  --text-muted: #75787B;
  --border: #e8e8e8;
  --red: #e53935;
  --orange: #f57c00;
  --green: #2e7d32;
  --sidebar-w: 220px;
  --header-h: 56px;
}

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

body {
  font-family: 'Roboto', sans-serif;
  background: var(--gray-light);
  color: var(--text);
  font-size: 13px;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: #16202e;
  border-right: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  height: 100vh;
}

/* ── Logo area ── */
.sidebar-logo {
  margin: 10px 10px 6px 10px;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 12px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo img {
  height: 26px;
  max-width: 100%;
  object-fit: contain;
  background: transparent;
  display: block;
}

.sidebar-logo-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .01em;
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255,255,255,.35);
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* ── Nav ── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.2);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 12px 8px 4px;
}

.nav-separator {
  height: 1px;
  background: rgba(255,255,255,0.25);
  margin: 6px 12px;
}
.sidebar.collapsed .nav-separator {
  margin: 6px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  padding: 7px 10px;
  cursor: pointer;
  border-radius: 10px;
  transition: background .15s, color .15s;
  color: rgba(255,255,255,.45);
  font-size: 13px;
  font-weight: 400;
  position: relative;
  user-select: none;
  margin-bottom: 2px;
  white-space: nowrap;
}

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

.nav-item:hover .nav-icon-box {
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.9);
}

.nav-item.active {
  background: #1e3245;
  color: #fff;
  font-weight: 600;
}

.nav-item.active .nav-icon-box {
  background: var(--teal);
  color: #fff;
}

/* Icon box */
.nav-icon-box {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
  color: rgba(255,255,255,.5);
}

.nav-icon-box svg { width: 15px; height: 15px; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
}

.nav-badge.orange { background: var(--orange); }

/* Editor-only nav items */
.editor-only { display: none; }
.nav-item.editor-only[style] { display: flex !important; align-items: center !important; flex-wrap: nowrap !important; }

.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 8px 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s;
}

.sidebar-user:hover { background: rgba(255,255,255,.04); }

.sidebar-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 500; color: rgba(255,255,255,.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 10px; color: rgba(255,255,255,.35); }

/* ── MAIN ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOP HEADER ── */
.topbar {
  background: var(--white);
  border-bottom: none;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.topbar-search {
  display: flex;
  align-items: center;
  background: var(--gray-light);
  border: 1.5px solid var(--teal);
  border-radius: 8px;
  padding: 10px 12px;
  gap: 6px;
  width: 260px;
  transition: border-color .15s, box-shadow .15s;
}

.topbar-search:focus-within {
  border-color: var(--teal-dark);
  box-shadow: 0 0 0 3px rgba(0,140,149,.18);
  background: #fff;
}

.topbar-search input {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  outline: none;
  width: 100%;
}

.topbar-search input::placeholder { color: var(--text-muted); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  height: 32px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: white; font-weight: 600; box-shadow: 0 3px 8px rgba(13,148,136,.30); }
.btn-primary:hover { background: var(--teal-dark); box-shadow: 0 4px 12px rgba(13,148,136,.4); }
.btn-outline { background: white; color: var(--text); border: 1.5px solid var(--border); font-weight: 500; }
.btn-outline:hover { border-color: var(--teal); color: var(--teal); background: #f0fdf9; }
/* ══ Variantes de botón para modales (btn-warning, btn-danger, btn-secondary, btn-success) ══ */
.btn-warning {
  background: transparent;
  color: #d97706;
  font-weight: 600;
  border: 2px solid #f59e0b;
  box-shadow: none;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.btn-warning:hover {
  background: #fef3c7;
  color: #b45309;
  border-color: #d97706;
  box-shadow: rgba(245, 158, 11, 0.2) 0px 3px 8px;
}

.btn-success {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: white;
  font-weight: 600;
  box-shadow: rgba(22, 163, 74, 0.3) 0px 3px 8px;
}
.btn-success:hover {
  background: #15803d;
  box-shadow: rgba(22, 163, 74, 0.45) 0px 4px 12px;
}

.btn-danger {
  background: white;
  color: #e53935;
  border: 1.5px solid #e53935;
  font-weight: 500;
}
.btn-danger:hover {
  background: #fff5f5;
  box-shadow: rgba(229, 57, 53, 0.15) 0px 3px 8px;
}

.btn-secondary {
  background: white;
  color: var(--teal);
  border: 1.5px solid var(--teal);
  font-weight: 500;
}
.btn-secondary:hover {
  background: #f0fdf9;
  box-shadow: rgba(13, 148, 136, 0.15) 0px 3px 8px;
}

.btn-nuevo-contrato {
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  height: auto;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(13,148,136,.35);
}
.btn-nuevo-contrato:hover { background: var(--teal-dark); box-shadow: 0 4px 14px rgba(13,148,136,.45); }
.btn-publish { background: #00ad9f; color: white; }
.btn-publish:hover { background: #009088; }
/* Botón pequeño para tablas — misma altura que btn pero más compacto */
.btn-sm { height: 28px; padding: 0 10px; font-size: 11px; }
/* Botón mínimo para paginación (‹ ›) */
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; }

/* ── ESTADÍSTICAS ── */
.stats-tabs-nav {
  display: flex;
  gap: 4px;
  background: #e8e5e0;
  border-radius: 9px;
  padding: 4px;
  width: fit-content;
  margin-bottom: 22px;
}
.stats-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  transition: color .15s, background .15s, box-shadow .15s;
  white-space: nowrap;
}
.stats-tab-btn:hover:not(.active) { color: var(--text); background: rgba(255,255,255,.5); }
.stats-tab-btn.active { color: var(--teal); background: var(--white); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.stats-tab-panel { display: none; }
.stats-tab-panel.active { display: block; animation: fadeInUp .18s ease; }

.stats-kpi-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.stats-kpi-row.cols3 { grid-template-columns: repeat(3,1fr); }
.stats-kpi-card {
  background: var(--white);
  border-radius: 12px;
  padding: 18px 20px;
  border: 1px solid var(--border);
}
.stats-kpi-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 8px; }
.stats-kpi-value { font-size: 26px; font-weight: 700; line-height: 1; color: var(--teal); }
.stats-kpi-value.green { color: #2a8c5f; }
.stats-kpi-value.orange { color: var(--orange); }
.stats-kpi-value.purple { color: #7c3aed; }
.stats-kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 5px; }

.stats-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.stats-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.stats-grid65 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 16px; }

.stats-card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
}
.stats-card-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 4px; }
.stats-card-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 16px; }
.stats-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted);
  margin: 22px 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.stats-section-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.stats-bar-list { display: flex; flex-direction: column; gap: 11px; }
.stats-bar-row { display: grid; grid-template-columns: 150px 1fr 70px; align-items: center; gap: 10px; }
.stats-bar-label { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-bar-track { height: 8px; background: #f0ede8; border-radius: 20px; overflow: hidden; }
.stats-bar-fill { height: 100%; border-radius: 20px; background: var(--teal); transition: width .4s ease; }
.stats-bar-val { font-size: 12px; font-weight: 600; text-align: right; color: var(--text); }

.stats-donut-wrap { display: flex; align-items: center; gap: 24px; }
.stats-legend { display: flex; flex-direction: column; gap: 9px; flex: 1; }
.stats-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.stats-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.stats-legend-label { flex: 1; }
.stats-legend-val { font-weight: 600; }
.stats-legend-pct { color: var(--text-muted); font-size: 11px; margin-left: 4px; }

.stats-alert-list { display: flex; flex-direction: column; gap: 6px; }
.stats-alert-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  transition: background .12s;
}
.stats-alert-item:hover { background: #fafafa; }

/* solo colorear cuando hay incidencia */
.stats-alert-item.warn  { border-left: 3px solid #f59e0b; }
.stats-alert-item.info  { border-left: 3px solid #3b82f6; }
.stats-alert-item.ok    { opacity: .65; }

.stats-alert-icon-wrap {
  width: 32px; height: 32px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--gray-light);
  color: var(--text-muted);
}
.stats-alert-item.warn .stats-alert-icon-wrap { background: #fef3c7; color: #b45309; }
.stats-alert-item.info .stats-alert-icon-wrap { background: #dbeafe; color: #1d4ed8; }
.stats-alert-icon-wrap svg { width: 15px; height: 15px; stroke-width: 2; }

.stats-alert-body { flex: 1; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stats-alert-desc { font-size: 13px; color: var(--text); line-height: 1.4; flex: 1; }
.stats-alert-desc strong { font-weight: 600; }

.stats-alert-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 20px;
  flex-shrink: 0;
}
.badge-urgent { background: #fef3c7; color: #92400e; }
/* badge-pending: see Design Tokens below */
.badge-ok      { background: #f0fdf4; color: #166534; }

.stats-alert-count-pill {
  font-size: 13px; font-weight: 700; color: var(--text);
  background: var(--gray-light); border-radius: 6px;
  padding: 2px 8px; flex-shrink: 0;
}
.stats-alert-item.warn .stats-alert-count-pill { background: #fef3c7; color: #92400e; }
.stats-alert-item.info .stats-alert-count-pill { background: #dbeafe; color: #1e40af; }

.stats-alert-action {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--teal);
  cursor: pointer; white-space: nowrap;
  transition: color .12s;
}
.stats-alert-action:hover { color: var(--teal-dark); text-decoration: underline; }
.stats-alert-action svg { width: 11px; height: 11px; stroke-width: 2.5; }

/* ── CARD HEADER (Proposal B) ── */
.card-header {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.card-header-left { min-width: 0; }
.card-header-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.card-header-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}
/* Icono de página en cabeceras */
.page-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0d9488, #0f766e);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(13,148,136,.25);
  color: white;
}
.page-header-icon svg {
  width: 20px;
  height: 20px;
}
.card-header-left-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Inline search for card-headers */
.inline-search {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--gray-light);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 12px;
  width: 240px;
  transition: border-color .15s, box-shadow .15s;
}
.inline-search:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,140,149,.10);
  background: #fff;
}
.inline-search input {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
}
.inline-search input::placeholder { color: #bbb; }

/* Pills inside card-header (dashboard) */
.card-header-right .banner-chip {
  padding: 8px 16px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border: 2px solid transparent;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  transition: opacity .15s, transform .1s;
}
.card-header-right .banner-chip[onclick]:hover {
  opacity: .85;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}
.chip-green  { background: #dcfce7; color: #15803d; border-color: #86efac; }
.chip-yellow { background: #fef9c3; color: #92400e; border-color: #fde047; }
.chip-orange { background: #fff7ed; color: #9a3412; border-color: #f97316; }
.chip-red    { background: #fff1f2; color: #881337; border-color: #f43f5e; }
.chip-teal   { background: #e6f7f8; color: #005f65; border-color: #80cdd1; }
.chip-orange .chip-num { font-size: 16px; font-weight: 800; color: #ea580c; }
.chip-red    .chip-num { font-size: 16px; font-weight: 800; color: #dc2626; }
.chip-datetime {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #94a3b8;
  gap: 8px;
}
.chip-datetime-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: #94a3b8;
  margin: 0 2px;
  vertical-align: middle;
}
.chip-datetime-time {
  font-family: monospace;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .5px;
  color: #0f766e;
}

/* ── PAGE CONTENT ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── VIEWS ── */
.view { display: none; padding: 10px 24px 8px 24px; }
.view.active { display: block; }

/* ── DASHBOARD ── */
.dashboard-greeting {
  font-size: 20px;
  font-weight: 300;
  color: var(--text);
  margin-bottom: 20px;
}

.dashboard-greeting span { font-weight: 600; color: var(--teal); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.kpi-card-text { flex: 1; min-width: 0; }

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-accent { color: var(--teal); }
.kpi-card.accent-teal { border-top: 3px solid var(--teal); }
.kpi-card.accent-orange { border-top: 3px solid var(--orange); }
.kpi-card.accent-green { border-top: 3px solid var(--green); }
.kpi-card.accent-red { border-top: 3px solid var(--red); }

.kpi-donut-wrap { flex-shrink: 0; }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
  align-items: stretch;
}

.dash-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.dash-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: flex; align-items: center; gap: 6px;
}

.dash-card-body { padding: 12px 16px; }

/* ── Alert rows (dashboard vencimientos) ── */
.alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-light);
  cursor: pointer;
  transition: background .12s;
}
.alert-row:last-child { border-bottom: none; }
.alert-row:hover { background: var(--gray-light); margin: 0 -16px; padding: 10px 16px; }

.alert-row-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.alert-row-icon.red    { background: #fef2f2; color: var(--red); }
.alert-row-icon.orange { background: #fff7ed; color: var(--orange); }
.alert-row-icon.yellow { background: #fefce8; color: #ca8a04; }
.alert-row-icon svg { width: 14px; height: 14px; stroke-width: 2; }

.alert-row-body { flex: 1; min-width: 0; }
.alert-row-label { font-size: 12px; color: var(--text); font-weight: 500; }
.alert-row-bar-wrap { height: 4px; background: var(--gray-light); border-radius: 4px; margin-top: 5px; overflow: hidden; }
.alert-row-bar { height: 100%; border-radius: 4px; transition: width .4s ease; }

.alert-count { font-size: 18px; font-weight: 700; color: var(--text); flex-shrink: 0; }
.alert-arrow { color: var(--text-muted); font-size: 14px; flex-shrink: 0; }

.equipo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--gray-light);
}

.equipo-row:last-child { border-bottom: none; }

.equipo-name { font-size: 13px; font-weight: 600; flex: 1; }
.equipo-count { font-size: 13px; color: var(--text-muted); min-width: 40px; text-align: right; }
.equipo-bar-wrap { flex: 2; height: 6px; background: var(--gray-light); border-radius: 3px; overflow: hidden; }
.equipo-bar { height: 100%; background: var(--teal); border-radius: 3px; }
.equipo-money { font-size: 13px; color: var(--teal); font-weight: 600; min-width: 80px; text-align: right; }

/* Backup card */
#viewDashboard .backup-card { display: none !important; }
.backup-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.backup-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.backup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── CONTRATOS VIEW ── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.view-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.filters-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--white);
  cursor: pointer;
  outline: none;
}

.filter-select:focus { border-color: var(--teal); }

/* ── Contratos header: misma altura en buscador y botones ── */
#viewContratos .card-header-right .inline-search,
#viewContratos .card-header-right .btn {
  height: 34px;
  box-sizing: border-box;
}
#viewContratos .card-header-right .inline-search {
  padding-top: 0;
  padding-bottom: 0;
}

/* ── Contratos: alinear cabecera y barra de filtros ── */
#viewContratos .card-header {
  padding-left: 16px;
  padding-right: 16px;
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}
#viewContratos .filters-bar {
  padding-left: 16px;
  padding-right: 16px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
  margin-bottom: 14px;
}
#viewContratos #alertFilterBanner {
  padding-left: 16px;
  padding-right: 16px;
}

/* ── Clientes: tabla ocupa toda la altura disponible ── */
#viewClientes .contracts-layout {
  height: calc(100vh - 176px);
}

/* ── Clientes: alinear cabecera y barra de filtros (igual que Contratos) ── */
#viewClientes .card-header {
  padding-left: 16px;
  padding-right: 16px;
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}
/* 1/05/2026: Proveedores comparte estructura "banda 1 + KPIs + filtros" con
   Clientes — sin estos overrides, el margin-bottom default de .card-header
   genera un gap blanco entre el header teal y la banda de KPIs. */
#viewProveedores .card-header {
  padding-left: 16px;
  padding-right: 16px;
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}
#viewClientes .filters-bar {
  padding-left: 16px;
  padding-right: 16px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
  margin-bottom: 14px;
}

/* ── Equipos: alinear cabecera y barra de filtros (igual que Contratos) ── */
#viewEquipos .card-header {
  padding-left: 16px;
  padding-right: 16px;
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}
#viewEquipos .filters-bar {
  padding-left: 16px;
  padding-right: 16px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
  margin-bottom: 14px;
}

/* ── Emails: cabecera + filtros alineados + lista con scroll interno ── */
#viewEmails .card-header {
  padding-left: 16px;
  padding-right: 16px;
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}
#viewEmails .filters-bar {
  padding-left: 16px;
  padding-right: 16px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
  margin-bottom: 14px;
}
#viewEmails .emg-list-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  height: calc(100vh - 230px);
  overflow-y: auto;
}
#viewEmails .emg-list-wrap::-webkit-scrollbar { width: 8px; }
#viewEmails .emg-list-wrap::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
#viewEmails .emg-list-wrap::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
#viewEmails .emg-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 13px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s ease;
  user-select: none;
}
#viewEmails .emg-filter-chip svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
#viewEmails .emg-filter-chip:hover {
  background: #f0fafa;
  border-color: #80cdd1;
  color: #007a82;
}
#viewEmails .emg-filter-chip.active {
  background: #008C95;
  border-color: #008C95;
  color: #fff;
}
#viewEmails .emg-filter-chip.active:hover {
  background: #007a82;
  border-color: #007a82;
}
#viewEmails .emg-contacto-row {
  padding: 12px 16px 12px 13px;
  border-bottom: 1px solid #e5e7eb;
  border-left: 3px solid transparent;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: background .1s;
}

/* Barra lateral coloreada según dirección del último email */
#viewEmails .emg-contacto-row.dir-in  { border-left-color: #22c55e; }
#viewEmails .emg-contacto-row.dir-out { border-left-color: #3b82f6; }

/* Círculo con flecha dentro para dirección */
#viewEmails .emg-dir-badge {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#viewEmails .emg-dir-badge svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#viewEmails .emg-dir-in  { background: #dcfce7; color: #166534; }
#viewEmails .emg-dir-out { background: #dbeafe; color: #1d4ed8; }

/* Columna avatar (fijo) */
#viewEmails .emg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

/* Columna nombre + tag (ancho fijo para alinear todas las filas) */
#viewEmails .emg-name-col {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
#viewEmails .emg-name {
  font-size: 13px;
  font-weight: 500;
  color: #111;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#viewEmails .emg-tag {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 500;
  border: 0.5px solid;
  text-transform: uppercase;
  letter-spacing: .03em;
  flex-shrink: 0;
}

/* Columna asunto (flexible — se adapta al ancho disponible) */
#viewEmails .emg-subject-col {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #475569;
  overflow: hidden;
}
#viewEmails .emg-arrow {
  font-weight: 500;
  flex-shrink: 0;
}
#viewEmails .emg-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Columna metadatos — ahora 3 columnas separadas alineadas */
#viewEmails .emg-col-emails {
  width: 120px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
}
#viewEmails .emg-adj-slot {
  width: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#viewEmails .emg-adj-icon { color: #94a3b8; flex-shrink: 0; }
#viewEmails .emg-col-pill {
  width: 115px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
#viewEmails .emg-col-date {
  width: 80px;
  flex-shrink: 0;
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  text-align: right;
}
/* Pill de sentimiento — más grande y visible */
#viewEmails .emg-sent-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
#viewEmails .emg-sent-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Badge de sin leer dentro de la columna emails */
#viewEmails .emg-unread-badge {
  font-size: 9px;
  background: #fef2f2;
  color: #b91c1c;
  border: 0.5px solid #fecaca;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 500;
  white-space: nowrap;
}
#viewEmails .emg-contacto-row:last-child { border-bottom: none; }
#viewEmails .emg-contacto-row:hover { background: #ebebec; }
#viewEmails .emg-contacto-row.unread { background: #fafbff; }
#viewEmails .emg-contacto-row.unread:hover { background: #ebebec; }

#viewEmails .emg-actions {
  display: flex;
  gap: 4px;
  align-self: center;
  flex-shrink: 0;
}
#viewEmails .emg-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .1s ease;
}
#viewEmails .emg-action-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#viewEmails .emg-action-btn:hover {
  background: #f0fafa;
  border-color: #80cdd1;
  color: #007a82;
}


.filter-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--white);
  outline: none;
  width: 160px;
}

.filter-input:focus { border-color: var(--teal); }

.results-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

/* Table */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.contracts-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 220px);
}

/* ── Averías: soldado cabecera+filtros + layout ── */
#viewAverias .card-header {
  padding-left: 16px;
  padding-right: 16px;
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}
#viewAverias .filters-bar {
  padding-left: 16px;
  padding-right: 16px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
  margin-bottom: 14px;
}

/* ── Leads: card-header + banner + filters-bar unidos ── */
#viewLeads .card-header {
  padding-left: 16px;
  padding-right: 16px;
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}
#viewLeads #leadsFilterBanner {
  padding-left: 16px;
  padding-right: 16px;
}
#viewLeads .filters-bar {
  padding-left: 16px;
  padding-right: 16px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
  margin-bottom: 14px;
}
.averias-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 176px);
  padding-bottom: 6px;
}

/* ── Averías: row hover ── */
#averiasTableWrap tbody tr.av-tr:not(.av-row-cerrada):hover,
#averiasTableWrap tbody tr.av-tr:not(.av-row-cerrada):hover td {
  background: #ebebec !important;
}
#averiasTableWrap tbody tr.av-row-cerrada:hover,
#averiasTableWrap tbody tr.av-row-cerrada:hover td {
  background: #f5c6cb !important;
}

.equipos-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 176px);
  padding-bottom: 6px;
}

.table-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: flex .2s;
}

.detail-panel {
  width: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--white);
  transition: width .2s;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.detail-panel.open {
  width: 380px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  background: #ebebec;
  padding: 13px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #3a424f;
  white-space: nowrap;
  border-bottom: 2px solid #c8c8c8;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
}

thead th:hover { color: var(--teal); }

tbody tr {
  border-bottom: 1px solid var(--gray-light);
  cursor: pointer;
  transition: background .1s;
}

tbody tr:hover { background: #ebebec; }
tbody tr:hover td { background: #ebebec !important; }

/* ── Equipos: row hover ── */
#equiposTable tbody tr.eq-estado-disponible:hover,
#equiposTable tbody tr.eq-estado-disponible:hover td {
  background: #bbf7d0 !important;
}
#equiposTable tbody tr.eq-estado-baja:hover,
#equiposTable tbody tr.eq-estado-baja:hover td {
  background: #fecaca !important;
}
tbody tr.selected { background: var(--teal-light); }
tbody tr.selected:hover { background: #b2dfdb; }
tbody tr.selected:hover td { background: #b2dfdb !important; }

/* Filas con fondo de estado: hover más oscuro del mismo tono */
tbody tr[style*="background:#fce4ec"]:hover,
tbody tr[style*="background:#fce4ec"]:hover td { background: #f5c6cb !important; }
tbody tr[style*="background:#FFF3E0"]:hover,
tbody tr[style*="background:#FFF3E0"]:hover td { background: #ffe0b2 !important; }
tbody tr[style*="background:#f0fdf4"]:hover,
tbody tr[style*="background:#f0fdf4"]:hover td { background: #bbf7d0 !important; }
tbody tr[style*="background:#fff5f5"]:hover,
tbody tr[style*="background:#fff5f5"]:hover td { background: #fecaca !important; }

tbody td {
  padding: 12px 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  border-bottom: 1px solid #eef0f2;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.badge-active { background: #e8f5e9; color: #2e7d32; }
.badge-expired { background: #fff8e1; color: #e65100; border: 1px solid #ffcc02; }  /* expirado: amarillo */
.badge-opcion { background: #e3f2fd; color: #1565c0; }
.badge-tipo-alquiler { background: #e8f5e9; color: #2e7d32; font-size:10px; }
.badge-tipo-opcion { background: #e3f2fd; color: #1565c0; font-size:10px; }
.badge-tipo-renting { background: #f3e8ff; color: #7c3aed; font-size:10px; }

.table-scroll { overflow-y: auto; flex: 1; }

.table-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--white);
  border-radius: 0 0 10px 10px;
}

.page-size-select {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text);
}

/* ── DETAIL PANEL ── */
.detail-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-close {
  width: 26px; height: 26px;
  border: none;
  background: var(--gray-light);
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

.detail-close:hover { background: var(--border); }

.detail-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.detail-body { flex: 1; overflow-y: auto; padding: 0; }

.detail-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-light);
}

.detail-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 4px 0;
  gap: 8px;
}

.detail-row-label {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 90px;
}

.detail-row-value {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

.detail-actions {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: var(--white);
}

.detail-notes {
  padding: 12px 16px;
}

.detail-notes textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px;
  font-family: inherit;
  font-size: 12px;
  resize: none;
  color: var(--text);
  outline: none;
}

.detail-notes textarea:focus { border-color: var(--teal); }

/* ── CLIENTES VIEW ── */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.client-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}

.client-card:hover {
  border-color: var(--teal);
  box-shadow: 0 2px 12px rgba(0,140,149,.1);
}

.client-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.client-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.client-card-stats {
  display: flex;
  gap: 12px;
}

.client-stat {
  font-size: 11px;
  color: var(--text-muted);
}

.client-stat strong {
  font-size: 13px;
  color: var(--teal);
  display: block;
}

/* ── CONFIG VIEW ── */
.config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.config-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.config-card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.config-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.config-card-body { padding: 4px 0; max-height: 510px; overflow-y: auto; }

/* ── Tabs Configuración ── */
.cfg-tabs-nav {
  display: flex;
  gap: 6px;
  background: #eeece8;
  border-radius: 10px;
  padding: 5px;
  margin-bottom: 20px;
  border-bottom: none;
  width: fit-content;
}
.cfg-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  transition: color .15s, background .15s, box-shadow .15s;
  white-space: nowrap;
}
.cfg-tab-btn:hover:not(.active) { color: var(--text); background: rgba(255,255,255,.5); }
.cfg-tab-btn.active { color: var(--teal); background: var(--white); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.cfg-tab-panel { display: none; }
.cfg-tab-panel.active { display: block; animation: fadeInUp .18s ease; }
@keyframes fadeInUp { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.cfg-inline-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  height: 28px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  width: 200px;
  transition: border-color .15s;
  box-sizing: border-box;
}
.cfg-inline-input:focus { border-color: var(--teal); }
/* Badge candado — misma altura que btn-sm */
.lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #d97706;
  font-size: .75rem;
  font-weight: 700;
  vertical-align: middle;
}

/* ── Sub-tabs dentro de Catálogo ── */
.cfg-subtabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 18px;
}
.cfg-subtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-family: inherit;
  transition: color .15s;
  white-space: nowrap;
}
.cfg-subtab:hover:not(.active) { color: var(--text); }
.cfg-subtab.active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 600; }
.cfg-subtab-count {
  background: var(--teal-light);
  color: var(--teal);
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
}
.cfg-subtab:not(.active) .cfg-subtab-count { background: #eeece8; color: var(--muted); }
.cfg-subpanel { display: none; }
.cfg-subpanel.active { display: block; animation: fadeInUp .15s ease; }

.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  border-bottom: 1px solid var(--gray-light);
  font-size: 12px;
  break-inside: avoid;
}

.config-item:last-child { border-bottom: none; }

.config-item-name { color: var(--text); flex: 1; }
.config-item-count { color: var(--text-muted); font-size: 11px; margin-right: 8px; }

.config-add-row {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}

.config-add-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-family: inherit;
  font-size: 12px;
  outline: none;
}

.config-add-input:focus { border-color: var(--teal); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: 12px;
  width: min(620px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}

.modal-title { font-size: 15px; font-weight: 600; flex: 1; }

.modal-close {
  width: 28px; height: 28px;
  border: none;
  background: var(--gray-light);
  border-radius: 7px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}

.modal-close:hover { background: var(--border); }

.modal-body { padding: 18px 22px; }
.modal-footer {
  padding: 12px 22px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--white);
  z-index: 2;
}

.form-sections { display: flex; flex-direction: column; gap: 18px; }

.form-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-light);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-1 { grid-template-columns: 1fr; }

.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.span-2 { grid-column: span 2; }

.form-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-input, .form-select {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  outline: none;
  background: var(--white);
  transition: border-color .15s;
}

.form-input:focus, .form-select:focus { border-color: var(--teal); }

/* ── USER MANAGEMENT ── */
.users-table { width:100%; border-collapse:collapse; font-size:12px; }
.users-table th { background:#eef0f1; padding:13px 14px; text-align:left; font-weight:700; font-size:10px; text-transform:uppercase; letter-spacing:.07em; color:var(--text-muted); border-bottom:2px solid var(--border); white-space:nowrap; }
.users-table td { padding:11px 14px; border-bottom:1px solid var(--gray-light); color:var(--text); vertical-align:middle; }
.users-table tr:last-child td { border-bottom:none; }
.users-table tr:hover td { background:#f9fbfb; }
.role-badge { display:inline-block; padding:2px 8px; border-radius:10px; font-size:10px; font-weight:700; }
.role-admin { background:#e8f4fd; color:#1565c0; }
.role-editor { background:#e8f5e9; color:#2e7d32; }
.role-consulta { background:#f3e5f5; color:#6a1b9a; }
.status-badge { display:inline-block; padding:2px 8px; border-radius:10px; font-size:10px; font-weight:700; }
.status-active { background:#e8f5e9; color:#2e7d32; }
.status-inactive { background:#fce4e4; color:#c62828; }

/* Login screen */
#loginScreen { position:fixed; inset:0; background:var(--gray-light); z-index:5000; display:flex; align-items:center; justify-content:center; }
.login-card { background:white; border-radius:16px; width:min(400px,92vw); padding:36px 32px; box-shadow:0 24px 64px rgba(0,0,0,.15); text-align:center; }
.login-logo { font-size:2rem; margin-bottom:8px; }
.login-title { font-size:20px; font-weight:700; color:var(--text); margin-bottom:4px; }
.login-sub { font-size:12px; color:var(--text-muted); margin-bottom:24px; }
.login-field { text-align:left; margin-bottom:14px; }
.pass-wrap { position:relative; }
.pass-wrap .login-input { padding-right:38px; }
.pass-eye { position:absolute; right:11px; top:50%; transform:translateY(-50%); background:none; border:none; cursor:pointer; color:#aaa; padding:0; line-height:1; }
.pass-eye:hover { color:var(--teal); }
.login-label { font-size:11px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:.05em; display:block; margin-bottom:5px; }
.login-input { width:100%; border:1.5px solid var(--border); border-radius:9px; padding:10px 14px; font-family:inherit; font-size:13px; outline:none; transition:border-color .15s; }
.login-input:focus { border-color:var(--teal); }
.login-error { font-size:11px; color:var(--red); min-height:16px; margin-bottom:10px; text-align:center; }
.login-btn { width:100%; padding:11px; border-radius:9px; border:none; background:var(--teal); color:white; font-family:inherit; font-size:14px; font-weight:600; cursor:pointer; transition:background .15s; }
.login-btn:hover { background:var(--teal-dark); }

/* Profile modal */
#profileModal { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:3000; display:none; align-items:center; justify-content:center; }
#profileModal.open { display:flex; }

.auth-modal {
  background: var(--white);
  border-radius: 14px;
  width: min(380px, 92vw);
  padding: 32px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
}

.auth-icon { font-size: 2.2rem; margin-bottom: 12px; }
.auth-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.auth-subtitle { font-size: 12px; color: var(--text-muted); margin-bottom: 22px; line-height: 1.5; }

.auth-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13px;
  text-align: center;
  letter-spacing: .1em;
  outline: none;
  margin-bottom: 6px;
}

.auth-input:focus { border-color: var(--teal); }
.auth-error { font-size: 11px; color: var(--red); min-height: 16px; margin-bottom: 10px; }

.auth-btn-primary {
  width: 100%;
  padding: 10px;
  border-radius: 9px;
  border: none;
  background: var(--teal);
  color: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background .15s;
}

.auth-btn-primary:hover { background: var(--teal-dark); }

.auth-btn-secondary {
  width: 100%;
  padding: 10px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s;
}

.auth-btn-secondary:hover { border-color: var(--teal); color: var(--teal); }
.auth-hint { font-size: 11px; color: var(--gray-mid); margin-top: 14px; line-height: 1.5; }

/* ── READ-ONLY BANNER ── */
.readonly-banner {
  background: #fff8e1;
  border-bottom: 1px solid #ffe082;
  padding: 8px 24px;
  font-size: 12px;
  color: #f57f17;
  display: none;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.readonly-banner.show { display: flex; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  white-space: nowrap;
  transition: opacity .4s;
}

/* ── CFG ERROR MODAL ── */
#cfgErrModal { position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:2000;display:none;align-items:center;justify-content:center; }
#cfgErrModal.open { display:flex; }
.cfg-err-box { background:white;border-radius:12px;width:min(500px,94vw);max-height:80vh;overflow-y:auto;padding:24px;box-shadow:0 20px 60px rgba(0,0,0,.2); }
.cfg-err-title { font-size:14px;font-weight:700;margin-bottom:12px;color:var(--text); }
.cfg-err-list { font-size:12px;color:var(--text-muted);max-height:300px;overflow-y:auto; }
.cfg-err-item { padding:6px 0;border-bottom:1px solid var(--gray-light); }

/* Drive success modal */
#driveSuccessModal { position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:2000;display:none;align-items:center;justify-content:center; }
#driveSuccessModal.open { display:flex; }
#driveErrModal { position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:2000;display:none;align-items:center;justify-content:center; }
#driveErrModal.open { display:flex; }
#driveConfigModal { position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:2000;display:none;align-items:center;justify-content:center; }
#driveConfigModal.open { display:flex; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-dark); }

/* Unsaved indicator */
#unsavedDot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--orange);
  display: none;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ── RENTING BBVA ─────────────────────────────────────────────── */
.renting-bbva-section {
  background: rgba(124, 58, 237, 0.04);
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 8px;
  padding: 12px !important;
  margin-top: 4px;
}

.cuota-bbva {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: #7c3aed;
}
.cuota-bbva-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  background: #f3e8ff;
  color: #7c3aed;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

/* Renting dashboard card */
.renting-dash-card {
  border: 1px solid rgba(124, 58, 237, 0.2);
  border-radius: 12px;
  background: #fff;
}
.renting-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border: 1px solid #ede9fe;
  border-radius: 10px;
  overflow: hidden;
}
.renting-kpi-item {
  background: #faf5ff;
  border-radius: 0;
  padding: 12px 14px;
  border-left: none;
  border-right: 1px solid #ede9fe;
  text-align: center;
}
.renting-kpi-item:last-child { border-right: none; }
.renting-kpi-item.orange { border-left: none; }
.renting-kpi-val {
  font-size: 28px;
  letter-spacing: -.3px;
  font-weight: 700;
  color: #7c3aed;
}
.renting-kpi-item.orange .renting-kpi-val { color: #c8572a; }
.renting-kpi-lbl {
  font-size: 10px;
  color: #75787B;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}
.renting-modelo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.renting-modelo-card {
  background: #f8f8f8;
  border-radius: 8px;
  padding: 10px 12px;
}
.renting-modelo-card-title {
  font-size: 11px;
  font-weight: 600;
  color: #75787B;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.renting-modelo-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
}
.renting-modelo-row span:last-child { font-weight: 600; }

@media (max-width: 768px) {
  .renting-kpi-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .renting-modelo-grid { grid-template-columns: 1fr; }
}

/* ── Dashboard: contenedor centrado estilo Holded ── */
#viewDashboard {
  background: #f5f4f0;
}
#viewDashboard .card-header {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.dash-center-wrap {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ── Dashboard: KPIs estilo Holded (grid inline en JS) ── */
.home-kpi-card {
  background: var(--white);
  border: none;
  border-radius: 0;
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.home-kpi-card.accent-teal  { border-top: none; }
.home-kpi-card.accent-green { border-top: none; }
.home-kpi-card.accent-orange{ border-top: none; }
.home-kpi-card .kpi-label {
  font-size: 14px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  margin-bottom: 3px;
}
.home-kpi-card .kpi-sub-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 400;
}
.home-kpi-card .kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 10px;
  letter-spacing: -.5px;
}
.home-kpi-card .kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.home-kpi-card .kpi-donut-wrap {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
}
.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}
.kpi-trend.up   { background: #dcfce7; color: #15803d; }
.kpi-trend.down { background: #fee2e2; color: #b91c1c; }
.kpi-trend.flat { background: #f1f5f9; color: #64748b; }

/* ── Dashboard: dash-grid y dash-card sin borde pesado ── */
#viewDashboard .dash-grid {
  gap: 12px;
  margin-bottom: 12px;
}
#viewDashboard .dash-card {
  border-radius: 10px;
  border: 1px solid #e8e8e8;
  background: var(--white);
}
#viewDashboard .renting-dash-card {
  border-radius: 10px;
  margin-top: 0;
}
#viewDashboard .dash-card-header {
  border-bottom: 1px solid #f0f0f0;
  padding: 12px 16px;
}
#viewDashboard .dash-card-body {
  padding: 10px 16px;
}
#viewDashboard .dash-tab-bar {
  margin-bottom: 16px;
}
#viewDashboard .dash-tab-hint {
  margin-top: 12px;
  border: 1px dashed #e0e0e0;
  background: transparent;
}

@media (max-width: 1200px) {
  .dash-center-wrap { max-width: 100%; }
  #viewDashboard .card-header { max-width: 100%; }
}
@media (max-width: 900px) {
  .home-kpi-card .kpi-value { font-size: 26px; }
}
@media (max-width: 600px) {
  .dash-tab { padding: 9px 10px; font-size: 11px; }
}

.dash-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin: 0 0 20px;
}
.dash-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 9px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s;
}
.dash-tab svg { flex-shrink: 0; }
.dash-tab:hover { color: var(--text); }
.dash-tab.active { color: var(--teal); border-bottom-color: var(--teal); }

.dash-tab-panel { display: none; }
.dash-tab-panel.active { display: block; }

/* ── Dashboard: Action items (acciones pendientes) ── */
.dash-action-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-light);
  cursor: pointer;
  transition: background .1s;
}
.dash-action-item:last-child { border-bottom: none; }
.dash-action-item:hover { background: var(--gray-light); margin: 0 -16px; padding: 10px 16px; }
.dash-action-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.dash-action-icon svg { width: 14px; height: 14px; }
.dash-action-text { flex: 1; font-size: 12px; color: var(--text); }
.dash-action-count { font-size: 20px; font-weight: 700; flex-shrink: 0; min-width: 28px; text-align: right; }
.dash-action-arrow { color: var(--text-muted); font-size: 14px; flex-shrink: 0; }

/* ── Dashboard: Retención y Churn (contenido inline en JS) ── */

/* ── Dashboard: Hint tab Análisis ── */
.dash-tab-hint {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--white); border: 1px dashed var(--border);
  border-radius: 10px; padding: 12px 16px; margin-top: 14px;
  font-size: 12px; color: var(--text-muted);
}
.dash-tab-hint a { font-size: 11px; color: var(--teal); text-decoration: none; }

@media (max-width: 900px) {
}
@media (max-width: 600px) {
  .dash-tab { padding: 9px 10px; font-size: 11px; }
}

/* ── Dashboard: Distribución en Resumen (compacta, sin excluidos) ── */
.dash-dist-compact .dash-excluidos { display: none; }


.dash-donas-section {
  margin-top: 16px;
}
.dash-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.dash-donas-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.dash-dona-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dash-dona-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  align-self: flex-start;
  width: 100%;
}
.dash-dona-wrap {
  position: relative;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.dash-dona-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.dash-dona-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.dash-dona-sub {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
}
.dash-dona-legend {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dash-dona-leg-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text);
}
.dash-dona-leg-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dash-dona-leg-pct {
  margin-left: auto;
  font-size: 9px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Dashboard: Fila inferior (sparkline + top farmacias) ── */
.dash-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.dash-spark-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 54px;
  margin-bottom: 6px;
}
.dash-spark-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: var(--gray-light);
  min-width: 0;
}
.dash-spark-bar.current { background: var(--teal); }
.dash-spark-bar.prev { background: #80cdd1; }
.dash-spark-labels {
  display: flex;
  gap: 4px;
}
.dash-spark-lbl {
  flex: 1;
  text-align: center;
  font-size: 9px;
  color: var(--text-muted);
}
.dash-spark-lbl.current { color: var(--teal); font-weight: 700; }
.dash-spark-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-light);
  font-size: 11px;
  color: var(--text-muted);
}
.dash-spark-total strong { font-size: 13px; font-weight: 700; color: var(--teal); }
.dash-farm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--gray-light);
}
.dash-farm-row:last-child { border-bottom: none; }
.dash-farm-rank { font-size: 10px; color: var(--text-muted); width: 14px; flex-shrink: 0; }
.dash-farm-name { font-size: 11px; color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-farm-bar-wrap { width: 60px; flex-shrink: 0; }
.dash-farm-track { height: 4px; background: var(--gray-light); border-radius: 2px; }
.dash-farm-fill { height: 4px; border-radius: 2px; background: var(--teal); }
.dash-farm-val { font-size: 11px; color: var(--teal); font-weight: 600; width: 58px; text-align: right; flex-shrink: 0; }

/* ── Dashboard: filter pills equipos ── */
.dash-filter-pills { display: flex; gap: 5px; margin-bottom: 10px; flex-wrap: wrap; }
.dash-fpill {
  font-size: 10px; padding: 2px 7px; border-radius: 20px;
  font-weight: 600; border: 1px solid;
}
.dash-fpill-on  { background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7; }
.dash-fpill-off { background: var(--gray-light); color: var(--text-muted); border-color: var(--border); text-decoration: line-through; opacity: .55; }

/* Excluidos note */
.dash-excluidos {
  margin-top: 10px; padding: 7px 10px;
  background: var(--gray-light); border-radius: 7px;
  font-size: 10px; color: var(--text-muted);
}
.dash-excluidos-row { display: flex; justify-content: space-between; padding: 2px 0; }

@media (max-width: 1100px) {
  .dash-donas-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .dash-donas-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-bottom-grid { grid-template-columns: 1fr; }
}

/* ── Edit Modal: Read-only mode ── */
#editModal .edit-field[readonly],
#editModal .edit-field[disabled] {
  background: #f8f7f5 !important;
  cursor: default;
  color: #1a1a18;
}
#editModal .edit-field[readonly]:focus,
#editModal .edit-field[disabled]:focus {
  outline: none;
  box-shadow: none;
  border-color: #e0ddd8;
}

/* Pack info box */
#editPackInfo {
  background: #f3e8ff;
  border-radius: 8px;
  font-size: 11px;
  color: #7c3aed;
  line-height: 1.6;
}

/* ── Edit Modal Tabs ── */
.edit-tabs {
  display: flex;
  border-bottom: 1px solid #f0ede8;
  padding: 0 16px;
  background: #fafaf8;
  overflow-x: auto;
  scrollbar-width: thin;
}
.edit-tabs::-webkit-scrollbar { height: 4px; }
.edit-tabs::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 2px; }
.edit-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: #75787B;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.edit-tab:hover { color: #1a1a18; }
.edit-tab.active {
  font-weight: 700;
  color: #008C95;
  border-bottom-color: #008C95;
}
.edit-tab.active svg { opacity: 1; }
.edit-tab svg { opacity: 0.5; }

.edit-tab-panel { display: none; }
.edit-tab-panel.active { display: block; }

/* Modal cliente: más ancho para acomodar 7 tabs y mejorar legibilidad */
#clienteModal .modal { width: min(800px, 95vw); }

/* ═══════════════════════════════════════════════════════════════ */
/* ── RESOLUCIÓN DE CONTRATOS ─────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════ */

/* Expired row in table - gradient across ALL columns */
#contratosBody tr:has(.badge-expired) {
  background: linear-gradient(90deg, #fef2f2 0%, #fff5f5 60%, transparent 100%);
}
#contratosBody tr:has(.badge-expired):hover {
  background: linear-gradient(90deg, #fee2e2 0%, #fef2f2 60%, #fafafa 100%);
}

/* badge-expired defined above in Design Tokens */

/* Resolution badges */
.badge-resol-ret {
  background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0;
  font-size: .65rem; padding: 2px 8px; border-radius: 10px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.badge-resol-ret svg { width: 11px; height: 11px; flex-shrink: 0; }
.badge-resol-churn {
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
  font-size: .65rem; padding: 2px 8px; border-radius: 10px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.badge-resol-churn svg { width: 11px; height: 11px; flex-shrink: 0; }
.badge-resol-pend {
  background: #fffbeb; color: #92400e; border: 1px solid #fde68a;
  font-size: .65rem; padding: 2px 8px; border-radius: 10px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.badge-resol-pend svg { width: 11px; height: 11px; flex-shrink: 0; }

/* Detail panel - expired header */
.detail-expired {
  border-top: 3px solid #ef4444 !important;
}
.detail-expired .detail-header {
  background: linear-gradient(180deg, #fef2f2 0%, transparent 100%);
}

/* Resolution section in detail */
.resolucion-section {
  background: #fefce8; border-radius: 10px; padding: 12px 14px; border: 1px solid #fde68a;
}
.resolucion-section .detail-section-title { display: flex; align-items: center; gap: 6px; }
.resolucion-section .detail-section-title svg { width: 14px; height: 14px; }

/* Resolution modal */
#resolModal { z-index: 10001; }
#resolModal .modal { border-top: 3px solid var(--teal); }

.resol-contract-info {
  background: var(--bg); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px;
  border: 1px solid var(--border);
}
.resol-info-name { font-weight: 600; font-size: 13px; color: var(--text); }
.resol-info-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

.resol-question {
  font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 10px;
}

/* Two-panel layout */
.resol-panels { display: flex; gap: 12px; }
.resol-panel {
  flex: 1; border-radius: 10px; padding: 12px; border: 1px solid;
}
.resol-panel-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 10px; display: flex; align-items: center; gap: 5px;
}
.resol-panel-title svg { flex-shrink: 0; }

.resol-card {
  padding: 10px 12px; border: 1.5px solid var(--norm-border); border-radius: 8px;
  cursor: pointer; background: #fff; transition: all .12s; margin-bottom: 6px;
}
.resol-card:last-child { margin-bottom: 0; }
.resol-card:hover { border-color: var(--sel-border); }
.resol-card.selected {
  border: 2px solid var(--sel-border); background: var(--sel-bg);
}
.resol-card-row { display: flex; align-items: center; gap: 8px; }
.resol-card-icon { flex-shrink: 0; display: flex; align-items: center; }
.resol-card-icon svg { width: 18px; height: 18px; }
.resol-card-label { font-size: 13px; font-weight: 600; color: var(--text); }
.resol-card-desc { font-size: 11px; color: var(--muted); margin-top: 2px; margin-left: 24px; line-height: 1.3; }

@media (max-width: 520px) {
  .resol-panels { flex-direction: column; }
}

/* Dashboard retention card */
.ret-kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
.ret-kpi-item { text-align: center; }
.ret-kpi-val { font-size: 22px; font-weight: 800; line-height: 1.2; }
.ret-kpi-label { font-size: 11px; font-weight: 600; color: var(--text); margin-top: 2px; }
.ret-kpi-sub { font-size: 10px; color: var(--muted); margin-top: 1px; }

@media (max-width: 768px) {
  .ret-kpi-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* btn-sm */
.btn-sm { font-size: 11px !important; padding: 4px 10px !important; }

/* Resolve button in table */
.resol-resolve-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: 10px; cursor: pointer;
  font-size: .65rem; font-weight: 600; font-family: inherit;
  color: #92400e; background: #fffbeb; border: 1px solid #fde68a;
  transition: all .15s; vertical-align: middle;
  line-height: 1.4;
}
.resol-resolve-btn:hover {
  background: #fef3c7; border-color: #f59e0b; color: #78350f;
}
.resol-cell-wrap { display: inline-flex; align-items: center; gap: 4px; }

/* ═══ VIEW HEADERS (inline with teal border) ═══ */
.view-banner {
  padding: 14px 24px 12px;
  margin: -20px -24px 16px;
  background: #fff;
  border-bottom: 3px solid var(--teal);
  display: flex;
  align-items: center;
  gap: 14px;
}
.banner-content { display: flex; align-items: center; gap: 14px; flex: 1; }
.banner-text { flex-shrink: 0; }
.banner-title { font-size: 17px; font-weight: 700; color: var(--text); }
.banner-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.banner-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.banner-chip {
  padding: 4px 10px; border-radius: 8px; text-align: center;
  background: var(--teal-light); border: 1px solid rgba(0,140,149,.15);
}
.banner-chip-val { font-size: 15px; font-weight: 700; color: var(--teal); line-height: 1.2; }
.banner-chip-val.warn { color: #f59e0b; }
.banner-chip-label { font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 1px; }
.banner-teal, .banner-dark { /* no longer colored - unified white */ }

@media (max-width: 768px) {
  .view-banner { flex-direction: column; align-items: flex-start; }
  .banner-chips { margin-left: 0; margin-top: 8px; }
}

/* ── AVERÍAS ─────────────────────────────────────────────────────── */
/* badge-open/closed/pending: see Design Tokens below */
.nav-badge.red { background: #e53935; }
.equipo-wiz-option { border:2px solid var(--border);border-radius:8px;padding:10px 14px;cursor:pointer;display:flex;align-items:center;gap:10px;transition:all .15s;margin-bottom:8px; }
.equipo-wiz-option:hover { border-color:var(--teal);background:var(--teal-light); }
.wiz-result-item { padding:10px 14px;cursor:pointer;display:flex;align-items:center;gap:10px;border-bottom:1px solid #f4f4f4;transition:background .1s; }
.wiz-result-item:hover { background:var(--teal-light); }
.wiz-result-item:last-child { border-bottom:none; }
.kpi-label { font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--gray-dark);margin-bottom:6px; }
.kpi-value { font-size:26px;font-weight:700;line-height:1; }
.kpi-value.red    { color:#e53935; }
.kpi-value.orange { color:#f57c00; }
.kpi-value.green  { color:#2e7d32; }
.kpi-sub  { font-size:11px;color:var(--gray-dark);margin-top:3px; }


/* ═══════════════════════════════════════════════════════
   SIDEBAR COLLAPSE — estilo Holded
   ═══════════════════════════════════════════════════════ */

/* Variable para ancho colapsado */
:root {
  --sidebar-w-collapsed: 56px;
}

/* Transición suave en el sidebar */
.sidebar {
  transition: width .22s cubic-bezier(.4,0,.2,1);
  overflow: visible;
  position: relative;
}

/* Textos y logo-text se ocultan con fade */
.sidebar .nav-label,
.sidebar .sidebar-logo-text,
.sidebar .sidebar-user-info,
.sidebar .sidebar-user + svg,
.sidebar-user > svg {
  transition: opacity .18s ease, width .22s ease;
  overflow: hidden;
  white-space: nowrap;
}

/* Logo text wrapper */
.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Botón collapse ── */
.sidebar-collapse-btn {
  position: absolute;
  top: 18px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #1e3245;
  border: 2px solid #16202e;
  color: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, background .15s ease;
  padding: 0;
}

.sidebar-collapse-btn svg {
  width: 12px;
  height: 12px;
}

.sidebar-collapse-btn:hover {
  background: var(--teal);
  color: #fff;
}

/* Mostrar botón al hacer hover sobre el sidebar */
.sidebar:hover .sidebar-collapse-btn {
  opacity: 1;
  pointer-events: auto;
}

/* ── Estado COLAPSADO ── */
.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
  max-width: 0;
  overflow: hidden;
  pointer-events: none;
}

.sidebar.collapsed .sidebar-logo-text {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.sidebar.collapsed .sidebar-user-info {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.sidebar.collapsed .sidebar-user > svg {
  opacity: 0;
  width: 0;
}

/* Ocultar versión y badges cuando colapsado */
.sidebar.collapsed .nav-badge {
  display: none !important;
}

.sidebar.collapsed [style*="padding:6px 18px"] {
  display: none;
}

/* Centrar iconos cuando colapsado */
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 7px 0;
  gap: 0;
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
  max-width: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  left: -9999px;
}

.sidebar.collapsed .sidebar-logo {
  justify-content: center;
  padding: 16px 0;
}

.sidebar.collapsed .sidebar-user {
  justify-content: center;
  padding: 8px 0;
}

/* Tooltip via JS (#sidebarTooltip) — el ::after CSS fue eliminado para evitar duplicados */


/* ── Logo dual: full / icon ── */
.sidebar-logo-icon { display: none !important; }
.sidebar-logo-full { display: block; }

.sidebar.collapsed .sidebar-logo-full { display: none !important; }
.sidebar.collapsed .sidebar-logo-icon { display: block !important; }

/* Quitar el texto "InnovaSalus" que aparecía (sidebar-logo-text ya no existe pero por si acaso) */
.sidebar-logo-text { display: none !important; }

/* ═══════════════════════════════════════════════════════
   SIDEBAR FIXES v2 — logo blanco, tooltip hover, bottom
   ═══════════════════════════════════════════════════════ */

/* Versión pequeña */
.sidebar-version {
  padding: 4px 18px 2px;
  font-size: 10px;
  color: rgba(255,255,255,.35);
  letter-spacing: .04em;
  transition: opacity .18s ease;
}
.sidebar.collapsed .sidebar-version { opacity: 0; pointer-events: none; }

/* Botón cerrar sesión */
.sidebar-logout-wrap { padding: 4px 10px 10px; }
.sidebar-logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid rgba(255,80,80,.35);
  background: rgba(255,80,80,.08);
  color: rgba(255,120,120,.9);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-logout-btn.hov,
.sidebar-logout-btn:hover { background: rgba(255,80,80,.2); }

/* Colapsado: logout solo icono centrado */
.sidebar.collapsed .sidebar-logout-btn {
  padding: 7px 0;
  justify-content: center;
}
.sidebar.collapsed .sidebar-logout-btn .nav-label {
  width: 0; opacity: 0; pointer-events: none;
}

/* Usuario colapsado: centrar avatar */
.sidebar.collapsed .sidebar-user {
  justify-content: center;
  padding: 10px 0;
}
.sidebar.collapsed .sidebar-user-chevron {
  display: none;
}

/* tooltip movido a JS */

/* Logo colapsado: fondo blanco con borde redondeado, centrado */
.sidebar.collapsed .sidebar-logo {
  margin: 10px 6px 6px 6px;
  padding: 8px 6px;
  justify-content: center;
  border-radius: 12px;
}


/* ═══════════════════════════════════════════════════════
   SIDEBAR — Correcciones v2
   ═══════════════════════════════════════════════════════ */

/* 1. ZONA LOGO — fondo blanco (border-radius definido arriba, no duplicar) */

/* 2. TOOLTIPS via JS (#sidebarTooltip) — CSS ::after eliminado para evitar duplicados */

/* 3. LOGOUT colapsado — centrar icono, ocultar texto */
.sidebar.collapsed .sidebar-logout-wrap {
  padding: 4px 0 10px;
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .sidebar-logout-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255,80,80,.12);
  color: rgba(255,100,100,.8);
}

.sidebar.collapsed .sidebar-logout-btn .nav-label {
  display: none;
}

/* 4. USUARIO colapsado — centrar avatar */
.sidebar.collapsed .sidebar-user {
  justify-content: center;
  padding: 8px 0;
}

.sidebar.collapsed .sidebar-user .sidebar-user-info,
.sidebar.collapsed .sidebar-user .sidebar-user-chevron {
  display: none;
}


/* tooltips v2 movidos a JS */


/* ── Tooltip flotante JS (sidebar collapsed) ── */
#sidebarTooltip {
  position: fixed;
  background: #1e3245;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 99999;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.1);
  display: none;
  transform: translateY(-50%);
}
#sidebarTooltip.logout {
  color: rgba(255,120,120,.95);
  border-color: rgba(255,80,80,.25);
}


/* ═══════════════════════════════════════════════════
   DESIGN TOKENS — Sistema unificado de badges y texto
   Aplica a: contratos, clientes, equipos, averías (desktop + mobile)
   ═══════════════════════════════════════════════════ */

/* Base badge — estructura única para todas las pantallas */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  letter-spacing: .01em;
}

/* ── Tipo de contrato (contratos, averías, equipos) ── */
.badge-tipo-alquiler { background:#e8f5e9; color:#1b5e20; border-color:#a5d6a7; font-size:11px; }
.badge-tipo-renting  { background:#f3e8ff; color:#4a1d96; border-color:#c4b5fd; font-size:11px; }
.badge-tipo-opcion   { background:#e3f2fd; color:#0d47a1; border-color:#90caf9; font-size:11px; }

/* ── Estado contrato ── */
.badge-active  { background:#e8f5e9; color:#1b5e20; border-color:#a5d6a7; }
.badge-expired { background:#fff8e1; color:#e65100; border-color:#ffcc02; }
.badge-cerrado { background:#fce4ec; color:#880e4f; border-color:#f48fb1; }
.badge-baja    { background:#ffebee; color:#b71c1c; border-color:#ef9a9a; }
.badge-sincontrato-activo    { background:#e8f4f5; color:#0F6E56; border-color:#9FE1CB; }
.badge-sincontrato-excliente { background:#FAEEDA; color:#854F0B; border-color:#FAC775; }
.badge-sincontrato-fantasma  { background:#f3f4f6; color:#6b7280; border-color:#D3D1C7; }

/* ── Estado avería ── */
.badge-open    { display:inline-flex; align-items:center; gap:4px; padding:2px 8px; border-radius:6px; font-size:11px; font-weight:600; background:#ffebee; color:#b71c1c; border:1px solid #ef9a9a; }
.badge-pending { display:inline-flex; align-items:center; gap:4px; padding:2px 8px; border-radius:6px; font-size:11px; font-weight:600; background:#fff8e1; color:#e65100; border:1px solid #ffcc02; }
.badge-closed  { display:inline-flex; align-items:center; gap:4px; padding:2px 8px; border-radius:6px; font-size:11px; font-weight:600; background:#e8f5e9; color:#1b5e20; border:1px solid #a5d6a7; }

/* ── Estado equipo ── */
.badge-eq-disponible { background:#e8f5e9; color:#1b5e20; border-color:#a5d6a7; }
.badge-eq-contrato   { background:#e3f2fd; color:#0d47a1; border-color:#90caf9; }
.badge-eq-propiedad  { background:#fff3e0; color:#bf360c; border-color:#ffcc80; }
.badge-eq-baja       { background:#ffebee; color:#b71c1c; border-color:#ef9a9a; }

/* ── Tipo relación en averías ── */
.badge-rel-alquiler  { background:#e8f5e9; color:#1b5e20; border-color:#a5d6a7; font-size:11px; font-weight:600; }
.badge-rel-renting   { background:#f3e8ff; color:#4a1d96; border-color:#c4b5fd; font-size:11px; font-weight:600; }
.badge-rel-propiedad { background:#fff3e0; color:#bf360c; border-color:#ffcc80; font-size:11px; font-weight:600; }
.badge-rel-opcion    { background:#e3f2fd; color:#0d47a1; border-color:#90caf9; font-size:11px; font-weight:600; }

/* ── Tipografía de tabla unificada ── */
tbody td       { padding: 10px 8px; font-size: 12px; color: var(--text); }
tbody td.td-id { font-size: 11px; color: var(--text-muted); }
tbody td.td-sm { font-size: 11px; color: var(--text-muted); }
tbody td.td-id { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
thead th, .th-style {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #3a424f;
  padding: 10px 8px; white-space: nowrap;
}
