:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --sidebar: #0f172a;
    --sidebar-hover: #1e293b;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 12px rgba(15, 23, 42, .05);
    --font: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--sidebar);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}
.sidebar .brand {
    padding: 20px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar .brand .logo {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.sidebar .brand small { display: block; font-size: 11px; font-weight: 400; color: #94a3b8; }

.sidebar nav { padding: 12px 0; overflow-y: auto; flex: 1; }
.sidebar nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 20px;
    color: #cbd5e1;
    font-size: 14px;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-hover); color: #fff; border-left-color: var(--primary); }
.sidebar nav a .ico { width: 20px; text-align: center; }

.sidebar .user-box { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar .user-box .name { color: #fff; font-weight: 600; }
.sidebar .user-box .role { color: #94a3b8; font-size: 12px; }
.sidebar .user-box .logout { margin-top: 10px; display: block; color: #fca5a5; }

.main { flex: 1; margin-left: 250px; display: flex; flex-direction: column; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar .actions { display: flex; gap: 10px; align-items: center; }

.content { padding: 24px 28px; flex: 1; }

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.card .card-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ===== Stat cards ===== */
.stat { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; }
.stat .stat-label { color: var(--muted); font-size: 13px; }
.stat .stat-value { font-size: 26px; font-weight: 800; }
.stat .stat-sub { color: var(--muted); font-size: 12px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    text-decoration: none;
    color: #fff;
    background: var(--primary);
}
.btn:hover { opacity: .92; text-decoration: none; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: #eff6ff; }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-neutral { background: #f1f5f9; color: var(--text); border-color: var(--border); }
.btn-neutral:hover { background: #e2e8f0; }

/* ===== Badges ===== */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px; font-weight: 600;
    white-space: nowrap;
}
.badge.rojo { background: #fee2e2; color: #b91c1c; }
.badge.amarillo { background: #fef3c7; color: #b45309; }
.badge.verde { background: #dcfce7; color: #15803d; }
.badge.gris { background: #f1f5f9; color: #475569; }
.badge.azul { background: #dbeafe; color: #1d4ed8; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.table th, table.table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.table th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
table.table tbody tr:hover { background: #f8fafc; }
table.table .mono { font-family: 'Consolas', 'Courier New', monospace; font-weight: 600; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ===== Alerts ===== */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.alert.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ===== Bar chart ===== */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-row .bar-label { width: 130px; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.bar-row .bar-track { flex: 1; background: #eef2f7; height: 22px; border-radius: 6px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width .4s; }
.bar-row .bar-value { width: 90px; text-align: right; font-weight: 700; font-size: 13px; flex-shrink: 0; }

/* ===== Timeline ===== */
.timeline { list-style: none; padding-left: 4px; }
.timeline li { position: relative; padding-left: 28px; padding-bottom: 18px; }
.timeline li::before {
    content: ''; position: absolute; left: 6px; top: 6px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary);
}
.timeline li:not(:last-child)::after {
    content: ''; position: absolute; left: 10px; top: 20px; bottom: 0;
    width: 2px; background: var(--border);
}
.timeline .t-time { color: var(--muted); font-size: 12px; }

/* ===== Modal ===== */
.modal-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5); z-index: 200;
    align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 90%; max-width: 480px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }

/* ===== Toast ===== */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 12px 18px; border-radius: 8px; color: #fff; font-weight: 500; box-shadow: 0 8px 20px rgba(0,0,0,.18); animation: slidein .25s ease; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Spinner de carga */
.spinner { display:inline-block; width:14px; height:14px; border:2px solid currentColor; border-top-color:transparent; border-radius:50%; animation:spin .6s linear infinite; vertical-align:-2px; margin-right:6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Utilidades ===== */
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .sidebar { width: 68px; }
    .sidebar .brand span, .sidebar nav a span, .sidebar .user-box { display: none; }
    .sidebar nav a { justify-content: center; padding: 14px 0; }
    .main { margin-left: 68px; }
    .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .topbar { padding: 12px 16px; }
}

/* ===== Seguimiento público — hero camión ===== */
.pc-track {
    min-height: 520px;
    background-color: #111;
    background-image:
        linear-gradient(90deg, rgba(0,0,0,.25), rgba(255,255,255,.15) 55%, #f7f7f8 78%),
        url('../img/public/home/hero-seguimiento-camion.jpg');
    background-size: cover;
    background-position: center left;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
}
.pc-track-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 48px 24px;
    display: flex;
    justify-content: flex-end;
}
.pc-track-card {
    width: 440px;
    max-width: 100%;
    background: #fff;
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 16px 40px rgba(0,0,0,.12);
}
.pc-track-title {
    font: 800 32px/1.2 Inter, system-ui, sans-serif;
    color: #111111;
    margin: 0 0 8px;
}
.pc-track-sub {
    font: 400 15px/1.5 Inter, sans-serif;
    color: #5C5C5C;
    margin: 0 0 20px;
}
.pc-track-card input {
    width: 100%;
    height: 48px;
    border: 1px solid #E6E6E6;
    border-radius: 10px;
    padding: 0 14px;
    font-size: 15px;
    color: #111111;
    box-sizing: border-box;
    margin-bottom: 12px;
    background: #fff;
}
.pc-track-card input::placeholder { color: #9CA3AF; }
.pc-track-card input:focus {
    outline: none;
    border-color: #111111;
    box-shadow: 0 0 0 3px rgba(17, 17, 17, .08);
}
.pc-track-card button {
    width: 100%;
    height: 48px;
    background: #FFD200;
    color: #111111;
    border: 0;
    border-radius: 10px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    font-family: Inter, system-ui, sans-serif;
}
.pc-track-card button:hover { background: #E6BD00; }
.pc-track-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 18px;
}
.pc-track-pills .pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    font-family: Inter, system-ui, sans-serif;
    color: #333333;
}
.pc-track-pills .pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.pc-track-pills .por-salir { background: #FFF1F2; }
.pc-track-pills .por-salir .dot { background: #E11D48; }
.pc-track-pills .en-ruta { background: #FFF8D6; }
.pc-track-pills .en-ruta .dot { background: #FFD200; }
.pc-track-pills .entregado { background: #F0FDF4; }
.pc-track-pills .entregado .dot { background: #16A34A; }

@media (max-width: 767px) {
    .pc-track { min-height: 0; display: block; background: none; }
    .pc-track::before {
        content: '';
        display: block;
        height: 220px;
        background: #111 url('../img/public/home/hero-seguimiento-camion.jpg') center / cover no-repeat;
    }
    .pc-track-container { padding: 0; display: block; }
    .pc-track-card { width: 100%; max-width: 100%; border-radius: 0; box-shadow: none; }
}

/* ===== Header público (home + seguimiento) ===== */
.pc-top {
    background: #111;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.pc-top .pc-top-logo { display: flex; align-items: center; text-decoration: none; flex-shrink: 0; }
.pc-top .pc-top-logo img { height: 46px; width: auto; max-width: 220px; object-fit: contain; display: block; }
.pc-top a { color: #fff; text-decoration: none; font: 500 14px Inter, sans-serif; white-space: nowrap; }
.pc-top a:hover { color: #FFD200; }
.pc-top a.is-active { color: #FFD200; box-shadow: inset 0 -2px 0 #FFD200; }
.pc-top-nav { display: flex; align-items: center; gap: 22px; }
.pc-top-nav a { padding: 8px 0; }
.pc-top-actions { display: flex; align-items: center; gap: 10px; }
.pc-top .wa { background: #25D366; color: #fff; border-radius: 999px; padding: 8px 14px; }
.pc-top .wa:hover { color: #fff; }
.pc-top .login { background: #FFD200; color: #111; border-radius: 999px; padding: 8px 16px; font-weight: 700; }
.pc-top .login:hover { color: #111; }
.pc-top-burger {
    display: none;
    background: none;
    border: 1px solid rgba(255,255,255,.4);
    color: #fff;
    font-size: 20px;
    border-radius: 6px;
    padding: 4px 11px;
    cursor: pointer;
}
@media (max-width: 900px) {
    .pc-top-nav {
        display: none;
        position: absolute;
        top: 72px;
        left: 0;
        right: 0;
        background: #111;
        flex-direction: column;
        align-items: flex-start;
        padding: 16px 28px;
        gap: 14px;
        box-shadow: 0 14px 24px rgba(0,0,0,.25);
    }
    .pc-top-nav.open { display: flex; }
    .pc-top-burger { display: block; }
}

/* ===== Seguimiento: ocultar hero al haber resultado ===== */
.pc-track.is-hidden { display: none; }
.pc-result { max-width: 880px; margin: 28px auto; padding: 0 16px; }
.pc-otra { display: flex; gap: 10px; margin-bottom: 16px; }
.pc-otra input {
    flex: 1;
    height: 44px;
    border: 1px solid #E6E6E6;
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    color: #111;
    background: #fff;
    box-sizing: border-box;
}
.pc-otra button {
    background: #FFD200;
    color: #111;
    border: 0;
    border-radius: 10px;
    padding: 0 18px;
    height: 44px;
    font-weight: 700;
    cursor: pointer;
}
.pc-nuevo {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0 14px;
    border: 1px solid #111;
    border-radius: 10px;
    color: #111;
    background: #fff;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}
.pc-nuevo:hover { color: #111; text-decoration: none; }
@media (max-width: 600px) {
    .pc-otra { flex-direction: column; align-items: stretch; }
    .pc-otra input { width: 100%; flex: none; }
    .pc-otra button { height: 44px; }
    .pc-nuevo { justify-content: center; }
}

/* ===== Autocompletado de contactos ===== */
.ac-list {
    position: absolute;
    z-index: 60;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 100%;
    max-height: 240px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 8px 20px rgba(0,0,0,.12);
}
.ac-list .ac-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.ac-list .ac-item:hover { background: #f8fafc; }
.ac-list .ac-item:last-child { border-bottom: 0; }
.ac-list .ac-nombre { font-weight: 600; color: var(--text); font-size: 14px; }
.ac-list .ac-doc { font-size: 12px; color: var(--muted); }


