/* ================================================================
   GestiónSSOMA — Custom Stylesheet
   Bootstrap 5.3 + Vanilla JS
================================================================ */

/* ── ROOT VARIABLES ─────────────────────────────────────────── */
:root {
  --primary:           #2563eb;
  --primary-hover:     #1d4ed8;
  --primary-light:     #eff6ff;
  --primary-border:    #bfdbfe;
  --sidebar-bg:          #ffffff;
  --sidebar-text:        #64748b;
  --sidebar-text-active: #ffffff;
  --sidebar-hover:       #f1f5f9;
  --sidebar-active:      #2563eb;
  --sidebar-width:     260px;
  --sidebar-collapsed: 64px;
  --topbar-height:     60px;
  --body-bg:           #f1f5f9;
  --card-border:       #e2e8f0;
  --text-primary:      #0f172a;
  --text-secondary:    #334155;
  --text-muted:        #64748b;
  --text-faint:        #94a3b8;

  /* Status palette */
  --s-vigente:         #16a34a;
  --s-vigente-bg:      #dcfce7;
  --s-por-vencer:      #ea580c;
  --s-por-vencer-bg:   #fff7ed;
  --s-vencido:         #d97706;
  --s-vencido-bg:      #fffbeb;
  --s-rechazado:       #dc2626;
  --s-rechazado-bg:    #fef2f2;
  --s-pendiente:       #2563eb;
  --s-pendiente-bg:    #eff6ff;
  --s-validado:        #16a34a;
  --s-validado-bg:     #dcfce7;
  --s-planificado:     #94a3b8;
  --s-planificado-bg:  #f1f5f9;
  --s-atrasado:        #d97706;
  --s-atrasado-bg:     #fffbeb;
  --s-por-validar:     #2563eb;
  --s-por-validar-bg:  #eff6ff;
}

/* ── BASE ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--body-bg);
  color: var(--text-secondary);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

/* Brand */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 1rem;
  height: var(--topbar-height);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.brand-logo {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff;
  flex-shrink: 0; letter-spacing: -1px;
}
.brand-name {
  font-size: 15px; font-weight: 700; color: #fff;
  white-space: nowrap;
  transition: opacity .2s;
}
.brand-sub {
  font-size: 10px; color: var(--sidebar-text);
  white-space: nowrap; transition: opacity .2s;
}
.sidebar.collapsed .brand-name,
.sidebar.collapsed .brand-sub { opacity: 0; pointer-events: none; }

/* Brand logo images — sidebar */
.bl-full-light, .bl-full-dark { height: 52px; object-fit: contain; flex-shrink: 0; }
.bl-icon-light, .bl-icon-dark { height: 36px; width: 36px; object-fit: contain; flex-shrink: 0; }

/* Light mode expanded: dark logo */
.bl-full-dark, .bl-icon-light, .bl-icon-dark { display: none; }
.bl-full-light { display: block; }

/* Light mode collapsed: dark icon */
.sidebar.collapsed .bl-full-light { display: none; }
.sidebar.collapsed .bl-icon-light { display: block; }

/* Dark mode expanded: light logo */
[data-theme="dark"] .bl-full-light                { display: none; }
[data-theme="dark"] .bl-full-dark                 { display: block; }

/* Dark mode collapsed: light icon */
[data-theme="dark"] .sidebar.collapsed .bl-full-dark  { display: none; }
[data-theme="dark"] .sidebar.collapsed .bl-icon-light { display: none; }
[data-theme="dark"] .sidebar.collapsed .bl-icon-dark  { display: block; }

/* Login page logo */
.login-logo-light { display: none; }
[data-theme="dark"] .login-logo-dark  { display: none; }
[data-theme="dark"] .login-logo-light { display: block; }

/* Nav scroll area */
.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: .5rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.08); border-radius: 2px;
}

/* Section labels */
.nav-section {
  padding: .875rem 1rem .25rem;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: rgba(148,163,184,.45);
  white-space: nowrap;
  transition: opacity .2s;
}
.sidebar.collapsed .nav-section { opacity: 0; }

