:root {
  --bg: #f3f6fc;
  --panel: #ffffff;
  --panel-alt: #eef2f9;
  --panel-raised: #e4ebf7;
  --border: #dde6f2;
  --border-soft: #e9eff8;
  --text: #17233b;
  --text-muted: #5b6b87;
  --text-dim: #94a2ba;
  --accent: #12b886;
  --accent-dim: #0d8c66;
  --accent-soft: #e4f9f2;
  --accent-blue: #2f6fed;
  --accent-blue-soft: #eaf1ff;
  --accent-amber: #e08a1f;
  --accent-amber-soft: #fdf1e0;
  --accent-red: #e0483f;
  --accent-red-soft: #fbe9e8;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-blue-soft); color: var(--accent-blue); }

a { color: var(--accent-blue); }

.hidden { display: none !important; }

/* ---------- background texture ---------- */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 15% 10%, rgba(47,111,237,0.07), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(18,184,134,0.07), transparent 45%);
  z-index: 0;
}

/* =========================================================
   LOGIN
   ========================================================= */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 28px;
  box-shadow: 0 24px 50px -20px rgba(30,50,90,0.18);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-blue-soft);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-blue);
  box-shadow: 0 0 0 4px rgba(47,111,237,0.16);
  animation: pulse-soft 2.4s ease-in-out infinite;
}

.login-brand h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--text);
}

.login-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; }

.field-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

input[type="text"], input[type="password"], input[type="search"] {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
  width: 100%;
}

input:focus { border-color: var(--accent-blue); background: var(--panel); }

.btn-primary {
  margin-top: 6px;
  background: var(--accent-blue);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-weight: 600;
  font-size: 14px;
  font-family: var(--font-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.7; cursor: default; }

.btn-spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #ffffff;
  animation: spin 0.7s linear infinite;
}

.alert {
  font-size: 12.5px;
  padding: 9px 11px;
  border-radius: 7px;
  line-height: 1.4;
}
.alert-error { background: var(--accent-red-soft); border: 1px solid rgba(224,72,63,0.3); color: #b03a33; }
.alert-notice { background: var(--accent-amber-soft); border: 1px solid rgba(224,138,31,0.3); color: #8a5a15; }

.login-foot {
  margin: 22px 0 0;
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
}
.login-foot code {
  font-family: var(--font-mono);
  background: var(--panel-alt);
  padding: 1px 5px;
  border-radius: 4px;
}

/* =========================================================
   DASHBOARD SHELL
   ========================================================= */
.app {
  display: grid;
  grid-template-rows: 58px 1fr;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  z-index: 5;
}

.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
.topbar-brand .brand-dot { width: 8px; height: 8px; }
.topbar-brand h1 {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.topbar-spacer { flex: 1; }

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  padding: 6px 11px;
  border-radius: 100px;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); }
.status-pill.live { color: var(--accent-dim); background: var(--accent-soft); border-color: rgba(18,184,134,0.25); }
.status-pill.live .dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(18,184,134,0.2); animation: pulse-soft 2s ease-in-out infinite; }
.status-pill.down { color: #b03a33; background: var(--accent-red-soft); border-color: rgba(224,72,63,0.25); }
.status-pill.down .dot { background: var(--accent-red); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}
.topbar-user .who { color: var(--text-muted); }
.topbar-user .who b { color: var(--text); font-weight: 600; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s ease;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); background: var(--panel-alt); }

/* ---------- layout body ---------- */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 0;
}

/* ---------- sidebar ---------- */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-search {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border-soft);
}

.sidebar-meta {
  padding: 0 14px 12px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.account-list {
  overflow-y: auto;
  flex: 1;
  padding: 6px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 3px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.account-card:hover { background: var(--panel-alt); }
.account-card.selected { background: var(--accent-blue-soft); border-color: var(--accent-blue); }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--panel-raised);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  flex-shrink: 0;
  position: relative;
}
.avatar .presence {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--panel);
}
.presence.online { background: var(--accent); }
.presence.stale { background: var(--accent-amber); }
.presence.offline { background: var(--text-dim); }

