/* ============================================================
   KIS-CRM — Web stylesheet (desktop-first)
   ============================================================ */

:root {
  --primary:        #2563EB;
  --primary-light:  #EFF6FF;
  --primary-dark:   #1E40AF;
  --primary-hover:  #1D4ED8;

  --green:      #16A34A;  --green-bg:  #DCFCE7;
  --red:        #DC2626;  --red-bg:    #FEE2E2;
  --orange:     #D97706;  --orange-bg: #FEF3C7;
  --gray:       #6B7280;  --gray-bg:   #F3F4F6;
  --gray-light: #E5E7EB;

  --text:       #111827;
  --text-muted: #6B7280;
  --bg:         #F1F5F9;
  --surface:    #FFFFFF;
  --border:     #E2E8F0;

  --sidebar-w: 220px;
  --topbar-h:  60px;
  --radius:    10px;
  --radius-sm: 7px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Tema oscuro ─────────────────────────────────────────────── */
body.dark {
  --primary-light:  #1E3A5F;
  --text:           #F1F5F9;
  --text-muted:     #94A3B8;
  --bg:             #0F172A;
  --surface:        #1E293B;
  --border:         #334155;
  --gray-bg:        #1E293B;
  --gray-light:     #334155;
  --green-bg:       #14532D;
  --red-bg:         #7F1D1D;
  --orange-bg:      #78350F;
}
body.dark input,
body.dark select,
body.dark textarea { background: #1E293B; color: var(--text); border-color: var(--border); }
body.dark .modal__overlay { background: rgba(0,0,0,.7); }
body.dark .topbar { background: #1E293B; border-bottom-color: #334155; }

/* Switch tema en sidebar */
.theme-switch {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; margin-bottom: 4px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.theme-switch__label {
  font-size: 12px; color: #94A3B8; display: flex; align-items: center; gap: 6px;
}
.theme-switch__track {
  width: 36px; height: 20px; border-radius: 10px;
  background: #334155; cursor: pointer; position: relative;
  transition: background .2s; flex-shrink: 0; border: none; padding: 0;
}
.theme-switch__track.on { background: var(--primary); }
.theme-switch__thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: white; transition: transform .2s;
  pointer-events: none;
}
.theme-switch__track.on .theme-switch__thumb { transform: translateX(16px); }
body.sidebar-collapsed .theme-switch__label { display: none; }
body.sidebar-collapsed .theme-switch { justify-content: center; padding: 8px 0; }

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── App layout ─────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: #0F172A;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  z-index: 50;
  transition: width .2s ease, min-width .2s ease;
  overflow: hidden;
}

.sidebar__logo {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
#empresa-logo-wrap {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.sidebar__logo-text {
  font-size: 22px;
  font-weight: 800;
  color: white;
  letter-spacing: -1px;
}
.sidebar__logo-sub {
  font-size: 13px;
  font-weight: 500;
  color: #94A3B8;
  margin-left: 1px;
}

.sidebar__nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #94A3B8;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #CBD5E1; }
.nav-item.active {
  background: var(--primary);
  color: white;
}
.nav-item svg { width: 16px; height: 16px; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: 8px 4px;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.sidebar__footer {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar__user { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar__avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary);
  color: white; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar__user-info { min-width: 0; }
.sidebar__user-name {
  color: #F1F5F9; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__user-role { color: #64748B; font-size: 11px; margin-top: 1px; }
.sidebar__logout {
  color: #475569; padding: 6px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.sidebar__logout:hover { color: #F1F5F9; background: rgba(255,255,255,.08); }
.sidebar__logout svg { width: 16px; height: 16px; }

/* ── Sidebar toggle button ──────────────────────────────────── */
.sidebar__toggle {
  margin-left: auto;
  color: #475569;
  padding: 4px;
  border-radius: 5px;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.sidebar__toggle:hover { color: #CBD5E1; background: rgba(255,255,255,.08); }
.sidebar__toggle svg { width: 15px; height: 15px; }

/* ── Sidebar collapsed ──────────────────────────────────────── */
body.sidebar-collapsed { --sidebar-w: 54px; }
body.sidebar-collapsed .sidebar__logo-text,
body.sidebar-collapsed .sidebar__logo-sub { display: none; }
body.sidebar-collapsed .sidebar__logo { justify-content: center; }
body.sidebar-collapsed .sidebar__toggle svg { transform: rotate(180deg); }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 9px 0; }
body.sidebar-collapsed .nav-item span:not(.nav-badge) { display: none; }
body.sidebar-collapsed .nav-badge { position: absolute; top: 3px; right: 3px; min-width: 14px; height: 14px; font-size: 9px; padding: 0 3px; }
body.sidebar-collapsed .sidebar__user-info { display: none; }
body.sidebar-collapsed .sidebar__footer { justify-content: center; padding: 14px 0; }
body.sidebar-collapsed .sidebar__user { justify-content: center; }
body.sidebar-collapsed .sidebar__logout { display: none; }

/* ── Main wrapper ───────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: margin-left .2s ease;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 12px;
  flex-shrink: 0;
}
.topbar__left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
#header-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.topbar__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Main content ───────────────────────────────────────────── */
#main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

/* ── Utilities ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.page   { padding: 28px; max-width: 1200px; }
.page-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 80px 24px; gap: 12px; text-align: center;
}
.page-empty svg { width: 40px; height: 40px; color: var(--gray-light); }
.page-empty p   { color: var(--text-muted); font-size: 14px; }
.page-loader {
  display: flex; align-items: center; justify-content: center; padding: 80px;
}
.page-loader .spinner { border-color: var(--border); border-top-color: var(--primary); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  transition: background .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap; cursor: pointer;
}
.btn:hover { opacity: .9; }
.btn:active { opacity: .8; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); opacity: 1; }
.btn-danger  { background: var(--red);     color: white; }
.btn-success { background: var(--green);   color: white; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--gray-bg); opacity: 1; }
.btn-ghost   { background: var(--gray-bg); color: var(--text); }
.btn-ghost:hover { background: var(--gray-light); opacity: 1; }
.btn-sm  { padding: 5px 12px; font-size: 12.5px; }
.btn-lg  { padding: 10px 22px; font-size: 15px; }
.btn-full { width: 100%; }
.btn-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--gray-bg); color: var(--text); }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-body   { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header__title { font-size: 14px; font-weight: 600; }

/* ── Stats grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card__num   { font-size: 32px; font-weight: 800; line-height: 1; }
.stat-card__label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-card--blue   { border-top: 3px solid var(--primary); }
.stat-card--green  { border-top: 3px solid var(--green); }
.stat-card--red    { border-top: 3px solid var(--red); }
.stat-card--orange { border-top: 3px solid var(--orange); }

/* ── Oportunidad card ───────────────────────────────────────── */
.ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.op-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 8px;
}
.op-card:hover { box-shadow: var(--shadow-md); border-color: #CBD5E1; }
.op-card__top    { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.op-card__name   { font-weight: 600; font-size: 14px; }
.op-card__project{ font-size: 12px; color: var(--text-muted); }
.op-card__meta   { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.op-card__exec   { font-size: 12px; color: var(--text-muted); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .2px;
  white-space: nowrap;
}
.badge--abierta          { background: #DBEAFE; color: #1D4ED8; }
.badge--cerrada_lograda  { background: var(--green-bg); color: var(--green); }
.badge--cerrada_perdida  { background: var(--red-bg);   color: var(--red); }
.badge--borrador         { background: var(--gray-bg);  color: var(--gray); }
.badge--enviada          { background: #EDE9FE; color: #6D28D9; }
.badge--aceptada         { background: var(--green-bg); color: var(--green); }
.badge--rechazada        { background: var(--red-bg);   color: var(--red); }
.badge--alta             { background: var(--red-bg);    color: var(--red); }
.badge--media            { background: var(--orange-bg); color: var(--orange); }
.badge--baja             { background: var(--gray-bg);   color: var(--gray); }
.badge--disponible       { background: var(--green-bg);  color: var(--green); }
.badge--bloqueada        { background: var(--orange-bg); color: var(--orange); }
.badge--reservada        { background: #FEF3C7; color: #B45309; }
.badge--vendida          { background: var(--gray-bg);   color: var(--gray); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px;
}
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-control::placeholder { color: #CBD5E1; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Sections ───────────────────────────────────────────────── */
.section-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-muted);
  margin-bottom: 12px; margin-top: 24px;
}
.section-title:first-child { margin-top: 0; }

/* ── List items ─────────────────────────────────────────────── */
.list-item {
  display: flex; align-items: center; padding: 12px 20px; gap: 12px;
  cursor: pointer; transition: background .1s;
}
.list-item:hover { background: var(--gray-bg); }
.list-item + .list-item { border-top: 1px solid var(--border); }
.list-item__body { flex: 1; min-width: 0; }
.list-item__title { font-weight: 500; font-size: 14px; }
.list-item__sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Task card ──────────────────────────────────────────────── */
.tarea-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start;
  transition: box-shadow .15s;
}
.tarea-card:hover { box-shadow: var(--shadow); }
.tarea-card + .tarea-card { margin-top: 8px; }
.tarea-card__check {
  width: 20px; height: 20px; flex-shrink: 0;
  border: 2px solid var(--border); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; margin-top: 2px;
  transition: all .15s;
}
.tarea-card__check:hover { border-color: var(--green); background: var(--green-bg); }
.tarea-card__body  { flex: 1; min-width: 0; }
.tarea-card__tipo  { font-weight: 600; font-size: 14px; }
.tarea-card__desc  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.tarea-card__meta  { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.tarea-card__fecha { font-size: 12px; color: var(--text-muted); }
.tarea-card__fecha.vencida { color: var(--red); font-weight: 600; }
.tarea-card.completada { opacity: .5; }
.tarea-card.completada .tarea-card__check {
  background: var(--green); border-color: var(--green);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 10' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='1.5,5 4,7.5 8.5,2.5' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 12px;
}

/* ── Avatares de usuario ────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px;
  object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: white;
  flex-shrink: 0;
}
.avatar--initials { background: var(--primary); }

.avatar--ejecutivo,
.avatar--supervisor,
.avatar--administrador { border-radius: 50%; }

/* ── Timeline de gestiones ──────────────────────────────────── */
.timeline { position: relative; padding: 4px 0; }
.timeline::before {
  content: ''; position: absolute; left: 23px; top: 20px; bottom: 20px;
  width: 2px; background: var(--border);
}
.timeline-item {
  position: relative; margin-bottom: 16px;
  display: flex; gap: 10px; align-items: flex-start;
}
.timeline-left {
  width: 48px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  z-index: 1;
}
.timeline-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--border);
  flex-shrink: 0;
  overflow: hidden;
}
.timeline-dot img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.timeline-dot--prev { background: #c8dff8; box-shadow: 0 0 0 2px #e8f0fb; }
.timeline-body {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.timeline-header {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.timeline-tipo  { font-weight: 600; font-size: 14px; }
.timeline-desc  { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.timeline-meta  { display: flex; gap: 6px; font-size: 12px; color: var(--text-muted); align-items: center; flex-wrap: wrap; margin-top: 8px; }
.timeline-dot[title] { cursor: pointer; }
.timeline-dot[title]:hover { box-shadow: 0 0 0 3px var(--primary); }

.timeline-user-badge {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 48px; flex-shrink: 0;
}
.timeline-user-badge img,
.timeline-user-badge .badge-avatar {
  width: 40px; height: 40px; border-radius: 6px; object-fit: cover;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
  border: 1px solid var(--border);
}
.timeline-user-badge span {
  font-size: 9px; color: var(--text-muted); text-align: center;
  line-height: 1.2; word-break: break-word; max-width: 48px;
}
.timeline-item--done .timeline-body { opacity: .75; }

/* ── Cotizacion ─────────────────────────────────────────────── */
.cot-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.cot-item:last-child { border-bottom: none; }
.cot-item__name    { font-weight: 500; }
.cot-item__price   { font-weight: 600; text-align: right; flex-shrink: 0; margin-left: 24px; }
.cot-item__discount{ font-size: 11px; color: var(--red); margin-top: 2px; }
.cot-totals        { padding: 12px 0 0; }
.cot-total-row {
  display: flex; justify-content: space-between;
  padding: 4px 0; font-size: 14px;
}
.cot-total-row.final {
  font-size: 16px; font-weight: 700;
  padding-top: 10px; border-top: 2px solid var(--text); margin-top: 6px;
}
.cot-financing {
  background: var(--primary-light); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-top: 16px;
}
.cot-financing__title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--primary); margin-bottom: 10px; }
.cot-financing__row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 3px 0; color: var(--primary-dark);
}

/* ── Alert ──────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 12px;
  display: flex; gap: 8px; align-items: flex-start;
}
.alert--warning { background: var(--orange-bg); color: #92400E; border: 1px solid #FCD34D; }
.alert--danger  { background: var(--red-bg);    color: #991B1B; border: 1px solid #FCA5A5; }
.alert--info    { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #BFDBFE; }
.alert svg      { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table  { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
th {
  text-align: left; padding: 10px 16px;
  background: var(--gray-bg); color: var(--text-muted);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  white-space: nowrap; border-bottom: 1px solid var(--border);
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #F8FAFC; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .15s ease-out;
}
.modal__header {
  padding: 20px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal__title  { font-size: 16px; font-weight: 700; }
.modal__close  {
  color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: 6px;
}
.modal__close:hover { background: var(--gray-bg); color: var(--text); }
.modal__body   { padding: 20px 24px; }
.modal__actions {
  padding: 0 24px 20px;
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal__actions .btn { min-width: 100px; }

@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes scaleIn { from { transform: scale(.96); opacity: 0 } to { transform: scale(1); opacity: 1 } }

/* ── Toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 300; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; min-width: 280px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: scaleIn .2s ease-out;
  pointer-events: auto;
}
.toast--success { background: #052E16; color: #BBF7D0; }
.toast--error   { background: #450A0A; color: #FECACA; }
.toast--info    { background: #0C1445; color: #BFDBFE; }

/* ── Login ──────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}
.login-left {
  flex: 1;
  background: #0F172A;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px;
}
.login-logo      { font-size: 48px; font-weight: 900; color: white; letter-spacing: -3px; }
.login-logo span { color: var(--primary); }
.login-tagline   { font-size: 16px; color: #64748B; margin-top: 12px; max-width: 300px; text-align: center; line-height: 1.5; }
.login-right {
  width: 480px;
  display: flex; align-items: center; justify-content: center;
  padding: 60px 48px;
}
.login-card { width: 100%; }
.login-card h2  { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.login-card p   { color: var(--text-muted); margin-bottom: 32px; font-size: 14px; }

/* ── Spinner ────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white; border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ── Oportunidad detalle layout ─────────────────────────────── */
.op-detail-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .op-detail-grid { grid-template-columns: 1fr; }
}

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px; gap: 0;
}
.tab-btn {
  padding: 10px 18px;
  font-size: 13.5px; font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Organigrama ─────────────────────────────────────────────── */
/* legacy classes kept for reference, new ones below */
.org-wrap {
  padding: 24px 24px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}
/* Zona picker multi-select */
.zonas-picker {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 180px;
  overflow-y: auto;
  background: white;
}
.zonas-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.zonas-picker label:last-child { border-bottom: none; }
.zonas-picker label:hover { background: #F8FAFC; }
.org-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 32px 28px;
  min-width: 220px;
}
.org-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--primary);
  background: #EEF2FF;
  border: 1px solid #C7D2FE;
  border-radius: 20px;
  padding: 4px 14px;
  margin-bottom: 28px;
}
/* Row of nodes */
.org-row {
  display: flex;
  justify-content: center;
  gap: 40px;
  position: relative;
}
/* Node: circle + label */
.org-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: default;
}
.org-avatar-ring {
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.org-avatar-ring--sup  { width: 60px; height: 60px; font-size: 22px; background: var(--primary); border: 3px solid var(--primary); }
.org-avatar-ring--ejec { width: 46px; height: 46px; font-size: 16px; background: #6B7280; border: 2px solid #9CA3AF; }
.org-avatar-ring--admin { width: 46px; height: 46px; font-size: 16px; background: #7C3AED; border: 2px solid #A78BFA; }
.org-node-name {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  max-width: 90px;
  line-height: 1.3;
}
.org-node-role {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2px;
  max-width: 90px;
}
/* Connector lines via pseudo-elements */
/* Vertical down from supervisor row */
.org-row--sup {
  padding-bottom: 36px;
}
.org-row--sup::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 36px;
  background: #CBD5E1;
}
/* Multiple supervisors: horizontal bar connecting them */
.org-row--sup .org-node:not(:only-child) {
  padding-top: 20px;
}
.org-row--sup .org-node:not(:only-child)::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 20px;
  background: #CBD5E1;
}
.org-row--sup .org-node:not(:only-child)::after {
  content: '';
  position: absolute;
  top: 0;
  height: 2px;
  background: #CBD5E1;
}
.org-row--sup .org-node:first-child:not(:only-child)::after { left: 50%; right: -20px; }
.org-row--sup .org-node:last-child:not(:only-child)::after  { right: 50%; left: -20px; }
.org-row--sup .org-node:not(:first-child):not(:last-child):not(:only-child)::after { left: -20px; right: -20px; }
/* Ejecutivos row: lines from horizontal bar down to each node */
.org-row--ejec .org-node {
  padding-top: 28px;
}
.org-row--ejec .org-node::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 28px;
  background: #CBD5E1;
}
.org-row--ejec .org-node:not(:only-child)::after {
  content: '';
  position: absolute;
  top: 0;
  height: 2px;
  background: #CBD5E1;
}
.org-row--ejec .org-node:first-child:not(:only-child)::after { left: 50%; right: -20px; }
.org-row--ejec .org-node:last-child:not(:only-child)::after  { right: 50%; left: -20px; }
.org-row--ejec .org-node:not(:first-child):not(:last-child):not(:only-child)::after { left: -20px; right: -20px; }

/* ── Learning ──────────────────────────────────────────────────────────── */
.learning-shell { display:flex; height:calc(100vh - 56px); overflow:hidden; }

.learning-nav {
  width: 280px; flex-shrink: 0; overflow-y: auto; background: var(--surface);
  border-right: 1px solid var(--border); padding-bottom: 24px;
}
.learning-viewer {
  flex: 1; min-width: 0; overflow-y: auto; background: var(--bg);
}
.learning-welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; padding: 32px; text-align: center; color: var(--text-muted);
}
.learning-loading { padding: 32px; text-align: center; color: var(--text-muted); font-size:14px; }

/* Nav tree */
.ln-ruta { padding: 0; }
.ln-ruta__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  color: var(--text-muted); text-transform: uppercase;
}
.ln-pct { font-size: 11px; font-weight: 600; color: var(--primary); }
.ln-progress {
  height: 3px; background: var(--border); margin: 0 14px 8px; border-radius: 99px;
}
.ln-progress > div { height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s; }

.ln-curso { margin-bottom: 4px; }
.ln-curso__head {
  display: flex; align-items: center; gap: 6px; padding: 6px 14px;
  font-size: 12px; font-weight: 600; color: var(--text);
}
.ln-mini-count { margin-left: auto; font-size: 11px; color: var(--text-muted); font-weight: 400; }

.ln-lec {
  display: flex; align-items: center; gap: 6px; padding: 5px 14px 5px 26px;
  font-size: 12px; cursor: pointer; color: var(--text); transition: background .12s;
}
.ln-lec:hover { background: var(--primary-light); }
.ln-lec--active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.ln-lec--done { color: var(--text-muted); }
.ln-lec--done .ln-lec__check { color: var(--green); font-weight: 700; }
.ln-lec__check { width: 14px; flex-shrink: 0; font-size: 11px; color: var(--border); }
.ln-lec__icon  { flex-shrink: 0; }
.ln-lec__name  { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ln-lec__dur   { flex-shrink: 0; font-size: 10px; color: var(--text-muted); }

/* Viewer */
.ln-lec-viewer { max-width: 760px; margin: 0 auto; padding: 24px; }
.ln-lec-viewer__header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.ln-lec-viewer__body { line-height: 1.7; font-size: 15px; }
.ln-texto { font-size: 15px; line-height: 1.75; color: var(--text); }
.ln-texto p { margin: 0 0 14px; }
.ln-texto ul, .ln-texto ol { margin: 0 0 14px; padding-left: 20px; }

.ln-video-wrap {
  position: relative; padding-bottom: 56.25%; height: 0; border-radius: 10px;
  overflow: hidden; background: #000;
}
.ln-video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Evaluación */
.ln-pregunta { margin-bottom: 20px; padding: 16px; background: var(--surface); border-radius: 8px; border: 1px solid var(--border); }
.ln-pregunta__texto { font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.ln-opcion {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 6px;
  border-radius: 6px; cursor: pointer; transition: background .12s; font-size: 14px;
}
.ln-opcion:hover { background: var(--primary-light); }
.ln-opcion input { flex-shrink: 0; }

/* Admin eval builder */
.ln-pregunta-editor {
  padding: 14px; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 12px; background: var(--bg);
}

/* Nav sidebar: filter tabs */
.ln-filter {
  display: flex; gap: 4px; padding: 10px 10px 8px; border-bottom: 1px solid var(--border);
}
.ln-filter__tab {
  flex: 1; padding: 5px 6px; font-size: 11px; font-weight: 600; border-radius: 6px;
  background: transparent; border: 1px solid transparent; color: var(--text-muted);
  cursor: pointer; transition: all .12s;
}
.ln-filter__tab:hover { background: var(--primary-light); color: var(--primary); }
.ln-filter__tab--active {
  background: var(--primary-light); color: var(--primary); border-color: var(--primary);
}

/* Nav sidebar: ruta cards */
.ln-ruta-list { padding: 8px 8px 24px; }
.ln-ruta-item {
  padding: 12px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 6px;
  border: 1px solid var(--border); background: var(--bg); transition: all .12s;
}
.ln-ruta-item:hover { border-color: var(--primary); background: var(--primary-light); }
.ln-ruta-item--active {
  border-color: var(--primary); background: var(--primary-light);
}
.ln-ruta-item__name {
  font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 2px;
}
.ln-ruta-item--active .ln-ruta-item__name { color: var(--primary); }
.ln-ruta-item__meta { font-size: 11px; color: var(--text-muted); }
.ln-ruta-item__pct  { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

/* Ruta detail (viewer) */
.ln-ruta-detail { max-width: 760px; margin: 0 auto; padding: 24px; }
.ln-ruta-detail__header {
  display: flex; align-items: flex-start; gap: 16px; justify-content: space-between;
  margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.ln-ruta-detail__cursos { display: flex; flex-direction: column; gap: 16px; }
.ln-ruta-detail__modulo {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.ln-ruta-detail__modulo-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text);
}
.ln-ruta-detail__lecciones { padding: 4px 0; }


/* ── Server Health ──────────────────────────────────────────── */
.sh-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 16px;
}
.sh-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sh-dot--ok  { background: #22c55e; box-shadow: 0 0 6px #22c55e88; }
.sh-dot--err { background: #ef4444; }

.sh-loading { display: flex; justify-content: center; padding: 60px; }

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

.sh-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* Gauge cards */
.sh-row--gauges .sh-card { flex: 1; min-width: 180px; }

.sh-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.sh-card__label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted); margin-bottom: 4px;
}
.sh-card__pct {
  font-size: 36px; font-weight: 800; line-height: 1; margin-bottom: 8px;
}
.sh-bar-wrap {
  height: 6px; background: var(--border); border-radius: 99px; overflow: hidden;
  margin-bottom: 6px;
}
.sh-bar { height: 100%; border-radius: 99px; transition: width .4s ease; }
.sh-card__sub { font-size: 12px; color: var(--text-muted); }

/* Stat cards */
.sh-row--stats .sh-card { flex: 1; min-width: 160px; }
.sh-card--stat { display: flex; align-items: center; gap: 12px; }
.sh-card__icon { font-size: 24px; line-height: 1; flex-shrink: 0; }
.sh-card__body { min-width: 0; }
.sh-card__value {
  font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2;
}

/* ── Server Health – charts ─────────────────────────────────── */
.sh-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (max-width: 640px) { .sh-chart-grid { grid-template-columns: 1fr; } }

.sh-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.sh-chart-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Toggle switch ──────────────────────────────────────────── */
.toggle-switch { position:relative; display:inline-block; width:40px; height:22px; cursor:pointer; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-slider {
  position:absolute; inset:0; background:#d1d5db; border-radius:99px; transition:.2s;
}
.toggle-slider::before {
  content:''; position:absolute; width:16px; height:16px; background:#fff; border-radius:50%;
  left:3px; top:3px; transition:.2s; box-shadow:0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background:var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform:translateX(18px); }
