/* ============================================================
   MOTOIQ — Estilos Globales
   Tema Industrial / Mecánica a Domicilio
   ============================================================ */

:root {
    --red:      #E63946;
    --red-dark: #c62d3a;
    --dark:     #0D0D0D;
    --panel:    #141414;
    --card:     #1C1C1C;
    --card2:    #222222;
    --border:   #2A2A2A;
    --text:     #F0EDE8;
    --muted:    #888880;
    --muted2:   #555550;
    --gold:     #F4A261;
    --green:    #22C55E;
    --yellow:   #EAB308;
    --blue:     #3B82F6;
    --sidebar-w: 260px;
    --topbar-h:  64px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--dark);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ---- ADMIN LAYOUT ---- */
.admin-body {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform .3s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo-icon {
    width: 40px; height: 40px;
    background: var(--red);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px; color: white;
    flex-shrink: 0;
}

.sidebar-logo-name {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px; letter-spacing: 2px;
}

.sidebar-logo-role {
    font-size: 10px; color: var(--muted);
    text-transform: uppercase; letter-spacing: 2px;
}

/* NAV */
.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section {
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--muted2);
    padding: 16px 8px 6px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--muted);
    transition: all .15s;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--card);
    color: var(--text);
}

.nav-item.active {
    background: rgba(230,57,70,.15);
    color: var(--red);
    font-weight: 600;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* SIDEBAR FOOTER */
.sidebar-footer {
    padding: 16px 16px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.sidebar-avatar {
    width: 36px; height: 36px;
    background: var(--red);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 16px; color: white;
    flex-shrink: 0;
}

.btn-logout {
    display: block;
    text-align: center;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--muted);
    transition: all .15s;
}

.btn-logout:hover {
    border-color: var(--red);
    color: var(--red);
    background: rgba(230,57,70,.08);
}

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* TOPBAR */
.topbar {
    height: var(--topbar-h);
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    letter-spacing: 2px;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notif-btn {
    position: relative;
    width: 38px; height: 38px;
    background: var(--card);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: background .15s;
}

.notif-btn:hover { background: var(--card2); }

.notif-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 16px; height: 16px;
    padding: 0 3px;
    background: var(--red);
    border-radius: 50px;
    font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-weight: 700;
    animation: notif-pulse 2s infinite;
}

@keyframes notif-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(230,57,70,.6); }
    50%       { box-shadow: 0 0 0 5px rgba(230,57,70,0); }
}

.topbar-avatar {
    width: 38px; height: 38px;
    background: var(--red);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px; color: white;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
}

/* PAGE CONTENT */
.page-content {
    flex: 1;
    padding: 28px;
}

/* ---- CARDS ---- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 20px;
    letter-spacing: 1px;
}

/* ---- STAT CARDS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: border-color .2s;
}

.stat-card:hover { border-color: var(--red); }

.stat-card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-card-num {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 42px;
    line-height: 1;
    color: var(--text);
}

.stat-card-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.stat-card-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px;
    opacity: 0.08;
}

/* ---- GRID LAYOUTS ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: rgba(255,255,255,.02); }

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .5px;
    white-space: nowrap;
}

.badge-success  { background: rgba(34,197,94,.15);  color: #4ade80; }
.badge-warning  { background: rgba(234,179,8,.15);  color: #fbbf24; }
.badge-danger   { background: rgba(230,57,70,.15);  color: #f87171; }
.badge-info     { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-primary  { background: rgba(230,57,70,.2);   color: var(--red); }
.badge-secondary{ background: rgba(255,255,255,.08);color: var(--muted); }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn-red    { background: var(--red);   color: white; }
.btn-red:hover { background: var(--red-dark); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(230,57,70,.35); }

.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--muted); background: var(--card); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--card); color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 7px;
}

.form-control {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 14px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(230,57,70,.1);
}

.form-control::placeholder { color: #3a3a3a; }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* FORM GRID */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }

