/* NORTE · Estilos propios sobre Bootstrap 5.3
   Concepto: centro de control personal. Sobrio, claro, una sola mano en móvil. */

:root {
  --norte-ink: #16324f;
  --norte-accent: #1f6aa5;
  --norte-accent-soft: #e6f0f8;
  --norte-bg: #f4f6f8;
  --norte-surface: #ffffff;
  --norte-border: #e1e6eb;
  --norte-muted: #6b7785;
  --norte-crit: #c0392b;
  --norte-high: #d9822b;
  --norte-mid: #3d7ab8;
  --norte-low: #8a96a3;
  --norte-ok: #2e8b57;
  --norte-sidebar-w: 248px;
  --norte-radius: 14px;
  --bs-primary: #1f6aa5;
  --bs-primary-rgb: 31, 106, 165;
  --bs-link-color: #1f6aa5;
  --bs-link-color-rgb: 31, 106, 165;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-bg: var(--norte-bg);
  --bs-border-radius: 10px;
}

[data-bs-theme="dark"] {
  --norte-ink: #dbe6f1;
  --norte-accent: #6cb0e6;
  --norte-accent-soft: #1b2b3b;
  --norte-bg: #0f1419;
  --norte-surface: #171e26;
  --norte-border: #26313d;
  --norte-muted: #93a1b0;
  --norte-crit: #ef6b5b;
  --norte-high: #f0a35c;
  --norte-mid: #6fa8de;
  --norte-low: #8391a0;
  --norte-ok: #5cc28a;
  --bs-primary: #4f97d3;
  --bs-primary-rgb: 79, 151, 211;
  --bs-link-color: #6cb0e6;
  --bs-link-color-rgb: 108, 176, 230;
  --bs-body-bg: var(--norte-bg);
  --bs-body-color: #dfe6ee;
}

.btn-primary { --bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary); --bs-btn-hover-bg: #195a8d; --bs-btn-hover-border-color: #195a8d; --bs-btn-active-bg: #164f7c; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0f1419; --bs-btn-hover-color: #0f1419; --bs-btn-active-color: #0f1419; --bs-btn-hover-bg: #6cb0e6; --bs-btn-hover-border-color: #6cb0e6; }
.btn-outline-primary { --bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary); --bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary); }

html, body { height: 100%; }
body { background: var(--norte-bg); -webkit-tap-highlight-color: transparent; }

/* ---------- Arranque e ingreso ---------- */
.boot { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--norte-ink); }
.boot-mark { font-size: 2.6rem; color: var(--norte-accent); }
.boot-name, .login-brand span, .brand span { font-weight: 700; letter-spacing: .28em; }
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--norte-surface); border: 1px solid var(--norte-border); border-radius: 18px; padding: 32px 28px; box-shadow: 0 10px 30px rgba(22, 50, 79, .06); }
.login-brand { display: flex; align-items: center; gap: .6rem; color: var(--norte-ink); font-size: 1.3rem; margin-bottom: 1.5rem; }
.login-brand i { color: var(--norte-accent); font-size: 1.7rem; }

/* ---------- Estructura ---------- */
.shell { min-height: 100%; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--norte-sidebar-w); flex-direction: column; background: var(--norte-surface); border-right: 1px solid var(--norte-border); padding: 18px 12px; z-index: 1020; }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--norte-ink); text-decoration: none; font-size: 1.15rem; padding: 2px 10px 10px; }
.brand i { color: var(--norte-accent); font-size: 1.45rem; }
.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.side-nav .nav-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: var(--norte-muted); padding: 10px 12px 3px; }
.side-nav .nav-group:empty { padding: 4px 0; }
.side-nav a { display: flex; align-items: center; gap: .7rem; padding: 7px 12px; border-radius: 10px; color: var(--bs-body-color); text-decoration: none; font-size: .94rem; }
.side-nav a i { font-size: 1.05rem; color: var(--norte-muted); width: 1.2rem; text-align: center; }
.side-nav a:hover { background: var(--norte-accent-soft); }
.side-nav a.active { background: var(--norte-accent-soft); color: var(--norte-accent); font-weight: 600; }
.side-nav a.active i { color: var(--norte-accent); }
.side-nav .count { margin-left: auto; font-size: .72rem; background: var(--norte-border); border-radius: 999px; padding: 1px 8px; color: var(--bs-body-color); }
.side-foot { border-top: 1px solid var(--norte-border); padding: 12px 10px 0; color: var(--norte-muted); }

