:root {
  --brand-dark: #0f2340;
  --brand: #14335e;
  --brand-light: #2c5ea8;
  --accent: #ff9f1c;
  --bg: #f4f6fa;
}

body {
  background-color: var(--bg);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.app-navbar {
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
}

.kpi-card {
  border: none;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(15, 35, 64, 0.08);
  overflow: hidden;
}

.kpi-card .kpi-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  color: #fff;
}

.kpi-value { font-size: 1.6rem; font-weight: 700; }
.kpi-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; }

.card { border: none; border-radius: 14px; box-shadow: 0 2px 10px rgba(15,35,64,.06); }
.card-header { background: #fff; border-bottom: 1px solid #eef1f5; font-weight: 600; border-radius: 14px 14px 0 0 !important; }

.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #6c757d; border-bottom-width: 1px; }

.badge-tipo-diesel { background: #ffe8cc; color: #b45309; }
.badge-tipo-caseta { background: #dbeafe; color: #1d4ed8; }
.badge-tipo-imprevisto { background: #fee2e2; color: #b91c1c; }
.badge-tipo-otro { background: #e5e7eb; color: #374151; }

.login-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand-light));
}

.login-card {
  border-radius: 18px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}

.thumb-evidencia {
  width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid #dee2e6;
}

.utilidad-positiva { color: #157347; font-weight: 700; }
.utilidad-negativa { color: #b91c1c; font-weight: 700; }

/* ===== Widget de evidencias / escáner (v3) ===== */
.ev-widget { border: 1px dashed #c3ccd9; border-radius: 12px; padding: 14px; background: #fbfcfe; }
.ev-botones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ev-lista { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.ev-thumb { position: relative; width: 84px; height: 108px; border: 1px solid #dee2e6; border-radius: 8px; overflow: hidden; background: #fff; }
.ev-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ev-thumb-num { position: absolute; bottom: 2px; left: 4px; background: rgba(15,35,64,.8); color: #fff; font-size: 11px; padding: 0 6px; border-radius: 6px; }
.ev-thumb-del { position: absolute; top: 2px; right: 2px; border: none; background: rgba(185,28,28,.9); color: #fff; width: 20px; height: 20px; border-radius: 50%; line-height: 1; cursor: pointer; }
.ev-aviso { margin-top: 10px; font-size: .85rem; }

.ev-modal { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.ev-modal-caja { background: #111; border-radius: 14px; overflow: hidden; width: min(96vw, 620px); }
.ev-modal-top { display: flex; justify-content: space-between; align-items: center; color: #fff; padding: 10px 14px; background: #1b2b45; }
.ev-video-wrap { position: relative; background: #000; }
.ev-video { width: 100%; display: block; max-height: 65vh; object-fit: contain; }
.ev-guia { position: absolute; inset: 8% 6%; border: 2px dashed rgba(255,255,255,.75); border-radius: 10px; pointer-events: none; }
.ev-estado { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; color: #fff; font-size: .9rem; text-shadow: 0 1px 3px #000; }
.ev-modal-bottom { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 14px; background: #1b2b45; flex-wrap: wrap; }
.ev-auto-lbl { color: #fff; font-size: .85rem; display: flex; align-items: center; gap: 6px; margin: 0; }
.ev-flash .ev-video-wrap { outline: 6px solid #fff; }

/* ===== Responsive (v4) ===== */

/* El menú colapsado (celular/tablet vertical) se ve como panel, no como barra */
@media (max-width: 991.98px) {
  .navbar-collapse {
    background: var(--brand-dark);
    margin: 8px -12px -8px -12px;
    padding: 10px 16px 16px;
    border-radius: 0 0 12px 12px;
  }
  .navbar-nav .dropdown-menu {
    background: transparent;
    border: none;
    box-shadow: none;
    padding-left: 12px;
  }
  .navbar-nav .dropdown-item { color: #dbe4f3; }
  .navbar-nav .dropdown-item:hover, .navbar-nav .dropdown-item:focus { background: rgba(255,255,255,.08); color: #fff; }
}

/* Pantallas muy angostas (celulares chicos): todo un poco más compacto */
@media (max-width: 420px) {
  .kpi-value { font-size: 1.3rem; }
  .kpi-icon { width: 40px; height: 40px; font-size: 18px; }
  main.container-fluid { padding-left: .75rem !important; padding-right: .75rem !important; }
  .card-body { padding: 1rem; }
  h4.fw-bold { font-size: 1.15rem; }
}

/* Tablet (vertical y horizontal): más aire entre tarjetas y botones que no se pegan */
@media (min-width: 576px) and (max-width: 991.98px) {
  .kpi-card .kpi-value { font-size: 1.4rem; }
}

/* Barras de acciones (título + botón) siempre apilan limpio en móvil */
@media (max-width: 575.98px) {
  .d-flex.flex-wrap.justify-content-between > .btn,
  .d-flex.flex-wrap.justify-content-between > .btn-group {
    width: 100%;
  }
  .btn-group.d-flex { flex-wrap: wrap; }
}

/* Modales de captura/edición: nunca más anchos que la pantalla, con margen cómodo */
.modal-dialog { margin-left: auto; margin-right: auto; }
@media (max-width: 575.98px) {
  .modal-dialog { margin: .75rem; }
}

/* Formularios: los grupos de botones de acción nunca se cortan */
.d-flex.gap-2 { flex-wrap: wrap; }

/* Tarjetas de KPI: que el ícono no se aplaste en pantallas muy angostas */
.kpi-card.p-3.d-flex.flex-row { align-items: center; }
.kpi-card .kpi-icon { flex-shrink: 0; }

/* Catálogos tiene varias pestañas (operadores, clientes, ubicaciones...):
   en pantallas angostas se deslizan en vez de encimarse o partirse en dos líneas */
@media (max-width: 767.98px) {
  .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .nav-tabs .nav-link { white-space: nowrap; }
}