/* ---- ALERTS ---- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-danger  { background: rgba(230,57,70,.1); border: 1px solid rgba(230,57,70,.25); color: #f87171; }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.25); color: #4ade80; }
.alert-warning { background: rgba(234,179,8,.1); border: 1px solid rgba(234,179,8,.25); color: #fbbf24; }
.alert-info    { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.25); color: #60a5fa; }

/* ---- MODALS ---- */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn .2s ease;
}

@keyframes modalIn {
    from { opacity:0; transform:translateY(16px) scale(.97); }
    to   { opacity:1; transform:translateY(0) scale(1); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    letter-spacing: 1px;
}

.modal-close {
    width: 32px; height: 32px;
    background: var(--card2);
    border: none;
    border-radius: 50%;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}

.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

.empty-state-icon { font-size: 56px; margin-bottom: 16px; opacity: .4; }
.empty-state-title { font-family: 'Bebas Neue', sans-serif; font-size: 24px; color: var(--text); margin-bottom: 8px; }
.empty-state-desc { font-size: 14px; }

/* ---- MOTO CARD ---- */
.moto-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: border-color .2s, transform .2s;
    position: relative;
    overflow: hidden;
}

.moto-card:hover {
    border-color: var(--red);
    transform: translateY(-2px);
}

.moto-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--red);
    transform: scaleX(0);
    transition: transform .2s;
}

.moto-card:hover::before { transform: scaleX(1); }

.moto-brand { font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 1px; }
.moto-model { font-size: 14px; color: var(--muted); }
.moto-plate {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    background: var(--card2);
    padding: 3px 8px;
    border-radius: 4px;
    color: var(--gold);
}

/* ---- PAGE HEADER ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 32px;
    letter-spacing: 2px;
}

.page-header-sub { font-size: 14px; color: var(--muted); }

/* ---- SEARCH BAR ---- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 14px;
    min-width: 260px;
}

.search-bar input {
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    flex: 1;
}

.search-bar input::placeholder { color: var(--muted2); }

/* ---- PROGRESS BAR ---- */
.progress {
    height: 6px;
    background: var(--card2);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--red);
    transition: width .4s ease;
}

.progress-bar.green  { background: var(--green); }
.progress-bar.yellow { background: var(--yellow); }

/* ---- TIMELINE ---- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
    content: '';
    position: absolute;
    left: 8px; top: 0; bottom: 0;
    width: 1px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-dot {
    position: absolute;
    left: -24px; top: 4px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--red);
    border: 2px solid var(--dark);
}

.timeline-date { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.timeline-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.timeline-desc  { font-size: 13px; color: var(--muted); }

/* ---- MAINTENANCE STATUS ---- */
.maint-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.maint-item:last-child { border-bottom: none; }
.maint-name { font-size: 14px; font-weight: 500; }
.maint-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- RESPONSIVE: ver bloque completo al final ---- */

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* ---- TOAST ---- */
.toast-container {
    position: fixed;
    bottom: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 9999;
}

.toast {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    font-size: 14px;
    display: flex; align-items: center; gap: 10px;
    animation: toastIn .3s ease;
    box-shadow: 0 8px 30px rgba(0,0,0,.4);
    min-width: 280px;
}

.toast-success { border-left: 3px solid var(--green); }
.toast-danger  { border-left: 3px solid var(--red); }
.toast-warning { border-left: 3px solid var(--yellow); }

@keyframes toastIn {
    from { opacity:0; transform: translateX(20px); }
    to   { opacity:1; transform: translateX(0); }
}

/* ---- CLIENT LAYOUT ---- */
.client-body {
    display: flex;
    min-height: 100vh;
}

