@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Brand */
    --primary:      #2563eb;
    --primary-dk:   #1d4ed8;
    --primary-lt:   #eff6ff;
    --primary-ring: rgba(37,99,235,0.2);
    --navy:         #1e3a8a;
    --nav-bg:       #1a3a8a;

    /* Semantic */
    --success:    #059669;
    --success-lt: #ecfdf5;
    --warning:    #d97706;
    --warning-lt: #fffbeb;
    --danger:     #dc2626;
    --danger-lt:  #fef2f2;

    /* Surfaces */
    --bg:      #eef2ff;
    --surface: #ffffff;
    --surface2: #f8faff;
    --border:  #e2e8f0;
    --border2: #cbd5e1;

    /* Text */
    --text:   #0f172a;
    --text-2: #334155;
    --muted:  #64748b;
    --muted2: #94a3b8;

    /* Shadows */
    --sh-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
    --sh-md: 0 4px 14px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
    --sh-lg: 0 12px 36px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);

    /* Layout */
    --sat: env(safe-area-inset-top,    0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left,   0px);
    --sar: env(safe-area-inset-right,  0px);
    --header-h: 58px;
    --nav-h:    66px;
    --r:  14px;
    --rs: 10px;
    --rx: 7px;
}

/* ── ICONS ────────────────────────────────────────────────────────────────── */
.ic {
    width: 17px; height: 17px;
    flex-shrink: 0;
    vertical-align: -3px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ic-fill { fill: currentColor; stroke: none; }
.ic-sm { width: 14px; height: 14px; }
.ic-lg { width: 24px; height: 24px; vertical-align: -5px; }
.ic-xl { width: 46px; height: 46px; vertical-align: middle; }
.ic-danger  { color: var(--danger); }
.ic-warning { color: var(--warning); }
.ic-success { color: var(--success); }
.ic-muted   { color: var(--muted); }
.ic-primary { color: var(--primary); }

html { height: 100%; overflow-x: hidden; }

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    overflow-x: hidden;
    font-size: 15px;
    line-height: 1.45;
}

.hidden { display: none !important; }

/* ── LOGIN (compatibility) ───────────────────────────────────────────────── */
.login-page { min-height:100dvh; display:flex; flex-direction:column; align-items:center; justify-content:center; background:linear-gradient(160deg,var(--navy),#3b82f6); padding:20px; }
.login-card { background:white; border-radius:20px; padding:36px 28px 32px; width:100%; max-width:420px; box-shadow:var(--sh-lg); }

/* ── APP LAYOUT ─────────────────────────────────────────────────────────────*/
#app { display: flex; flex-direction: column; height: 100dvh; }

/* ── HEADER ─────────────────────────────────────────────────────────────────*/
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: white;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 16px 10px;
    padding-top: calc(var(--sat) + 10px);
    height: calc(var(--header-h) + var(--sat));
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    padding-left:  max(16px, calc(var(--sal) + 8px));
    padding-right: max(16px, calc(var(--sar) + 8px));
}

.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    color: white;
}
.logo-text-top {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    display: block;
    margin-bottom: 2px;
}
.logo-text-main {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.3px;
    display: block;
}
.header-logo {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 8px;
    border: 1.5px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
    background: rgba(255,255,255,0.1);
}

.header-right { display: flex; align-items: center; gap: 4px; }

.user-badge {
    display: none;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    color: white;
    padding: 5px 10px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.1px;
}

.icon-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    padding: 7px 8px;
    font-size: 16px;
    line-height: 1;
    touch-action: manipulation;
    min-width: 36px;
    min-height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 7px;
    transition: background .15s, color .15s;
    position: relative;
}
.icon-btn:active { color: white; background: rgba(255,255,255,0.12); }
.icon-btn .ic { width: 19px; height: 19px; }

/* ── CONTENT ─────────────────────────────────────────────────────────────── */
#content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    margin-top: calc(var(--header-h) + var(--sat));
    padding: 14px max(14px, var(--sar)) calc(var(--nav-h) + var(--sab) + 28px) max(14px, var(--sal));
}