.account-info { flex: 1; min-width: 0; }
.account-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.account-sub {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-top: 2px;
  display: flex; gap: 8px;
}

.account-dist {
  text-align: right;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.account-dist .km { font-size: 13.5px; font-weight: 600; color: var(--accent-dim); }
.account-dist .eta { display: block; font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------- map area ---------- */
.map-wrap {
  position: relative;
  min-height: 0;
}

#map {
  height: 100%;
  width: 100%;
  background: #eaf0fa;
}

/* corner bracket frame - signature ops/targeting motif */
.map-frame { position: absolute; inset: 14px; pointer-events: none; z-index: 400; }
.map-frame .corner {
  position: absolute;
  width: 22px; height: 22px;
  border-color: rgba(47,111,237,0.55);
  border-style: solid;
  border-width: 0;
}
.map-frame .c-tl { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; border-radius: 4px 0 0 0; }
.map-frame .c-tr { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; border-radius: 0 4px 0 0; }
.map-frame .c-bl { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; border-radius: 0 0 0 4px; }
.map-frame .c-br { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; border-radius: 0 0 4px 0; }

/* readout panel */
.readout {
  position: absolute;
  left: 32px; bottom: 32px;
  z-index: 500;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  min-width: 240px;
  box-shadow: 0 20px 40px -18px rgba(30,50,90,0.28);
}
.readout-title {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.readout-close { cursor: pointer; color: var(--text-dim); font-size: 14px; }
.readout-close:hover { color: var(--text); }
.readout-name { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.readout-stat .label { font-size: 10.5px; color: var(--text-dim); }
.readout-stat .value { font-family: var(--font-mono); font-size: 19px; font-weight: 600; color: var(--accent-dim); margin-top: 3px; }
.readout-stat .value.blue { color: var(--accent-blue); }
.readout-updated { margin-top: 12px; font-size: 10.5px; color: var(--text-dim); font-family: var(--font-mono); }

/* geolocation banner */
.geo-banner {
  position: absolute;
  top: 32px; left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: var(--accent-amber-soft);
  border: 1px solid rgba(224,138,31,0.35);
  color: #8a5a15;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 12px 24px -12px rgba(30,50,90,0.25);
}
.geo-banner button {
  background: var(--accent-amber);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

/* leaflet layer switcher (Jalan / Satelit) */
.leaflet-control-layers {
  border: none !important;
  border-radius: 10px !important;
  box-shadow: 0 10px 24px -8px rgba(20,40,80,0.2) !important;
  font-family: var(--font-body);
  background: #ffffff !important;
}
.leaflet-control-layers-toggle { border-radius: 10px !important; }
.leaflet-control-layers label { font-size: 12.5px; color: var(--text); padding: 2px 0; }
.leaflet-control-layers-selector { margin-right: 7px; }
.leaflet-touch .leaflet-control-layers { border-radius: 10px; }
.leaflet-bar a {
  background: #ffffff;
  color: var(--text);
  border-color: rgba(20,40,80,0.12) !important;
}
.leaflet-bar a:hover { background: var(--panel-alt); }

/* leaflet marker custom */
.me-marker {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-blue);
  border: 3px solid #ffffff;
  box-shadow: 0 1px 4px rgba(20,40,80,0.35), 0 0 0 6px rgba(47,111,237,0.22);
}
.acct-marker {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.acct-marker .ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: radar-ping 2.2s ease-out infinite;
}
.acct-marker.stale .ring { border-color: var(--accent-amber); }
.acct-marker.offline .ring { display: none; }
.acct-marker .core {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid #ffffff;
  box-shadow: 0 1px 4px rgba(20,40,80,0.35);
  z-index: 1;
}
.acct-marker.stale .core { background: var(--accent-amber); }
.acct-marker.offline .core { background: var(--text-dim); }

@keyframes radar-ping {
  0% { transform: scale(0.5); opacity: 0.65; }
  100% { transform: scale(1.9); opacity: 0; }
}
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* scrollbar */
.account-list::-webkit-scrollbar { width: 8px; }
.account-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
  .readout { left: 14px; right: 14px; bottom: 14px; min-width: 0; }
}
