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

:root {
  --navy:   #0C1E3D;
  --blue:   #1E3A8A;
  --green:  #16a34a;
  --orange: #d97706;
  --red:    #dc2626;
  --info:   #2563eb;
  --purple: #7c3aed;
  --bg:     #F5F6FA;
  --white:  #FFFFFF;
  --border: #e2e8f0;
  --text:   #1e293b;
  --muted:  #64748b;
  --sidebar-w: 192px;
  --topbar-h:  44px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }

/* ── Layout shell ───────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .logo-title {
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.sidebar-logo .logo-sub {
  color: rgba(255,255,255,0.45);
  font-size: 10px;
  margin-top: 2px;
}

/* Nav sections */
.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-label {
  color: rgba(255,255,255,0.35);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: var(--white);
}

.nav-item.active {
  background: rgba(30, 58, 138, 0.4);
  color: var(--white);
  border-left-color: #60a5fa;
}

.nav-item .nav-icon { font-size: 15px; width: 18px; text-align: center; }
.nav-item .nav-label { flex: 1; }

/* Sidebar avatar */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-avatar {
  display: flex;
  align-items: center;
  gap: 9px;
}

.avatar-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar-photo {
  object-fit: cover;
  background: transparent;
  border: 2px solid rgba(255,255,255,.25);
}

.avatar-info .avatar-name {
  color: var(--white);
  font-size: 12px;
  font-weight: 600;
}

.avatar-info .avatar-role {
  color: rgba(255,255,255,0.4);
  font-size: 10px;
}

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

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.topbar-search {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  gap: 6px;
  width: 220px;
}

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

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

/* ── Page content ───────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-header p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* ── KPI Grid ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border-radius: 10px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.kpi-value.green  { color: var(--green); }
.kpi-value.orange { color: var(--orange); }
.kpi-value.red    { color: var(--red); }
.kpi-value.blue   { color: var(--info); }

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

/* ── Section title ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* ── Empresa cards grid ─────────────────────────────────── */
.empresa-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.empresa-card {
  background: var(--white);
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.15s;
}

.empresa-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.07); }

.empresa-card.estado-activa       { border-left-color: var(--green); }
.empresa-card.estado-implementando { border-left-color: var(--orange); }
.empresa-card.estado-suspendida   { border-left-color: var(--red); }