/* ── BOTTOM NAV ─────────────────────────────────────────────────────────────*/
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    background: var(--nav-bg);
    display: flex;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-bottom: var(--sab);
    padding-left:  var(--sal);
    padding-right: var(--sar);
    height: calc(var(--nav-h) + var(--sab));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.3);
    font-size: 10px;
    font-weight: 600;
    touch-action: manipulation;
    font-family: 'DM Sans', sans-serif;
    padding: 6px 2px;
    min-height: 44px;
    transition: color .15s;
    -webkit-user-select: none;
    user-select: none;
    letter-spacing: 0.2px;
    position: relative;
}

.nav-icon { font-size: 21px; line-height: 1; }
.nav-icon .ic { width: 22px; height: 22px; vertical-align: -4px; }
.nav-dot {
    position: absolute;
    top: 7px;
    right: calc(50% - 16px);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--nav-bg);
}
.nav-btn.active { color: white; }

/* White indicator line under active tab */
.nav-btn.active:not(.nav-fab)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: white;
    border-radius: 3px 3px 0 0;
}

.nav-fab { color: rgba(255,255,255,0.7) !important; }

/* FAB: white circle on blue nav */
.fab-circle {
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 300;
    font-family: 'DM Sans', sans-serif;
    color: #1e3a8a;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 1px 4px rgba(0,0,0,0.1);
    line-height: 1;
    transition: transform .1s;
}
.nav-fab:active .fab-circle { transform: scale(0.93); }

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

label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-family: 'DM Sans', sans-serif;
}

input, select, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--rs);
    font-size: 16px;
    color: var(--text);
    background: white;
    font-family: 'DM Sans', sans-serif;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
    cursor: pointer;
}
input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    padding: 0;
    border: 1.5px solid var(--border);
    border-radius: 5px;
    background: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='11' fill='none'%3E%3Cpath d='M1 5.5l4 4 8-9' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}
input[type="checkbox"]:focus {
    box-shadow: 0 0 0 3px var(--primary-ring);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
    background: white;
}
textarea { resize: vertical; min-height: 92px; line-height: 1.55; }

/* ── BUTTONS ────────────────────────────────────────────────────────────────*/
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 13px 20px;
    border-radius: var(--rs);
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    touch-action: manipulation;
    transition: filter .15s, transform .1s, box-shadow .15s;
    white-space: nowrap;
    min-height: 48px;
    letter-spacing: 0.1px;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(37,99,235,0.35), 0 1px 3px rgba(37,99,235,0.2);
}
.btn-primary:active { filter: brightness(0.93); }