.client-sidebar {
    width: 240px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.client-main {
    margin-left: 240px;
    flex: 1;
}



/* ═══════════════════════════════════════════════════════════
   RESPONSIVE COMPLETO — MotoIQ v2
   Corrige bugs iOS/Android admin y cliente
   ═══════════════════════════════════════════════════════════ */

/* ── 1. Box-sizing global y max-width seguro ─────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { overflow-x: hidden; }
img  { max-width: 100%; height: auto; }

/* ── 2. Tablas: scroll horizontal sin romper layout ─────── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
.table-wrap table { min-width: 760px; }
@media (max-width: 640px) {
    .hide-mobile { display: none !important; }
    .table-wrap table { min-width: 600px; }
}

/* ── 3. ADMIN SIDEBAR ────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 200;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0,0,0,.6);
    }
    .main-content { margin-left: 0 !important; }
    .sidebar-toggle { display: flex !important; }
}

/* ── 4. ADMIN TOPBAR ─────────────────────────────────────── */
@media (max-width: 768px) {
    .topbar { padding: 0 12px; gap: 8px; }
    .topbar-title { font-size: 13px; letter-spacing: .5px; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .notif-btn, .topbar-avatar { width: 34px; height: 34px; font-size: 14px; flex-shrink: 0; }
}

/* ── 5. OVERLAY (admin y cliente) ───────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 199;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.open { display: block; }

/* ── 6. GRIDS ────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
    .form-row, .form-row-3    { grid-template-columns: 1fr !important; }
    .stats-grid { grid-template-columns: repeat(2,1fr); }
    .page-content { padding: 14px; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 10px; }
    .stat-card { padding: 14px; }
    .stat-card-num { font-size: 20px; }
    .stat-card-icon { font-size: 28px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .page-header-title { font-size: 15px; }
}

/* ── 7. CARDS ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .card { border-radius: 10px; }
    .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
    .btn { font-size: 13px; padding: 7px 12px; }
    .btn-sm { font-size: 11px; padding: 4px 8px; }
    .alert { font-size: 13px; padding: 10px 14px; }
}

/* ── 8. ORDEN DETALLE: columna derecha va abajo ─────────── */
@media (max-width: 900px) {
    .orden-detalle-grid { grid-template-columns: 1fr !important; }
}

/* ── 9. CLIENTE DETALLE ──────────────────────────────────── */
@media (max-width: 768px) {
    .cliente-detalle-grid { grid-template-columns: 1fr !important; }
}

/* ── 10. AGENDA ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .agenda-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .agenda-grid { grid-template-columns: repeat(7,minmax(110px,1fr)) !important; }
}

/* ── 11. FORMULARIOS — evita zoom en iOS ─────────────────── */
@media (max-width: 768px) {
    input.form-control,
    select.form-control,
    textarea.form-control { font-size: 16px !important; }
}

/* ── 12. MODALES — sheet desde abajo en móvil ───────────── */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.open { display: flex; }

@media (max-width: 540px) {
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0 !important;
        margin: 0 !important;
    }
    .modal-body { padding: 14px 16px; }
    .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .modal-footer .btn { flex: 1; justify-content: center; }
}

/* ── 13. TABS y FILTROS ──────────────────────────────────── */
@media (max-width: 768px) {
    .tabs-row, .filter-row { flex-wrap: wrap; gap: 6px; }
    .tabs-row .btn, .filter-row .btn { font-size: 12px; padding: 5px 10px; }
}

/* ── 14. REPORTES ────────────────────────────────────────── */
@media (max-width: 768px) {
    .reportes-form { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 480px) {
    .reportes-form { grid-template-columns: 1fr !important; }
}

/* ── 15. TOAST (móvil: ancho completo abajo) ─────────────── */
.toast-container {
    position: fixed;
    bottom: 20px; right: 16px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 9999;
    max-width: calc(100vw - 32px);
}
.toast { min-width: 260px; max-width: 340px; }
@media (max-width: 480px) {
    .toast-container { left: 16px; right: 16px; bottom: 16px; }
    .toast { min-width: unset; max-width: 100%; width: 100%; }
}

/* ─────────────────────────────────────────────────────────
   CLIENT LAYOUT — Corrección completa iOS/Android
   ───────────────────────────────────────────────────────── */

/* ── 16. Client sidebar base ─────────────────────────────── */
.client-sidebar {
    width: 240px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform .25s ease;
}
.client-main {
    margin-left: 240px;
    flex: 1;
    min-width: 0; /* Fix: evita overflow en flex */
}

/* ── 17. Client topbar (hamburger, SOLO en móvil) ────────── */
.client-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: 52px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 90;
    flex-shrink: 0;
}
.client-topbar .sidebar-toggle {
    display: flex;
    background: none;
    border: none;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
}
.client-topbar .ct-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .5px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── 18. Admin topbar .sidebar-toggle oculto en desktop ──── */
.sidebar-toggle { display: none; }

/* ── 19. CLIENT RESPONSIVE ───────────────────────────────── */
@media (max-width: 768px) {
    /* Sidebar se oculta */
    .client-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    .client-sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0,0,0,.6);
    }
    /* El main ocupa todo */
    .client-main { margin-left: 0 !important; }
    /* Mostrar topbar hamburger */
    .client-topbar { display: flex; }
    /* Ocultar el topbar de admin que viene duplicado en client_layout */
    .client-main > .topbar { display: none !important; }
    /* Sidebar toggle visible */
    .sidebar-toggle { display: flex !important; }
}

