:root {
  --bg: #14181d; --panel: #1c2229; --panel-2: #232b34; --line: #2e3844;
  --amber: #ffc233; --amber-dim: #b78a1f; --green: #35d07f; --red: #ff5a5a;
  --text: #e8edf2; --muted: #8a97a5;
  --mono: 'JetBrains Mono', monospace; --disp: 'Archivo', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); overflow: hidden; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
.mono { font-family: var(--mono); }

.btn { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--muted); }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #17130a; }
.btn-amber:hover { background: #ffd056; border-color: #ffd056; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-tg { background: #2aabee; border-color: #2aabee; color: #fff; }
.btn-tg:hover { background: #4dbdf5; border-color: #4dbdf5; }
.tg-chat-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; max-height: 160px; overflow-y: auto; }
.tg-chat-opt { text-align: left; display: flex; justify-content: space-between; align-items: center; }

.input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }
.input:focus { outline: none; border-color: var(--amber); }
.badge { font-family: var(--mono); font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); padding: 2px 8px; border-radius: 20px; color: var(--muted); }

.login-screen { height: 100%; display: flex; align-items: center; justify-content: center; background: repeating-linear-gradient(90deg, transparent 0 46px, rgba(255,194,51,.05) 46px 60px), var(--bg); }
.login-card { width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 36px 30px; }
.login-logo { display: flex; align-items: center; gap: 12px; }
.login-logo h1 { font-family: var(--disp); font-weight: 800; font-size: 26px; letter-spacing: -.5px; }
.login-logo span, .topbar-brand span { color: var(--amber); }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 24px; }
.login-card input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 12px 14px; font-size: 15px; margin-bottom: 12px; }
.login-card input:focus { outline: none; border-color: var(--amber); }
.login-card .btn { width: 100%; padding: 12px; font-size: 15px; }
.login-error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }

.blocked-screen { height: 100%; display: flex; align-items: center; justify-content: center; }
.blocked-card { width: 400px; text-align: center; background: var(--panel); border: 1px solid var(--red); border-radius: 14px; padding: 40px 30px; }
.blocked-icon { font-size: 44px; color: var(--red); }
.blocked-card h2 { font-family: var(--disp); margin: 14px 0 10px; }
.blocked-card p { color: var(--text); font-size: 15px; }
#blockedReason { font-weight: 600; color: var(--amber); margin-bottom: 8px; }
.blocked-hint { color: var(--muted) !important; font-size: 13px !important; margin-bottom: 22px; }

