/* ============================================================
   Budovision — sistema visual v3 (azul tecnológico, barra lateral)
   Oscuro por defecto; claro con [data-theme="light"].
   ============================================================ */
:root, [data-theme="dark"] {
    --bg:            #0b1220;
    --surface:       #111a2e;
    --surface-2:     #172340;
    --surface-3:     #1e2c4f;
    --border:        #243352;
    --border-strong: #33466b;
    --text:          #e6ecf7;
    --text-muted:    #9fb0cc;
    --text-faint:    #6f819f;

    --accent:        #3b82f6;
    --accent-soft:   rgba(59,130,246,.16);
    --accent-text:   #7fb0ff;
    --select:        #22d3ee;   /* seleccionado en mapa y gráficas */

    --btn-bg:        #3b82f6;
    --btn-text:      #ffffff;
    --btn-bg-hover:  #2f6fe0;

    --danger:        #f26d6d;  --danger-bg:  #2b1c24;
    --success:       #3ecf7a;  --success-bg: #12291f;
    --warn:          #f0b04a;  --warn-bg:    #2b2518;

    --st-nuevo: #60a5fa; --st-confirmado: #f59e0b; --st-en_reparacion: #a78bfa; --st-reparado: #22c55e; --st-descartado: #6b7280;
    --sev-alta: #ef4444; --sev-media: #f59e0b; --sev-baja: #22c55e;

    --radius: 10px; --radius-sm: 7px; --topbar-h: 56px; --sidebar-w: 240px; --sidebar-c: 64px;
    --shadow:    0 1px 2px rgba(0,0,0,.35);
    --shadow-md: 0 6px 16px rgba(0,0,0,.35);
    --shadow-lg: 0 18px 48px rgba(0,0,0,.55);
    --ease: cubic-bezier(.33,.1,.25,1);
    --font-ui: "IBM Plex Sans", "Segoe UI", Roboto, system-ui, sans-serif;
    --font-display: "Barlow Semi Condensed", "Arial Narrow", "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
    color-scheme: dark;
}
[data-theme="light"] {
    --bg: #f3f6fb; --surface: #ffffff; --surface-2: #eaf0f9; --surface-3: #dde6f3;
    --border: #d6dfec; --border-strong: #b9c7dc;
    --text: #101a2e; --text-muted: #526180; --text-faint: #8593ab;
    --accent: #2563eb; --accent-soft: rgba(37,99,235,.12); --accent-text: #1d4ed8; --select: #0891b2;
    --btn-bg: #2563eb; --btn-text: #ffffff; --btn-bg-hover: #1d4ed8;
    --danger: #d64545; --danger-bg: #fdecec; --success: #1f9d5b; --success-bg: #e7f6ee; --warn: #b97f17; --warn-bg: #fbf2e1;
    --st-nuevo: #3b82f6;
    --shadow: 0 1px 2px rgba(16,24,40,.06); --shadow-md: 0 4px 12px rgba(16,24,40,.08); --shadow-lg: 0 16px 40px rgba(16,24,40,.16);
    color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid var(--bg); }
