body { overflow: hidden; }
.login-screen { height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1c2333, #2f6bff); }
.login-card { width: 320px; text-align: center; padding: 28px; }
.logo-big { font-size: 48px; }

.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
}
.brand { font-size: 17px; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* La barra nunca empuja "Salir" fuera de la pantalla: lo que se achica es el nombre del local */
.topbar > * { flex-shrink: 0; }
.topbar > .brand { flex-shrink: 1; }
.stats { display: flex; gap: 8px; overflow: hidden; }
.stat { background: var(--bg); border-radius: 8px; padding: 5px 11px; white-space: nowrap; }
.stat b { font-size: 15px; display: block; }
.stat span { font-size: 11px; color: var(--muted); }

.switch { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; color: var(--text); font-size: 13px; }
.switch input { display: none; }
.switch span { width: 38px; height: 22px; background: #ccd2de; border-radius: 99px; position: relative; transition: .2s; }
.switch span::after { content: ''; position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 50%; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { left: 19px; }

.layout { display: flex; height: calc(100vh - 58px); }
.sidenav { width: 84px; background: #1c2333; display: flex; flex-direction: column; padding: 8px 6px; gap: 4px; }
.nav {
  background: none; border: none; color: #aab3c7; padding: 10px 4px; border-radius: 8px; cursor: pointer;
  font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.nav span { font-size: 20px; }
.nav:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav.active { background: var(--primary); color: #fff; }

.view { flex: 1; min-width: 0; overflow: auto; }
#view-dispatch { display: flex; overflow: hidden; }
#view-dispatch.hidden { display: none; }

.orders-col { width: 360px; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tabs button {
  flex: 1; background: none; border: none; padding: 12px 2px; font-weight: 600; font-size: 12px; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs i { font-style: normal; background: var(--bg); border-radius: 99px; padding: 1px 6px; margin-left: 2px; font-size: 11px; }
.tabs button.active i { background: var(--primary); color: #fff; }
.order-list { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }

.ocard { border: 1px solid var(--border); border-radius: 10px; padding: 11px; cursor: pointer; background: #fff; transition: border .15s, box-shadow .15s; }
.ocard:hover { border-color: #b9c6e6; }
.ocard.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 107, 255, .15); }
.ocard.flash { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { background: #fff4dc; } }
.ocard .top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.ocard .code { font-weight: 800; }
.ocard .addr { color: var(--muted); font-size: 12px; margin: 3px 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ocard .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

.map-col { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }
.map-legend { position: absolute; bottom: 14px; left: 14px; z-index: 500; padding: 8px 12px; font-size: 12px; display: flex; gap: 12px; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: middle; }

.drivers-col { width: 250px; background: #fff; border-left: 1px solid var(--border); padding: 14px; overflow: auto; }
.dcard { display: flex; gap: 10px; align-items: center; padding: 9px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.dcard:hover { background: var(--bg); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #e5edff; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }

.page { padding: 22px; }
.table-wrap { padding: 0; overflow: auto; margin-top: 12px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-size: 11px; text-transform: uppercase; color: var(--muted); background: #fafbfd; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #f7f9fd; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 14px; }
.pcard { display: flex; flex-direction: column; gap: 6px; }
.pcard .img { font-size: 42px; height: 70px; display: flex; align-items: center; justify-content: center; background: var(--bg); border-radius: 8px; overflow: hidden; }
.pcard .img img { width: 100%; height: 100%; object-fit: cover; }
.pcard.off { opacity: .55; }

.items { width: 100%; border-collapse: collapse; margin: 8px 0; }
.items td { padding: 5px 0; border-bottom: 1px dashed var(--border); }
.items td:last-child { text-align: right; }
.timeline { list-style: none; padding: 0; margin: 8px 0; font-size: 12px; }
.timeline li { padding: 3px 0; }
#pickMap { height: 240px; border-radius: 10px; margin-top: 6px; }
.manual-items { max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.manual-items .row { padding: 4px 0; }
.manual-items input { width: 64px; }
.geo-results { border: 1px solid var(--border); border-radius: 8px; margin-top: 4px; max-height: 140px; overflow: auto; }
.geo-results div { padding: 7px 10px; cursor: pointer; font-size: 12px; }
.geo-results div:hover { background: var(--bg); }

@media (max-width: 1100px) { .drivers-col { display: none; } .stats { display: none; } }
@media (max-width: 760px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar #liveDot, .topbar .user-chip, .topbar .lbl-wide { display: none; }
  .orders-col { width: 100%; } .map-col { display: none; }
  .sidenav { width: 64px; } .nav { font-size: 0; }
}

/* ----- Rastreo GPS ----- */
.history-layout { display: flex; height: 100%; }
.history-form { width: 320px; margin: 14px; align-self: flex-start; max-height: calc(100% - 28px); overflow: auto; }
.history-map-wrap { flex: 1; position: relative; }
#historyMap { position: absolute; inset: 0; }
.history-stats { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.history-stats .stat b { font-size: 16px; }
.traccar-status { padding: 10px 12px; border-radius: 9px; margin-bottom: 6px; font-size: 13px; background: var(--bg); }
.traccar-status.ok { background: #dcf5e9; color: #0f7d4d; }
.traccar-status.warn { background: #fff4dc; color: #8a5a00; }
.traccar-status.err { background: #fde4e5; color: #9b1c21; }
.gps-tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: #e5edff; color: #2f6bff; margin-left: 4px; }
.gps-tag.app { background: #eef0f4; color: var(--muted); }
.table select { width: auto; min-width: 180px; padding: 6px 8px; }
@media (max-width: 760px) { .history-layout { flex-direction: column; } .history-form { width: auto; } .history-map-wrap { min-height: 360px; } }
.ocard.urgent { border-left: 4px solid var(--danger); }
.user-chip .avatar-sm { background: var(--primary); color: #fff; }

/* Mensajes con el Centro de control */
.nav { position: relative; }
.nav-badge {
  position: absolute; top: 6px; right: 10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-style: normal; font-weight: 800; line-height: 18px; text-align: center;
}
.msg-page { max-width: 820px; height: 100%; display: flex; flex-direction: column; box-sizing: border-box; }
.msg-card { flex: 1; min-height: 360px; padding: 0; overflow: hidden; display: flex; flex-direction: column; }

/* Foto del frente del local (Mi local) y foto de cada producto */
.facade-img { display: block; width: 100%; max-width: 420px; max-height: 280px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.facade-card .btn input[type="file"] { display: none; }
.pphoto { display: flex; gap: 12px; align-items: center; }
.pphoto-prev { width: 84px; height: 84px; flex-shrink: 0; border-radius: 10px; background: var(--bg); font-size: 40px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pphoto-prev img { width: 100%; height: 100%; object-fit: cover; }
.pphoto-acts { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pcard .img { height: 120px; }