.main { min-height: 100vh; display: flex; flex-direction: column; }
@media (min-width: 992px) { .main { margin-left: var(--norte-sidebar-w); } }

.topbar { position: sticky; top: 0; z-index: 1010; display: flex; align-items: center; gap: .5rem; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--norte-bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--norte-border); }
.page-title { font-size: 1.12rem; font-weight: 650; margin: 0; color: var(--norte-ink); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: .15rem; }
.btn-icon { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; border: 0; background: transparent; color: var(--bs-body-color); font-size: 1.2rem; position: relative; }
.btn-icon:hover { background: var(--norte-accent-soft); }
.bell-badge, .sync-badge { position: absolute; top: 5px; right: 4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--norte-crit); color: #fff; font-size: .66rem; display: flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 600; }
.sync-badge { background: var(--norte-high); }
.sync-state.error i { color: var(--norte-crit); }
.sync-state.offline i { color: var(--norte-muted); }
.sync-state.busy i { animation: norte-pulse 1s ease-in-out infinite; }
@keyframes norte-pulse { 50% { opacity: .35; } }
.offline-bar { background: #fff4e0; color: #7a4a00; font-size: .85rem; padding: 8px 16px; border-bottom: 1px solid #f3dcb3; }
[data-bs-theme="dark"] .offline-bar { background: #3a2a10; color: #f6d39a; border-color: #5a4318; }

.view { flex: 1; padding: 18px 16px 120px; max-width: 1180px; width: 100%; margin: 0 auto; outline: none; }
@media (min-width: 992px) { .view { padding: 26px 32px 110px; } }

/* ---------- Navegación inferior y botón de captura ---------- */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; background: var(--norte-surface); border-top: 1px solid var(--norte-border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; color: var(--norte-muted); text-decoration: none; padding: 4px 0; min-height: 48px; justify-content: center; }
.bottom-nav a i { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--norte-accent); font-weight: 600; }
.fab { position: fixed; z-index: 1040; border: 0; background: var(--norte-accent); color: #fff; box-shadow: 0 8px 22px rgba(31, 106, 165, .35); display: flex; align-items: center; justify-content: center; gap: .5rem; font-weight: 600; }
[data-bs-theme="dark"] .fab { color: #0f1419; }
.fab i { font-size: 1.5rem; }
@media (max-width: 991.98px) {
  .fab { left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); width: 62px; height: 62px; border-radius: 50%; }
  .fab .fab-label { display: none; }
}
@media (min-width: 992px) {
  .fab { right: 28px; bottom: 28px; height: 54px; padding: 0 22px 0 18px; border-radius: 27px; }
  .fab i { font-size: 1.25rem; }
}

/* ---------- Tarjetas y listas ---------- */
.card { --bs-card-bg: var(--norte-surface); --bs-card-border-color: var(--norte-border); border-radius: var(--norte-radius); }
.section-title { display: flex; align-items: center; gap: .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--norte-muted); font-weight: 650; margin: 0 0 .6rem; }
.section-title .ms-auto { text-transform: none; letter-spacing: 0; }
.panel { background: var(--norte-surface); border: 1px solid var(--norte-border); border-radius: var(--norte-radius); padding: 16px; }
.panel + .panel { margin-top: 14px; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 992px) { .grid-2 { grid-template-columns: 1.15fr .85fr; } }

.item-list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: .75rem; align-items: flex-start; padding: 11px 4px; border-bottom: 1px solid var(--norte-border); }
.item:last-child { border-bottom: 0; }
.item-main { flex: 1; min-width: 0; cursor: pointer; }
.item-title { font-weight: 550; line-height: 1.3; word-break: break-word; }
.item-meta { font-size: .8rem; color: var(--norte-muted); display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin-top: 2px; }
.item.done .item-title { text-decoration: line-through; color: var(--norte-muted); font-weight: 400; }
.item.archived { opacity: .6; }
.item-actions { display: flex; gap: .2rem; align-items: center; flex-shrink: 0; }
.check-btn { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--norte-border); background: transparent; display: inline-flex; align-items: center; justify-content: center; color: transparent; flex-shrink: 0; margin-top: 1px; }
.check-btn:hover { border-color: var(--norte-ok); color: var(--norte-ok); }
.check-btn.checked { background: var(--norte-ok); border-color: var(--norte-ok); color: #fff; }
.pending-sync { color: var(--norte-high); font-size: .75rem; }

.prio { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .3rem; vertical-align: middle; }
.prio-critica { background: var(--norte-crit); } .prio-alta { background: var(--norte-high); } .prio-media { background: var(--norte-mid); } .prio-baja { background: var(--norte-low); }
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; padding: 2px 9px; border-radius: 999px; background: var(--norte-accent-soft); color: var(--norte-ink); border: 1px solid transparent; white-space: nowrap; }
.chip-warn { background: #fff1e0; color: #8a4b00; } .chip-danger { background: #fde8e6; color: #9b2c1f; } .chip-ok { background: #e3f4ea; color: #1e6b41; } .chip-muted { background: transparent; border-color: var(--norte-border); color: var(--norte-muted); }
[data-bs-theme="dark"] .chip-warn { background: #3a2a10; color: #f6c27a; } [data-bs-theme="dark"] .chip-danger { background: #3c1c19; color: #f3a097; } [data-bs-theme="dark"] .chip-ok { background: #173326; color: #8ad8ab; }

.empty { text-align: center; color: var(--norte-muted); padding: 22px 10px; font-size: .9rem; }
.empty i { font-size: 1.6rem; display: block; margin-bottom: .35rem; opacity: .6; }

/* ---------- Mi día ---------- */
.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 16px; flex-wrap: wrap; }
.today-date { font-size: 1.55rem; font-weight: 700; color: var(--norte-ink); line-height: 1.15; }
.today-sub { color: var(--norte-muted); }
.today-clock { font-variant-numeric: tabular-nums; font-size: 1.55rem; font-weight: 300; color: var(--norte-ink); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--norte-surface); border: 1px solid var(--norte-border); border-radius: 12px; padding: 10px 12px; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 1.35rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .74rem; color: var(--norte-muted); }
.stat.alert-stat b { color: var(--norte-crit); }
@media (max-width: 575.98px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.prio-slot { display: flex; gap: .75rem; padding: 12px; border: 1px solid var(--norte-border); border-radius: 12px; margin-bottom: 8px; background: var(--norte-surface); }
.prio-slot .num { width: 30px; height: 30px; border-radius: 9px; background: var(--norte-accent-soft); color: var(--norte-accent); font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.prio-slot.empty-slot { border-style: dashed; color: var(--norte-muted); cursor: pointer; align-items: center; }
.prio-slot.empty-slot:hover { border-color: var(--norte-accent); color: var(--norte-accent); }
.prio-slot.done .num { background: var(--norte-ok); color: #fff; }
.transition-strip { display: flex; align-items: center; gap: .75rem; padding: 10px 14px; border-radius: 12px; background: var(--norte-accent-soft); margin-bottom: 14px; font-size: .9rem; text-decoration: none; color: var(--norte-ink); }
.transition-strip .progress { flex: 1; height: 6px; max-width: 220px; }

/* ---------- Calendario ---------- */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 12px; }
.cal-toolbar .cal-label { font-weight: 650; font-size: 1.05rem; min-width: 10rem; }
.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--norte-border); border-radius: var(--norte-radius); overflow: hidden; background: var(--norte-surface); }
.cal-month .dow { font-size: .72rem; text-transform: uppercase; color: var(--norte-muted); text-align: center; padding: 6px 0; border-bottom: 1px solid var(--norte-border); }
.cal-day { min-height: 92px; border-right: 1px solid var(--norte-border); border-bottom: 1px solid var(--norte-border); padding: 4px 5px; cursor: pointer; overflow: hidden; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.other { background: color-mix(in srgb, var(--norte-bg) 60%, transparent); color: var(--norte-muted); }
.cal-day.today .d { background: var(--norte-accent); color: #fff; }
[data-bs-theme="dark"] .cal-day.today .d { color: #0f1419; }
.cal-day .d { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; align-items: center; justify-content: center; font-size: .82rem; font-weight: 600; }
.cal-day .load { height: 4px; border-radius: 2px; margin: 3px 0; background: var(--norte-accent); }
.cal-ev { font-size: .72rem; line-height: 1.25; padding: 1px 4px; border-radius: 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--norte-mid); background: var(--norte-accent-soft); }
.cal-ev.t-reunion { border-color: #7a52b3; } .cal-ev.t-evento { border-color: #2e8b8b; } .cal-ev.t-recordatorio { border-color: var(--norte-high); } .cal-ev.t-prioridad { border-color: var(--norte-crit); } .cal-ev.t-compromiso { border-color: #8a6d3b; }
.cal-ev.st-done { text-decoration: line-through; opacity: .6; }
@media (max-width: 575.98px) { .cal-day { min-height: 58px; } .cal-day .cal-ev { display: none; } .cal-day .more { display: block !important; } }
.cal-week { display: grid; grid-template-columns: 52px repeat(7, minmax(110px, 1fr)); border: 1px solid var(--norte-border); border-radius: var(--norte-radius); background: var(--norte-surface); overflow-x: auto; }
.cal-week .hcol { font-size: .7rem; color: var(--norte-muted); text-align: right; padding-right: 6px; }
.cal-week .colhead { position: sticky; top: 0; text-align: center; font-size: .78rem; padding: 6px 2px; border-bottom: 1px solid var(--norte-border); border-left: 1px solid var(--norte-border); background: var(--norte-surface); cursor: pointer; text-transform: capitalize; }
.cal-week .colhead.today { color: var(--norte-accent); font-weight: 700; }
.cal-week .slot { border-left: 1px solid var(--norte-border); border-top: 1px dashed var(--norte-border); min-height: 44px; padding: 2px; }
.cal-week .allday { border-left: 1px solid var(--norte-border); padding: 2px; border-bottom: 1px solid var(--norte-border); min-height: 26px; }
.legend { display: flex; flex-wrap: wrap; gap: .8rem; font-size: .76rem; color: var(--norte-muted); margin-top: 10px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; background: var(--c); }
.agenda-day { font-weight: 650; font-size: .85rem; color: var(--norte-muted); margin: 14px 0 4px; text-transform: capitalize; }
.time-col { width: 3.2rem; flex-shrink: 0; font-variant-numeric: tabular-nums; color: var(--norte-muted); font-size: .85rem; padding-top: 2px; }

/* ---------- Formularios y varios ---------- */
.form-label { font-size: .85rem; font-weight: 550; margin-bottom: .25rem; }
.form-text { font-size: .76rem; }
.modal-content { border-radius: 18px; background: var(--norte-surface); }
/* En el celular los diálogos son hojas inferiores: los botones quedan al alcance del pulgar. */
@media (max-width: 575.98px) {
  .modal-dialog, .modal-dialog-scrollable { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; max-width: none; width: 100%; height: auto; max-height: 92vh; }
  .modal-dialog-scrollable .modal-content { max-height: 92vh; }
  .modal-content { border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .modal.fade .modal-dialog { transform: translateY(60px); }
  .modal.show .modal-dialog { transform: none; }
}
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 12px; }
.filters .form-select, .filters .form-control { width: auto; min-width: 9rem; flex: 1 1 9rem; max-width: 16rem; }
/* Pestañas segmentadas: una sola línea; si no entran, se desplazan con el dedo. */
.seg { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; background: var(--norte-surface); border: 1px solid var(--norte-border); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: nowrap; vertical-align: middle; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: .86rem; color: var(--bs-body-color); white-space: nowrap; flex-shrink: 0; transition: background .15s, color .15s; }
.seg button:hover { color: var(--norte-accent); }
.seg button.active { background: var(--norte-accent); color: #fff; font-weight: 600; box-shadow: 0 2px 6px rgba(31, 106, 165, .25); }
[data-bs-theme="dark"] .seg button.active { color: #0f1419; }
.tabs-scroll { overflow-x: auto; white-space: nowrap; margin-bottom: 12px; padding-bottom: 2px; }
.kv { display: grid; grid-template-columns: minmax(8rem, 30%) 1fr; gap: .35rem 1rem; font-size: .9rem; }
.kv dt { color: var(--norte-muted); font-weight: 500; }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.history-entry { border-left: 2px solid var(--norte-border); padding: 2px 0 10px 12px; margin-left: 4px; font-size: .86rem; }
.history-entry time { color: var(--norte-muted); font-size: .76rem; display: block; }
.diff-table td { vertical-align: top; font-size: .85rem; white-space: pre-wrap; word-break: break-word; }
.chart-box { position: relative; height: 260px; }
.review-q { margin-bottom: 14px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 767.98px) { .compare-grid { grid-template-columns: 1fr; } }
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .bottom-nav, .fab, .offline-bar, .no-print { display: none !important; }
  .main { margin: 0 !important; } .view { padding: 0; max-width: none; } .print-only { display: block; }
  .panel { border: 0; padding: 0; }
}
.toast { border-radius: 12px; }
.text-crit { color: var(--norte-crit) !important; }
.text-muted2 { color: var(--norte-muted) !important; }
.cursor-pointer { cursor: pointer; }
.min-w-0 { min-width: 0; }

/* ====================================================================
   Barra de filtros (búsqueda + píldoras con selección múltiple)
   ==================================================================== */
.view-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 12px; }
.view-head .ms-auto { flex-shrink: 0; }
.fbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .6rem; margin-bottom: 14px; }
.fbar-search { position: relative; flex: 1 1 15rem; max-width: 26rem; margin: 0; }
.fbar-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--norte-muted); font-size: .9rem; pointer-events: none; }
.fbar-search input { width: 100%; height: 38px; border-radius: 999px; border: 1px solid var(--norte-border); background: var(--norte-surface); padding: 0 14px 0 36px; font-size: .9rem; color: var(--bs-body-color); outline: none; transition: border-color .15s, box-shadow .15s; }
.fbar-search input:focus { border-color: var(--norte-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--norte-accent) 18%, transparent); }
.fbar-chips { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; min-width: 0; }
.fchip { display: inline-flex; align-items: center; gap: .35rem; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--norte-border); background: var(--norte-surface); color: var(--bs-body-color); font-size: .84rem; white-space: nowrap; flex-shrink: 0; cursor: pointer; transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
.fchip:hover { border-color: color-mix(in srgb, var(--norte-accent) 55%, var(--norte-border)); }
.fchip i { font-size: .85rem; color: var(--norte-muted); }
.fchip .fchev { font-size: .7rem; margin-left: .1rem; }
.fchip b { font-weight: 600; }
.fchip.active { background: var(--norte-accent-soft); border-color: color-mix(in srgb, var(--norte-accent) 45%, transparent); color: var(--norte-accent); }
.fchip.active i { color: var(--norte-accent); }
.fchip[aria-expanded="true"] { box-shadow: 0 0 0 3px color-mix(in srgb, var(--norte-accent) 18%, transparent); }
.fchip.fclear { border-style: dashed; color: var(--norte-muted); }
.fcount { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; align-items: center; justify-content: center; background: var(--norte-accent); color: #fff; font-size: .72rem; font-weight: 700; }
[data-bs-theme="dark"] .fcount { color: #0f1419; }
/* En el celular las píldoras quedan en una sola fila deslizable, sin ocupar media pantalla. */
@media (max-width: 767.98px) {
  .fbar-search { flex: 1 1 100%; max-width: none; }
  .fbar-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 4px; width: calc(100% + 32px); scrollbar-width: none; }
  .fbar-chips::-webkit-scrollbar { display: none; }
  .fbar-chips::after { content: ""; flex: 0 0 4px; }
}

/* ---------- Paneles emergentes / hojas inferiores ---------- */
.pop-backdrop { position: fixed; inset: 0; z-index: 1065; }
.pop-backdrop.is-sheet { background: rgba(10, 20, 30, 0); transition: background .16s; }
.pop-backdrop.is-sheet.open { background: rgba(10, 20, 30, .38); }
.pop-backdrop.closing { pointer-events: none; }
.pop { background: var(--norte-surface); color: var(--bs-body-color); border: 1px solid var(--norte-border); box-shadow: 0 14px 40px rgba(16, 32, 48, .18); }
.pop-float { position: fixed; border-radius: 14px; padding: 12px; max-height: min(70vh, 520px); overflow-y: auto; opacity: 0; transform: translateY(-4px); transition: opacity .12s, transform .12s; }
.pop-backdrop.open .pop-float { opacity: 1; transform: none; }
.pop-sheet { position: fixed; left: 0; right: 0; bottom: 0; border-radius: 20px 20px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 82vh; overflow-y: auto; transform: translateY(100%); transition: transform .18s ease-out; }
.pop-sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--norte-border); margin: 0 auto 10px; }
.pop-backdrop.open .pop-sheet { transform: none; }
.pop-backdrop.closing .pop-sheet { transform: translateY(100%); }
.fpop-head { display: flex; align-items: center; gap: .5rem; padding: 2px 4px 8px; font-size: .92rem; }
.fpop-head .btn-link { padding: 0; font-size: .82rem; text-decoration: none; }
.fpop-list { display: flex; flex-direction: column; gap: 2px; }
.fopt { display: flex; align-items: center; gap: .6rem; width: 100%; border: 0; background: transparent; padding: 9px 8px; border-radius: 10px; text-align: left; color: var(--bs-body-color); font-size: .9rem; }
.fopt:hover, .fopt:focus-visible { background: var(--norte-accent-soft); outline: none; }
.fbox { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--norte-border); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .12s, border-color .12s; }
.fbox.radio { border-radius: 50%; }
.fbox i { font-size: .8rem; color: transparent; }
.fopt.on .fbox { background: var(--norte-accent); border-color: var(--norte-accent); }
.fopt.on .fbox i { color: #fff; }
[data-bs-theme="dark"] .fopt.on .fbox i { color: #0f1419; }
.fdot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.flabel { flex: 1; min-width: 0; }
.fpop-foot { display: flex; align-items: center; gap: .5rem; border-top: 1px solid var(--norte-border); margin-top: 8px; padding-top: 10px; }
.fpresets { display: flex; flex-wrap: wrap; gap: .35rem; }
.fpresets .fchip { height: 30px; font-size: .8rem; }
@media (max-width: 575.98px) { .fopt { padding: 12px 8px; font-size: .95rem; } }

/* ---------- Selector de fecha y hora ---------- */
.dp { position: relative; }
.dp .dp-text { padding-left: 2.3rem; font-variant-numeric: tabular-nums; cursor: text; }
.dp .dp-text[readonly] { background-color: var(--bs-body-bg); cursor: pointer; }
.modal .dp .dp-text[readonly], .panel .dp .dp-text[readonly] { background-color: var(--bs-form-control-bg, #fff); }
.dp .dp-ico { position: absolute; left: 0; top: 0; bottom: 0; width: 2.3rem; display: flex; align-items: center; justify-content: center; color: var(--norte-muted); cursor: pointer; z-index: 2; }
.dp .dp-ico:hover { color: var(--norte-accent); }
.dp-sm .dp-text { padding-left: 2rem; }
.dp-sm .dp-ico { width: 2rem; font-size: .85rem; }
.dt-pair { display: grid; grid-template-columns: 1fr 8.5rem; gap: .5rem; }
.dp-inline { width: 7.5rem; }
.dp-pop { padding: 12px 12px 10px; }
.dp-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.dp-title { flex: 1; text-align: center; font-weight: 650; text-transform: capitalize; font-size: .95rem; }
.dp-nav { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 8px; color: var(--norte-muted); }
.dp-nav:hover { background: var(--norte-accent-soft); color: var(--norte-accent); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: .7rem; color: var(--norte-muted); font-weight: 600; padding: 4px 0; }
.dp-day { aspect-ratio: 1; border: 0; background: transparent; border-radius: 50%; font-size: .86rem; color: var(--bs-body-color); font-variant-numeric: tabular-nums; }
.dp-day:hover, .dp-day:focus-visible { background: var(--norte-accent-soft); outline: none; }
.dp-day.today { color: var(--norte-accent); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--norte-accent); }
.dp-day.sel { background: var(--norte-accent); color: #fff; font-weight: 700; box-shadow: none; }
[data-bs-theme="dark"] .dp-day.sel { color: #0f1419; }
.dp-foot { display: flex; align-items: center; gap: .4rem; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--norte-border); }
.dp-tlabel { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--norte-muted); font-weight: 650; margin: 2px 2px 6px; }
.dp-hours { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 10px; }
.dp-mins { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.dp-cell { border: 1px solid var(--norte-border); background: transparent; border-radius: 9px; height: 36px; font-size: .88rem; font-variant-numeric: tabular-nums; color: var(--bs-body-color); }
.dp-cell:hover:not(:disabled) { border-color: var(--norte-accent); color: var(--norte-accent); }
.dp-cell.sel { background: var(--norte-accent); border-color: var(--norte-accent); color: #fff; font-weight: 700; }
[data-bs-theme="dark"] .dp-cell.sel { color: #0f1419; }
.dp-cell:disabled { opacity: .35; }
@media (max-width: 575.98px) { .dp-day { font-size: .98rem; } .dp-cell { height: 42px; } .dp-pop { padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); } }

/* ---------- Tarjetas y filas: el texto nunca queda aplastado ---------- */
.item-main { overflow-wrap: anywhere; }
.item-meta > * { max-width: 100%; }
.item-meta .text-truncate { min-width: 0; }
@media (max-width: 575.98px) {
  .item { gap: .6rem; }
  .item-actions .btn { padding: .3rem .45rem; }
  .panel { padding: 14px; }
}
.stat { min-width: 0; }
.stat span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Calendario: barra, vistas adaptables y arrastre ---------- */
.cal-toolbar .cal-label { border: 0; background: transparent; padding: 4px 8px; border-radius: 8px; color: inherit; display: inline-flex; align-items: center; gap: .35rem; }
.cal-toolbar .cal-label:hover { background: var(--norte-accent-soft); }
.cal-toolbar .cal-label i { font-size: .75rem; color: var(--norte-muted); }
.cal-nav { display: inline-flex; align-items: center; background: var(--norte-surface); border: 1px solid var(--norte-border); border-radius: 999px; padding: 2px; }
.cal-nav button { border: 0; background: transparent; height: 32px; min-width: 32px; padding: 0 10px; border-radius: 999px; color: var(--bs-body-color); font-size: .86rem; }
.cal-nav button:hover { background: var(--norte-accent-soft); color: var(--norte-accent); }
.cal-week { grid-template-columns: 52px repeat(var(--cols, 7), minmax(0, 1fr)); overflow: visible; }
.cal-week.cols-1 { --cols: 1; }
.cal-week .slot { position: relative; }
.cal-week .slot::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dotted color-mix(in srgb, var(--norte-border) 60%, transparent); pointer-events: none; }
.cal-ev { cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cal-ev.drag { cursor: grab; }
.cal-week .cal-ev, .cal-week.cols-1 .cal-ev { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.cal-week.cols-1 .cal-ev { font-size: .82rem; padding: 4px 8px; -webkit-line-clamp: 3; }
.cal-ev.dragging-src { opacity: .35; }
.cal-ghost { position: fixed; z-index: 2000; pointer-events: none; font-size: .8rem; padding: 6px 10px; border-radius: 8px; background: var(--norte-surface); border-left: 4px solid var(--norte-accent); box-shadow: 0 10px 28px rgba(16, 32, 48, .28); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transform: translate(-50%, -120%) rotate(-2deg); }
.cal-ghost small { display: block; color: var(--norte-accent); font-weight: 650; }
.drop-target { background: color-mix(in srgb, var(--norte-accent) 14%, transparent) !important; box-shadow: inset 0 0 0 2px var(--norte-accent); }
.cal-ev.lift { animation: norte-lift .25s ease-out; }
@keyframes norte-lift { 0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none !important; }
.cal-hint { font-size: .78rem; color: var(--norte-muted); margin-top: 8px; }
@media (max-width: 575.98px) {
  .cal-week { grid-template-columns: 34px repeat(var(--cols, 7), minmax(0, 1fr)); }
  .cal-week .hcol { font-size: .6rem; padding-right: 3px; }
  .cal-week .colhead { font-size: .66rem; padding: 4px 0; line-height: 1.15; }
  .cal-week .cal-ev { font-size: .58rem; padding: 1px 2px; border-left-width: 2px; -webkit-line-clamp: 3; }
  .cal-week.cols-1 { grid-template-columns: 40px 1fr; }
  .cal-week.cols-1 .cal-ev { font-size: .8rem; }
  .cal-week .slot { min-height: 40px; }
  .cal-toolbar { gap: .4rem; }
  .cal-toolbar .cal-label { font-size: .95rem; min-width: 0; }
}
.seg-count { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; margin-left: .2rem; border-radius: 9px; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; background: var(--norte-border); color: var(--bs-body-color); vertical-align: 1px; }
.seg button.active .seg-count { background: rgba(255, 255, 255, .25); color: inherit; }
.view-head .seg { flex: 0 1 auto; min-width: 0; }
.view-head .fbar { margin-bottom: 0; }
[data-fbar="buscar"] .fbar-search { flex-basis: 100%; max-width: none; }
[data-fbar="buscar"] .fbar-search input { height: 46px; font-size: 1rem; }
@media (max-width: 575.98px) {
  .view-head { gap: .5rem; }
  .view-head .seg { flex: 1 1 auto; }
  .view-head > .btn { flex: 0 0 auto; }
}
.lock-ico { font-size: 3.2rem; color: var(--norte-accent); display: block; margin: .5rem 0 .75rem; }
@media (max-width: 767.98px) { .view-head > .fbar-chips { margin: 0; padding: 0; width: auto; flex: 1 1 auto; } }
.obj-desc { white-space: pre-line; font-size: .84rem; color: var(--norte-muted); margin-top: 6px; line-height: 1.45; overflow-wrap: anywhere; }

/* ---------- Ajuste a cualquier ancho (también con la letra del celular agrandada) ---------- */
/* Las columnas de grilla no pueden ser más anchas que la pantalla por el contenido. */
.grid-2 { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 992px) { .grid-2 { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); } }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 575.98px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.compare-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 767.98px) { .compare-grid { grid-template-columns: minmax(0, 1fr); } }
.panel, .grid-2 > *, .prio-slot > *, .item > *, .today-head > *, .view-head > * { min-width: 0; }
.section-title { flex-wrap: wrap; row-gap: .25rem; }
.prio-slot, .item-title, .item-meta, .panel, .today-sub, .transition-strip { overflow-wrap: anywhere; }
.transition-strip { flex-wrap: wrap; }
.today-date { overflow-wrap: anywhere; }
/* Red de seguridad: si algún contenido raro se pasara del ancho, no aparece desplazamiento lateral en la página. */
.main { overflow-x: clip; }

.view-head > .btn { max-width: 100%; white-space: normal; text-align: center; }
.stat span { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.2; }

/* ---------- Asistencia ---------- */
.att-row { flex-wrap: wrap; }
.att-row .item-main { flex: 1 1 14rem; }
.att-actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; margin-left: auto; }
@media (max-width: 575.98px) { .att-actions { width: 100%; justify-content: flex-end; } }
.att-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.att-cards .panel + .panel { margin-top: 0; }
.att-card { cursor: pointer; }
.att-card:hover { border-color: color-mix(in srgb, var(--norte-accent) 45%, var(--norte-border)); }
.att-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.att-grid-lg { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); }
.att-kv { background: var(--norte-bg); border-radius: 10px; padding: 7px 9px; min-width: 0; }
.att-grid-lg .att-kv { background: var(--norte-surface); border: 1px solid var(--norte-border); }
.att-kv span { display: block; font-size: .72rem; color: var(--norte-muted); }
.att-kv b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.att-kv small { display: block; font-size: .7rem; color: var(--norte-muted); overflow-wrap: anywhere; }
.att-kv.warn b { color: var(--norte-high); }
.att-alert { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: #fff4e0; color: #7a4a00; margin-bottom: 14px; font-size: .9rem; text-decoration: none; }
[data-bs-theme="dark"] .att-alert { background: #3a2a10; color: #f6d39a; }
.att-alert b { font-weight: 650; }
.sched { display: flex; flex-direction: column; gap: 6px; }
.sched-row { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr) minmax(0, 6.5rem) minmax(0, 6.5rem); gap: 6px; align-items: center; }
.sched-row.off .dp { opacity: .35; pointer-events: none; }
.sched-day { font-size: .86rem; font-weight: 550; }
@media (max-width: 575.98px) { .sched-row { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); gap: 4px; } .sched-day { grid-column: 1 / -1; margin-top: 2px; font-size: .8rem; } .sched-row .form-select { padding-left: .5rem; padding-right: 1.6rem; background-position: right .4rem center; } .sched-row .dp-sm .dp-text { padding-left: 1.7rem; padding-right: .3rem; } .sched-row .dp-sm .dp-ico { width: 1.7rem; } }

/* ---------------------------------------------------------------- Administración (usuarios, roles, actividad) */
.item.selected { background: var(--norte-accent-soft); border-radius: 10px; }
.item.selected .item-title { color: var(--norte-accent); }
.perm-matrix th { font-size: .78rem; font-weight: 600; color: var(--norte-muted); white-space: nowrap; }
.perm-matrix td:first-child { min-width: 12rem; }
.perm-matrix td .bi { color: var(--norte-muted); margin-right: .25rem; }
.perm-matrix .perm-group td { background: transparent; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--norte-muted); padding-top: .9rem; border-bottom-width: 0; }
.perm-matrix .form-check-input { width: 1.15rem; height: 1.15rem; cursor: pointer; }
.menu-order li { border-bottom: 1px solid var(--norte-border); }
.menu-order li:last-child { border-bottom: 0; }
.who-line { margin-top: .35rem; }
@media (max-width: 575.98px) {
  .perm-matrix td:first-child { min-width: 9rem; font-size: .85rem; }
}

/* Filas con varios botones: si el texto quedaría con menos de ~9 letras de ancho (celular chico o letra grande),
   los botones bajan a la línea siguiente en lugar de aplastar el texto. */
.item { flex-wrap: wrap; }
.item-main { flex: 1 1 9rem; }
.item-actions { margin-left: auto; }