/* ── 20. Overlay cliente ─────────────────────────────────── */
#client-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 199;
    -webkit-tap-highlight-color: transparent;
}
#client-overlay.open { display: block; }

/* ── 21. Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* ── 22. Safe area (iPhone X+ con notch) ────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .client-topbar, .topbar {
        padding-top: env(safe-area-inset-top);
    }
    .sidebar, .client-sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
    @media (max-width: 540px) {
        .modal-overlay { padding-bottom: env(safe-area-inset-bottom); }
    }
}

/* ── 23. Tap targets mínimos (WCAG / iOS) ────────────────── */
@media (max-width: 768px) {
    .nav-item { min-height: 44px; display: flex; align-items: center; }
    .btn      { min-height: 40px; }
    .btn-sm   { min-height: 34px; }
}

/* ── Client main wrapper (topbar + content juntos) ───────── */
.client-main {
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}
.client-main main {
    flex: 1;
}
@media (max-width: 768px) {
    .client-main {
        margin-left: 0 !important;
        width: 100%;
    }
    .client-topbar {
        display: flex !important;
        position: sticky;
        top: 0;
        z-index: 90;
        width: 100%;
    }
}

/* ---- VEHICLE CARD (vcard) ---- */
.vcard {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color .2s, transform .2s, box-shadow .2s;
    display: flex;
    flex-direction: column;
}
.vcard:hover {
    border-color: var(--red);
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0,0,0,.4);
}

/* Image area */
.vcard-img {
    height: 160px;
    background: var(--card2);
    position: relative;
    overflow: hidden;
}
.vcard-no-img {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 64px; opacity: .07;
}
.vcard-badge-warn {
    position: absolute; top: 10px; right: 10px;
    background: var(--red); color: #fff;
    border-radius: 20px; padding: 3px 10px;
    font-size: 11px; font-weight: 700;
    backdrop-filter: blur(4px);
}
.vcard-plate-row {
    position: absolute; bottom: 10px; left: 12px;
    display: flex; align-items: center; gap: 6px;
}
.vcard-color-chip {
    font-size: 11px; color: var(--muted);
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(6px);
    border-radius: 4px; padding: 2px 7px;
}

/* Body */
.vcard-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; flex: 1; }

.vcard-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.vcard-title { font-family: 'Bebas Neue', sans-serif; font-size: 21px; line-height: 1.1; letter-spacing: .5px; }
.vcard-model { color: var(--muted); }
.vcard-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.vcard-owner { text-align: right; flex-shrink: 0; }
.vcard-owner-name { font-size: 13px; font-weight: 600; line-height: 1.2; max-width: 110px; word-break: break-word; }
.vcard-wa {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--green); text-decoration: none;
    margin-top: 3px; transition: opacity .15s;
}
.vcard-wa:hover { opacity: .75; }

