:root {
  --navy: #0e2a3b; --navy-2: #173b52; --accent: #ff6a2b; --accent-d: #e5561a;
  --bg: #f3f5f7; --card: #fff; --line: #e2e7ec; --text: #1c2b36; --muted: #6a7b88;
  --ok: #16a34a; --warn: #d97706; --err: #dc2626; --info: #2563eb;
  --radius: 12px; --shadow: 0 1px 3px rgba(16,40,60,.08), 0 4px 14px rgba(16,40,60,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: var(--info); }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .grow { flex: 1; } .gap { gap: 16px; }
.hidden { display: none !important; }

/* botones y formularios */
button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 9px; transition: .12s; }
button:hover { background: #f0f3f6; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-d); }
button.danger { color: var(--err); border-color: #f2c4c4; } button.danger:hover { background: #fdeeee; }
button.ghost { background: transparent; border-color: transparent; color: var(--info); padding: 4px 8px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm { padding: 4px 9px; font-size: 12px; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid #cfd8df; border-radius: 9px; background: #fff; color: var(--text); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(255,106,43,.35); border-color: var(--accent); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.field { margin-bottom: 12px; } .field input, .field select, .field textarea { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* tarjetas, tablas */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi b { display: block; font-size: 28px; line-height: 1.1; } .kpi span { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f7f9fb; }
.tablewrap { overflow-x: auto; }

/* insignias */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; background: #e8edf1; color: #46586a; }
.badge.blue { background: #dbeafe; color: #1e40af; } .badge.indigo { background: #e0e7ff; color: #3730a3; }
.badge.orange { background: #ffe6d6; color: #b4400c; } .badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; } .badge.amber { background: #fef3c7; color: #92400e; }
.badge.teal { background: #ccfbf1; color: #115e59; } .badge.purple { background: #f3e8ff; color: #6b21a8; }
.progress { height: 8px; border-radius: 6px; background: #e8edf1; overflow: hidden; display: flex; min-width: 90px; }
.progress i { display: block; height: 100%; } .progress .d { background: var(--ok); } .progress .f { background: var(--err); }

/* layout del panel */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 800; font-size: 17px; letter-spacing: -.01em; } .brand span { color: var(--accent); }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
.tabs a { color: #b9cad6; text-decoration: none; padding: 17px 13px; font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: #fff; } .tabs a.on { color: #fff; border-bottom-color: var(--accent); }
.topbar .user { font-size: 12px; color: #b9cad6; white-space: nowrap; } .topbar button { background: transparent; color: #fff; border-color: #3b5a70; }
main { max-width: 1280px; margin: 0 auto; padding: 20px; }
.map { height: 420px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 1; }
.map.sm { height: 260px; }
.split { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
@media (max-width: 960px) { .split { grid-template-columns: 1fr; } main { padding: 12px; } }

/* modal y avisos */
.overlay { position: fixed; inset: 0; background: rgba(10,25,36,.55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: min(760px, 100%); padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(1000px, 100%); } .modal.narrow { width: min(460px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; } .modal-head h2 { margin: 0; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 200; box-shadow: var(--shadow); max-width: 92vw; }
.toast.err { background: var(--err); } .toast.ok { background: var(--ok); }
.timeline { list-style: none; margin: 0; padding: 0; } .timeline li { padding: 6px 0 6px 18px; border-left: 2px solid var(--line); position: relative; margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

/* escaneo en bodega */
.scanbox { display: flex; gap: 10px; } .scanbox input { flex: 1; font-size: 22px; padding: 14px 16px; border-width: 2px; }
.scanlog { margin-top: 14px; } .scanitem { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; border-left: 5px solid; background: #fff; box-shadow: var(--shadow); }
.scanitem.ok { border-color: var(--ok); } .scanitem.dup { border-color: var(--warn); } .scanitem.err { border-color: var(--err); background: #fff5f5; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; border-radius: 0; padding: 9px 16px; } .seg button.on { background: var(--navy); color: #fff; }
.pin { background: var(--accent); color: #fff; font-weight: 700; font-size: 11px; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin.depot { background: var(--navy); border-radius: 6px; } .pin.drv { background: var(--info); }
pre.code { background: #0e2a3b; color: #d6e6f0; padding: 14px; border-radius: 10px; overflow-x: auto; font-size: 12px; }
.apikey { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: #f0f3f6; padding: 3px 7px; border-radius: 6px; }

/* login */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--navy), var(--navy-2)); padding: 20px; }
.login .box { background: #fff; border-radius: 16px; padding: 30px; width: min(380px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login h1 { font-size: 26px; } .login h1 span { color: var(--accent); }
.err-msg { color: var(--err); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

.traffic-toggle{background:#fff;padding:6px 10px;font:600 12px system-ui,sans-serif;cursor:pointer;display:flex;gap:6px;align-items:center;box-shadow:0 1px 4px rgba(0,0,0,.3)}

.timeline.custody li { padding-bottom: 12px; } .evn { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 11px; font-weight: 700; margin-right: 6px; }
.evth { margin-top: 6px; width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.custsum { background: #f3f7fb; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 6px 0; font-size: 13px; }