.empresa-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.empresa-nombre {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.empresa-razon {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.empresa-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green  { background: #dcfce7; color: #15803d; }
.badge-orange { background: #fef3c7; color: #b45309; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-teal   { background: #ccfbf1; color: #0f766e; }

/* ── Progress bar ───────────────────────────────────────── */
.progress-section { display: flex; flex-direction: column; gap: 4px; }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.progress-label strong { color: var(--text); font-weight: 700; }

.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width 0.3s;
}

.progress-fill.low    { background: var(--red); }
.progress-fill.medium { background: var(--orange); }
.progress-fill.high   { background: var(--green); }

/* ── Alert strip ────────────────────────────────────────── */
.alert-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ── Card footer ────────────────────────────────────────── */
.empresa-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.empresa-meta {
  font-size: 11px;
  color: var(--muted);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn:hover { opacity: 0.88; }

.btn-primary { background: var(--info); color: var(--white); }
.btn-claude  { background: var(--purple); color: var(--white); }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--info); border-bottom-color: var(--info); }

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state p { margin-top: 8px; font-size: 13px; }

/* ── Badge extra ────────────────────────────────────────── */
.badge-innecesario { background: #f8fafc; color: #94a3b8; border: 1px solid #e2e8f0; }

/* ── Filter bar ─────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  outline: none;
}

.filter-bar input { flex: 1; min-width: 200px; }
.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--info); }

/* ── Tabs overflow (9 tabs) ─────────────────────────────── */
.tabs {
  overflow-x: auto;
  white-space: nowrap;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

/* ── Ficha header ───────────────────────────────────────── */
.ficha-header {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.ficha-avatar-lg {
  width: 64px; height: 64px;
  border-radius: 14px;
  background: var(--blue);
  color: var(--white);
  font-size: 22px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.ficha-body { flex: 1; display: flex; flex-direction: column; gap: 10px; }

.ficha-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ficha-nombre { font-size: 22px; font-weight: 800; color: var(--text); }
.ficha-razon  { font-size: 13px; color: var(--muted); margin-top: 2px; }

.ficha-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.ficha-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.ficha-meta-item { display: flex; align-items: center; gap: 4px; }
.ficha-meta-item strong { color: var(--text); }

.ficha-progress { display: flex; flex-direction: column; gap: 4px; }

.ficha-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

/* ── Mini KPI grid (empresa dashboard tab) ──────────────── */
.kpi-grid-sm {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card-sm {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card-sm .kpi-label { font-size: 10px; }
.kpi-card-sm .kpi-value { font-size: 26px; }

/* ── Construction placeholder ───────────────────────────── */
.module-placeholder {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
  background: var(--white);
  border-radius: 10px;
  border: 1px dashed var(--border);
}

.module-placeholder .placeholder-icon { font-size: 48px; margin-bottom: 12px; }
.module-placeholder h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.module-placeholder p  { font-size: 13px; margin-top: 4px; }

/* ── Document section ───────────────────────────────────── */
.doc-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.doc-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.doc-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.doc-section-code {
  background: var(--navy);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.doc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}

.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: #fafafa; }

.doc-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  width: 54px;
  flex-shrink: 0;
  font-family: monospace;
}

.doc-nombre {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

.doc-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Doc summary bar ────────────────────────────────────── */
.doc-resumen {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.doc-resumen-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}

.doc-resumen-item strong { font-size: 15px; font-weight: 800; color: var(--text); }
.doc-resumen-sep { color: var(--border); }

/* ── Worker cards ───────────────────────────────────────── */
.worker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.worker-card-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.worker-card-link:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(37,99,235,0.12);
}
.worker-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.worker-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.worker-nombre { font-size: 13px; font-weight: 700; color: var(--text); }
.worker-cargo  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.worker-meta   { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }

/* ── Incident cards ─────────────────────────────────────── */
.incident-list { display: flex; flex-direction: column; gap: 10px; }

.incident-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.incident-card.sev-critica { border-left-color: var(--red); }
.incident-card.sev-alta    { border-left-color: var(--orange); }
.incident-card.sev-media   { border-left-color: var(--info); }
.incident-card.sev-baja    { border-left-color: #94a3b8; }

.incident-info { flex: 1; }
.incident-title { font-size: 14px; font-weight: 700; color: var(--text); }
.incident-meta  { font-size: 11px; color: var(--muted); margin-top: 3px; }
.incident-badges { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Accordion (Registros Vivos) ────────────────────────── */
.accordion { display: flex; flex-direction: column; gap: 10px; }

.accordion-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: #f8fafc;
}

.accordion-header:hover { background: #f1f5f9; }

.accordion-body {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.accordion-body .empty-registros {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Section action bar ─────────────────────────────────── */
.section-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* ── Tab panel ──────────────────────────────────────────── */
.tab-panel { padding-top: 20px; }

/* ── Chart grid ─────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.chart-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

/* ── Alertas grid ───────────────────────────────────────── */
.alertas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.alerta-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.alerta-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.alerta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  gap: 8px;
}

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

.alerta-empresa {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.alerta-nombre { font-size: 13px; font-weight: 600; color: var(--text); }
.alerta-sub    { font-size: 11px; color: var(--muted); }

.success-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #dcfce7;
  color: #15803d;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Empresa lista (sin KPIs) ───────────────────────────── */
.lista-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.lista-toolbar .search-input {
  flex: 1;
  min-width: 240px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  outline: none;
}

.lista-toolbar .search-input:focus { border-color: var(--info); }

.lista-toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  outline: none;
}

.lista-toolbar select:focus { border-color: var(--info); }

.empresa-counter {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}

.empresa-counter strong { color: var(--text); }

/* ── Consultor en card ──────────────────────────────────── */
.card-consultor {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

/* ── Data table ─────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.data-table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #fafafa; }

/* ── Finanzas revenue cards ─────────────────────────────── */
.revenue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.revenue-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  border-top: 3px solid var(--blue);
}
.revenue-card.t-green  { border-top-color: var(--green); }
.revenue-card.t-purple { border-top-color: var(--purple); }
.revenue-card.t-orange { border-top-color: var(--orange); }
.revenue-plan  { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.revenue-value { font-size: 20px; font-weight: 800; color: var(--text); margin-top: 4px; }
.revenue-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Consultor card ─────────────────────────────────────── */
.consultor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.consultor-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}
.consultor-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white);
  font-size: 20px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.consultor-nombre { font-size: 14px; font-weight: 700; color: var(--text); }
.consultor-rol    { font-size: 12px; color: var(--muted); }
.consultor-badges { display: flex; gap: 6px; justify-content: center; }

/* ── Login page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon {
  width: 52px; height: 52px;
  background: var(--blue);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  margin: 0 auto 12px;
}
.login-logo-title { font-size: 20px; font-weight: 800; color: var(--text); }
.login-logo-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.login-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  color: var(--text);
  outline: none;
}
.login-field input:focus { border-color: var(--info); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.login-btn {
  width: 100%;
  padding: 11px;
  background: var(--info);
  color: var(--white);
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}
.login-btn:hover { background: #1d4ed8; }
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: #fff;
  border: 1.5px solid #dadce0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #3c4043;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
  box-sizing: border-box;
  margin-bottom: 4px;
}
.google-btn:hover { background: #f8f9fa; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  color: #94a3b8;
  font-size: 11px;
}
.login-divider::before,
.login-divider::after { content: ''; flex: 1; height: 1px; background: #e2e8f0; }
.login-error {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
  font-weight: 500;
}
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255,255,255,0.4);
  font-size: 11px;
  padding: 8px 0 0;
  cursor: pointer;
  transition: color 0.15s;
}
.sidebar-logout:hover { color: rgba(255,255,255,0.75); }

/* ── Modal overlay ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-card,
.modal-box {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-close { cursor: pointer; font-size: 22px; color: var(--muted); background: none; border: none; line-height: 1; padding: 0; }
.modal-body  { padding: 20px; max-height: 60vh; overflow-y: auto; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

/* ── Form fields ────────────────────────────────────────── */
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  outline: none;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: var(--info); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-field .required-star { color: var(--red); }
.field-error { border-color: var(--red) !important; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Wizard ─────────────────────────────────────────────── */
.wizard-container { max-width: 740px; margin: 0 auto; }
.wizard-steps {
  display: flex;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 24px;
  margin-bottom: 20px;
  gap: 0;
}
.wizard-step { display: flex; align-items: center; gap: 8px; }
.wizard-step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--muted);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.wizard-step.active .wizard-step-num { background: var(--info); color: var(--white); }
.wizard-step.done   .wizard-step-num { background: var(--green); color: var(--white); }
.wizard-step-label  { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.wizard-step.active .wizard-step-label { color: var(--info); }
.wizard-step.done   .wizard-step-label { color: var(--green); }
.wizard-connector { flex: 1; height: 2px; background: #e2e8f0; margin: 0 8px; min-width: 12px; }
.wizard-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  margin-bottom: 16px;
}
.wizard-panel h2 { font-size: 16px; font-weight: 700; margin-bottom: 20px; color: var(--text); }
.wizard-nav { display: flex; justify-content: space-between; margin-top: 24px; }

/* ── Segmentación factores ──────────────────────────────── */
.factor-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}
.factor-row:last-child { border-bottom: none; }
.factor-label { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); }
.factor-sub   { font-size: 11px; color: var(--muted); margin-top: 1px; }
.factor-select { width: 200px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* ── Carga result ────────────────────────────────────────── */
.carga-display { text-align: center; padding: 20px 0 12px; }
.carga-number  { font-size: 72px; font-weight: 900; line-height: 1; transition: color 0.3s; }
.carga-label   { font-size: 13px; color: var(--muted); margin-top: 6px; }
.carga-msg     { font-size: 14px; font-weight: 600; margin-top: 10px; }
.carga-breakdown { margin-top: 20px; }
.carga-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.carga-bar-label { width: 160px; color: var(--muted); text-align: right; }
.carga-bar-track { flex: 1; height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.carga-bar-fill  { height: 100%; border-radius: 999px; background: var(--info); transition: width 0.4s; }
.carga-bar-val   { width: 30px; font-weight: 700; color: var(--text); }

/* ── Consultor selector ─────────────────────────────────── */
.consultor-options { display: flex; flex-direction: column; gap: 10px; }
.consultor-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.consultor-option:hover   { border-color: var(--info); }
.consultor-option.selected { border-color: var(--info); background: #eff6ff; }
.consultor-option-info { flex: 1; }
.consultor-option-name  { font-size: 13px; font-weight: 700; color: var(--text); }
.consultor-option-carga { font-size: 11px; color: var(--muted); margin-top: 2px; }
.co-bar-track { flex: 1; height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.co-bar-fill  { height: 100%; border-radius: 999px; }

/* ── Summary grid ───────────────────────────────────────── */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary-item { background: #f8fafc; border-radius: 8px; padding: 12px 14px; }
.summary-label { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing:.04em; }
.summary-value { font-size: 14px; font-weight: 700; color: var(--text); margin-top: 3px; }

/* ── Timeline ────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.timeline-body { flex: 1; }
.timeline-text { font-size: 13px; color: var(--text); font-weight: 500; }
.timeline-rel  { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Consultor carga bars ────────────────────────────────── */
.carga-consultor-item { margin-bottom: 16px; }
.carga-consultor-header { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 13px; }
.carga-consultor-name  { font-weight: 700; color: var(--text); }
.carga-consultor-val   { color: var(--muted); font-size: 12px; }
.carga-track { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.carga-fill  { height: 100%; border-radius: 999px; transition: width 0.4s; }
.carga-fill.green  { background: var(--green); }
.carga-fill.orange { background: var(--orange); }
.carga-fill.red    { background: var(--red); }
.carga-consultor-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Two-col layout ─────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel-card { background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
.panel-card-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 14px; }

/* ── Toast notifications ────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--navy); color: #fff;
  padding: 12px 20px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  opacity: 0; transform: translateY(12px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--green); }
.toast-error   { background: var(--red); }

/* ── Badge innecesario ──────────────────────────────────── */
.badge-innecesario { background: #f1f5f9; color: #94a3b8; }

/* ── Summary grid ───────────────────────────────────────── */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary-item { background: var(--bg); border-radius: 8px; padding: 12px 14px; }
.summary-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing:.04em; margin-bottom: 4px; }
.summary-value { font-size: 14px; font-weight: 700; color: var(--text); }

/* ── Data cards (ficha rediseño) ────────────────────────── */
.data-card { background: var(--white); border-radius: 12px; padding: 20px 24px; box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid var(--border); }
.data-row { display: flex; padding: 9px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.data-row:last-child { border-bottom: none; }
.data-label { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; width: 130px; flex-shrink: 0; padding-top: 1px; }
.data-value { font-size: 13px; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-container { background: var(--white); border-radius: 12px; padding: 20px 24px; box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid var(--border); min-height: 280px; display: flex; flex-direction: column; }
.chart-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 14px; }
.kpi-card { min-height: 110px; }

/* ── Clickable empresa cards ────────────────────────────── */
.ecard {
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
  text-decoration: none;
  display: block;
  color: inherit;
}
.ecard:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

/* ── Flash messages ─────────────────────────────────────── */
.flash-msg {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin-bottom: 8px;
  border-radius: 8px; font-size: 13px;
  border-left: 4px solid;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
  animation: slideInRight .25s ease;
}
.flash-success { border-color: #16a34a; color: #15803d; background: #f0fdf4; }
.flash-error   { border-color: #dc2626; color: #991b1b; background: #fef2f2; }
.flash-info    { border-color: #2563eb; color: #1d4ed8; background: #eff6ff; }
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Sidebar notification badge ────────────────────────── */
.badge-alert {
  background: #dc2626; color: #fff;
  border-radius: 10px; padding: 1px 6px;
  font-size: 10px; font-weight: 700;
  margin-left: auto; min-width: 18px;
  text-align: center; line-height: 16px;
  display: inline-block;
}

/* ── Nav progress bar ───────────────────────────────────── */
#nav-progress {
  position: fixed; top: 0; left: 0; height: 3px;
  background: #1E3A8A; width: 0; z-index: 9999;
  transition: width .3s ease;
}

/* ── Skeleton screens ───────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0;
}
@media (max-width: 768px) { .skeleton-kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* ── Button spinner ─────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; margin-right: 4px; }

/* ── Tab loading overlay ────────────────────────────────── */
.tab-loading-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.75); z-index: 10; pointer-events: none;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 48px;
  animation: fadeOverlay .4s ease forwards;
}
.tab-loading-overlay::after {
  content: '';
  width: 28px; height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: #1E3A8A;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes fadeOverlay {
  0%   { opacity: 1; }
  65%  { opacity: .9; }
  100% { opacity: 0; }
}

/* ── Mobile hamburger ───────────────────────────────────── */
.mobile-menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: none; border: none; cursor: pointer; color: #374151;
  border-radius: 6px; flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--bg); }

/* ── Responsive mobile ──────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-menu-btn { display: flex !important; }
  .main-area { width: 100%; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 13px; }
  .topbar-search { display: none; }

  .empresa-grid { grid-template-columns: 1fr; }

  .kpi-grid,
  div[style*="grid-template-columns:repeat(6"],
  div[style*="grid-template-columns:repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  div[style*="grid-template-columns:repeat(2"] {
    grid-template-columns: 1fr !important;
  }

  table {
    display: block; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tabs-cal { overflow-x: auto; }

  .page-content { padding: 16px 12px; }

  .modal-card,
  .modal-box { width: calc(100vw - 24px) !important; margin: 12px; }
}

/* Sidebar visible on mobile when toggled */
.sidebar.mobile-open { display: flex !important; position: fixed; z-index: 800; top: 0; left: 0; height: 100vh; }
