/* VMS Indonesia Dashboard - Dark Theme */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0a0a1a;
  color: #e0e0e0;
  min-height: 100vh;
}

/* Header */
.hd {
  background: linear-gradient(135deg, #0f0f2e, #1a1a3e);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.hd-left { display: flex; align-items: center; gap: 14px; }
.hd-left img { height: 32px; }
.hd h1 { font-size: 20px; font-weight: 700; }
.hd .sub { font-size: 12px; opacity: 0.6; margin-top: 2px; }
.hd-right { display: flex; gap: 8px; align-items: center; }
.hd-right a,
.hd-right button {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
  transition: background 0.15s;
}
.hd-right a:hover,
.hd-right button:hover { background: rgba(255,255,255,0.2); }

/* KPI Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  padding: 20px 28px 10px;
}
.cd {
  background: #12122a;
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
}
.cd:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transform: translateY(-1px);
  border-color: rgba(59,130,246,0.3);
}
.cd.on { border-color: #3b82f6; background: #151535; }
.cd .v { font-size: 24px; font-weight: 800; color: #fff; }
.cd .l {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.cd.warn { border-color: #f59e0b; }
.cd.warn .v { color: #f59e0b; }

/* Beacon type breakdown */
.bt-bar {
  padding: 2px 28px 10px;
  font-size: 12px;
  color: #666;
}

/* Stats panel (toggled) */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 16px 28px;
}
.stats-box {
  background: #12122a;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.stats-box h3 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #fff;
}
.stats-box table { width: 100%; font-size: 12px; border-collapse: collapse; }
.stats-box td { padding: 4px 8px; border-bottom: 1px solid #1a1a3e; color: #ccc; }

/* Filters */
.fl {
  padding: 8px 28px 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.fl input, .fl select {
  padding: 7px 12px;
  border: 1px solid #2a2a4a;
  border-radius: 7px;
  font-size: 13px;
  background: #12122a;
  color: #e0e0e0;
  outline: none;
  transition: border-color 0.15s;
}
.fl input:focus, .fl select:focus { border-color: #3b82f6; }
.fl input::placeholder { color: #666; }
.fl select option { background: #12122a; color: #e0e0e0; }

/* Buttons */
.btn {
  border: none;
  color: #fff;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.b1 { background: #3b82f6; }
.b2 { background: #dc2626; }
.b3 { background: #16a34a; }
.b4 { background: #7c3aed; }

/* Count bar & pagination */
.cb { padding: 0 28px 6px; font-size: 12px; color: #666; }
.pg {
  padding: 4px 28px 12px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.pg button {
  border: 1px solid #2a2a4a;
  background: #12122a;
  color: #ccc;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.pg button:hover { border-color: #3b82f6; color: #fff; }
.pg button.act {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

/* Table */
.tw {
  padding: 0 28px 28px;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: #12122a;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  font-size: 12px;
}
th {
  background: #0f0f2e;
  color: #94a3b8;
  padding: 9px 10px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid #1a1a3e;
}
th:hover { background: #1a1a3e; color: #fff; }
td {
  padding: 7px 10px;
  border-bottom: 1px solid #1a1a30;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ccc;
}
tr { cursor: pointer; }
tr:hover td { background: #1a1a40 !important; }

/* Row status colors */
.row-activated td { background: rgba(22,163,74,0.08); }
.row-paid td { background: rgba(22,163,74,0.08); }
.row-partial td { background: rgba(245,158,11,0.08); }
.row-on_hold td { background: rgba(245,158,11,0.12); }
.row-cancelled td { background: rgba(220,38,38,0.08); }
.row-deactivated td { background: rgba(220,38,38,0.08); }
.row-delivered td { background: rgba(59,130,246,0.06); }

/* Badges */
.bg {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.bg-b { background: rgba(59,130,246,0.2); color: #60a5fa; }
.bg-a { background: rgba(245,158,11,0.2); color: #fbbf24; }
.bg-t { background: rgba(20,184,166,0.2); color: #5eead4; }
.bg-x { background: rgba(148,163,184,0.15); color: #94a3b8; }
.bg-g { background: rgba(22,163,74,0.2); color: #4ade80; }
.bg-r { background: rgba(220,38,38,0.2); color: #f87171; }

.rp { text-align: right; font-variant-numeric: tabular-nums; }
.exp-warn { background: rgba(245,158,11,0.2); color: #fbbf24; font-weight: 700; }

/* Status badge */
.st-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Overlay + Panel */
.overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 10;
}
.panel {
  display: none;
  position: fixed;
  top: 0; right: 0;
  width: 560px; height: 100%;
  background: #0f0f2e;
  box-shadow: -4px 0 20px rgba(0,0,0,0.4);
  z-index: 11;
  overflow-y: auto;
}
.panel .ph {
  background: #0a0a20;
  color: #fff;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 3;
  border-bottom: 1px solid #1a1a3e;
}
.panel .ph h2 {
  font-size: 15px;
  font-weight: 700;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.panel .ph .x {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
.panel .tabs {
  display: flex;
  border-bottom: 2px solid #1a1a3e;
  padding: 0 16px;
  background: #0d0d28;
  position: sticky;
  top: 52px;
  z-index: 3;
  flex-wrap: wrap;
}
.panel .tab {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: #666;
  transition: color 0.15s;
}
.panel .tab:hover { color: #aaa; }
.panel .tab.on { color: #3b82f6; border-bottom-color: #3b82f6; }
.panel .tp { padding: 16px 20px; display: none; }
.panel .tp.on { display: block; }
.panel label {
  display: block;
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin: 10px 0 4px;
}
.panel label:first-child { margin-top: 0; }
.panel input,
.panel select,
.panel textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #12122a;
  color: #e0e0e0;
  transition: border-color 0.15s;
}
.panel input:focus,
.panel select:focus,
.panel textarea:focus { border-color: #3b82f6; }
.panel select option { background: #12122a; color: #e0e0e0; }
.panel textarea { height: 60px; resize: vertical; }
.panel .r2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel .sv {
  position: sticky;
  bottom: 0;
  background: #0f0f2e;
  padding: 12px 20px;
  border-top: 1px solid #1a1a3e;
  display: flex;
  gap: 10px;
}
.panel .sv button { flex: 1; }

/* Toast */
.toast {
  display: none;
  position: fixed;
  bottom: 24px; right: 24px;
  background: #16a34a;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.toast.err { background: #dc2626; }

/* Loading */
.loading {
  text-align: center;
  padding: 80px 20px;
  color: #666;
  font-size: 14px;
}
.loading .spinner {
  display: inline-block;
  width: 32px; height: 32px;
  border: 3px solid #1a1a3e;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.ft {
  text-align: center;
  padding: 16px;
  font-size: 11px;
  color: #444;
  border-top: 1px solid #1a1a30;
}

/* Responsive */
@media (max-width: 768px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .fl { flex-direction: column; }
  .panel { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; }
  .hd { flex-direction: column; gap: 10px; }
}
