:root { --hdr-h: 60px; --sb-w: 240px; }
body { background: var(--bs-tertiary-bg); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[data-bs-theme="dark"] body { background: #0b1220; }

/* Encabezado */
.app-header { position: fixed; top: 0; left: 0; right: 0; height: var(--hdr-h); background: var(--hdr-bg); color: var(--hdr-fg); z-index: 1030; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.app-header .hdr-btn, .app-header .hdr-brand { color: var(--hdr-fg) !important; }
.hdr-logo { height: 38px; border-radius: 4px; background: #fff; padding: 2px 4px; }
.hdr-pill { background: rgba(255,255,255,.15); color: var(--hdr-fg); border: 1px solid rgba(127,127,127,.35); font-weight: 500; }
.hdr-pill.warn { background: #f59e0b; color: #000; }

/* Menu lateral */
.app-sidebar { position: fixed; top: var(--hdr-h); bottom: 0; left: 0; width: var(--sb-w); background: var(--sb-bg); color: var(--sb-fg); overflow-y: auto; z-index: 1020; display: flex; flex-direction: column; justify-content: space-between; transition: transform .2s; }
.app-sidebar .nav-link { color: var(--sb-fg); opacity: .85; padding: .65rem 1.2rem; display: flex; gap: .75rem; align-items: center; border-left: 3px solid transparent; }
.app-sidebar .nav-link:hover { opacity: 1; background: rgba(255,255,255,.07); }
.app-sidebar .nav-link.active { opacity: 1; background: rgba(255,255,255,.14); border-left-color: #38bdf8; font-weight: 600; }
.app-sidebar .nav-link i { font-size: 1.1rem; }
.sb-foot { opacity: .55; }
.app-main { margin-left: var(--sb-w); padding-top: var(--hdr-h); min-height: 100vh; }
.sb-backdrop { display: none; }
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.show { transform: none; box-shadow: 4px 0 20px rgba(0,0,0,.3); }
  .sb-backdrop.show { display: block; position: fixed; inset: var(--hdr-h) 0 0 0; background: rgba(0,0,0,.4); z-index: 1010; }
  .app-main { margin-left: 0; }
}

/* Componentes */
.card { border: 1px solid var(--bs-border-color-translucent); box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.kpi .kpi-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; }
.kpi .kpi-val { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.page-title { font-weight: 700; margin: 0; }
.table > :not(caption) > * > * { vertical-align: middle; }
.status-tabs .nav-link { white-space: nowrap; }
.status-tabs { flex-wrap: nowrap; overflow-x: auto; }
.notif-menu { width: 360px; max-width: 92vw; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: block; padding: .6rem 1rem; border-bottom: 1px solid var(--bs-border-color-translucent); text-decoration: none; color: inherit; }
.notif-item.unread { background: rgba(2,132,199,.08); }
.notif-item:hover { background: var(--bs-secondary-bg); }
.timeline { list-style: none; padding-left: 0; position: relative; }
.timeline li { position: relative; padding-left: 28px; padding-bottom: 14px; }
.timeline li::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: -6px; width: 2px; background: var(--bs-border-color); }
.timeline li:last-child::before { display: none; }
.timeline li .dot { position: absolute; left: 2px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--bs-primary); border: 2px solid var(--bs-body-bg); }
.partidas input { min-width: 70px; }
.color-swatch { width: 46px; height: 38px; padding: 2px; }
.login-bg { min-height: 100vh; background: linear-gradient(135deg, #020617 0%, #0b2545 55%, #0284c7 100%); }
.chart-box { position: relative; height: 280px; }
.sig-pad { border: 2px dashed var(--bs-border-color); border-radius: 10px; touch-action: none; width: 100%; height: 220px; background: #fff; }

/* ---- SweetAlert2 integrado con Bootstrap (claro / oscuro) */
html .swal2-container .crm-swal.swal2-popup { background: var(--bs-body-bg); color: var(--bs-body-color); border: 1px solid var(--bs-border-color); border-radius: 14px; font-family: var(--bs-body-font-family); }
html .crm-swal .swal2-title { color: var(--bs-emphasis-color); font-size: 1.35rem; }
html .crm-swal .swal2-html-container { color: var(--bs-body-color); font-size: 1rem; }
html .swal2-container .crm-swal.swal2-toast { background: var(--bs-body-bg); color: var(--bs-body-color); box-shadow: 0 10px 30px rgba(0,0,0,.18) !important; }
html .crm-swal.swal2-toast .swal2-html-container { font-size: .9rem; margin: .25rem .5rem; }
.crm-swal .swal2-close { color: var(--bs-secondary-color); }
.crm-swal .swal2-timer-progress-bar { background: var(--bs-primary); }
.swal2-container { z-index: 2000; }

/* ---- Botones siempre rellenos: toggles (btn-check) marcan el seleccionado en azul */
.btn-check:checked + .btn-secondary, .btn-check:checked + .btn-light { background: var(--bs-primary); border-color: var(--bs-primary); color: #fff; }