html { height: 100%; }
body { min-height: 100%; font-family: var(--font-ui); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
.icon { flex-shrink: 0; }
::selection { background: var(--accent-soft); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: .01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --------------------------- Barra superior --------------------------- */
.app-layout { min-height: 100vh; display: flex; }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); transition: width .2s var(--ease), transform .2s var(--ease); z-index: 40; overflow: hidden; }
.sidebar-head { display: flex; align-items: center; height: var(--topbar-h); padding: 0 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(140deg, var(--accent), #1d4ed8); color: #fff; flex-shrink: 0; box-shadow: 0 4px 12px rgba(59,130,246,.35); }
.brand small { display: block; font-family: var(--font-ui); font-weight: 400; font-size: 11px; letter-spacing: .02em; text-transform: none; color: var(--text-muted); line-height: 1; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 10px; flex: 1; overflow-y: auto; overflow-x: hidden; }
.nav-label { font-family: var(--font-display); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); padding: 12px 12px 4px; white-space: nowrap; }
.nav-item { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 500; position: relative; white-space: nowrap; transition: background .15s var(--ease), color .15s var(--ease); }
.nav-item .icon { flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }
.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-toggle { display: flex; align-items: center; gap: 12px; width: 100%; height: 38px; padding: 0 12px; border: none; background: transparent; color: var(--text-muted); border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; font-size: 13px; white-space: nowrap; }
.sidebar-toggle:hover { background: var(--surface-2); color: var(--text); }
.sidebar-toggle .icon { transition: transform .2s var(--ease); flex-shrink: 0; transform: rotate(180deg); }
html.nav-collapsed .sidebar { width: var(--sidebar-c); }
html.nav-collapsed .brand > span:not(.brand-mark), html.nav-collapsed .nav-item span, html.nav-collapsed .sidebar-toggle span, html.nav-collapsed .nav-label { display: none; }
html.nav-collapsed .sidebar-head, html.nav-collapsed .nav-item, html.nav-collapsed .sidebar-toggle { justify-content: center; padding: 0; }
html.nav-collapsed .sidebar-toggle .icon { transform: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border: none; background: transparent; color: var(--text-muted); border-radius: var(--radius-sm); cursor: pointer; transition: .15s var(--ease); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.menu-btn { display: none; }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(4,8,16,.55); z-index: 39; }
.backdrop.show { display: block; }
.tenant-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; color: var(--text-muted); }

/* Menú de usuario / alertas */
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; background: transparent; border: 1px solid transparent; border-radius: 999px; cursor: pointer; color: var(--text); font-family: inherit; transition: .15s; }
.user-btn:hover { background: var(--surface-2); }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #ffffff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-name { font-weight: 500; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 250px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; opacity: 0; visibility: hidden; transform: translateY(-6px); transition: .16s var(--ease); z-index: 50; }
.user-menu.open .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-head { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-head small { color: var(--text-muted); }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text); }
.dropdown-item:hover { background: var(--surface-2); }
.alert-dot { position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; border-radius: 99px; display: grid; place-items: center; line-height: 1; box-shadow: 0 0 0 2px var(--surface); }

/* --------------------------- Contenido --------------------------- */
.content { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; flex: 1; }
body.page-full .content { padding: 0; max-width: none; margin: 0; display: flex; flex-direction: column; }
.page-anim { animation: fadeUp .3s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 22px 0 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 22px; font-weight: 600; }
.muted { color: var(--text-muted); }
.eyebrow { font-family: var(--font-display); font-weight: 600; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }

/* --------------------------- Flash / Toast --------------------------- */
.flash { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid transparent; }
.flash-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.flash-error   { background: var(--danger-bg);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.flash-info    { background: var(--accent-soft); color: var(--accent-text); }
.flash-close { background: none; border: none; color: inherit; cursor: pointer; display: grid; place-items: center; }
.toast-wrap { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 300; }
.toast { display: flex; align-items: center; gap: 11px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 12px 14px; border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 270px; max-width: 380px; animation: toastIn .25s var(--ease); }
.toast.success { border-left-color: var(--success); } .toast.success .toast-ico { color: var(--success); }
.toast.error   { border-left-color: var(--danger); }  .toast.error .toast-ico { color: var(--danger); }
.toast-ico { color: var(--accent); }
.toast.hide { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* --------------------------- Botones / badges --------------------------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap; font-family: inherit; transition: background .15s var(--ease), border-color .15s var(--ease), transform .09s var(--ease); }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--btn-bg); color: var(--btn-text); border-color: var(--btn-bg); font-weight: 600; }
.btn-primary:hover { background: var(--btn-bg-hover); border-color: var(--btn-bg-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 7px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-muted   { background: var(--surface-2); color: var(--text-muted); box-shadow: inset 0 0 0 1px var(--border); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warn    { background: var(--warn-bg); color: var(--warn); }
.badge-accent  { background: var(--accent-soft); color: var(--accent-text); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--text); font-family: inherit; transition: .15s var(--ease); }
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.chip .d { width: 9px; height: 9px; border-radius: 50%; }

/* --------------------------- Cards / grids / stats --------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-header h2 { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.stat-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); flex-shrink: 0; }
.stat-meta .stat-label { color: var(--text-muted); font-size: 12.5px; }
.stat-meta .stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi .v { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1.1; }
.kpi .l { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }
.kpi .delta { font-size: 12px; margin-top: 6px; font-weight: 600; }
.kpi .delta.up { color: var(--success); } .kpi .delta.down { color: var(--danger); } .kpi .delta.flat { color: var(--text-faint); }
.hbar { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.hbar .lab { width: 130px; font-size: 13px; flex-shrink: 0; display: flex; align-items: center; gap: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { flex: 1; height: 9px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; border-radius: 99px; transition: width .5s var(--ease); }
.hbar .num { width: 42px; text-align: right; font-size: 13px; font-weight: 600; }
.ring { --p: 0; width: 96px; height: 96px; border-radius: 50%; background: conic-gradient(var(--success) calc(var(--p) * 1%), var(--surface-2) 0); display: grid; place-items: center; position: relative; }
.ring::before { content: ""; position: absolute; width: 72px; height: 72px; border-radius: 50%; background: var(--surface); }
.ring .rv { position: relative; font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* --------------------------- Formularios / tablas --------------------------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 420px; }
.search-box .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.search-box input { padding-left: 36px; }
.spacer { flex: 1; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.input-group { display: flex; gap: 8px; }
.input-group input { font-family: var(--font-mono); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.table th { font-family: var(--font-display); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.r, .table th.r { text-align: right; }
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pager a, .pager span { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; color: var(--text); }
.pager .cur { background: var(--btn-bg); color: var(--btn-text); border-color: var(--btn-bg); }
.pager .disabled { opacity: .4; pointer-events: none; }

/* --------------------------- Videos --------------------------- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.video-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.video-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.video-thumb { position: relative; aspect-ratio: 16 / 9; background: #0a0d12; display: grid; place-items: center; color: rgba(255,255,255,.28); cursor: pointer; overflow: hidden; }
.video-thumb .thumb-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0a0d12; }
.video-thumb .play-overlay { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; opacity: 0; transition: opacity .15s; background: rgba(0,0,0,.32); z-index: 2; }
.video-thumb:hover .play-overlay { opacity: 1; }
.video-badge { position: absolute; top: 8px; left: 8px; z-index: 3; background: rgba(0,0,0,.6); color: #fff; }
.video-info { padding: 12px 14px 6px; }
.video-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-sub { display: flex; align-items: center; gap: 9px; color: var(--text-muted); font-size: 12px; flex-wrap: wrap; }
.video-sub span { display: inline-flex; align-items: center; gap: 4px; }
.video-actions { display: flex; align-items: center; justify-content: space-between; padding: 4px 14px 12px; }
.empty-state { text-align: center; padding: 52px 24px; color: var(--text-muted); }
.empty-state .empty-icon { display: inline-grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; background: var(--surface-2); color: var(--text-faint); margin-bottom: 14px; }
.empty-state h3 { color: var(--text); font-size: 17px; margin-bottom: 6px; }

/* --------------------------- Modal --------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(6,9,13,.66); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; opacity: 0; visibility: hidden; transition: opacity .18s; backdrop-filter: blur(2px); }
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); transform: translateY(10px) scale(.97); transition: transform .2s var(--ease); max-height: 92vh; display: flex; flex-direction: column; }
.modal-overlay.open .modal { transform: none; }
.modal-lg { max-width: 820px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-body video { width: 100%; border-radius: var(--radius); background: #000; display: block; max-height: 64vh; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-top: 14px; font-size: 13px; }
.meta-grid .k { color: var(--text-muted); }

/* --------------------------- Dropzone --------------------------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 28px 20px; text-align: center; cursor: pointer; transition: .15s; background: var(--surface-2); }
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-icon { display: inline-grid; place-items: center; width: 50px; height: 50px; border-radius: 50%; background: var(--surface); color: var(--accent-text); margin-bottom: 12px; }
.dropzone strong { color: var(--accent-text); }
.dz-file { display: none; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); margin-top: 14px; font-size: 13px; }
.dz-file.show { display: flex; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 14px; display: none; }
.progress.show { display: block; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* --------------------------- Auth --------------------------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-aside { background: #0f1318; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; border-right: 1px solid var(--border); }
.auth-aside::after { content: ""; position: absolute; left: 48px; right: 48px; bottom: 40px; height: 4px; background: repeating-linear-gradient(90deg, var(--accent) 0 36px, transparent 36px 60px); }
.auth-aside .a-brand { display: flex; align-items: center; gap: 11px; font-family: var(--font-display); font-size: 20px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.auth-aside .a-hero h2 { font-size: 34px; font-weight: 700; line-height: 1.15; margin-bottom: 14px; }
.auth-aside .a-hero p { color: #aeb9cc; max-width: 400px; font-size: 15px; }
.auth-feats { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; }
.auth-feats .f { display: flex; align-items: center; gap: 11px; color: #d3dae6; font-size: 14px; }
.auth-feats .f .fi { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.08); color: var(--accent); }
.auth-main { display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .auth-logo { display: none; }
.auth-h { font-family: var(--font-display); font-size: 28px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { color: var(--text-muted); margin-bottom: 22px; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--text-muted); }
.auth-switch a { color: var(--accent-text); font-weight: 600; }

/* --------------------------- Utilidades --------------------------- */
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}
.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.flex{display:flex}.items-center{align-items:center}.gap-1{gap:8px}.gap-2{gap:12px}
.text-mono{font-family:var(--font-mono)}
.nowrap{white-space:nowrap}
.link-accent { color: var(--accent-text); font-weight: 600; }
.link-accent:hover { text-decoration: underline; }
pre.code { padding: 14px; overflow: auto; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); line-height: 1.6; font-family: var(--font-mono); }
.zoomable { cursor: zoom-in; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* --------------------------- Responsive --------------------------- */
@media (max-width: 980px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); width: var(--sidebar-w) !important; }
    .sidebar.open { transform: translateX(0); }
    html.nav-collapsed .brand > span:not(.brand-mark), html.nav-collapsed .nav-item span, html.nav-collapsed .nav-label { display: initial; }
    html.nav-collapsed .nav-item { justify-content: flex-start; padding: 0 12px; }
    html.nav-collapsed .sidebar-head { justify-content: flex-start; padding: 0 14px; }
    .sidebar-foot { display: none; }
    .menu-btn { display: grid; }
    .topbar { padding: 0 12px; }
    .user-name, .tenant-chip { display: none; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-card .auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 20px; font-weight: 700; margin-bottom: 18px; }
    .content { padding: 16px 14px; }
}