/* Stats strip */
.vcard-stats {
    display: flex; align-items: center;
    background: var(--card2);
    border-radius: 10px;
    padding: 10px 14px;
    gap: 0;
}
.vcard-stat { flex: 1; text-align: center; }
.vcard-stat-val { display: block; font-family: 'Bebas Neue', sans-serif; font-size: 18px; line-height: 1; }
.vcard-stat-lbl { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.vcard-stat-divider { width: 1px; height: 32px; background: var(--border); flex-shrink: 0; }

/* Action buttons */
.vcard-actions { display: flex; gap: 7px; align-items: center; margin-top: auto; }
.vcard-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 5px; border: none; cursor: pointer;
    border-radius: 9px; font-family: 'DM Sans', sans-serif;
    font-size: 12px; font-weight: 500;
    padding: 8px 12px; transition: background .15s, transform .1s, box-shadow .15s;
    text-decoration: none; white-space: nowrap;
}
.vcard-btn:active { transform: scale(.97); }

.vcard-btn-primary {
    flex: 1;
    background: var(--red); color: #fff;
}
.vcard-btn-primary:hover { background: var(--red-dark); box-shadow: 0 4px 14px rgba(230,57,70,.35); }

.vcard-btn-secondary {
    flex: 1;
    background: var(--card2); color: var(--text);
    border: 1px solid var(--border);
}
.vcard-btn-secondary:hover { background: var(--border); border-color: var(--muted); }

.vcard-btn-danger {
    width: 36px; height: 36px; padding: 0; flex-shrink: 0;
    background: transparent; color: var(--muted);
    border: 1px solid var(--border);
}
.vcard-btn-danger:hover { background: rgba(230,57,70,.12); border-color: var(--red); color: var(--red); }

@media (max-width: 480px) {
    .vcard-btn-primary, .vcard-btn-secondary { font-size: 11px; padding: 7px 9px; }
}


/* ══════════════════════════════════════════════════════════════
   MOTOIQ — CORRECCIONES MOBILE (parche adicional)
   Cubre todos los casos que no estaban adaptados en app.css
   ══════════════════════════════════════════════════════════════ */

/* ── A. Wrapper principal de configuracion.php ─────────────── */
/* La cuadrícula 1fr 1fr del contenedor raíz pasa a 1 columna  */
@media (max-width: 768px) {
    div[style*="grid-template-columns:1fr 1fr;gap:20px"] {
        grid-template-columns: 1fr !important;
    }
}