/* Nav item */
.nav-item-link {
  display: flex; align-items: center; gap: 10px;
  padding: .55rem .75rem;
  margin: 1px .5rem;
  border-radius: 7px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
  position: relative;
}
.nav-item-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item-link.active { background: var(--sidebar-active); color: #fff; }
.nav-item-link i {
  font-size: 16px; width: 20px; text-align: center; flex-shrink: 0;
}
.nav-item-link .nav-label {
  font-size: 13.5px; font-weight: 500;
  transition: opacity .15s;
}
.nav-item-link .nav-count {
  margin-left: auto;
  background: #dc2626; color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  transition: opacity .15s;
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-count { opacity: 0; pointer-events: none; }

/* Collapsed tooltip */
.sidebar.collapsed .nav-item-link::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(var(--sidebar-collapsed) + 8px);
  top: 50%; transform: translateY(-50%);
  background: #1e293b; color: #fff;
  padding: 5px 10px; border-radius: 6px;
  font-size: 12.5px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
  z-index: 1050;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.sidebar.collapsed .nav-item-link:hover::after { opacity: 1; }

/* ── Nav group (collapsible) ── */
.nav-group-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: .55rem .75rem;
  margin: 1px .5rem;
  border-radius: 7px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
  border: none; background: none;
  width: calc(100% - 1rem); text-align: left;
  position: relative;
}
.nav-group-toggle:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-group-toggle.has-active { color: #e2e8f0; }
.nav-group-toggle i:first-child { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-group-toggle .nav-label { font-size: 13.5px; font-weight: 500; flex: 1; transition: opacity .15s; }
.nav-group-chevron { font-size: 10px; flex-shrink: 0; transition: transform .2s, opacity .15s; }
.nav-group-toggle.open .nav-group-chevron { transform: rotate(90deg); }

.nav-subitems { overflow: hidden; max-height: 0; transition: max-height .22s ease; }
.nav-subitems.open { max-height: 160px; }

.nav-subitem-link {
  display: flex; align-items: center; gap: 10px;
  padding: .42rem .75rem .42rem 2.625rem;
  margin: 1px .5rem;
  border-radius: 7px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap; font-size: 13px;
}
.nav-subitem-link i { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-subitem-link .nav-label { transition: opacity .15s; }
.nav-subitem-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-subitem-link.active { background: var(--sidebar-active); color: #fff; }

/* Collapsed state */
.sidebar.collapsed .nav-group-toggle .nav-label,
.sidebar.collapsed .nav-group-chevron { opacity: 0; pointer-events: none; }
.sidebar.collapsed .nav-subitems { display: none; }
.sidebar.collapsed .nav-group-toggle::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(var(--sidebar-collapsed) + 8px);
  top: 50%; transform: translateY(-50%);
  background: #1e293b; color: #fff;
  padding: 5px 10px; border-radius: 6px;
  font-size: 12.5px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
  z-index: 1050;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.sidebar.collapsed .nav-group-toggle:hover::after { opacity: 1; }

/* Bottom user bar */
.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,.06);
  padding: .625rem .5rem;
  flex-shrink: 0;
}
.sidebar-user {
  display: flex; align-items: center; gap: 9px;
  padding: .5rem .5rem; border-radius: 7px;
  cursor: pointer; transition: background .15s;
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-user .su-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user .su-name {
  font-size: 12.5px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity .15s;
}
.sidebar-user .su-role {
  font-size: 11px; color: var(--sidebar-text);
  white-space: nowrap; transition: opacity .15s;
}
.sidebar.collapsed .su-name,
.sidebar.collapsed .su-role { opacity: 0; pointer-events: none; }

/* ── MAIN CONTENT ───────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .25s cubic-bezier(.4,0,.2,1);
}
.main-wrap.collapsed { margin-left: var(--sidebar-collapsed); }

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  height: var(--topbar-height);
  display: flex; align-items: center;
  padding: 0 1.5rem; gap: 1rem;
  position: sticky; top: 0; z-index: 100;
}
.topbar-toggle {
  background: none; border: none;
  width: 34px; height: 34px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 18px; cursor: pointer;
  transition: background .15s, color .15s; flex-shrink: 0;
}
.topbar-toggle:hover { background: #f1f5f9; color: var(--text-primary); }
.topbar .breadcrumb { margin: 0; font-size: 13px; }
.topbar .breadcrumb-item.active { color: var(--text-primary); font-weight: 600; }
.topbar-spacer { flex: 1; }
.topbar-search {
  position: relative; width: 220px;
}
.topbar-search input {
  width: 100%; padding: .4rem .875rem .4rem 2.25rem;
  font-size: 13px; border-radius: 8px;
  border: 1px solid #e2e8f0; background: #f8fafc;
  transition: border-color .15s, background .15s;
  outline: none;
}
.topbar-search input:focus {
  border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.topbar-search .si { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 13px; }
.topbar-sep { width: 1px; height: 22px; background: #e2e8f0; flex-shrink: 0; }
.topbar-btn {
  background: none; border: none;
  width: 34px; height: 34px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 16px; cursor: pointer;
  position: relative; transition: background .15s, color .15s;
}
.topbar-btn:hover { background: #f1f5f9; color: var(--text-primary); }
.topbar-btn .dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%;
  background: #dc2626; border: 2px solid #fff;
}
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: 8px;
  cursor: pointer; transition: background .15s;
}
.topbar-user:hover { background: #f1f5f9; }
.topbar-user .tu-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.topbar-user .tu-info .tu-name { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.topbar-user .tu-info .tu-role { font-size: 11px; color: var(--text-muted); }

/* Tenant bar */
.tenant-bar {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 5px 1.5rem;
  font-size: 11.5px; color: #64748b;
  display: flex; align-items: center; gap: .75rem;
}
.tenant-bar .tb-badge {
  background: #eff6ff; color: #2563eb;
  padding: 1px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
}

/* ── PAGE CONTENT ───────────────────────────────────────────── */
.page-body { padding: 1.5rem; flex: 1; }

.page-hdr { margin-bottom: 1.5rem; }
.page-hdr h1 { font-size: 20px; font-weight: 700; color: var(--text-primary); margin: 0 0 3px; }
.page-hdr p  { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 10px 10px 0 0 !important;
  padding: .875rem 1.25rem;
  display: flex; align-items: center; gap: .75rem;
}
.card-header h6 { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 0; }
.card-header .card-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.card-body { padding: 1.25rem; }

/* ── KPI CARDS ──────────────────────────────────────────────── */
.kpi {
  background: #fff; border: 1px solid var(--card-border);
  border-radius: 10px; padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: box-shadow .2s, transform .2s;
}
.kpi:hover { box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-1px); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .625rem; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.kpi-value { font-size: 30px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.kpi-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-bottom: .375rem; }
.kpi-trend { font-size: 12px; display: flex; align-items: center; gap: 3px; }
.kpi-trend.up   { color: #16a34a; }
.kpi-trend.down { color: #dc2626; }
.kpi-trend.flat { color: #64748b; }

/* ── STATUS BADGES ──────────────────────────────────────────── */
.bs {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
}
.bs::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; flex-shrink: 0;
}
.bs-vigente     { background: var(--s-vigente-bg);     color: var(--s-vigente);     } .bs-vigente::before     { background: var(--s-vigente);     }
.bs-por-vencer  { background: var(--s-por-vencer-bg);  color: var(--s-por-vencer);  } .bs-por-vencer::before  { background: var(--s-por-vencer);  }
.bs-vencido     { background: var(--s-vencido-bg);     color: var(--s-vencido);     } .bs-vencido::before     { background: var(--s-vencido);     }
.bs-rechazado   { background: var(--s-rechazado-bg);   color: var(--s-rechazado);   } .bs-rechazado::before   { background: var(--s-rechazado);   }
.bs-pendiente   { background: var(--s-pendiente-bg);   color: var(--s-pendiente);   } .bs-pendiente::before   { background: var(--s-pendiente);   }
.bs-validado    { background: var(--s-validado-bg);    color: var(--s-validado);    } .bs-validado::before    { background: var(--s-validado);    }
.bs-planificado { background: var(--s-planificado-bg); color: var(--s-planificado); } .bs-planificado::before { background: var(--s-planificado); }
.bs-atrasado    { background: var(--s-atrasado-bg);    color: var(--s-atrasado);    } .bs-atrasado::before    { background: var(--s-atrasado);    }
.bs-por-validar { background: var(--s-por-validar-bg); color: var(--s-por-validar); } .bs-por-validar::before { background: var(--s-por-validar); }
.bs-reprobado   { background: var(--s-rechazado-bg);   color: var(--s-rechazado);   } .bs-reprobado::before   { background: var(--s-rechazado);   }
.bs-aprobado    { background: var(--s-validado-bg);    color: var(--s-validado);    } .bs-aprobado::before    { background: var(--s-validado);    }

/* ── CERTIFICATION BADGES ───────────────────────────────────── */
.cert-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700;
}
.cert-bronce { background: rgba(180,83,9,.1);  color: #92400e; border: 1px solid rgba(180,83,9,.25); }
.cert-plata  { background: rgba(100,116,139,.1); color: #475569; border: 1px solid rgba(100,116,139,.3); }
.cert-oro    { background: rgba(234,179,8,.12); color: #854d0e; border: 1px solid rgba(234,179,8,.3); }

/* ── TABLES ─────────────────────────────────────────────────── */
.tbl thead th {
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); background: #f8fafc;
  border-bottom: 1px solid #e2e8f0; border-top: none;
  padding: .7rem 1rem;
}
.tbl tbody td {
  padding: .7rem 1rem; vertical-align: middle;
  border-color: #f1f5f9; font-size: 13.5px; color: var(--text-secondary);
}
.tbl tbody tr:hover td { background: #fafcff; }
.tbl tbody tr.clickable { cursor: pointer; }

/* ── SEARCH BOX (replaces .topbar-search — works everywhere) ─── */
.search-box {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.search-box .search-icon {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 13px;
  pointer-events: none;
  line-height: 1;
}
.search-box input {
  width: 100%;
  min-width: 180px;
  padding: .4rem .875rem .4rem 2.1rem;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: var(--text-secondary);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-box input::placeholder { color: #b0bec5; }
.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ── FILTER BAR ─────────────────────────────────────────────── */
.filter-bar {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: .875rem 1.25rem; margin-bottom: 1rem;
  display: flex; gap: .625rem; flex-wrap: wrap; align-items: center;
}
/* Only direct-child inputs/selects, so nested .search-box input keeps its own padding */
.filter-bar > select, .filter-bar > input {
  font-size: 13px; border-radius: 7px; border: 1px solid #e2e8f0;
  padding: .375rem .75rem; color: var(--text-secondary);
  background: #f8fafc; outline: none; transition: border-color .15s;
}
.filter-bar > select:focus, .filter-bar > input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
/* Keep search-box inside filter-bar visually consistent with sibling selects */
.filter-bar .search-box input {
  background: #f8fafc;
  border-radius: 7px;
  padding: .375rem .875rem .375rem 2rem;
  min-width: 200px;
}

/* ── CUSTOM TABS ────────────────────────────────────────────── */
.tabs-line { border-bottom: 1px solid #e2e8f0; }
.tabs-line .nav-link {
  border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-size: 13.5px; font-weight: 500;
  padding: .65rem 1rem; border-radius: 0;
  transition: color .15s, border-color .15s;
}
.tabs-line .nav-link:hover { color: var(--primary); border-bottom-color: var(--primary-border); }
.tabs-line .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }
.tabs-line .nav-link .tab-count {
  background: #e2e8f0; color: var(--text-muted);
  font-size: 10.5px; font-weight: 700; border-radius: 10px;
  padding: 1px 6px; margin-left: 5px;
}
.tabs-line .nav-link.active .tab-count { background: var(--primary-light); color: var(--primary); }

/* ── PROGRESS ───────────────────────────────────────────────── */
.progress { height: 6px; border-radius: 4px; background: #e2e8f0; }
.progress-bar { border-radius: 4px; }

/* ── TIMELINE ───────────────────────────────────────────────── */
.timeline { padding: 0; }
.tl-item { display: flex; gap: .875rem; padding-bottom: 1.25rem; position: relative; }
.tl-item:not(:last-child)::before {
  content: ''; position: absolute; left: 15px; top: 30px; bottom: 0;
  width: 1px; background: #e2e8f0;
}
.tl-dot {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.tl-body { flex: 1; padding-top: 4px; }
.tl-title { font-size: 13px; font-weight: 500; color: var(--text-primary); margin-bottom: 2px; }
.tl-meta  { font-size: 11.5px; color: var(--text-faint); }

/* ── ALERT STRIP ────────────────────────────────────────────── */
.alert-strip {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .75rem 1rem; border-radius: 8px; border: 1px solid transparent;
  font-size: 13px;
}
.alert-strip.danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-strip.warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-strip.info    { background: var(--primary-light); border-color: var(--primary-border); color: #1e40af; }

/* ── DOC CARD ───────────────────────────────────────────────── */
.doc-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 9px;
  padding: .875rem 1rem; display: flex; align-items: center; gap: .875rem;
  transition: box-shadow .15s;
}
.doc-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.07); }
.doc-icon {
  width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}

/* ── FILE BROWSER ───────────────────────────────────────────── */
.folder-tree { font-size: 13.5px; }
.ft-item {
  display: flex; align-items: center; gap: 7px;
  padding: .45rem .75rem; border-radius: 6px; cursor: pointer;
  transition: background .15s; color: var(--text-secondary);
}
.ft-item:hover { background: #f1f5f9; }
.ft-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.ft-item .ft-indent { display: inline-block; }

.file-grid .fgrid-item {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 9px;
  padding: 1rem; display: flex; flex-direction: column; align-items: center;
  gap: .5rem; cursor: pointer; transition: box-shadow .15s;
  text-align: center;
}
.file-grid .fgrid-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.file-grid .fgrid-icon { font-size: 2.5rem; }
.file-grid .fgrid-name { font-size: 12.5px; font-weight: 500; color: var(--text-secondary); word-break: break-word; }
.file-grid .fgrid-meta { font-size: 11px; color: var(--text-faint); }

/* ── CALENDAR ───────────────────────────────────────────────── */
.cal-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); padding: .5rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
  min-height: 82px; padding: 4px;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.other { background: #fafafa; }
.cal-cell .cn {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; margin-bottom: 2px;
}
.cal-cell.today .cn { background: var(--primary); color: #fff; }
.cal-cell.other .cn { color: #cbd5e1; }
.cal-ev {
  font-size: 10.5px; padding: 2px 5px; border-radius: 3px;
  margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; cursor: pointer;
}
.cal-ev.planificado { background: var(--s-planificado-bg); color: var(--s-planificado); }
.cal-ev.atrasado    { background: var(--s-atrasado-bg);    color: var(--s-atrasado); }
.cal-ev.validado    { background: var(--s-validado-bg);    color: var(--s-validado); }

/* ── KIOSK / PORTERÍA ───────────────────────────────────────── */
.kiosk-bg {
  min-height: 100vh; background: #0f172a;
  display: flex; flex-direction: column;
}
.kiosk-header {
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.07);
  padding: 1rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
}
.kiosk-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 2rem; gap: 2rem;
}
.kiosk-panel {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px; padding: 2rem;
  backdrop-filter: blur(10px);
}
.kiosk-result {
  border-radius: 12px; padding: 1.5rem; text-align: center;
}
.kiosk-allow { background: rgba(22,163,74,.12); border: 1px solid rgba(22,163,74,.25); }
.kiosk-deny  { background: rgba(220,38,38,.12);  border: 1px solid rgba(220,38,38,.25); }

/* ── INSIGNIAS / BADGES ─────────────────────────────────────── */
.insignia-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.insignia-icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.insignia-bronce .insignia-icon { background: linear-gradient(135deg,#cd7f32,#92400e); color:#fff; box-shadow: 0 2px 8px rgba(180,83,9,.3); }
.insignia-plata  .insignia-icon { background: linear-gradient(135deg,#c0c0c0,#94a3b8); color:#fff; box-shadow: 0 2px 8px rgba(148,163,184,.3); }
.insignia-oro    .insignia-icon { background: linear-gradient(135deg,#fbbf24,#f59e0b); color:#fff; box-shadow: 0 2px 8px rgba(251,191,36,.3); }
.insignia-label { font-size: 11px; font-weight: 600; color: var(--text-muted); }

/* ── COMPLIANCE RING ────────────────────────────────────────── */
.ring-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-label {
  position: absolute; font-size: 18px; font-weight: 800; color: var(--text-primary);
}
.ring-label-sm { font-size: 14px; }

/* ── LOGIN PAGE ─────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex;
  background: var(--body-bg);
}
.login-side {
  width: 420px; flex-shrink: 0;
  background: #fff; border-right: 1px solid #e2e8f0;
  display: flex; flex-direction: column; padding: 2.5rem;
}
.login-hero {
  flex: 1; background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3rem; position: relative; overflow: hidden;
}
.login-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ── MISC UTILS ─────────────────────────────────────────────── */
.fs-xs  { font-size: 11px; }
.fs-sm  { font-size: 12.5px; }
.text-faint { color: #94a3b8; }
.fw-600  { font-weight: 600; }
.fw-700  { font-weight: 700; }
.rounded-lg { border-radius: 10px; }
.btn-xs { padding: 3px 10px; font-size: 12px; border-radius: 6px; }

.avatar-sm {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.avatar-stack { display: flex; }
.avatar-stack .avatar-sm { border: 2px solid #fff; margin-left: -6px; }
.avatar-stack .avatar-sm:first-child { margin-left: 0; }

.empty-state { padding: 3rem 1.5rem; text-align: center; color: var(--text-faint); }
.empty-state i { font-size: 3rem; color: #cbd5e1; display: block; margin-bottom: 1rem; }
.empty-state h6 { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.empty-state p  { font-size: 12.5px; margin: 0; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrap { margin-left: 0 !important; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 1039;
  }
  .sidebar-overlay.show { display: block; }
  .login-side { width: 100%; border-right: none; }
  .login-hero { display: none; }
}
@media (max-width: 575.98px) {
  .page-body { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .topbar-search { display: none; }
}

/* ================================================================
   SIDEBAR CLARO — correcciones de colores hardcodeados
   Las variables ya apuntan a claro; aquí sobreescribimos los
   valores que estaban embebidos directamente en el CSS original.
================================================================ */
.sidebar {
  border-right: 1px solid #e2e8f0;
  box-shadow: 2px 0 8px rgba(0,0,0,.04);
}
.sidebar-brand    { border-bottom-color: #e2e8f0; }
.brand-name       { color: #0f172a; }
.nav-section           { color: #b0bec5; }
.nav-item-link:hover   { color: var(--text-secondary); }
.nav-item-link.active  { color: #fff; }
.nav-group-toggle:hover      { color: var(--text-secondary); }
.nav-group-toggle.has-active { color: var(--text-primary); }
.nav-subitem-link:hover      { color: var(--text-secondary); }
.nav-subitem-link.active     { color: #fff; }
.sidebar-bottom   { border-top-color: #e2e8f0; }
.sidebar-user .su-name { color: #0f172a; }
.sidebar-nav {
  scrollbar-color: #e2e8f0 transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb { background: #e2e8f0; }

/* ================================================================
   DARK MODE
   Activado con data-theme="dark" en <html>
================================================================ */

/* ── Transición suave al cambiar tema ── */
body,
.topbar, .card, .card-header, .card-body,
.kpi, .kpi-mini, .mod-card, .quick-link,
.tbl thead th, .tbl tbody td,
.filter-bar, .doc-card, .ft-item,
.dropdown-menu, .offcanvas, .modal-content,
.alert-strip, .page-link, .search-box input,
.form-select, .form-control, .input-group-text,
.stat-mini, .dept-card, .emp-row, .emp-panel,
.doc-cat-header, .panel-tabs, .ficha-stats-bar {
  transition: background-color .25s ease, border-color .25s ease, color .2s ease;
}

/* ── Variables root override + Bootstrap CSS vars ── */
[data-theme="dark"] {
  /* App variables */
  --body-bg:        #0a1120;
  --card-border:    #1e3352;
  --text-primary:   #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted:     #94a3b8;
  --text-faint:     #64748b;
  --primary-light:  rgba(37,99,235,.15);
  --primary-border: rgba(37,99,235,.4);

  /* Bootstrap CSS custom properties — cubren todos los componentes BS5 */
  --bs-body-bg:                    #0a1120;
  --bs-body-color:                 #cbd5e1;
  --bs-secondary-bg:               #0f1e35;
  --bs-tertiary-bg:                #0a1120;
  --bs-card-bg:                    #0f1e35;
  --bs-card-cap-bg:                #0f1e35;
  --bs-card-border-color:          #1e3352;
  --bs-border-color:               #1e3352;
  --bs-border-color-translucent:   rgba(30,51,82,.5);
  --bs-table-bg:                   transparent;
  --bs-table-color:                #cbd5e1;
  --bs-table-border-color:         #1e3352;
  --bs-table-hover-bg:             #142133;
  --bs-table-striped-bg:           rgba(255,255,255,.02);
  --bs-table-active-bg:            #142133;
  --bs-dropdown-bg:                #0f1e35;
  --bs-dropdown-border-color:      #1e3352;
  --bs-dropdown-link-color:        #cbd5e1;
  --bs-dropdown-link-hover-bg:     #1a2d48;
  --bs-dropdown-divider-bg:        #1e3352;
  --bs-modal-bg:                   #0f1e35;
  --bs-modal-border-color:         #1e3352;
  --bs-modal-header-border-color:  #1e3352;
  --bs-modal-footer-border-color:  #1e3352;
  --bs-offcanvas-bg:               #0f1e35;
  --bs-offcanvas-border-color:     #1e3352;
  --bs-pagination-bg:              #0f1e35;
  --bs-pagination-border-color:    #1e3352;
  --bs-pagination-color:           #cbd5e1;
  --bs-pagination-hover-bg:        #1a2d48;
  --bs-pagination-hover-color:     #f1f5f9;
  --bs-pagination-active-bg:       #2563eb;
  --bs-pagination-active-border-color: #2563eb;
  --bs-pagination-disabled-bg:     #142133;
  --bs-nav-tabs-border-color:          #1e3352;
  --bs-nav-tabs-link-hover-border-color: #1e3352;
  --bs-nav-tabs-link-active-bg:    #0f1e35;
  --bs-nav-tabs-link-active-border-color: #1e3352 #1e3352 #0f1e35;
  --bs-list-group-bg:              #0f1e35;
  --bs-list-group-border-color:    #1e3352;
  --bs-form-control-bg:            #142133;
  --bs-link-color:                 #60a5fa;
  --bs-link-hover-color:           #93c5fd;
  --bs-input-bg:                   #142133;
  --bs-input-border-color:         #1e3352;
  --bs-input-color:                #cbd5e1;
  --bs-input-placeholder-color:    #64748b;
}

/* ── Body & layout ── */
[data-theme="dark"] body { background: var(--body-bg); }

/* ── Sidebar (restaurar oscuro) ── */
[data-theme="dark"] .sidebar {
  background: #0f172a;
  border-right-color: transparent;
  box-shadow: none;
}
[data-theme="dark"] .sidebar-brand    { border-bottom-color: rgba(255,255,255,.06); }
[data-theme="dark"] .brand-name       { color: #fff; }
[data-theme="dark"] .nav-section      { color: rgba(148,163,184,.45); }
[data-theme="dark"] .nav-item-link:hover  { background: #1a2d48; color: #e2e8f0; }
[data-theme="dark"] .nav-item-link.active { color: #fff; }
[data-theme="dark"] .nav-group-toggle:hover { background: #1a2d48; color: #e2e8f0; }
[data-theme="dark"] .nav-subitem-link:hover  { background: #1a2d48; color: #e2e8f0; }
[data-theme="dark"] .nav-subitem-link.active { color: #fff; }
[data-theme="dark"] .sidebar-user:hover   { background: #1a2d48; }
[data-theme="dark"] .sidebar-bottom   { border-top-color: rgba(255,255,255,.06); }
[data-theme="dark"] .sidebar-user .su-name { color: #fff; }
[data-theme="dark"] .sidebar-nav {
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
[data-theme="dark"] .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); }

/* ── Tenant bar (restaurar oscuro) ── */
[data-theme="dark"] .tenant-bar {
  background: #060e1c;
  border-bottom-color: #1e3352;
  color: #94a3b8;
}
[data-theme="dark"] .tenant-bar .tb-badge {
  background: rgba(37,99,235,.3);
  color: #93c5fd;
}

/* ── Topbar ── */
[data-theme="dark"] .topbar {
  background: #0f1e35;
  border-bottom-color: #1e3352;
}
[data-theme="dark"] .topbar-sep { background: #1e3352; }
[data-theme="dark"] .topbar-toggle:hover,
[data-theme="dark"] .topbar-btn:hover { background: #1a2d48; }
[data-theme="dark"] .topbar-user:hover { background: #1a2d48; }
[data-theme="dark"] .topbar-user .tu-name { color: var(--text-primary); }


/* ── Cards ── */
[data-theme="dark"] .card            { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .card-header     { background: #0f1e35 !important; border-bottom-color: #1e3352 !important; }
[data-theme="dark"] .card-body       { background: #0f1e35 !important; }
[data-theme="dark"] .card-footer     { background: #0f1e35 !important; border-top-color: #1e3352 !important; }

/* ── KPIs ── */
[data-theme="dark"] .kpi,
[data-theme="dark"] .kpi-mini        { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .kpi:hover,
[data-theme="dark"] .kpi-mini:hover  { box-shadow: 0 6px 18px rgba(0,0,0,.4); }

/* ── Module cards & quick links ── */
[data-theme="dark"] .mod-card,
[data-theme="dark"] .quick-link      { background: #0f1e35 !important; border-color: #1e3352 !important; color: var(--text-secondary); }
[data-theme="dark"] .mod-card:hover,
[data-theme="dark"] .quick-link:hover { border-color: var(--primary-border); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
[data-theme="dark"] .mod-card .mod-name { color: var(--text-primary); }

/* ── Clases de páginas específicas (overrides !important por orden de carga) ── */

/* colaboradores-internos.html */
[data-theme="dark"] .stat-mini          { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .dept-card          { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .emp-row            { background: transparent !important; border-bottom-color: #1e3352 !important; }
[data-theme="dark"] .emp-row:hover      { background: #142133 !important; }
[data-theme="dark"] .emp-row.expanded   { background: #0c1a2e !important; }
[data-theme="dark"] .worker-name-link        { color: var(--text-primary) !important; }
[data-theme="dark"] .worker-name-link:hover  { color: #60a5fa !important; }
[data-theme="dark"] .dept-badge              { filter: none !important; }
[data-theme="dark"] .dept-mant               { background: rgba(29,78,216,.18) !important; color: #93c5fd !important; }
[data-theme="dark"] .dept-oper               { background: rgba(21,128,61,.18) !important; color: #86efac !important; }
[data-theme="dark"] .dept-ssoma              { background: rgba(220,38,38,.15) !important; color: #fca5a5 !important; }
[data-theme="dark"] .dept-admin              { background: rgba(147,51,234,.18) !important; color: #d8b4fe !important; }
[data-theme="dark"] .dept-ti                 { background: rgba(14,116,144,.18) !important; color: #67e8f9 !important; }
[data-theme="dark"] .dept-rrhh               { background: rgba(194,65,12,.18) !important; color: #fdba74 !important; }
[data-theme="dark"] .emp-panel          { background: #0a1526 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .doc-cat-header     { background: #142133 !important; color: var(--text-muted) !important; }
[data-theme="dark"] .doc-line:hover     { background: #142133 !important; }
[data-theme="dark"] .panel-tabs         { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .ficha-stats-bar    { background: #0a1526 !important; }
[data-theme="dark"] .pi-cal-hdr         { background: #142133 !important; }
[data-theme="dark"] .act-line:hover     { background: #142133 !important; }

/* empresas.html */
[data-theme="dark"] .empresa-row.child-row td    { background: #0d1b30 !important; }
[data-theme="dark"] .empresa-row.child-row-n4 td { background: #0d1b30 !important; }

/* centros.html */
[data-theme="dark"] .centro-card                 { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .centro-card:hover           { box-shadow: 0 6px 18px rgba(0,0,0,.4) !important; }
[data-theme="dark"] .centro-footer               { background: #142133 !important; border-top-color: #1e3352 !important; }
[data-theme="dark"] .centro-card .centro-name    { color: var(--text-primary) !important; }
[data-theme="dark"] .centro-card .centro-code    { color: var(--text-muted) !important; }

/* roles.html — panel izquierdo */
[data-theme="dark"] .role-list-panel             { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .role-list-header            { border-bottom-color: #1e3352 !important; background: #0f1e35 !important; }
[data-theme="dark"] .role-item                   { border-top-color: #162840 !important; }
[data-theme="dark"] .role-item:hover             { background: #142133 !important; }
[data-theme="dark"] .role-item.active            { background: #1a2d48 !important; border-left-color: var(--primary) !important; }
[data-theme="dark"] .role-item-name              { color: var(--text-primary) !important; }
[data-theme="dark"] .role-item-meta              { color: var(--text-faint) !important; }
[data-theme="dark"] .role-item-count             { background: #1e3352 !important; color: #94a3b8 !important; }
[data-theme="dark"] .role-item.active .role-item-count { background: rgba(37,99,235,.2) !important; color: #93c5fd !important; }
[data-theme="dark"] .role-built-in               { background: #1e3352 !important; color: #64748b !important; }

/* roles.html — panel derecho (editor de permisos) */
[data-theme="dark"] .perm-editor                 { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .perm-editor-header          { border-bottom-color: #1e3352 !important; }
[data-theme="dark"] .perm-module-group           { border-bottom-color: #1e3352 !important; }
[data-theme="dark"] .perm-module-title           { background: #142133 !important; color: #64748b !important; border-bottom-color: #1e3352 !important; }
[data-theme="dark"] .perm-row                    { border-top-color: #162840 !important; }
[data-theme="dark"] .perm-row:hover              { background: #142133 !important; }
[data-theme="dark"] .perm-row-label              { color: var(--text-secondary) !important; }
[data-theme="dark"] .perm-row-label .perm-sub    { color: var(--text-faint) !important; }

/* roles.html — toggle 3 estados */
[data-theme="dark"] .perm-toggle                 { background: #0a1526 !important; }
[data-theme="dark"] .perm-opt                    { color: #475569 !important; }
[data-theme="dark"] .perm-opt:hover              { color: #94a3b8 !important; }
[data-theme="dark"] .perm-opt.sel-none           { background: #1e3352 !important; color: #94a3b8 !important; box-shadow: 0 1px 3px rgba(0,0,0,.3) !important; }
[data-theme="dark"] .perm-opt.sel-read           { background: rgba(124,58,237,.18) !important; color: #c4b5fd !important; box-shadow: none !important; }
[data-theme="dark"] .perm-opt.sel-full           { background: rgba(22,163,74,.18) !important; color: #86efac !important; box-shadow: none !important; }

/* roles.html — chips de resumen */
[data-theme="dark"] .perm-summary-chip           { background: #142133 !important; border-color: #1e3352 !important; color: #94a3b8 !important; }
[data-theme="dark"] .perm-summary-chip.full      { background: rgba(22,163,74,.12) !important; border-color: rgba(22,163,74,.3) !important; color: #86efac !important; }
[data-theme="dark"] .perm-summary-chip.read      { background: rgba(124,58,237,.12) !important; border-color: rgba(124,58,237,.3) !important; color: #c4b5fd !important; }
[data-theme="dark"] .perm-summary-chip.none      { background: rgba(220,38,38,.1) !important; border-color: rgba(220,38,38,.3) !important; color: #fca5a5 !important; }
[data-theme="dark"] .locked-badge                { background: #1e3352 !important; color: #64748b !important; }

/* soporte.html */
[data-theme="dark"] .soporte-kpi                 { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .sk-val                      { color: var(--text-primary) !important; }
[data-theme="dark"] .soporte-tab-body            { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .video-card                  { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .video-body                  { background: #0f1e35 !important; }
[data-theme="dark"] .ai-chat-preview             { background: #142133 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .aichat-bubble.user          { background: #1d4ed8 !important; }
[data-theme="dark"] .aichat-bubble.bot           { background: #142133 !important; border-color: #1e3352 !important; color: var(--text-secondary) !important; }
/* documentos.html — barra de período */
[data-theme="dark"] .tbl-pnav                    { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .tbl-pnav span[style*="color:#475569"] { color: #94a3b8 !important; }

/* soporte.html — Nuevo Ticket form */
[data-theme="dark"] .form-section-title          { border-bottom-color: #1e3352 !important; color: #64748b !important; }
[data-theme="dark"] .upload-zone                 { border-color: #1e3352 !important; }
[data-theme="dark"] .upload-zone:hover           { border-color: var(--primary) !important; background: rgba(37,99,235,.06) !important; }
[data-theme="dark"] .tkt-detail-hdr              { border-bottom-color: #1e3352 !important; }
[data-theme="dark"] .tkt-msg-name                { color: var(--text-primary) !important; }

/* Bootstrap accordion (soporte.html) */
[data-theme="dark"] .accordion-item              { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] .accordion-button            { background: #0f1e35 !important; color: var(--text-primary) !important; }
[data-theme="dark"] .accordion-button:not(.collapsed) { background: rgba(37,99,235,.12) !important; color: #93c5fd !important; box-shadow: none !important; }
[data-theme="dark"] .accordion-button::after     { filter: invert(1) brightness(1.5); }
[data-theme="dark"] .accordion-collapse .accordion-body { background: #0f1e35 !important; color: var(--text-secondary) !important; }

/* Tablas: evitar que filas hereden blanco */
[data-theme="dark"] .tbl tbody tr  { background-color: transparent !important; }
[data-theme="dark"] .tbl tbody td  { background-color: transparent !important; }

/* Bootstrap utilities */
[data-theme="dark"] .bg-white      { background-color: #0f1e35 !important; }
[data-theme="dark"] .bg-light      { background-color: #142133 !important; }
[data-theme="dark"] .border        { border-color: #1e3352 !important; }
[data-theme="dark"] .border-bottom { border-bottom-color: #1e3352 !important; }
[data-theme="dark"] .border-top    { border-top-color:    #1e3352 !important; }

/* ── Tables ── */
[data-theme="dark"] .tbl thead th {
  background: #142133;
  color: var(--text-muted);
  border-bottom-color: #1e3352;
  border-top: none;
}
[data-theme="dark"] .tbl tbody td {
  border-color: #162840;
  color: var(--text-secondary);
}
[data-theme="dark"] .tbl tbody tr:hover td { background: #142133; }
[data-theme="dark"] .table { color: var(--text-secondary); }

/* ── Filter bar ── */
[data-theme="dark"] .filter-bar {
  background: #0f1e35;
  border-color: #1e3352;
}
[data-theme="dark"] .filter-bar > select,
[data-theme="dark"] .filter-bar > input {
  background: #142133;
  border-color: #1e3352;
  color: var(--text-secondary);
}
[data-theme="dark"] .filter-bar .search-box input {
  background: #142133;
  border-color: #1e3352;
}

/* ── Forms ── */
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-control {
  background-color: #142133 !important;
  border-color: #1e3352 !important;
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .form-select option,
[data-theme="dark"] .form-control option {
  background: #142133;
  color: var(--text-secondary);
}
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-control:focus {
  border-color: var(--primary) !important;
  background-color: #142133 !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15) !important;
}
[data-theme="dark"] .form-label { color: var(--text-secondary); }
[data-theme="dark"] .search-box input {
  background: #142133;
  border-color: #1e3352;
  color: var(--text-secondary);
}
[data-theme="dark"] .input-group-text {
  background: #142133 !important;
  border-color: #1e3352 !important;
  color: var(--text-muted);
}

/* ── Alert strips ── */
[data-theme="dark"] .alert-strip.danger  { background: rgba(220,38,38,.12);  border-color: rgba(220,38,38,.3);  color: #fca5a5; }
[data-theme="dark"] .alert-strip.warning { background: rgba(234,179,8,.1);   border-color: rgba(234,179,8,.25); color: #fde68a; }
[data-theme="dark"] .alert-strip.info    { background: rgba(37,99,235,.12);  border-color: rgba(37,99,235,.3);  color: #93c5fd; }
[data-theme="dark"] .alert-strip a       { color: inherit; opacity: .85; }
[data-theme="dark"] .alert-strip a:hover { opacity: 1; }

/* ── Dropdowns ── */
[data-theme="dark"] .dropdown-menu {
  background: #0f1e35;
  border-color: #1e3352;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
[data-theme="dark"] .dropdown-item { color: var(--text-secondary); }
[data-theme="dark"] .dropdown-item:hover { background: #1a2d48; color: var(--text-primary); }
[data-theme="dark"] .dropdown-divider { border-color: #1e3352; }

/* ── Offcanvas ── */
[data-theme="dark"] .offcanvas {
  background: #0f1e35;
  color: var(--text-secondary);
}
[data-theme="dark"] .offcanvas .border-bottom { border-color: #1e3352 !important; }
[data-theme="dark"] .offcanvas-footer { border-top-color: #1e3352 !important; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(2); }

/* ── Modals ── */
[data-theme="dark"] .modal-content {
  background: #0f1e35;
  border-color: #1e3352;
  color: var(--text-secondary);
}
[data-theme="dark"] .modal-header { border-bottom-color: #1e3352; }
[data-theme="dark"] .modal-footer { border-top-color: #1e3352; }
[data-theme="dark"] .modal-title  { color: var(--text-primary); }

/* ── Buttons ── */
[data-theme="dark"] .btn-outline-secondary {
  color: #94a3b8;
  border-color: #334155;
}
[data-theme="dark"] .btn-outline-secondary:hover {
  background: #334155;
  color: #e2e8f0;
  border-color: #334155;
}
[data-theme="dark"] .btn-outline-secondary.active,
[data-theme="dark"] .btn-outline-secondary:active {
  background: #1e3352 !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .btn-outline-primary         { color: #60a5fa; border-color: #1d4ed8; }
[data-theme="dark"] .btn-outline-primary:hover   { background: rgba(37,99,235,.2); color: #93c5fd; }
[data-theme="dark"] .btn-outline-primary.active,
[data-theme="dark"] .btn-outline-primary:active  { background: rgba(37,99,235,.3) !important; color: #93c5fd !important; border-color: #2563eb !important; }
[data-theme="dark"] .btn-outline-danger   { color: #f87171; border-color: #991b1b; }
[data-theme="dark"] .btn-outline-danger:hover   { background: rgba(220,38,38,.15); color: #fca5a5; }
[data-theme="dark"] .btn-outline-warning  { color: #fbbf24; border-color: #92400e; }
[data-theme="dark"] .btn-outline-warning:hover  { background: rgba(234,179,8,.1); color: #fde68a; }

/* ── Pagination ── */
[data-theme="dark"] .page-link {
  background: #0f1e35;
  border-color: #1e3352;
  color: var(--text-secondary);
}
[data-theme="dark"] .page-link:hover { background: #1a2d48; color: var(--text-primary); }
[data-theme="dark"] .page-item.active .page-link  { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .page-item.disabled .page-link { background: #142133; color: var(--text-faint); }

/* ── Tabs ── */
[data-theme="dark"] .tabs-line             { border-bottom-color: #1e3352; }
[data-theme="dark"] .tabs-line .nav-link   { color: var(--text-muted); }
[data-theme="dark"] .nav-tabs              { border-bottom-color: #1e3352; }
[data-theme="dark"] .nav-tabs .nav-link    { color: var(--text-muted); }
[data-theme="dark"] .nav-tabs .nav-link.active {
  color: var(--primary);
  background: transparent;
  border-color: #1e3352 #1e3352 #0f1e35;
}

/* ── Progress ── */
[data-theme="dark"] .progress { background: #1e3352; }

/* ── Timeline ── */
[data-theme="dark"] .tl-item::before { background: #1e3352; }

/* ── Doc card ── */
[data-theme="dark"] .doc-card {
  background: #0f1e35;
  border-color: #1e3352;
}
[data-theme="dark"] .doc-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.4); }

/* ── File browser ── */
[data-theme="dark"] .ft-item:hover  { background: #1a2d48; }
[data-theme="dark"] .ft-item.active { background: var(--primary-light); color: #60a5fa; }
[data-theme="dark"] .file-grid .fgrid-item {
  background: #0f1e35 !important;
  border-color: #1e3352 !important;
}
[data-theme="dark"] .file-grid .fgrid-item:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.4) !important;
  border-color: #2d4a6e !important;
}
[data-theme="dark"] .file-grid .fgrid-name { color: var(--text-secondary) !important; }
[data-theme="dark"] .file-grid .fgrid-meta { color: var(--text-faint) !important; }
[data-theme="dark"] .file-grid .fgrid-item[style*="border-style:dashed"] { border-color: #2d4a6e !important; }

/* ── Login side panel ── */
[data-theme="dark"] .login-side {
  background: #0f1e35;
  border-right-color: #1e3352;
}

/* ── Breadcrumb ── */
[data-theme="dark"] .topbar .breadcrumb-item a,
[data-theme="dark"] .topbar .breadcrumb-item a.text-muted { color: #94a3b8 !important; }
[data-theme="dark"] .topbar .breadcrumb-item.active,
[data-theme="dark"] .topbar .breadcrumb-item.active.fw-600 { color: #f1f5f9 !important; }
[data-theme="dark"] .topbar .breadcrumb-item + .breadcrumb-item::before { color: #475569; }

/* ── Scrollbar ── */
[data-theme="dark"] {
  scrollbar-color: #334155 #0a1120;
}
[data-theme="dark"] ::-webkit-scrollbar-track { background: #0a1120; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ── Chart canvas legibility ── */
[data-theme="dark"] canvas { opacity: .95; }

/* ── Theme toggle ── */
[data-theme="dark"] #themeToggle { color: #fbbf24; }
#themeToggle { color: var(--text-muted); }

/* ── Colores de texto inline oscuros (invisibles en dark) ── */
[data-theme="dark"] [style*="color:#334155"]  { color: #cbd5e1 !important; }
[data-theme="dark"] [style*="color: #334155"] { color: #cbd5e1 !important; }
[data-theme="dark"] [style*="color:#0f172a"]  { color: #e2e8f0 !important; }
[data-theme="dark"] [style*="color:#1e293b"]  { color: #cbd5e1 !important; }

/* text-muted en cabeceras de tabla custom */
[data-theme="dark"] .text-muted { color: #94a3b8 !important; }

/* ── Fondos inline sin clase (attribute selectors) ── */
[data-theme="dark"] div[style*="background:#f8fafc"]   { background: #142133 !important; border-color: #1e3352 !important; }
[data-theme="dark"] div[style*="background: #f8fafc"]  { background: #142133 !important; border-color: #1e3352 !important; }
[data-theme="dark"] div[style*="background:#fafafa"]   { background: #0f1e35 !important; border-color: #1e3352 !important; }
[data-theme="dark"] div[style*="background:#f1f5f9"]   { background: #142133 !important; border-color: #1e3352 !important; }
[data-theme="dark"] div[style*="background:#fafcff"]   { background: #0f1e35 !important; }
[data-theme="dark"] div[style*="background:#f0f9ff"]   { background: #0c1a2e !important; }
[data-theme="dark"] div[style*="background:#eff6ff"]   { background: #0c1a2e !important; border-color: #1e3352 !important; }
[data-theme="dark"] div[style*="background:#fff"]      { background: #0f1e35 !important; }
[data-theme="dark"] div[style*="background: #fff"]     { background: #0f1e35 !important; }
[data-theme="dark"] div[style*="background:white"]     { background: #0f1e35 !important; }
[data-theme="dark"] section[style*="background:#fff"]  { background: #0f1e35 !important; }
[data-theme="dark"] aside[style*="background:#fff"]    { background: #0f1e35 !important; }

/* emp-row variantes con fondo de estado inline */
[data-theme="dark"] .emp-row[style*="background:#fffbeb"] { background: rgba(234,179,8,.07) !important; }
[data-theme="dark"] .emp-row[style*="background:#fff7ed"] { background: rgba(234,179,8,.06) !important; }
[data-theme="dark"] .emp-row[style*="background:#fff7f7"] { background: rgba(220,38,38,.07) !important; }

/* Filas clickable del offcanvas con fondo de estado inline */
[data-theme="dark"] tr.clickable[style*="background:#fff7f7"]  { background: rgba(220,38,38,.07) !important; }
[data-theme="dark"] tr.clickable[style*="background:#fffbeb"]  { background: rgba(234,179,8,.07) !important; }
[data-theme="dark"] tr.clickable[style*="background:#fff7ed"]  { background: rgba(234,179,8,.07) !important; }
[data-theme="dark"] tr[style*="background:#fff7f7"]            { background: rgba(220,38,38,.07) !important; }
[data-theme="dark"] tr[style*="background:#fffbeb"]            { background: rgba(234,179,8,.07) !important; }

/* card-body con fondo de estado inline */
[data-theme="dark"] .card-body[style*="background:#fff7ed"]    { background: rgba(234,179,8,.06) !important; }
[data-theme="dark"] .card-body[style*="background:#fff7f7"]    { background: rgba(220,38,38,.07) !important; }
[data-theme="dark"] .card-body[style*="background:#fffbeb"]    { background: rgba(234,179,8,.07) !important; }
