/*
 * Expreso Loma Grande · Ajustes visuales 3.1
 * Complementa app.css, design-v2.css y design-v3.css.
 * No cambia consultas, datos, rutas, cálculos ni API.
 */

/* Evita que el tipo de letra personalizado del teléfono cambie el sistema. */
html,
body,
button,
input,
select,
textarea,
table {
    font-family: "Inter", Arial, Helvetica, sans-serif !important;
}

body {
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

/* ================================================================
   LOGIN: más pequeño en computadora
   ================================================================ */
@media (min-width: 761px) {
    .login-page-v3 {
        padding: 16px;
        gap: 8px;
    }

    .login-shell-v3 {
        width: min(940px, 100%);
        min-height: 500px;
        grid-template-columns: 350px minmax(0, 1fr);
        border-radius: 20px;
    }

    .login-brand-v3 {
        gap: 14px;
        padding: 27px 28px 24px;
    }

    .login-official-logo {
        width: min(278px, 100%);
        margin-inline: auto;
    }

    .login-brand-copy {
        margin-top: 16px;
    }

    .login-brand-line {
        width: 42px;
        height: 2px;
    }

    .login-brand-eyebrow {
        margin-top: 12px !important;
        margin-bottom: 6px !important;
        font-size: 8px !important;
    }

    .login-brand-v3 h1 {
        margin-bottom: 8px;
        font-size: clamp(27px, 2.4vw, 33px);
        line-height: 1.08;
    }

    .login-brand-v3 .login-brand-copy > p:last-child {
        font-size: 11px;
        line-height: 1.45;
    }

    .login-bus-photo {
        height: 180px;
        border-radius: 14px;
    }

    .login-bus-photo figcaption {
        left: 14px;
        bottom: 11px;
        font-size: 9px;
    }

    .login-card-v3 {
        padding: 29px 43px;
    }

    .login-card-inner {
        width: min(440px, 100%);
    }

    .login-card-header-v3 {
        margin-bottom: 18px;
    }

    .login-user-badge {
        width: 52px;
        height: 52px;
        margin-bottom: 10px;
    }

    .login-user-badge svg {
        width: 24px;
        height: 24px;
    }

    .login-card-kicker {
        margin-bottom: 5px !important;
        font-size: 8px !important;
    }

    .login-card-v3 h2 {
        margin-bottom: 5px;
        font-size: 25px;
    }

    .login-card-header-v3 > p:last-child {
        font-size: 11px;
    }

    .login-form-v3 label {
        margin-top: 12px;
        margin-bottom: 5px;
        font-size: 10px;
    }

    .login-input-wrap input {
        min-height: 44px;
        padding-left: 40px;
        border-radius: 9px;
        font-size: 11px;
    }

    .login-input-icon {
        left: 12px;
    }

    .login-input-icon svg {
        width: 17px;
        height: 17px;
    }

    .login-submit {
        min-height: 44px;
        margin-top: 17px;
        border-radius: 9px;
        font-size: 11px;
    }

    .login-security {
        margin-top: 17px;
        padding-top: 14px;
    }

    .login-security > span {
        width: 31px;
        height: 31px;
    }

    .login-security strong {
        font-size: 10px;
    }

    .login-security small {
        font-size: 8px;
    }

    .login-footer-v3 {
        font-size: 9px;
    }
}

/* ================================================================
   PANEL MÓVIL: encabezado y navegación más compactos
   ================================================================ */
@media (max-width: 860px) {
    .topbar {
        min-height: 58px;
        padding: 6px 10px;
        gap: 7px;
    }

    .menu-button {
        width: 35px;
        height: 35px;
    }

    .menu-button svg {
        width: 21px;
        height: 21px;
    }

    .topbar-brand-mobile img {
        width: 122px;
        height: 34px;
    }

    .avatar {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }

    .content {
        padding: 9px 9px calc(69px + env(safe-area-inset-bottom));
    }

    .mobile-bottom-nav {
        min-height: 58px;
        padding: 4px 6px calc(3px + env(safe-area-inset-bottom));
    }

    .mobile-bottom-nav a,
    .mobile-bottom-nav button {
        gap: 1px;
        padding: 3px 2px;
        border-radius: 8px;
    }

    .mobile-bottom-nav svg {
        width: 19px;
        height: 19px;
    }

    .mobile-bottom-nav small {
        font-size: 8px;
    }

    .sidebar {
        width: min(285px, 84vw);
    }

    .sidebar-brand {
        min-height: 72px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .sidebar-brand img {
        width: 177px;
        max-height: 53px;
    }

    .sidebar-nav {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .nav-link {
        min-height: 41px;
    }

    .panel,
    .filter-panel,
    .list-card {
        border-radius: 12px;
    }

    .panel {
        padding: 13px;
        margin-bottom: 11px;
    }

    .panel-header {
        gap: 9px;
        margin-bottom: 12px;
    }

    .panel-header h2 {
        font-size: 17px;
    }

    .panel-kpi {
        max-width: 130px;
        font-size: 8px;
        line-height: 1.25;
        text-align: right;
    }

    .eyebrow {
        font-size: 8px;
    }

    input,
    select,
    textarea {
        min-height: 42px;
        font-size: 12px;
    }

    label {
        font-size: 10px;
    }

    .btn {
        min-height: 40px;
        font-size: 10px;
    }
}

/* ================================================================
   LOGIN MÓVIL: logo y foto más bajos; formulario visible sin tanta
   necesidad de desplazamiento
   ================================================================ */
@media (max-width: 760px) {
    .login-page-v3 {
        min-height: 100svh;
        padding: 7px;
        background: #eef3fa;
    }

    .login-shell-v3 {
        width: 100%;
        border-radius: 16px;
    }

    .login-brand-v3 {
        gap: 8px;
        padding: 10px 12px 12px;
    }

    .login-official-logo {
        width: 185px;
        max-width: 65%;
    }

    .login-bus-photo {
        height: 98px;
        border-radius: 11px;
    }

    .login-bus-photo img {
        object-position: center 56%;
    }

    .login-bus-photo figcaption {
        left: 11px;
        bottom: 8px;
        font-size: 8px;
    }

    .login-photo-status {
        width: 6px;
        height: 6px;
        box-shadow: 0 0 0 3px rgba(39, 215, 118, .18);
    }

    .login-card-v3 {
        padding: 17px 15px 15px;
    }

    .login-card-header-v3 {
        margin-bottom: 12px;
    }

    .login-user-badge {
        width: 41px;
        height: 41px;
        margin-bottom: 7px;
        box-shadow: inset 0 0 0 5px #f8fbff;
    }

    .login-user-badge svg {
        width: 20px;
        height: 20px;
    }

    .login-card-kicker {
        margin-bottom: 3px !important;
        font-size: 7px !important;
    }

    .login-card-v3 h2 {
        margin-bottom: 3px;
        font-size: 21px;
    }

    .login-card-header-v3 > p:last-child {
        font-size: 10px;
    }

    .login-form-v3 label {
        margin-top: 10px;
        margin-bottom: 4px;
        font-size: 9px;
    }

    .login-input-wrap input {
        min-height: 43px;
        padding-left: 39px;
        font-size: 11px;
    }

    .login-input-icon {
        left: 12px;
    }

    .login-input-icon svg {
        width: 16px;
        height: 16px;
    }

    .login-submit {
        min-height: 43px;
        margin-top: 14px;
        font-size: 10px;
    }

    .login-security {
        margin-top: 13px;
        padding-top: 11px;
    }

    .login-security > span {
        width: 29px;
        height: 29px;
    }

    .login-security strong {
        font-size: 9px;
    }

    .login-security small {
        font-size: 7px;
    }

    .login-footer-v3 {
        padding-top: 7px;
        font-size: 7px;
    }
}

@media (max-width: 390px) {
    .login-brand-v3 {
        padding: 8px 10px 10px;
    }

    .login-official-logo {
        width: 165px;
    }

    .login-bus-photo {
        height: 86px;
    }

    .login-card-v3 {
        padding: 14px 13px 13px;
    }

    .login-card-v3 h2 {
        font-size: 19px;
    }
}

/* ================================================================
   DASHBOARD MÓVIL más corto
   ================================================================ */
@media (max-width: 620px) {
    .live-toolbar {
        margin-bottom: 8px;
    }

    .dashboard-kpis {
        gap: 7px;
        margin-bottom: 8px;
    }

    .dashboard-kpi {
        min-height: 86px;
        padding: 9px 8px;
        gap: 6px;
    }

    .dashboard-kpi:last-child {
        min-height: 65px;
    }

    .dashboard-kpi-icon {
        width: 30px;
        height: 30px;
    }

    .dashboard-kpi-copy > span {
        font-size: 6px;
    }

    .dashboard-kpi-copy strong {
        margin: 5px 0;
        font-size: 15px;
    }

    .dashboard-kpi-copy small {
        font-size: 6px;
        line-height: 1.25;
    }

    .company-hero {
        min-height: 139px;
        margin-bottom: 8px;
        background-position: 65% center;
    }

    .company-hero-copy {
        padding: 12px 12px 9px;
    }

    .company-hero-kicker {
        font-size: 6px;
    }

    .company-hero h2 {
        max-width: 205px;
        margin: 4px 0;
        font-size: 18px;
    }

    .company-hero p {
        max-width: 205px;
        font-size: 8px;
        line-height: 1.35;
    }

    .hero-info-row {
        margin-top: 8px;
        padding: 5px;
    }

    .hero-info-row > div {
        grid-template-columns: 16px 1fr;
        padding-inline: 5px;
    }

    .hero-info-row span {
        font-size: 14px;
    }

    .hero-info-row small {
        font-size: 5px;
    }

    .hero-info-row strong {
        font-size: 7px;
    }

    .dashboard-alert-strip {
        gap: 6px;
        margin-bottom: 8px;
    }

    .alert-chip {
        min-width: 128px;
        padding: 7px 8px;
    }

    .dashboard-card {
        padding: 11px 9px;
    }

    .dashboard-card-header > div > strong {
        font-size: 15px;
    }

    .line-chart-wrap,
    .passenger-bars {
        min-height: 150px;
    }

    .line-chart {
        height: 138px;
    }

    .passenger-bar-item {
        height: 137px;
    }

    .dashboard-shortcuts > a {
        min-height: 72px;
    }
}

/* ================================================================
   FILTROS Y RESÚMENES: dos columnas en celular para evitar páginas
   demasiado largas.
   ================================================================ */
@media (max-width: 620px) {
    .filter-grid,
    .filter-grid-wide,
    .filter-grid-renditions,
    .maintenance-filter,
    .maintenance-filter-wide,
    .report-filter-grid,
    .form-grid.form-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 9px !important;
    }

    .filter-search,
    .filter-actions,
    .filter-buttons,
    .maintenance-filter .filter-actions,
    .report-filter-grid .filter-search {
        grid-column: 1 / -1 !important;
    }

    .filter-actions,
    .filter-buttons {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .filter-actions .btn,
    .filter-buttons .btn {
        width: 100%;
    }

    .mini-stats,
    .report-kpi-grid,
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        margin-bottom: 11px;
    }

    .mini-stats article,
    .report-kpi-grid > *,
    .stats-grid > * {
        min-width: 0;
        padding: 11px;
    }

    .mini-stats > :last-child:nth-child(odd),
    .report-kpi-grid > :last-child:nth-child(odd),
    .stats-grid > :last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .mini-stats span {
        font-size: 9px;
    }

    .mini-stats strong {
        font-size: 15px;
        text-align: right;
    }
}

@media (max-width: 355px) {
    .filter-grid,
    .filter-grid-wide,
    .filter-grid-renditions,
    .maintenance-filter,
    .maintenance-filter-wide,
    .report-filter-grid,
    .form-grid.form-grid-2 {
        grid-template-columns: 1fr !important;
    }

    .mini-stats,
    .report-kpi-grid,
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ================================================================
   TABLAS MÓVILES: cada fila se convierte en una tarjeta legible.
   Las etiquetas se agregan automáticamente desde el encabezado por JS.
   ================================================================ */
@media (max-width: 700px) {
    .mobile-card-wrapper {
        overflow: visible !important;
        margin-inline: 0 !important;
    }

    .mobile-card-table {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
    }

    .mobile-card-table thead {
        display: none !important;
    }

    .mobile-card-table tbody {
        display: grid;
        gap: 10px;
    }

    .mobile-card-table tbody tr {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0;
        overflow: hidden;
        border: 1px solid #e2e8f1 !important;
        border-radius: 11px;
        background: #fff;
        box-shadow: 0 4px 14px rgba(16, 39, 79, .045);
    }

    .mobile-card-table tbody td {
        min-width: 0 !important;
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        padding: 9px 10px !important;
        border: 0 !important;
        border-bottom: 1px solid #edf1f6 !important;
        color: #17243a;
        font-size: 10px !important;
        line-height: 1.35;
        text-align: left !important;
        overflow-wrap: anywhere;
    }

    .mobile-card-table tbody td:nth-child(odd) {
        border-right: 1px solid #edf1f6 !important;
    }

    .mobile-card-table tbody td::before {
        content: attr(data-label);
        display: block;
        color: #748198;
        font-size: 7px;
        font-weight: 800;
        letter-spacing: .045em;
        text-transform: uppercase;
    }

    .mobile-card-table tbody td strong {
        font-size: 10px;
    }

    .mobile-card-table tbody td small {
        margin-top: 1px;
        color: #7d899b;
        font-size: 8px;
    }

    .mobile-card-table .badge {
        width: fit-content;
        max-width: 100%;
        padding: 4px 7px;
        font-size: 7px;
    }

    .mobile-card-table .btn {
        width: 100%;
        min-height: 36px;
        padding: 7px 9px;
    }

    .mobile-card-table .mobile-action-cell,
    .mobile-card-table .mobile-important-cell:has(.btn),
    .mobile-card-table .mobile-important-cell:has(form) {
        grid-column: 1 / -1;
    }

    .mobile-card-table .mobile-action-cell::before {
        display: none;
    }

    .mobile-card-table .mobile-empty-row {
        display: block !important;
    }

    .mobile-card-table .mobile-empty-cell {
        display: block !important;
        padding: 22px 13px !important;
        text-align: center !important;
    }

    .mobile-card-table .mobile-empty-cell::before {
        display: none;
    }

    /* Evita una línea sobrante al final de cada tarjeta. */
    .mobile-card-table tbody td:nth-last-child(-n + 2) {
        border-bottom: 0 !important;
    }

    .mobile-card-table tbody td:last-child:nth-child(odd) {
        grid-column: 1 / -1;
        border-right: 0 !important;
        border-bottom: 0 !important;
    }

    .table-wrap.report-detail-table {
        overflow: visible !important;
    }

    .report-detail-table table {
        min-width: 0 !important;
    }
}

/* Navegadores que aún no soportan :has(). */
@supports not selector(:has(*)) {
    @media (max-width: 700px) {
        .mobile-card-table .mobile-important-cell {
            grid-column: 1 / -1;
        }
    }
}