.btn-success { background: linear-gradient(135deg, #059669 0%, #047857 100%); color: white; box-shadow: 0 2px 8px rgba(5,150,105,0.3); }
.btn-success:active { filter: brightness(0.93); }
.btn-danger  { background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%); color: white; box-shadow: 0 2px 8px rgba(220,38,38,0.3); }
.btn-danger:active  { filter: brightness(0.93); }

.btn-ghost {
    background: white;
    color: var(--text-2);
    border: 1.5px solid var(--border);
    box-shadow: var(--sh-sm);
}
.btn-ghost:active { border-color: var(--primary); color: var(--primary); background: var(--primary-lt); }

.btn-full { width: 100%; margin-bottom: 10px; }
.btn-full:last-child { margin-bottom: 0; }
.btn-sm { padding: 7px 12px; font-size: 13px; min-height: 34px; border-radius: 7px; }
.btn-sm.btn-primary { box-shadow: 0 1px 6px rgba(37,99,235,0.3); }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ── CARDS ──────────────────────────────────────────────────────────────────*/
.card {
    background: var(--surface);
    border-radius: var(--r);
    padding: 14px 16px;
    border: 1px solid var(--border);
    box-shadow: var(--sh-sm);
}
.card + .card { margin-top: 10px; }

/* ── BADGES ─────────────────────────────────────────────────────────────────*/
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.2px;
    border: 1px solid transparent;
}
.badge-success { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.badge-warning { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.badge-orange  { background: #ffedd5; color: #c2410c; border-color: #fed7aa; }
.badge-danger  { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
.badge-info    { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.badge-gray    { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.badge-pending { background: var(--primary-lt); color: var(--primary); border-color: #bfdbfe; }

/* ── STATS ROW ──────────────────────────────────────────────────────────────*/
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}

.stat-card {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--r);
    padding: 15px 10px 13px;
    text-align: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform .1s, box-shadow .15s;
    box-shadow: var(--sh-sm);
}
.stat-card:active { transform: scale(0.97); }

/* Per-card tinted backgrounds matching the accent bar */
.stats-row .stat-card:nth-child(1) { background: #eff6ff; border-color: #bfdbfe; }
.stats-row .stat-card:nth-child(2) { background: #fffbeb; border-color: #fde68a; }
.stats-row .stat-card:nth-child(3) { background: #fff5f5; border-color: #fecaca; }

/* Accent top bar per stat */
.stats-row .stat-card:nth-child(1)::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background: var(--primary); }
.stats-row .stat-card:nth-child(2)::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background: var(--warning); }
.stats-row .stat-card:nth-child(3)::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background: var(--danger); }

.stat-value {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.5px;
    /* color set inline by JS — matches the accent bar */
}
.stat-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--muted);
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── SECTION TITLE ──────────────────────────────────────────────────────────*/
.sec-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--muted);
    margin: 22px 0 9px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sec-title::before {
    content: '';
    width: 3px;
    height: 14px;
    background: var(--primary);
    border-radius: 3px;
    flex-shrink: 0;
}
.sec-title:first-child { margin-top: 0; }

/* ── PAGE HEADER ────────────────────────────────────────────────────────────*/
.page-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    background: var(--surface);
    border-radius: var(--r);
    padding: 13px 16px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    box-shadow: var(--sh-sm);
}
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
    padding-left: 38px;
}
.page-header h2 {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 22px;
    font-weight: 800;
    flex: 1;
    color: var(--text);
    letter-spacing: 0.3px;
}

.back-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: var(--muted);
    line-height: 1;
    min-width: 36px;
    min-height: 44px;
    display: flex; align-items: center;
    touch-action: manipulation;
    margin-right: 2px;
}
.back-btn:active { color: var(--primary); }

/* ── TRUCK CARD ─────────────────────────────────────────────────────────────*/
.truck-card {
    display: flex;
    align-items: center;
    gap: 13px;
    cursor: pointer;
    touch-action: manipulation;
    transition: box-shadow .15s, transform .1s;
}
.truck-card:active { transform: scale(0.99); box-shadow: var(--sh-md); }

.truck-info { flex: 1; min-width: 0; }

/* Plate style for main identifier */
.truck-mat {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--navy);
    background: var(--primary-lt);
    border: 1.5px solid #bfdbfe;
    padding: 2px 9px;
    border-radius: 5px;
    display: inline-block;
    line-height: 1.5;
    text-transform: uppercase;
}

.truck-meta { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.3; }
.truck-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.truck-counts { font-size: 11px; color: var(--muted); }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
    display: flex; justify-content: space-between; align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 13px;
}
.history-name { font-weight: 600; color: var(--navy); }
.history-range { font-size: 12px; color: var(--muted); text-align: right; }

