* { box-sizing: border-box; }
body { font-family: -apple-system, Segoe UI, Roboto, sans-serif; margin: 0; background: #f4f6f8; color: #1a1a1a; }
.topbar { background: #12213b; color: #fff; padding: 14px 24px; display: flex; justify-content: space-between; align-items: center; }
.topbar a { color: #cfd8e3; margin-left: 18px; text-decoration: none; font-size: 14px; }
.topbar a:hover { color: #fff; }
.brand { font-weight: 600; display: flex; align-items: center; gap: 10px; }
.topbar .brand-link { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; margin-left: 0; }
.topbar .brand-link:hover { color: inherit; opacity: 0.85; }
.brand-logo-wrap { background: #fff; padding: 4px 12px; border-radius: 6px; display: inline-flex; align-items: center; }
.brand-logo { height: 24px; width: auto; display: block; }
.content { padding: 28px; max-width: 1100px; margin: 0 auto; }
.content:has(.flota-wide) { max-width: 1600px; }
.cards { display: flex; gap: 16px; margin: 20px 0; }
.card { background: #fff; border: 1px solid #dde3ea; border-radius: 8px; padding: 20px 24px; text-decoration: none; color: #12213b; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card:hover { border-color: #12213b; }
.hint { color: #667085; font-size: 14px; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; margin-top: 12px; }
.data-table th, .data-table td { border-bottom: 1px solid #eaecef; padding: 8px 10px; text-align: left; font-size: 14px; }
.data-table th { background: #f0f2f5; }
.btn, button { background: #12213b; color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-block; font-size: 14px; }
.btn-danger { background: #b3261e; }
.form label { display: block; margin-top: 10px; font-size: 13px; color: #444; }
.form input, .form select { width: 100%; padding: 8px; margin-top: 4px; border: 1px solid #ccd2d9; border-radius: 6px; }
.form button { margin-top: 16px; }
.login-body { display: flex; align-items: stretch; justify-content: center; height: 100vh; background: #12213b; margin: 0; }
.login-panel-ilustracion { flex: 1.1; display: flex; }
.login-panel-ilustracion svg { width: 100%; height: 100%; object-fit: cover; }
.login-panel-form { flex: 1; display: flex; align-items: center; justify-content: center; background: #f4f6f8; }
.login-logo { display: block; max-width: 160px; margin: 0 auto 14px; }
.login-box { background: #fff; padding: 32px; border-radius: 10px; width: 320px; box-shadow: 0 8px 30px rgba(0,0,0,.12); align-self: center; }
.login-box h1 { margin: 0 0 4px; font-size: 20px; text-align: center; }
@media (max-width: 800px) {
    .login-panel-ilustracion { display: none; }
}
.subtitle { margin: 0 0 20px; color: #667085; font-size: 13px; }
.login-box label { display: block; margin-top: 12px; font-size: 13px; }
.login-box input { width: 100%; padding: 9px; margin-top: 4px; border: 1px solid #ccd2d9; border-radius: 6px; }
.login-box button { width: 100%; margin-top: 20px; padding: 10px; }
.error { color: #b3261e; font-size: 13px; }

/* === Dashboard de Flota === */
.kpi-row { display: flex; gap: 14px; margin-bottom: 16px; }
.kpi-card { flex: 1; background: #fff; border-radius: 8px; padding: 14px 18px; border-left: 5px solid #ccc; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.kpi-total { border-left-color: #1e88e5; }
.kpi-elec { border-left-color: #1e88e5; }
.kpi-bat { border-left-color: #c62828; }
.kpi-off { border-left-color: #9e9e9e; }
.kpi-label { font-size: 12px; color: #667085; font-weight: 600; letter-spacing: .03em; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; }

.flota-main { display: grid; grid-template-columns: 380px 1fr 280px; gap: 12px; height: clamp(460px, 58vh, 620px); margin-bottom: 16px; }
.flota-sidebar { background: #fff; border-radius: 8px; padding: 12px; overflow-y: auto; }
.sidebar-header { font-weight: 700; margin-bottom: 8px; }
.buscador { width: 100%; padding: 7px; margin-bottom: 8px; border: 1px solid #ccd2d9; border-radius: 6px; }
.lista-maquinas { list-style: none; margin: 0; padding: 0; }
.maquina-item { padding: 7px 4px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #f0f2f5; display: flex; align-items: center; gap: 6px; }
.maquina-item:hover { background: #f4f6f8; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-ok { background: #2e7d32; }
.dot-offline { background: #9e9e9e; }
.dot-elec_error { background: #1e88e5; }
.dot-bat_low { background: #c62828; }

.flota-mapa { background: #fff; border-radius: 8px; overflow: hidden; }
#mapa-flota { width: 100%; height: 100%; }

.flota-panel { background: #12213b; color: #fff; border-radius: 8px; padding: 14px; overflow-y: auto; }
.panel-header { font-weight: 700; margin-bottom: 10px; }
.panel-detalle .hint { color: #cfd8e3; }
.detalle-dispositivo h3 { margin: 0 0 6px; }
.detalle-tabla { width: 100%; margin-top: 10px; font-size: 13px; }
.detalle-tabla td { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.1); }
.detalle-tabla td:first-child { color: #9fb0c9; width: 45%; }
.detalle-dispositivo .btn { margin-top: 12px; display: inline-block; }

.flota-tablas { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.tabla-alerta { background: #fff; border-radius: 8px; padding: 12px; }
.tabla-alerta h3 { margin: 0 0 8px; font-size: 15px; }
.tabla-elec h3 { color: #1e88e5; }
.tabla-bat h3 { color: #c62828; }
.tabla-off h3 { color: #667085; }

.icono-maquina-circulo { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }

.filtros-flota { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; background: #fff; padding: 12px 16px; border-radius: 8px; flex-wrap: wrap; }
.filtros-flota label { font-size: 13px; color: #444; font-weight: 600; }
.filtros-flota select { padding: 6px 8px; border: 1px solid #ccd2d9; border-radius: 6px; min-width: 180px; }
.btn-secundario { background: #eef1f5; color: #12213b; }

.icono-ficha { text-decoration: none; margin-left: 4px; font-size: 12px; }
.maquina-item { justify-content: space-between; }
.maquina-nombre { display: flex; align-items: center; gap: 6px; overflow: hidden; flex: 1; min-width: 0; }
.maquina-texto { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icono-ficha { flex-shrink: 0; }

.breadcrumb { font-size: 13px; color: #667085; }
.breadcrumb a { color: #1e88e5; text-decoration: none; }
.ficha-grid { display: grid; grid-template-columns: 1fr 1fr 320px; gap: 24px; margin-top: 16px; }
.ficha-col h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: #667085; border-bottom: 1px solid #dde3ea; padding-bottom: 6px; margin: 18px 0 8px; }
.ficha-col h3:first-child { margin-top: 0; }
.detalle-tabla-clara { width: 100%; font-size: 14px; }
.detalle-tabla-clara td { padding: 5px 0; border-bottom: 1px solid #f0f2f5; }
.detalle-tabla-clara td:first-child { color: #667085; width: 50%; }
#mapa-ficha { width: 100%; height: 260px; border-radius: 8px; }

.rango-selector { margin-top: 24px; background: #fff; border-radius: 8px; padding: 14px 16px; }
.rango-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rango-form label { font-size: 13px; color: #444; }
.rango-form input[type="date"] { padding: 6px; border: 1px solid #ccd2d9; border-radius: 6px; }
.rango-resumen { margin: 10px 0 0; font-size: 14px; color: #444; }

.tabs { display: flex; gap: 4px; margin-top: 20px; border-bottom: 2px solid #dde3ea; }
.tab { padding: 10px 16px; cursor: pointer; font-size: 13px; font-weight: 600; color: #667085; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: #1e88e5; border-bottom-color: #1e88e5; }
.tab-content { background: #fff; border-radius: 0 0 8px 8px; padding: 16px; }
.subtitulo-tab { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: #667085; margin: 22px 0 8px; }
.subtitulo-tab:first-child { margin-top: 0; }

.ciclos-kpi-row { display: flex; gap: 14px; margin-bottom: 12px; }
.ciclo-kpi { background: #f4f6f8; border-radius: 8px; padding: 10px 18px; text-align: center; }
.ciclo-kpi .num { font-size: 22px; font-weight: 700; }
.ciclo-kpi .lbl { font-size: 12px; color: #667085; }
.motivo-fallo { font-size: 12px; color: #c62828; padding-top: 0 !important; padding-bottom: 8px !important; }

#custom-tooltip {
    display: none;
    position: fixed;
    z-index: 3000;
    background: #fff;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.18);
    padding: 12px 14px;
    max-width: 320px;
    pointer-events: none;
}
.nombre-hover { cursor: default; border-bottom: 1px dotted #999; }

/* === Dropdown de navegación (Configuración) === */
.nav-dropdown { position: relative; display: inline-block; margin-left: 18px; }
.nav-dropdown > a { margin-left: 0; }
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
    min-width: 220px;
    padding: 6px 0;
    z-index: 100;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
    display: block;
    padding: 9px 16px;
    color: #12213b;
    font-size: 14px;
    margin-left: 0;
    white-space: nowrap;
}
.nav-dropdown-menu a:hover { background: #f0f2f5; color: #12213b; }

/* === Mensajes flash (confirmación de acciones) === */
.flash { padding: 10px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: #e3f6e8; color: #1b6b34; border: 1px solid #b8e3c4; }
.flash-error { background: #fbe4e2; color: #942b25; border: 1px solid #f0bcb8; }

/* === Selector de dispositivos (dos listas) === */
.selector-dual { display: flex; gap: 12px; align-items: stretch; margin-top: 6px; }
.selector-dual .selector-col { flex: 1; display: flex; flex-direction: column; }
.selector-dual .selector-col label { margin-top: 0; margin-bottom: 4px; }
.selector-dual select {
    height: 260px;
    padding: 6px;
    border: 1px solid #ccd2d9;
    border-radius: 6px;
    width: 100%;
}
.selector-dual .selector-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}
.selector-dual .selector-buttons button {
    margin-top: 0;
    padding: 6px 10px;
    font-size: 13px;
}
.selector-search { width: 100%; padding: 6px 8px; margin-bottom: 6px; border: 1px solid #ccd2d9; border-radius: 6px; font-size: 13px; }

/* === Barra de bienvenida, debajo del menú === */
.subbar {
    background: #eef2f7;
    color: #46536b;
    font-size: 13px;
    padding: 6px 24px;
    text-align: right;
    border-bottom: 1px solid #dde3ea;
}

/* === Lista de checkboxes (roles, etc.) === */
.checkbox-list {
    border: 1px solid #ccd2d9;
    border-radius: 6px;
    padding: 10px 14px;
    margin-top: 4px;
}
.checkbox-item { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 14px; }
.checkbox-item input[type="checkbox"] { width: auto; margin: 0; }

/* === Campo de contraseña con botón de mostrar/ocultar === */
.campo-password { position: relative; display: flex; align-items: center; }
.campo-password input { flex: 1; padding-right: 40px !important; }
.btn-ver-password {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; font-size: 16px;
    padding: 4px 6px; margin: 0; width: auto; line-height: 1;
}

/* === Aviso de sesión suplantada === */
.aviso-suplantacion { color: #c00000; font-weight: 600; margin-left: 8px; }
.btn-salir-suplantacion {
    margin-left: 8px; padding: 3px 10px; font-size: 12px;
    background: #c00000; color: #fff; border: none; border-radius: 4px; cursor: pointer;
}

/* === Panel de generación de enlace de suplantación === */
.suplantacion-caja { margin-top: 8px; padding: 12px; background: #fff8e1; border: 1px solid #ffe082; border-radius: 6px; }
.suplantacion-enlace { width: 100%; padding: 8px; font-family: monospace; font-size: 12px; margin-top: 6px; }
