@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #0e1b3d;
  --ink-2: #33405f;
  --muted: #6b7489;
  --line: #e7e5de;
  --bg: #f6f5f1;
  --card: #ffffff;
  --brand: #ff5a1f;
  --brand-2: #ff7a45;
  --brand-soft: #fff0e8;
  --blue: #2557e8;
  --blue-soft: #e8eeff;
  --ok: #10a35a;
  --ok-soft: #e4f6ec;
  --warn: #c98200;
  --warn-soft: #fff5dc;
  --danger: #dc3545;
  --danger-soft: #fdebed;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(14, 27, 61, .06), 0 8px 24px rgba(14, 27, 61, .08);
  --shadow-lg: 0 12px 40px rgba(14, 27, 61, .18);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.ic { flex-shrink: 0; vertical-align: middle; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.strong { font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num { font-variant-numeric: tabular-nums; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 700; cursor: pointer; background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); transition: transform .08s, background .15s, box-shadow .15s; text-decoration: none; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(255, 90, 31, .28); }
.btn-primary:hover { background: #f04d12; }
.btn-dark { background: var(--ink); color: #fff; box-shadow: none; }
.btn-ok { background: var(--ok); color: #fff; box-shadow: none; }
.btn-danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-soft { background: var(--bg); box-shadow: none; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 18px; font-size: 16px; border-radius: 16px; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 12px; }

/* Chips de estado */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-muted { background: #eef0f4; color: var(--muted); }
.chip-info { background: var(--blue-soft); color: var(--blue); }
.chip-brand { background: var(--brand-soft); color: #d9420b; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }

/* Tarjetas y formularios */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; display: block; }
.field { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: 14px; padding: 0 12px; border: 1.5px solid transparent; transition: border-color .15s, background .15s; }
.field:focus-within { border-color: var(--ink); background: #fff; }
.field input, .field select { border: 0; background: transparent; outline: none; padding: 13px 0; width: 100%; min-width: 0; }
.field .ic { color: var(--muted); }
.seg { display: flex; background: var(--bg); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 10px 8px; border-radius: 10px; font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(14, 27, 61, .12); }
.pills { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.pills::-webkit-scrollbar { display: none; }
.pill { border: 0; background: var(--bg); padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--ink-2); }
.pill:hover { background: #ecebe5; }
.option { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--bg); border: 2px solid transparent; cursor: pointer; text-align: left; width: 100%; }
.option.on { border-color: var(--ink); background: #fff; }
.option .opt-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: #fff; }
.option.on .opt-ic { background: var(--ink); color: #fff; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }
.avatar { width: 44px; height: 44px; border-radius: 14px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; flex-shrink: 0; }
.avatar.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; }

/* Línea de tiempo */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 30px; font-size: 14px; }
.timeline li::before { content: ''; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--line); }
.timeline li.done .dot { background: var(--ok); border-color: var(--ok); }
.timeline li.done::before { background: var(--ok); }
.timeline li.now .dot { background: var(--brand); border-color: var(--brand); box-shadow: 0 0 0 5px var(--brand-soft); }
.timeline li.todo { color: var(--muted); }

/* Ruta origen → destino */
.route { display: grid; grid-template-columns: 18px 1fr; gap: 2px 10px; }
.route .r-dot { width: 12px; height: 12px; border-radius: 50%; margin: 4px 3px 0; }
.route .r-dot.a { background: var(--ink); }
.route .r-dot.b { background: var(--brand); border-radius: 3px; }
.route .r-line { width: 2px; background: repeating-linear-gradient(var(--line) 0 4px, transparent 4px 8px); margin: 0 auto; min-height: 14px; }
.route .r-name { font-weight: 700; font-size: 14px; }
.route .r-addr { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* Marcadores de mapa */
.lf-html-marker, .gm-html-marker, .svg-html-marker { position: absolute; width: 0; height: 0; background: none; border: 0; }
.lf-html-marker.smooth, .svg-html-marker.smooth { transition: transform 1s linear, left 1s linear, top 1s linear; }
.leaflet-zoom-anim .lf-html-marker.smooth { transition: none; }
.mk { position: absolute; left: 0; top: 0; cursor: pointer; }
.mk-driver .mk-dot, .mk-me .mk-dot { position: absolute; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--ok); border: 3px solid #fff; box-shadow: 0 4px 12px rgba(14, 27, 61, .3); }
.mk-busy .mk-dot { background: var(--brand); }
.mk-offline .mk-dot { background: #9aa1b1; }
.mk-me .mk-dot { width: 40px; height: 40px; background: var(--ink); }
.mk-pulse { position: absolute; width: 80px; height: 80px; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(37, 87, 232, .18); animation: pulse 2s infinite; }
@keyframes pulse { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; } }
.mk-label { position: absolute; transform: translate(-50%, 22px); background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.mk-pin .mk-head { position: absolute; transform: translate(-50%, -100%); width: 32px; height: 32px; border-radius: 50% 50% 50% 4px; rotate: -45deg; transform-origin: 0 0; display: grid; place-items: center; color: #fff; background: var(--ink); border: 3px solid #fff; box-shadow: 0 4px 12px rgba(14, 27, 61, .3); }
.mk-pin .mk-head { rotate: none; transform: translate(-50%, calc(-100% - 6px)); border-radius: 12px; }
.mk-pin .mk-head::after { content: ''; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #fff; }
.mk-dropoff .mk-head { background: var(--brand); }
.mk-pick .mk-head { background: var(--blue); }
.mk-pin .mk-label { transform: translate(-50%, 6px); }

.svgmap { position: relative; overflow: hidden; background: #f2f1ec; touch-action: none; cursor: grab; }
.svgmap-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.svgmap-layer { position: absolute; inset: 0; pointer-events: none; }
.svgmap-layer .svg-html-marker { pointer-events: auto; }
.svgmap-note { position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: #9a9483; background: rgba(255, 255, 255, .7); padding: 2px 6px; border-radius: 6px; }

/* Modales y toasts */
.modal-back { position: fixed; inset: 0; background: rgba(14, 27, 61, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 2000; animation: fade .2s; }
.modal { background: #fff; width: 100%; max-width: 460px; border-radius: 24px 24px 0 0; padding: 20px; max-height: 92vh; overflow: auto; animation: up .25s cubic-bezier(.2, .9, .3, 1.1); }
@media (min-width: 700px) { .modal-back.center { align-items: center; } .modal-back.center .modal { border-radius: 24px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); animation: up .25s; transition: opacity .4s, transform .4s; }
.toast-danger { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(-10px); }

/* Layout móvil (cliente y conductor) */
.phone { position: relative; height: 100dvh; max-width: 460px; margin: 0 auto; background: var(--bg); overflow: hidden; display: flex; flex-direction: column; }
@media (min-width: 700px) {
  body.mobile-app { display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #ffe3d6, transparent 40%), radial-gradient(circle at 80% 80%, #dfe6ff, transparent 40%), #eceae3; }
  body.mobile-app .phone { height: min(880px, 96vh); width: 420px; border-radius: 36px; box-shadow: 0 30px 80px rgba(14, 27, 61, .25), 0 0 0 10px #0e1b3d; }
  body.embedded.mobile-app { background: transparent; }
  body.embedded.mobile-app .phone { height: 100vh; width: 100%; max-width: none; border-radius: 0; box-shadow: none; }
}
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.scroll { flex: 1; overflow-y: auto; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 17px; margin: 0; }
.tabbar { display: flex; background: #fff; border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.tabbar button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px; font-size: 11px; font-weight: 700; color: var(--muted); cursor: pointer; border-radius: 12px; }
.tabbar button.on { color: var(--ink); }
.tabbar button.on .ic { color: var(--brand); }
.map-wrap { position: relative; flex: 1; min-height: 0; }
.map { position: absolute; inset: 0; }
.sheet { position: relative; background: #fff; border-radius: 26px 26px 0 0; box-shadow: 0 -8px 30px rgba(14, 27, 61, .12); margin-top: -26px; z-index: 500; padding: 8px 16px 16px; }
.sheet::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.floating { position: absolute; z-index: 600; }
.brand-mark { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: var(--brand); display: grid; place-items: center; }
.leaflet-container { font-family: inherit; background: #f2f1ec; }
.leaflet-control-attribution { font-size: 10px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .ic { color: #c3c7d1; margin-bottom: 8px; }
.section-title { font-size: 15px; font-weight: 800; margin: 4px 0 10px; }
.kv { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; }
.kv span:first-child { color: var(--muted); }
.big-number { font-size: 34px; font-weight: 800; letter-spacing: -.03em; }
.conn { position: fixed; bottom: 12px; right: 12px; background: var(--danger); color: #fff; padding: 6px 10px; border-radius: 10px; font-size: 12px; font-weight: 700; z-index: 3000; }