/* Detail view header truck name */
.truck-nombre {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.truck-alias { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── ALERTS ─────────────────────────────────────────────────────────────────*/
.alert {
    padding: 11px 14px;
    border-radius: var(--rs);
    margin-bottom: 9px;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-warning { background: var(--warning-lt); color: #78350f; border-color: #fde68a; }
.alert-danger  { background: var(--danger-lt);  color: #991b1b; border-color: #fecaca; }

/* ── INCIDENCIA ─────────────────────────────────────────────────────────────*/
.inc-item {
    display: flex;
    gap: 12px;
    padding: 13px 14px;
    border-radius: var(--r);
    border: 1.5px solid var(--border);
    background: white;
    cursor: pointer;
    touch-action: manipulation;
    margin-bottom: 9px;
    overflow: hidden;
    box-shadow: var(--sh-sm);
    transition: box-shadow .15s;
}

/* Solo la urgencia máxima destaca la carta entera */
.inc-item.urg-bg-alta {
    background: white;
    border-color: var(--danger);
    box-shadow: 0 0 0 1px rgba(220,38,38,0.15), var(--sh-sm);
    animation: pulse-danger 2.2s ease-in-out infinite;
}
@keyframes pulse-danger {
    0%, 100% { box-shadow: 0 0 0 1px rgba(220,38,38,0.15), var(--sh-sm); }
    50%      { box-shadow: 0 0 0 4px rgba(220,38,38,0.18), var(--sh-md); }
}

.inc-body { flex: 1; min-width: 0; }

.inc-tipo {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.2px;
    color: var(--text);
    line-height: 1.2;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.inc-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
    margin-left: 10px;
}

.urg-label {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
    white-space: nowrap;
}
.urg-label-alta  { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
.urg-label-media { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.urg-label-baja  { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }

.urg-label-plain {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.urg-text-alta  { color: #dc2626; }
.urg-text-media { color: #b45309; }
.urg-text-baja  { color: #15803d; }

.inc-desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
    margin-top: 3px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}
.inc-meta { font-size: 11px; color: var(--muted2); margin-top: 7px; }
.inc-actions { margin-top: 11px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ── MANTENIMIENTO ──────────────────────────────────────────────────────────*/
.mant-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: white;
    margin-bottom: 9px;
    box-shadow: var(--sh-sm);
    transition: box-shadow .15s;
}
/* Inside grouped card */
.card .mant-item {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    margin-bottom: 0;
    box-shadow: none;
}
.card .mant-item:last-child { border-bottom: none; }

.mant-ico {
    width: 44px; height: 44px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 21px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.04);
}
.mant-ico .ic { width: 22px; height: 22px; }
.mant-info { flex: 1; min-width: 0; }
.mant-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.2px;
    color: var(--text);
}
.mant-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.mant-italic { font-style: italic; }
.mant-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

.mant-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; vertical-align: middle; position: relative; top: -1px; }
.mant-dot-danger  { background: var(--danger); }
.mant-dot-warning { background: #f59e0b; }
.mant-dot-pending { background: var(--primary); }
.mant-dot-success { background: var(--success); }
.mant-dot-gray    { background: var(--muted2); }

/* Truck group header in "by truck" view */
.truck-group-hdr {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    cursor: pointer;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
}
.truck-group-hdr:active { background: var(--border); }

/* ── TABS ───────────────────────────────────────────────────────────────────*/
.tabs {
    display: flex;
    background: var(--surface2);
    border-radius: var(--rs);
    padding: 4px;
    margin-bottom: 14px;
    gap: 3px;
    border: 1px solid var(--border);
}
.tab {
    flex: 1;
    padding: 9px 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    border-radius: 7px;
    font-family: 'DM Sans', sans-serif;
    touch-action: manipulation;
    transition: all .18s;
}
.tab.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── MODAL ──────────────────────────────────────────────────────────────────*/
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
#modal {
    background: white;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 92dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--sab);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.2);
    animation: slideUp .22s cubic-bezier(0.32, 1.15, 0.64, 1);
}
@keyframes slideUp { from { transform:translateY(60px); opacity:0; } to { transform:translateY(0); opacity:1; } }

.modal-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 15px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}
.modal-hdr::before {
    content: '';
    position: absolute;
    top: 9px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 5px;
    background: var(--border);
    border-radius: 5px;
}
.modal-hdr h3 {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.3px;
}
.modal-hdr .icon-btn { color: var(--muted); background: var(--surface2); border: 1px solid var(--border); }
#modal-body { padding: 18px 20px 26px; }

/* ── ADMIN LIST ─────────────────────────────────────────────────────────────*/
.admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 15px;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--r);
    margin-bottom: 8px;
    gap: 10px;
    flex-wrap: wrap;
    box-shadow: var(--sh-sm);
    transition: border-color .15s, box-shadow .15s;
}
.admin-row:active { border-color: var(--primary); box-shadow: var(--sh-md); }

.admin-name {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 17px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
    color: var(--text);
    letter-spacing: 0.2px;
}
.admin-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── EMPTY / LOADING / ERROR ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-icon  { font-size: 52px; margin-bottom: 14px; opacity: 0.45; }
.empty-icon .ic { width: 46px; height: 46px; }
.empty-state p { font-size: 14px; line-height: 1.65; }

.loading-wrap { display: flex; justify-content: center; padding: 72px 0; }
.spinner {
    width: 34px; height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-state { text-align: center; padding: 40px 20px; color: var(--danger); font-size: 14px; }

/* ── TOAST ──────────────────────────────────────────────────────────────────*/
.toast {
    position: fixed;
    bottom: calc(var(--nav-h) + var(--sab) + 16px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 11px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 999;
    box-shadow: 0 8px 28px rgba(0,0,0,0.3);
    white-space: nowrap;
    pointer-events: none;
    animation: toastIn .2s ease;
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: calc(100vw - 32px);
}
.toast::before { font-size: 15px; flex-shrink: 0; }
.toast-success { background: #14532d; }
.toast-success::before { content:'✓'; color:#4ade80; }
.toast-error   { background: #7f1d1d; }
.toast-error::before   { content:'✕'; color:#f87171; }
.toast-warning { background: #78350f; }
.toast-warning::before { content:'⚠'; color:#fbbf24; }
.toast-info    { background: #1e3a8a; }
.toast-info::before    { content:'ℹ'; color:#93c5fd; }
@keyframes toastIn { from { opacity:0; transform:translateX(-50%) translateY(10px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* ── SIDE PANEL (filtros / orden) ────────────────────────────────────────────*/
.side-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 210;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.side-panel {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 86vw;
    max-width: 340px;
    background: white;
    box-shadow: -8px 0 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    animation: slideInRight .22s cubic-bezier(0.32, 1.15, 0.64, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--sab);
}
@keyframes slideInRight { from { transform:translateX(100%); } to { transform:translateX(0); } }
.side-panel-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}
.side-panel-hdr h3 {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 19px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.3px;
}
.side-panel-hdr .icon-btn { color: var(--muted); background: var(--surface2); border: 1px solid var(--border); }
#side-panel-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
#side-panel-body label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
}
.filter-toggle-btn {
    position: relative;
}
.filter-toggle-dot {
    position: absolute;
    top: -3px; right: -3px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 1.5px solid white;
}

/* ── FILTER BAR ─────────────────────────────────────────────────────────────*/
.filter-bar {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--r);
    padding: 12px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    box-shadow: var(--sh-sm);
}
.filter-bar select {
    font-size: 13px;
    padding: 8px 10px;
    border-radius: var(--rx);
    border: 1.5px solid var(--border);
    background: var(--surface2);
    color: var(--text-2);
    width: 100%;
    font-family: 'DM Sans', sans-serif;
}
.filter-bar select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px var(--primary-ring); }
.filter-bar select.filter-active,
.filter-bar input.filter-active { border-color: var(--primary); background: var(--primary-lt); color: var(--primary); font-weight: 600; }

.filter-search {
    font-size: 14px !important;
    padding: 10px 14px !important;
    border: 1.5px solid var(--border) !important;
    background: var(--surface2) !important;
    width: 100%;
    font-family: 'DM Sans', sans-serif !important;
    border-radius: var(--rs) !important;
}
.filter-search:focus { border-color: var(--primary) !important; box-shadow: 0 0 0 3px var(--primary-ring) !important; outline: none; }
.filter-count { font-size: 12px; color: var(--muted); margin-bottom: 10px; text-align: right; font-weight: 500; }

/* ── SEARCH ─────────────────────────────────────────────────────────────────*/
.search-wrap { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; position: relative; }
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    display: flex;
    pointer-events: none;
}
.search-icon .ic { width: 16px; height: 16px; }
.search-wrap .search-input {
    flex: 1;
    padding-left: 38px;
}
.search-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--rs);
    font-size: 15px;
    color: var(--text);
    background: white;
    font-family: 'DM Sans', sans-serif;
    box-shadow: var(--sh-sm);
    -webkit-appearance: none;
    appearance: none;
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.search-wrap .filter-toggle-btn {
    flex-shrink: 0;
    box-shadow: var(--sh-sm);
    height: 44px;
    width: 44px;
    border-radius: var(--rs);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* ── OTRO INPUT ─────────────────────────────────────────────────────────────*/
.otro-input { margin-top: 8px; display: none; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }

/* ── FORM ERROR ─────────────────────────────────────────────────────────────*/
.form-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 10px;
    display: none;
    padding: 10px 13px;
    background: var(--danger-lt);
    border-radius: var(--rx);
    border: 1px solid #fecaca;
    font-weight: 500;
}

/* ── NOTIFICACIONES ─────────────────────────────────────────────────────────*/
.notif-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: 800;
    min-width: 16px; height: 16px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px;
    line-height: 1;
    pointer-events: none;
    border: 1.5px solid var(--navy);
}

.notif-panel {
    position: fixed;
    top: calc(var(--header-h) + var(--sat));
    left: 0; right: 0;
    z-index: 150;
    background: white;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 10px 32px rgba(0,0,0,0.14);
    max-height: 58vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: slideDown .2s ease;
    padding: 10px max(14px,var(--sar)) 16px max(14px,var(--sal));
}
@keyframes slideDown { from { opacity:0; transform:translateY(-10px); } to { opacity:1; transform:translateY(0); } }

.notif-section-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin: 10px 0 6px;
    display: flex; align-items: center; gap: 6px;
}
.notif-section-title::before { content:''; width:3px; height:12px; background:var(--primary); border-radius:3px; }
.notif-section-title:first-child { margin-top: 0; }

.notif-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--rs);
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    gap: 8px;
    border: 1px solid transparent;
}
.notif-item:active { filter: brightness(.96); }
.notif-danger  { background: var(--danger-lt); color: #991b1b; border-color: #fecaca; }
.notif-warning { background: var(--warning-lt); color: #78350f; border-color: #fde68a; }
.notif-meta { font-size: 11px; font-weight: 700; opacity: .7; flex-shrink: 0; }

/* ── CALENDARIO ─────────────────────────────────────────────────────────────*/
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-month-label { font-family: 'Barlow Condensed', sans-serif; font-size: 20px; font-weight: 800; color: var(--text); }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; margin-bottom: 14px; }
.cal-hdr  { text-align: center; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 4px 0 6px; }
.cal-day  {
    aspect-ratio: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 9px;
    cursor: pointer;
    touch-action: manipulation;
    gap: 2px;
    border: 1.5px solid transparent;
    transition: background .12s;
    min-height: 0;
}
.cal-day:active { background: var(--border); }
.cal-day-empty  { cursor: default; pointer-events: none; }
.cal-day-today .cal-day-num {
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.cal-day-sel { background: var(--primary-lt); border-color: var(--primary); }
.cal-day-num { font-size: 13px; font-weight: 600; line-height: 1; color: var(--text-2); }
.cal-dots    { display: flex; gap: 2px; justify-content: center; }
.cal-dot     { width: 5px; height: 5px; border-radius: 50%; }
.cal-legend  { display: flex; gap: 14px; font-size: 11px; color: var(--muted); margin-bottom: 10px; align-items: center; font-weight: 600; }
.cal-legend span { display: flex; align-items: center; gap: 4px; }
.cal-dot-danger  { background: var(--danger); }
.cal-dot-warning { background: #f59e0b; }
.cal-dot-ok      { background: var(--success); }

/* ── 6-item nav (admin) ──────────────────────────────────────────────────────*/
.bottom-nav:has(#admin-nav-btn:not([style*="none"])) .nav-btn { font-size: 9px; padding: 4px 1px; }
.bottom-nav:has(#admin-nav-btn:not([style*="none"])) .nav-icon { font-size: 18px; }
.bottom-nav:has(#admin-nav-btn:not([style*="none"])) .fab-circle { width: 42px; height: 42px; font-size: 26px; }

/* ── HOVER (desktop) ────────────────────────────────────────────────────────*/
@media (hover: hover) {
    .truck-card:hover { box-shadow: var(--sh-md); }
    .btn-primary:hover { filter: brightness(1.07); }
    .btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-lt); }
    .nav-btn:hover { color: rgba(255,255,255,.5); }
    .nav-btn.active:hover { color: white; }
    .icon-btn:hover { background: rgba(255,255,255,0.12); color: white; }
    .stat-card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
    .inc-item:hover { box-shadow: var(--sh-md); }
    .mant-item:hover { box-shadow: var(--sh-md); }
    .admin-row:hover { border-color: var(--border2); box-shadow: var(--sh-md); }
}

/* ── iPhone SE / small ──────────────────────────────────────────────────────*/
@media (max-width: 375px) {
    .stats-row { gap: 6px; }
    .stat-value { font-size: 28px; }
    .stat-label { font-size: 8px; letter-spacing: .8px; }
    .nav-btn { font-size: 9px; gap: 1px; }
    .fab-circle { width: 44px; height: 44px; font-size: 27px; }
    .truck-mat { font-size: 16px; letter-spacing: 1.5px; }
    .btn { padding: 11px 14px; font-size: 14px; }
    input, select, textarea { padding: 11px 12px; }
    .page-header h2 { font-size: 19px; }
    .inc-tipo { font-size: 15px; }
}

/* ── Tablet / desktop ───────────────────────────────────────────────────────*/
@media (min-width: 600px) {
    .app-header, .bottom-nav { left: 50%; transform: translateX(-50%); width: 560px; }
    .app-header { border-radius: 0 0 14px 14px; }
    .bottom-nav { border-radius: 16px 16px 0 0; }
    #content { max-width: 560px; margin-left: auto; margin-right: auto; }
    #modal { border-radius: 20px; margin-bottom: 48px; }
    #modal-overlay { align-items: center; }
    .notif-panel { left: calc(50% - 280px); right: auto; width: 560px; }
}

/* ── Escritorio (pantallas grandes) ──────────────────────────────────────── */
@media (min-width: 900px) {
    body { font-size: 16px; }

    .app-header, .bottom-nav { width: 760px; }
    #content { max-width: 760px; }
    .notif-panel { left: calc(50% - 380px); width: 760px; }

    #modal { max-width: 640px; margin: 0 auto 48px; }

    /* La barra inferior se vuelve más cómoda de usar con ratón */
    .bottom-nav { padding-bottom: 10px; }
    .nav-btn { font-size: 12px; }

    /* Aprovechar el ancho extra en listados de dos columnas */
    .stats-row { gap: 14px; }
}

@media (min-width: 1200px) {
    .app-header, .bottom-nav { width: 880px; }
    #content { max-width: 880px; }
    .notif-panel { left: calc(50% - 440px); width: 880px; }
    #modal { max-width: 720px; }
}

/* ── Galería de imágenes (partes / comentarios) ─────────────────────────────*/
.inc-gallery {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin: 10px 0;
}
.inc-gallery img {
    width: 84px; height: 84px; object-fit: cover;
    border-radius: var(--rs); border: 1px solid var(--border);
    background: var(--surface2);
}

/* ── Comentarios ──────────────────────────────────────────────────────────── */
.comentario-item {
    border-top: 1px solid var(--border);
    padding: 10px 0;
}
.comentario-item:first-child { border-top: none; }
.comentario-hdr {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--text-2); margin-bottom: 4px;
}
.comentario-fecha { color: var(--muted); font-size: 12px; font-weight: 400; }
.comentario-hdr .icon-btn-sm { margin-left: auto; padding: 2px; }
.comentario-texto { font-size: 14px; white-space: pre-wrap; }

.comentario-form { margin-top: 10px; }
.comentario-form textarea {
    width: 100%; resize: vertical;
    border: 1px solid var(--border2); border-radius: var(--rs);
    padding: 10px 12px; font-family: inherit; font-size: 14px;
}
.comentario-form-row {
    display: flex; align-items: center; gap: 10px; margin-top: 8px;
    justify-content: space-between;
}
.comentario-form-row input[type=file] { font-size: 12px; max-width: 60%; }

.icon-btn-sm {
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: none; cursor: pointer; color: var(--muted);
    border-radius: 6px;
}
.icon-btn-sm:hover { background: var(--danger-lt); }

/* ── Banner "Instalar app" ────────────────────────────────────────────────*/
.install-banner {
    position: fixed;
    top: calc(var(--header-h) + var(--sat) + 8px);
    left: 8px; right: 8px;
    z-index: 40;
    display: flex; align-items: center; gap: 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); box-shadow: var(--sh-md);
    padding: 10px 12px;
}
.install-banner-icon { width: 36px; height: 36px; border-radius: var(--rx); object-fit: cover; flex-shrink: 0; }
.install-banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.install-banner-text strong { font-size: 13px; }
.install-banner-text span { font-size: 11px; color: var(--muted); }

@media (min-width: 600px) {
    .install-banner { left: 50%; transform: translateX(-50%); width: 560px; }
}
@media (min-width: 900px)  { .install-banner { width: 760px; } }
@media (min-width: 1200px) { .install-banner { width: 880px; } }
