/* Tracking portal */
#portal { background: var(--bg-soft); min-height: 70vh; }
.muted { color: var(--muted); }
.login-wrap { min-height: 72vh; display: grid; place-items: center; padding: 56px 16px;
  background: linear-gradient(160deg, var(--navy) 0 45%, var(--bg-soft) 45%); }
.login-card { width: min(440px, 100%); background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 40px; }
@media (max-width: 480px) { .login-card { padding: 26px; } }

.app-bar { background: #fff; border-bottom: 1px solid var(--line); }
.app-bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; flex-wrap: wrap; }
.app-actions { display: flex; gap: 8px; }
.tabs { display: flex; gap: 4px; background: var(--bg-soft); padding: 4px; border-radius: 999px; }
.tabs button, .seg button { border: 0; background: transparent; padding: .45rem 1rem; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button.on, .seg button.on { background: var(--navy); color: #fff; }
.tab-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.tab-head h2 { margin: 0; font-size: 2rem; }

.loads-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .loads-layout { grid-template-columns: 1fr; } }
.load-list { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; position: sticky; top: 88px; max-height: calc(100vh - 110px); overflow: auto; }
@media (max-width: 900px) { .load-list { position: static; max-height: 420px; } }
.list-head { display: flex; gap: 8px; margin-bottom: 10px; }
.list-head input { padding: .55rem .8rem; }
.seg { display: flex; gap: 4px; background: var(--bg-soft); border-radius: 999px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; padding: .35rem .5rem; font-size: .85rem; }
.load-item { display: block; width: 100%; text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; font: inherit; color: inherit; transition: border-color .15s, background .15s; }
.load-item:hover { border-color: #cbd5e1; }
.load-item.on { border-color: var(--accent); background: #eef4ff; }
.load-item .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.load-item b { font-size: 1rem; }
.load-item .lane { font-size: .88rem; color: var(--ink); margin-top: 4px; }
.load-item .sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; background: #e2e8f0; color: #334155; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.s-booked, .pill.s-dispatched { background: #e0e7ff; color: #3730a3; }
.pill.s-at-pickup, .pill.s-at-delivery { background: #dbeafe; color: #1d4ed8; }
.pill.s-in-transit { background: #dcfce7; color: #15803d; }
.pill.s-delivered { background: #f1f5f9; color: #475569; }
.pill.s-cancelled { background: #fee2e2; color: #b91c1c; }
.pill.stopped { background: #fef3c7; color: #b45309; }

.load-detail { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; min-height: 520px; }
.load-detail .empty { text-align: center; color: var(--muted); padding: 120px 20px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head h2 { margin: 0; font-size: 2.1rem; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: 1fr 1fr; } }
.kpi { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi span { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.kpi b { display: block; font-family: var(--display); font-size: 1.55rem; line-height: 1.15; color: var(--navy); }
.kpi small { color: var(--muted); font-size: .8rem; }
.kpi.warn { background: #fffbeb; border-color: #fde68a; }
#map { height: 420px; border-radius: 12px; border: 1px solid var(--line); z-index: 0; }
@media (max-width: 640px) { #map { height: 320px; } }
.stops { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
@media (max-width: 640px) { .stops { grid-template-columns: 1fr; } }
.stop { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; border-left: 5px solid var(--green); }
.stop.del { border-left-color: var(--red); }
.stop h4 { margin: 0 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.stop b { display: block; }
.stop p { margin: 2px 0 0; font-size: .9rem; color: var(--muted); }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; margin-top: 16px; padding: 14px 16px; background: var(--bg-soft); border-radius: 12px; font-size: .9rem; }
.meta span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.eta-note { font-size: .82rem; color: var(--muted); margin-top: 10px; }

.eld { margin-top: 18px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.eld-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--navy); color: #fff; flex-wrap: wrap; }
.eld-head .live { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .85rem; }
.eld-head .live::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.3); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } }
.eld-head a { color: var(--navy); }
.eld iframe { width: 100%; height: 420px; border: 0; display: block; background: var(--bg-soft); }
.eld-foot { font-size: .8rem; color: var(--muted); padding: 8px 14px; background: var(--bg-soft); }

.timeline { list-style: none; padding: 0; margin: 10px 0 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline small { color: var(--muted); }

table.data { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.data th, .data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
.data th { background: var(--bg-soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.data td:last-child { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.modal { position: fixed; inset: 0; background: rgba(17, 24, 54, .55); z-index: 2000; display: grid; place-items: start center; overflow-y: auto; padding: 40px 16px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 18px; width: min(760px, 100%); box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-x { border: 0; background: none; font-size: 1.8rem; cursor: pointer; color: var(--muted); line-height: 1; }
#modal-body { padding: 22px; }
#modal-body .form { gap: 14px; }
#modal-body h4 { margin: 8px 0 -4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent-2); }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.leaflet-div-icon.px-pin { background: none; border: 0; }
.px-pin div { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,.3); display: grid; place-items: center; }
.px-pin span { transform: rotate(45deg); color: #fff; font-weight: 800; font-size: 13px; }
.px-truck div { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(5,64,160,.3), 0 4px 10px rgba(0,0,0,.3); display: grid; place-items: center; font-size: 18px; }