.app { height: 100%; display: flex; flex-direction: column; }
.topbar { height: 52px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; flex-shrink: 0; }
.topbar-brand { display: flex; align-items: center; gap: 10px; font-family: var(--disp); font-size: 18px; font-weight: 800; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.whoami { color: var(--muted); font-size: 13px; }
.layout { flex: 1; display: flex; min-height: 0; }

.sidebar { width: 280px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sidebar-title { font-family: var(--disp); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.truck-list { flex: 1; overflow-y: auto; padding: 8px; }
.truck-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 8px; cursor: pointer; transition: border-color .15s, background .15s; }
.truck-item:hover { border-color: var(--muted); }
.truck-item.selected { border-color: var(--amber); background: var(--panel-2); }
.truck-item-top { display: flex; align-items: center; justify-content: space-between; }
.truck-name { font-weight: 600; font-size: 14px; }
.truck-plate { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 2px; }
.truck-status { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.truck-status.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.truck-meta { display: flex; gap: 12px; margin-top: 8px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.truck-meta b { color: var(--text); }
.truck-actions { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.truck-actions .btn { flex: 1; padding: 6px; font-size: 12px; min-width: 60px; }
.truck-owner { font-size: 11px; color: var(--amber-dim); margin-top: 2px; }
.empty-note { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 10px; }

.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #0d1013; }
.leaflet-container { font-family: 'Inter', sans-serif; }
.truck-marker { transition: transform .8s linear; }
.truck-marker svg { filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
.marker-label { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 600; white-space: nowrap; }

.playback { position: absolute; left: 16px; right: 16px; bottom: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px 16px; z-index: 900; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.playback-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.playback-info b { font-family: var(--disp); font-size: 15px; }
.playback-info .mono { color: var(--muted); font-size: 12px; margin-left: 10px; }
.playback-stats { display: flex; gap: 16px; align-items: center; font-size: 13px; color: var(--amber); }
.pb-close { background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 0 4px; }
.pb-close:hover { color: var(--red); }

.road-track { position: relative; height: 38px; background: #10141a; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; overflow: hidden; }
.road-line { position: absolute; left: 0; right: 0; top: 50%; height: 3px; transform: translateY(-50%); background: repeating-linear-gradient(90deg, var(--amber-dim) 0 18px, transparent 18px 32px); opacity: .45; }
.road-progress { position: absolute; left: 0; top: 50%; height: 3px; transform: translateY(-50%); width: 0%; background: repeating-linear-gradient(90deg, var(--amber) 0 18px, transparent 18px 32px); }
.road-truck { position: absolute; top: 50%; left: 0%; transform: translate(-50%, -58%); pointer-events: none; }

.playback-controls { display: flex; align-items: center; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.btn-play { width: 44px; height: 40px; font-size: 16px; padding: 0; border-radius: 10px; }
.pb-time { display: flex; align-items: baseline; gap: 14px; font-size: 15px; }
.pb-speed-now { color: var(--green); font-weight: 700; font-size: 18px; }
.pb-speed-now small { font-size: 11px; color: var(--muted); font-weight: 500; }
.pb-speeds { margin-left: auto; display: flex; gap: 6px; }
.speed-btn { font-family: var(--mono); background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); padding: 6px 11px; border-radius: 7px; font-size: 13px; font-weight: 700; }
.speed-btn.active { background: var(--amber); border-color: var(--amber); color: #17130a; }

.modal { position: fixed; inset: 0; background: rgba(10,13,16,.7); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.modal-card { width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; max-height: 90vh; overflow-y: auto; }
.modal-card h3 { font-family: var(--disp); margin-bottom: 16px; }
.modal-sub { color: var(--muted); font-size: 13px; margin: -8px 0 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.admin-panel { position: fixed; inset: 52px 0 0 0; background: var(--bg); z-index: 1500; overflow-y: auto; }
.admin-inner { max-width: 1050px; margin: 0 auto; padding: 26px 20px 60px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.admin-head h2 { font-family: var(--disp); font-weight: 800; }
.admin-section { margin-bottom: 36px; }
.admin-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.admin-section-head h3 { font-family: var(--disp); font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.table-wrap { border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); }
th { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: none; }
td .btn { margin-right: 6px; margin-bottom: 4px; }
.status-chip { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.status-active { background: rgba(53,208,127,.12); color: var(--green); }
.status-blocked { background: rgba(255,90,90,.12); color: var(--red); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 80px); background: var(--panel-2); border: 1px solid var(--amber); color: var(--text); padding: 12px 22px; border-radius: 10px; font-size: 14px; z-index: 3000; opacity: 0; transition: transform .25s, opacity .25s; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.mobile-trucks-btn { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 760px) {
  .sidebar { position: fixed; top: 52px; bottom: 0; left: 0; width: min(85vw, 320px); z-index: 1200; transform: translateX(-105%); transition: transform .25s ease; box-shadow: 8px 0 30px rgba(0,0,0,.5); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 52px 0 0 0; background: rgba(10,13,16,.55); z-index: 1100; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  .mobile-trucks-btn { display: flex; align-items: center; gap: 8px; position: absolute; top: 12px; left: 12px; z-index: 1000; background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
  .mobile-trucks-btn svg { color: var(--amber); }
  .mbadge { font-family: var(--mono); background: var(--amber); color: #17130a; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 12px; }
  .truck-actions .btn { padding: 10px; font-size: 13px; }
  .truck-item { padding: 14px; }
  .playback { left: 8px; right: 8px; bottom: 8px; padding: 10px 12px 12px; }
  .playback-info .mono { display: block; margin-left: 0; }
  .playback-controls { flex-wrap: wrap; gap: 10px; }
  .pb-speeds { margin-left: 0; width: 100%; justify-content: space-between; }
  .speed-btn { flex: 1; padding: 9px 4px; }
  .btn-play { width: 52px; height: 44px; }
  .whoami { display: none; }
  .modal-card { width: calc(100vw - 32px); max-width: 400px; }
  .admin-inner { padding: 16px 10px 60px; }
  th, td { padding: 9px 10px; font-size: 13px; }
}
@media (max-width: 760px) and (display-mode: standalone) {
  .playback { bottom: calc(8px + env(safe-area-inset-bottom)); }
}