/* ── B. Estadísticas en bloque de 4 columnas (config, users) ── */
/* repeat(4,1fr) → 2 columnas en tablet, 1 en mobile            */
@media (max-width: 900px) {
    div[style*="grid-template-columns:repeat(4,1fr)"] {
        grid-template-columns: repeat(2,1fr) !important;
    }
}
@media (max-width: 480px) {
    div[style*="grid-template-columns:repeat(4,1fr)"] {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ── C. Estadísticas usuarios: clase stats-grid fija en 4 cols ─ */
@media (max-width: 768px) {
    .stats-grid[style*="grid-template-columns:repeat(4,1fr)"] {
        grid-template-columns: repeat(2,1fr) !important;
    }
}

/* ── D. Botones de pausar bot (control del bot) ─────────────── */
@media (max-width: 640px) {
    #bot-telefono-row,
    div:has(> #bot-telefono) {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    #btn-pausar, #btn-activar {
        min-width: unset !important;
        width: 100%;
    }
}

/* ── E. Grids 1fr 1fr dentro de modales y tarjetas ──────────── */
@media (max-width: 540px) {
    .modal div[style*="grid-template-columns:1fr 1fr"],
    .modal div[style*="grid-template-columns: 1fr 1fr"],
    .card  div[style*="grid-template-columns:1fr 1fr"],
    .card  div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ── F. Orden detalle: firma / grid repeat(5,1fr) ───────────── */
@media (max-width: 640px) {
    div[style*="grid-template-columns:repeat(5,1fr)"] {
        grid-template-columns: repeat(3,1fr) !important;
    }
}
@media (max-width: 400px) {
    div[style*="grid-template-columns:repeat(5,1fr)"] {
        grid-template-columns: repeat(2,1fr) !important;
    }
}

/* ── G. Preview de fotos en modal moto: repeat(4,1fr) ────────── */
@media (max-width: 540px) {
    #fotos-preview,
    div[style*="grid-template-columns:repeat(4,1fr)"] {
        grid-template-columns: repeat(2,1fr) !important;
    }
}

/* ── H. Reportes form: muchas columnas auto ─────────────────── */
/* Ya tiene clase .reportes-form manejada, pero reforzamos      */
@media (max-width: 640px) {
    .reportes-form {
        grid-template-columns: 1fr !important;
    }
    .reportes-form button[type="submit"] {
        width: 100%;
    }
}

/* ── I. Tabla de órdenes: acciones con nowrap ────────────────── */
/* En pantallas pequeñas los botones de acción se apilan         */
@media (max-width: 640px) {
    .table-wrap td div[style*="flex-wrap:nowrap"],
    .table-wrap td div[style*="flex-wrap: nowrap"] {
        flex-wrap: wrap !important;
    }
}

/* ── J. Configuracion: grid-column:span 2 en móvil no funciona ─ */
@media (max-width: 540px) {
    div[style*="grid-column:span 2"],
    div[style*="grid-column: span 2"] {
        grid-column: span 1 !important;
    }
}

/* ── K. Botones de búsqueda/control del bot en fila ─────────── */
@media (max-width: 600px) {
    /* El div que tiene id bot-telefono cambia a columna */
    div:has(#bot-telefono) {
        flex-direction: column !important;
        gap: 10px !important;
    }
    div:has(#bot-telefono) .btn {
        width: 100% !important;
        min-width: unset !important;
    }
    /* Filas de la lista de bots */
    .bot-row {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .bot-row > div:first-child {
        flex-basis: 100%;
    }
}

/* ── L. Mis motos (cliente): stats del modal en 1 columna ───── */
@media (max-width: 480px) {
    div[style*="grid-template-columns:1fr 1fr;gap:12px;margin-bottom:16px"] {
        grid-template-columns: 1fr !important;
    }
}

/* ── M. Mantenimiento cliente: grid 1fr 1fr ─────────────────── */
@media (max-width: 768px) {
    div[style*="grid-template-columns:1fr 1fr;gap:20px"] {
        grid-template-columns: 1fr !important;
    }
}

/* ── N. Page header: título y badge en columna en mobile ─────── */
@media (max-width: 480px) {
    .page-header {
        gap: 6px !important;
    }
    .page-header > div:last-child {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    .page-header .btn {
        font-size: 12px !important;
        padding: 6px 10px !important;
    }
}

/* ── O. Inputs de teléfono en bot control ───────────────────── */
@media (max-width: 600px) {
    #bot-telefono {
        width: 100% !important;
    }
}

/* ── P. Card padding en mobile muy pequeño ──────────────────── */
@media (max-width: 400px) {
    .card > div[style*="padding:24px"] {
        padding: 14px !important;
    }
    .card > div[style*="padding: 24px"] {
        padding: 14px !important;
    }
}

/* ── Q. Overflow seguro en tablas dentro de tarjetas ─────────── */
@media (max-width: 768px) {
    .card .table-wrap {
        margin: 0 -14px;
        border-radius: 0;
    }
}

/* ── R. Solicitudes WhatsApp: grid en tarjetas ───────────────── */
@media (max-width: 480px) {
    div[style*="grid-template-columns:1fr 1fr;gap:8px"],
    div[style*="grid-template-columns: 1fr 1fr;gap:8px"] {
        grid-template-columns: 1fr !important;
    }
}
