:root {
  --blue: #123b68;
  --blue2: #0d5ca8;
  --blue-dark: #0b2747;   /* fin del degradado del encabezado */
  --soft: #eff6ff;        /* fondo de selección */
  --soft2: #dce8f3;       /* fondo de miniaturas */
  --ring: #0d5ca822;      /* halo de foco/selección */
  --ring-soft: #0d5ca814;
  --burgundy: #7b2433;
  --bg: #eef3f8;
  --card: #fff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #dce5ef;
  --green: #16a34a;
  --orange: #f59e0b;
  --red: #dc2626;
  --gray: #64748b;
  --shadow: 0 10px 30px rgba(15, 35, 60, .10);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
[hidden] { display: none !important; }
a { color: var(--blue2); }

/* ---------- Encabezado ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
header.top {
  height: 64px; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px; gap: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .16); z-index: 1000; flex: none;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 38px; height: 38px; border-radius: 11px; background: #fff; color: var(--blue); display: grid; place-items: center; font-weight: 900; font-size: 17px; }
.brand strong { font-size: 17px; } .brand small { display: block; opacity: .72; font-size: 11px; margin-top: 2px; }
nav.main { display: flex; gap: 4px; flex: 1; margin-left: 20px; }
nav.main a { color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 9px; opacity: .8; font-weight: 600; }
nav.main a:hover { background: #ffffff18; opacity: 1; }
nav.main a.active { background: #ffffff26; opacity: 1; }
.usermenu { position: relative; }
.usermenu > button { background: #ffffff18; color: #fff; border: 1px solid #ffffff40; border-radius: 22px; padding: 6px 12px; cursor: pointer; font: inherit; display: flex; gap: 8px; align-items: center; }
.usermenu .role { font-size: 10px; opacity: .75; text-transform: uppercase; letter-spacing: .05em; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--text); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--border); min-width: 200px; overflow: hidden; }
.dropdown button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 11px 14px; font: inherit; cursor: pointer; }
.dropdown button:hover { background: var(--bg); }

/* ---------- Controles ---------- */
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; min-height: 38px; background: var(--blue); color: #fff; }
.btn:hover { background: var(--blue2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--red); }
.btn.small { padding: 5px 10px; min-height: 30px; font-size: 12px; }
.btn.block { width: 100%; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select, textarea { width: 100%; border: 1px solid #d6e0eb; border-radius: 10px; padding: 10px 12px; background: #fff; font: inherit; color: inherit; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue2); box-shadow: 0 0 0 3px var(--ring-soft); }
.field-error { color: var(--red); font-size: 12px; margin-top: 4px; }
.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.ok { background: #dcfce7; color: #166534; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0 12px; }
.grid5 { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0 12px; }

/* ---------- Estados (texto + color) ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 20px; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ACTIVE, .badge.st-ACTIVE { background: #dcfce7; color: #166534; }
.badge.PENDING { background: #fef3c7; color: #92400e; }
.badge.COMPLETED { background: #dbeafe; color: #1e40af; }
.badge.CANCELLED, .badge.BLOCKED, .badge.INACTIVE { background: #fee2e2; color: #991b1b; }
.badge.stale { background: #ffedd5; color: #9a3412; }
.badge.role { background: #e2e8f0; color: #334155; }

/* ---------- Login / setup ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); padding: 28px; }
.auth-card .brand { margin-bottom: 22px; }
.auth-card .logo { background: var(--blue); color: #fff; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card p.muted { margin: 0 0 18px; font-size: 13px; }

/* ---------- Monitor ---------- */
main.monitor { display: grid; grid-template-columns: 380px 1fr; flex: 1; min-height: 0; height: calc(100vh - 64px); }
.sidebar { padding: 16px; background: #f7f9fc; border-right: 1px solid var(--border); overflow: auto; }
.topline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.topline h1 { font-size: 19px; margin: 0; }
.count { font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { border: 1px solid var(--border); background: #fff; border-radius: 20px; padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.chip b { font-weight: 700; margin-left: 3px; }
.search { margin-bottom: 12px; }
.cards { display: grid; gap: 10px; }
.ship-card { height: 190px; perspective: 1000px; cursor: pointer; }
.ship-card .flip-inner { position: relative; width: 100%; height: 100%; transition: transform .65s cubic-bezier(.2, .75, .25, 1); transform-style: preserve-3d; }
.ship-card.flipped .flip-inner { transform: rotateY(180deg); }
.ship-card.no-anim .flip-inner { transition: none; }
.ship-card .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #fff; border: 1px solid #dfe7f0; border-radius: 14px; box-shadow: 0 2px 8px rgba(15, 35, 60, .05); overflow: hidden; outline: none; }
.ship-card .face:focus-visible { box-shadow: 0 0 0 3px #0d5ca855; }
.ship-card:hover .face { border-color: #b8cbe0; }
.ship-card.selected .face { border-color: var(--blue2); box-shadow: 0 0 0 3px var(--ring); }
.ship-card .front { display: flex; gap: 12px; padding: 12px; align-items: center; }
.ship-card .back { transform: rotateY(180deg); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.ship-card .back-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; white-space: nowrap; overflow: hidden; }
.ship-card .back-head b { overflow: hidden; text-overflow: ellipsis; }
.ship-card .mini-map { flex: 1; min-height: 0; border-radius: 10px; background: var(--soft2); }
.ship-card .mini-map.empty { display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.ship-card .back-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; }
.ship-card .thumb { position: relative; width: 110px; height: 110px; border-radius: 12px; background: var(--soft2); flex: none; overflow: hidden; display: grid; place-items: center; color: var(--blue); }
.ship-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ship-card .thumb.icon-only .vicon { width: 80%; }
.thumb-ico { position: absolute; left: 6px; bottom: 6px; background: #fff; color: var(--blue); border-radius: 8px; padding: 3px 5px; box-shadow: 0 1px 4px #0003; line-height: 0; }
.thumb-ico .vicon { width: 26px; }
.vicon { fill: currentColor; display: block; height: auto; }
.vicon .w { fill: var(--ico-bg); }
.ship-card .info { min-width: 0; flex: 1; }
.ship-card h3 { margin: 0 0 3px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ship-card .sub { font-size: 12px; color: var(--muted); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ship-card .meta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.map-area { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.map-overlay { position: absolute; left: 58px; top: 14px; z-index: 500; background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; max-width: 360px; border: 1px solid #e1e8ef; }
.map-overlay h2 { margin: 0 0 4px; font-size: 15px; }
.map-overlay p { margin: 0; color: var(--muted); font-size: 12px; }
.stats { position: absolute; right: 14px; top: 14px; z-index: 500; display: flex; gap: 8px; }
.stat { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 9px 12px; min-width: 84px; }
.stat b { display: block; font-size: 17px; } .stat span { font-size: 10px; color: var(--muted); }
.detail { position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 500; background: #fff; border-radius: 16px; box-shadow: var(--shadow); border: 1px solid #e1e8ef; padding: 14px 16px; max-width: 760px; }
.detail .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.detail h2 { margin: 0; font-size: 16px; }
.detail .kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; }
.detail .kv div span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.detail .kv div b { font-size: 13px; font-weight: 600; word-break: break-word; }
.detail .route-line { font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend { position: absolute; right: 14px; bottom: 14px; z-index: 400; background: #fff; padding: 10px 12px; border-radius: 12px; box-shadow: var(--shadow); font-size: 11px; }
.legend div { margin: 4px 0; } .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.veh-marker { position: relative; width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 12px #0005; display: grid; place-items: center; color: #fff; }
.veh-marker .vicon { width: 26px; }
.veh-marker .st { position: absolute; right: -6px; top: -6px; width: 17px; height: 17px; border-radius: 50%; background: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 1px 3px #0005; }
.veh-marker.sel { animation: pulse 1.8s infinite; }
.end-marker { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px #0004; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 #123b6850, 0 4px 12px #0005; } 50% { box-shadow: 0 0 0 10px #123b6800, 0 4px 12px #0005; } }
.popup-title { font-weight: 800; margin-bottom: 4px; } .popup-line { font-size: 11px; color: var(--muted); margin: 2px 0; }

/* ---------- Administración ---------- */
main.page { flex: 1; padding: 20px; max-width: 1200px; width: 100%; margin: 0 auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
.toolbar .spacer { flex: 1; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 2px 8px rgba(15, 35, 60, .05); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #edf2f7; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
tr.pending td { background: #fffbeb; }

div.field { margin-bottom: 14px; }
.field > .label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.icon-picker label { cursor: pointer; }
.icon-picker input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.icon-picker span { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px 8px; border: 1px solid var(--border); border-radius: 12px; color: var(--blue); text-align: center; }
.icon-picker .vicon { width: 44px; }
.icon-picker small { font-size: 11px; color: var(--text); line-height: 1.2; }
.icon-picker label:hover span { border-color: #b8cbe0; }
.icon-picker input:checked + span { border-color: var(--blue2); background: var(--soft); box-shadow: 0 0 0 3px var(--ring); }
.icon-picker input:checked + span .vicon .w { fill: var(--soft); }
.icon-picker input:focus-visible + span { outline: 2px solid var(--blue2); outline-offset: 2px; }
.photo-box { display: flex; gap: 14px; align-items: center; }
.photo-preview { position: relative; width: 160px; height: 120px; border-radius: 12px; overflow: hidden; background: var(--soft2); flex: none; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-preview .no-photo { height: 100%; display: grid; place-items: center; color: var(--blue); }
.photo-preview .no-photo .vicon { width: 70%; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.photo-actions p { width: 100%; margin: 0; font-size: 12px; }
.veh-cell { position: relative; width: 64px; height: 48px; border-radius: 8px; background: var(--soft2); overflow: hidden; display: grid; place-items: center; color: var(--blue); }
.veh-cell img { width: 100%; height: 100%; object-fit: cover; }
.veh-cell img + .vicon { position: absolute; left: 3px; bottom: 3px; width: 22px; background: #fff; border-radius: 5px; padding: 2px; }
.veh-cell > .vicon:only-child { width: 44px; }

/* ---------- Pedidos y seguimiento público ---------- */
.badge.RECEIVED { background: #e2e8f0; color: #334155; }
.badge.ASSIGNED { background: #fef3c7; color: #92400e; }
.badge.IN_TRANSIT { background: #dcfce7; color: #166534; }
.badge.DELIVERED { background: #dbeafe; color: #1e40af; }
.track-page { height: 100vh; display: grid; grid-template-rows: 64px 1fr auto; }
.track-map { position: relative; min-height: 260px; }
.track-card { background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -6px 20px rgba(15, 35, 60, .08); padding: 16px 20px 20px; max-height: 55vh; overflow: auto; }
.track-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.track-head h1 { margin: 2px 0; font-size: 19px; }
.steps { list-style: none; display: flex; padding: 0; margin: 0 0 14px; counter-reset: st; }
.steps li { flex: 1; position: relative; text-align: center; font-size: 11px; color: var(--muted); padding-top: 26px; }
.steps li::before { counter-increment: st; content: counter(st); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 22px; height: 22px; border-radius: 50%; background: #e2e8f0; color: #475569; display: grid; place-items: center; font-weight: 700; z-index: 1; }
.steps li::after { content: ''; position: absolute; top: 10px; left: -50%; width: 100%; height: 3px; background: #e2e8f0; }
.steps li:first-child::after { display: none; }
.steps li.done, .steps li.current { color: var(--text); font-weight: 600; }
.steps li.done::before { content: '✓'; background: var(--green); color: #fff; }
.steps li.done::after, .steps li.current::after { background: var(--green); }
.steps li.current::before { background: var(--blue); color: #fff; box-shadow: 0 0 0 4px var(--ring); }
.track-vehicle { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 12px; }
.track-vehicle .thumb { position: relative; width: 88px; height: 66px; border-radius: 10px; background: var(--soft2); overflow: hidden; display: grid; place-items: center; color: var(--blue); flex: none; }
.track-vehicle .thumb img { width: 100%; height: 100%; object-fit: cover; }
.track-vehicle .thumb.icon-only .vicon { width: 70%; }
.track-vehicle .thumb-ico .vicon { width: 20px; }
.track-pos { font-size: 12px; margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.track-route { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 16px; }
.track-route span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.track-route b { font-size: 13px; font-weight: 600; }
.order-line { font-size: 12px; margin-top: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
code.key { display: block; padding: 10px 12px; background: #0f172a; color: #e2e8f0; border-radius: 10px; font-size: 13px; word-break: break-all; }

/* ---------- Cuentas y dashboard ---------- */
.auth-links { font-size: 13px; text-align: center; margin: 14px 0 0; }
.auth-links.right { text-align: right; margin: -4px 0 12px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.google-btn { display: flex; justify-content: center; min-height: 44px; }
.company-chip { display: inline-flex; align-items: center; gap: 6px; color: #fff; text-decoration: none; background: #ffffff18; border: 1px solid #ffffff40; border-radius: 20px; padding: 6px 12px; font-size: 13px; font-weight: 600; max-width: 260px; }
.company-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-chip:hover { background: #ffffff28; }
.dropdown a { display: block; padding: 11px 14px; color: var(--text); text-decoration: none; }
.dropdown a:hover { background: var(--bg); }
.dropdown-head { padding: 10px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); word-break: break-all; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.dash-head h1 { margin: 0 0 4px; font-size: 22px; }
.dash-head p { margin: 0; }
.section-title { font-size: 16px; margin: 0 0 10px; }
.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.company-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 2px 8px rgba(15, 35, 60, .05); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.company-top { display: flex; gap: 12px; align-items: center; }
.company-avatar { width: 46px; height: 46px; border-radius: 12px; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.company-avatar.big { width: 72px; height: 72px; font-size: 22px; }
.logo-img { object-fit: contain; padding: 3px; background: #fff; border: 1px solid #ffffff55; }
.company-avatar.logo-img { border-color: var(--border); }
.logo-box { display: flex; gap: 14px; align-items: center; }
.theme-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.theme-picker label { cursor: pointer; }
.theme-picker input[type=radio] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme-picker span { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 6px; border: 1px solid var(--border); border-radius: 12px; text-align: center; }
.theme-picker small { font-size: 11px; line-height: 1.2; }
.theme-picker .swatch { width: 44px; height: 28px; border-radius: 8px; display: block; }
.theme-picker input[type=color] { width: 44px; height: 28px; padding: 0; border: 0; border-radius: 8px; cursor: pointer; background: none; }
.theme-picker input[type=radio]:checked + span { border-color: var(--text); box-shadow: 0 0 0 2px var(--text); }
.theme-picker input[type=radio]:focus-visible + span { outline: 2px solid var(--blue2); outline-offset: 2px; }
.theme-preview { margin-top: 10px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.tp-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: #fff; }
.tp-head .logo { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }
.tp-nav { margin-left: auto; font-size: 12px; background: #ffffff26; padding: 4px 10px; border-radius: 8px; }
.tp-body { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg); flex-wrap: wrap; }
.tp-btn { color: #fff; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 8px; }
.tp-chip { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; border: 2px solid; background: #fff; }
.tp-line { flex: 1; min-width: 60px; height: 5px; border-radius: 5px; }
.logo-preview { width: 88px; height: 88px; border-radius: 16px; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 26px; flex: none; }
.logo-preview.logo-img { background: repeating-conic-gradient(#f1f5f9 0 25%, #fff 0 50%) 0 0 / 16px 16px; border: 1px solid var(--border); }
.company-name { min-width: 0; }
.company-name h3 { margin: 0; font-size: 16px; }
.company-name .muted { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.company-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: #f8fafc; border-radius: 12px; padding: 10px; text-align: center; }
.company-stats b { display: block; font-size: 18px; }
.company-stats span { font-size: 11px; color: var(--muted); }
.company-warn { font-size: 12px; color: #92400e; background: #fef3c7; border-radius: 10px; padding: 8px 10px; }
.company-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.badge.owner { background: #ede9fe; color: #5b21b6; }
.empty-state { grid-column: 1 / -1; text-align: center; background: #fff; border: 1px dashed #b8cbe0; border-radius: 16px; padding: 36px 20px; }
.empty-state h3 { margin: 8px 0 4px; }
.doc-list { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.doc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #edf2f7; font-size: 13px; flex-wrap: wrap; }
.doc-row:last-child { border-bottom: 0; }
.doc-upload { display: flex; gap: 8px; align-items: center; }
.doc-upload select { width: auto; flex: 1; }
.plan-list { display: grid; gap: 8px; }
.plan-option { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; font-size: 13px; }
.plan-option input { width: auto; margin-top: 3px; }
.plan-option:has(input:checked) { border-color: var(--blue2); background: var(--soft); }

/* Plan y pagos */
.plan-status { padding: 16px 18px; margin-bottom: 20px; overflow: visible; }
.plan-status h3 { margin: 0 0 4px; font-size: 17px; }
.plan-status p { margin: 0 0 14px; }
.plan-status.EXPIRED { border-color: var(--red); }
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.usage-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.usage-top b { color: var(--text); }
.usage-bar { height: 8px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.usage-bar i { display: block; height: 100%; background: var(--blue2); border-radius: 6px; }
.usage-bar i.full { background: var(--orange); }
.package-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.package-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.package-card.current { border-color: var(--blue2); box-shadow: 0 0 0 3px var(--ring-soft); }
.package-card h3 { margin: 0; font-size: 16px; }
.package-card .price { font-size: 20px; font-weight: 800; }
.package-card .price .muted { font-size: 12px; font-weight: 500; white-space: nowrap; }
.package-card p { margin: 0; font-size: 13px; }
.package-card ul { list-style: none; margin: 0 0 6px; padding: 0; font-size: 13px; flex: 1; }
.package-card li { padding: 3px 0; border-bottom: 1px dashed var(--border); }
.package-card .btn, .package-card .badge { align-self: flex-start; }
.custom-builder { padding: 16px; overflow: visible; }
.custom-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.custom-grid small { display: block; margin-top: 4px; font-size: 11px; }
.custom-total { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.custom-total b { font-size: 20px; margin-right: auto; }
.mini-table td { padding: 6px 4px; border-bottom: 1px solid #edf2f7; }
.mini-table select { min-width: 160px; }
#accessTable select { min-width: 140px; padding: 6px 8px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 20px; }
.kv-grid span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.kv-grid b { font-weight: 600; }
.settings-form { padding: 20px; }
.provider-pick { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; }
.provider-pick label, label.check { display: flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 600; }
.provider-pick input, label.check input { width: auto; }
.provider-box { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; }
.provider-box legend { font-weight: 700; padding: 0 6px; }
label.check { margin-bottom: 10px; }
.small { font-size: 12px; }
code { font-size: 12px; background: #f1f5f9; padding: 1px 5px; border-radius: 5px; word-break: break-all; }

/* ---------- App del conductor (PWA, móvil primero) ---------- */
body.drv { background: var(--bg); }
.drv-app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }
.drv-top { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.drv-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.drv-brand strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drv-brand small { display: block; font-size: 11px; opacity: .8; }
.drv-brand .logo { width: 36px; height: 36px; flex: none; }
.drv-menu-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid #ffffff40; background: #ffffff18; color: #fff; font-size: 20px; cursor: pointer; }
.drv-menu { right: 12px; top: calc(100% - 4px); }
.drv-menu button { min-height: 46px; }
.drv-net { background: #fef3c7; color: #92400e; font-size: 13px; padding: 8px 14px; text-align: center; }
.drv-main { flex: 1; padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.drv-title { font-size: 20px; margin: 8px 0 2px; }
.drv-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 14px; box-shadow: 0 2px 8px rgba(15, 35, 60, .05); }
.drv-card.center { text-align: center; }
.drv-card h2 { font-size: 18px; margin: 8px 0; }
.drv-list { display: grid; gap: 10px; }
.drv-company { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; min-height: 72px; border-radius: 16px; border: 1px solid var(--border); background: #fff; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.drv-company span { flex: 1; min-width: 0; }
.drv-company b { display: block; font-size: 16px; }
.drv-company small { color: var(--muted); font-size: 12px; }
.drv-company i { font-style: normal; font-size: 26px; color: var(--muted); }
.drv-vehicle { display: flex; align-items: center; gap: 12px; }
.drv-vehicle .thumb { position: relative; width: 72px; height: 54px; border-radius: 10px; background: var(--soft2); overflow: hidden; display: grid; place-items: center; color: var(--blue); flex: none; }
.drv-vehicle .thumb img { width: 100%; height: 100%; object-fit: cover; }
.drv-vehicle .thumb.icon-only .vicon { width: 70%; }
.drv-vehicle .thumb-ico .vicon { width: 18px; }
.drv-vehicle b { display: block; font-size: 15px; }
.drv-vehicle span { font-size: 13px; color: var(--muted); }
.drv-section-head { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.drv-section-head h2 { font-size: 15px; margin: 0; }
.drv-trip { display: flex; flex-direction: column; gap: 6px; }
.drv-trip b { font-size: 16px; }
.drv-route { display: grid; gap: 4px; font-size: 13px; }
.drv-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; align-items: stretch; }
.drv-actions .btn.small { align-self: center; }
.drv-big { min-height: 52px; font-size: 16px; border-radius: 14px; }
.drv-finish { background: var(--red); }
.drv-finish:hover { background: #b91c1c; }
.drv-empty { text-align: center; padding: 10px; font-size: 14px; }
.drv-active { display: flex; flex-direction: column; gap: 12px; border: 2px solid var(--blue2); }
.drv-status { display: flex; align-items: center; gap: 12px; }
.drv-status b { display: block; font-size: 17px; }
.drv-status small { color: var(--muted); }
.drv-status i { width: 18px; height: 18px; border-radius: 50%; flex: none; background: var(--gray); }
.drv-status.on i { background: var(--green); animation: drvPulse 1.6s infinite; }
.drv-status.search i { background: var(--orange); animation: drvPulse 1.6s infinite; }
.drv-status.error i { background: var(--red); }
@keyframes drvPulse { 0% { box-shadow: 0 0 0 0 #16a34a66; } 70% { box-shadow: 0 0 0 12px #16a34a00; } 100% { box-shadow: 0 0 0 0 #16a34a00; } }
.drv-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.drv-stats div { background: var(--bg); border-radius: 12px; padding: 10px; }
.drv-stats span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.drv-stats b { font-size: 16px; }
.drv-history { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; }
.drv-history summary { cursor: pointer; font-weight: 600; min-height: 28px; }
.drv-hist-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid #edf2f7; font-size: 13px; }
.center { text-align: center; }
body.drv .modal-backdrop { align-items: end; padding: 0; }
body.drv .modal { max-width: 560px; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
body.drv .modal footer .btn { flex: 1; min-height: 48px; }
body.drv input, body.drv select { min-height: 46px; font-size: 16px; }

/* ---------- Modal y toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: #0f172a80; display: grid; place-items: center; z-index: 2000; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal header h3 { margin: 0; font-size: 16px; }
.modal header button { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.checklist { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.checklist label { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid #edf2f7; cursor: pointer; }
.checklist label:last-child { border-bottom: 0; }
.checklist input { width: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 3000; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: var(--red); }

@media (max-width: 900px) {
  main.monitor { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); max-height: 420px; }
  .map-area { height: 70vh; }
  .stats, .legend { display: none; }
  .detail .kv { grid-template-columns: repeat(2, 1fr); }
  nav.main { margin-left: 0; }
  .brand small { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  header.top { padding: 0 10px; gap: 8px; }
  .brand > div:last-child, .usermenu .uname { display: none; }
  .company-chip { padding: 5px 9px; }
  .company-chip span { display: none; }
  .track-page .brand > div:last-child { display: block; }
  .dash-head { flex-direction: column; }
  .company-grid { grid-template-columns: 1fr; }
  nav.main a { padding: 7px 8px; font-size: 13px; }
  .map-overlay { max-width: calc(100% - 72px); }
  .ship-card .thumb { width: 80px; height: 80px; }
  .detail .head { flex-wrap: wrap; }
  .detail .row { flex-wrap: wrap; }
  main.page { padding: 12px; }
  .photo-box { flex-wrap: wrap; }
}
.swatch-inline { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; }
body.drv input[type=checkbox] { min-height: 0; width: 20px; height: 20px; }
body.drv .toast { bottom: auto; top: calc(76px + env(safe-area-inset-top)); width: max-content; max-width: calc(100% - 32px); text-align: center; }
.access-link { background: var(--soft); border: 1px dashed var(--blue2); border-radius: 12px; padding: 10px 12px; font-size: 12px; }
.access-link > span { display: block; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.access-link > div { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.access-link a { word-break: break-all; flex: 1; min-width: 0; }
.slug-input { display: flex; align-items: center; border: 1px solid #d6e0eb; border-radius: 10px; background: #fff; overflow: hidden; }
.slug-input small { padding: 0 0 0 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; direction: rtl; }
.slug-input input { border: 0; box-shadow: none; padding-left: 2px; min-width: 0; }
@media (max-width: 600px) { .auth-card .brand > div:last-child { display: block; } }
.auth-card .brand .logo:not(.logo-img) { background: var(--blue) !important; color: #fff !important; }

/* Sucursales */
.branch-map { height: 280px; border-radius: 12px; border: 1px solid var(--border); margin-top: 6px; }
.geo-results { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; max-height: 160px; overflow: auto; }
.geo-results button { text-align: left; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.geo-results button:hover { background: var(--soft); border-color: var(--blue2); }
.geo-results p { margin: 0; font-size: 12px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--blue2); cursor: pointer; text-decoration: underline; }
.origin-pick { display: flex; flex-direction: column; gap: 6px; }
.origin-pick label { display: flex; gap: 8px; align-items: center; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; font-size: 14px; }
.origin-pick label:has(input:checked) { border-color: var(--blue2); background: var(--soft); }
.origin-pick input { width: auto; margin: 0; }