/* --------------------------- Consola --------------------------- */
.ops { position: relative; display: flex; height: calc(100vh - var(--topbar-h)); overflow: hidden; }
.ops-panel { width: 380px; flex-shrink: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); transition: margin-left .2s var(--ease); z-index: 5; }
.ops-panel.collapsed { margin-left: -380px; }
.ops-panel-show { position: absolute; left: 10px; top: 10px; z-index: 6; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center; }
.ops-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.ops-count { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.ops-filters { padding: 0 14px 10px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.ops-frow { display: flex; flex-wrap: wrap; gap: 6px; }
.ops-frow-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ops-frow-grid input, .ops-frow-grid select { padding: 6px 9px; font-size: 12.5px; }
.ops-list-head { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.ops-sort { width: auto; padding: 4px 8px; font-size: 12px; }
.ops-list { flex: 1; overflow-y: auto; position: relative; }
.ops-list-inner { position: relative; }
.ops-empty { padding: 30px 14px; color: var(--text-muted); text-align: center; }
.ops-row { position: absolute; left: 0; right: 0; height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s var(--ease); }
.ops-row:hover, .ops-row.hov { background: var(--surface-2); }
.ops-row.act { box-shadow: inset 3px 0 0 var(--accent); background: var(--surface-2); }
.ops-row.sel { background: color-mix(in srgb, var(--select) 18%, transparent); }
.ops-row img, .ops-noimg { width: 56px; height: 42px; object-fit: cover; border-radius: 5px; background: var(--surface-3); flex-shrink: 0; }
.ops-row-main { flex: 1; min-width: 0; }
.ops-row-t { display: flex; align-items: center; gap: 6px; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ops-row-s { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ops-row-time { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }
.ops-sev { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ops-chk { width: 16px; height: 16px; margin: 0; flex-shrink: 0; }
.ops-map { flex: 1; min-width: 0; background: var(--bg); position: relative; z-index: 0; }
/* Contexto de apilamiento propio: Leaflet usa z-index internos de hasta 1000 (paneles/controles/popups). Sin esto, en móvil el mapa se dibuja encima de la barra lateral (z 40) y la superior (z 30). */
.leaflet-container { font-family: var(--font-ui); background: var(--bg); position: relative; z-index: 0; isolation: isolate; }
.leaflet-bar a, .ops-heat-btn { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
.ops-heat-btn { width: 30px; height: 30px; line-height: 30px; text-align: center; font-size: 16px; cursor: pointer; }
.ops-heat-btn.on { color: var(--accent) !important; }
.marker-cluster { background: color-mix(in srgb, var(--accent) 30%, transparent) !important; }
.marker-cluster div { background: var(--accent) !important; color: #ffffff !important; font-family: var(--font-display); font-weight: 700; }
.ops-detail { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 420px; max-width: calc(100% - 24px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; z-index: 7; animation: fadeUp .2s var(--ease); }
.ops-detail-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ops-detail-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.ops-detail-body { padding: 14px; overflow-y: auto; }
.ops-photo { width: 100%; border-radius: var(--radius-sm); margin-bottom: 10px; display: block; background: var(--surface-3); }
.ops-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.ops-dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin-bottom: 12px; }
.ops-dl dt { color: var(--text-muted); } .ops-dl dd { margin: 0; }
.ops-actions { padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 12px; }
.ops-events { list-style: none; display: grid; gap: 8px; font-size: 13px; }
.ops-events li { padding-left: 10px; border-left: 2px solid var(--border); }
.ops-bulk { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--accent); border-radius: 999px; box-shadow: var(--shadow-lg); z-index: 8; white-space: nowrap; animation: fadeUp .2s var(--ease); }
@media (max-width: 900px) {
    .ops { flex-direction: column; }
    .ops-panel { width: 100%; height: 46vh; order: 2; border-right: 0; border-top: 1px solid var(--border); }
    .ops-panel.collapsed { margin-left: 0; height: 0; }
    .ops-map { order: 1; }
    .ops-detail { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-width: none; max-height: 70vh; border-radius: var(--radius) var(--radius) 0 0; }
    .ops-bulk { left: 8px; right: 8px; transform: none; overflow-x: auto; border-radius: var(--radius); }
}

/* --------------------------- Analítica --------------------------- */
.card-body canvas { width: 100% !important; height: 260px !important; }
@media print {
    html { color-scheme: light; }
    :root, [data-theme="dark"], [data-theme="light"] { --bg: #fff; --surface: #fff; --surface-2: #f3f4f6; --border: #d1d5db; --text: #111827; --text-muted: #4b5563; --text-faint: #9ca3af; --accent: #b8860b; --shadow: none; --shadow-md: none; --shadow-lg: none; }
    .topbar, .toast-wrap, #anPrint, [data-csv], .flash { display: none !important; }
    .content { padding: 0; max-width: none; }
    .card { break-inside: avoid; box-shadow: none; }
    .grid-2, .grid-3 { grid-template-columns: 1fr 1fr; }
}
