:root {
  --gold: #D4AF37;
  --gold-soft: #e8c86a;
  --gold-dim: #9a7d26;
  --black: #0c0c0d;
  --charcoal: #1a1a1c;
  --charcoal-2: #232326;
  --line: #333;
  --green: #35c759;
  --grey: #8a8a8e;
  --red: #ff453a;
  --text: #f3eede;
  --muted: #a9a398;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 700px at 50% -10%, #202024 0%, var(--black) 60%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 18px; }
.wrap.narrow { max-width: 520px; }

/* Simulasi badge */
.sim-badge {
  background: repeating-linear-gradient(45deg, #2a2206, #2a2206 10px, #201a05 10px, #201a05 20px);
  border: 1px solid var(--gold-dim);
  color: var(--gold-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
  padding: 7px 10px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* Brand */
.brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.brand .eagle {
  width: 46px; height: 46px; flex: 0 0 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #2a2a2e, #0e0e10);
  border: 1.5px solid var(--gold);
  box-shadow: 0 0 14px rgba(212,175,55,.35);
  font-size: 24px;
}
.brand .title { line-height: 1.05; }
.brand .title b {
  font-size: 20px; letter-spacing: 2px; font-weight: 800;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold-dim));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .title span { display: block; font-size: 10px; letter-spacing: 3px; color: var(--muted); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}

.card {
  background: linear-gradient(180deg, var(--charcoal) 0%, var(--charcoal-2) 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.card + .card { margin-top: 14px; }

h2.section { font-size: 15px; letter-spacing: 1px; color: var(--gold-soft); margin-bottom: 12px; text-transform: uppercase; }

label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 6px; letter-spacing: .5px; }

input, select {
  width: 100%; padding: 12px 14px; font-size: 15px;
  background: #121214; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, select:focus { border-color: var(--gold); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; font-size: 15px; font-weight: 700; letter-spacing: .5px;
  border: 1px solid var(--gold); border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--gold); transition: .15s;
}
.btn:hover { background: rgba(212,175,55,.12); }
.btn.gold { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #1a1500; border: none; }
.btn.gold:hover { filter: brightness(1.05); }
.btn.block { width: 100%; }
.btn.ghost { border-color: var(--line); color: var(--muted); }

/* Big check-in button */
.checkin-btn {
  width: 100%; padding: 26px; font-size: 22px; font-weight: 900; letter-spacing: 2px;
  border: none; border-radius: 18px; cursor: pointer; text-transform: uppercase;
  color: #1a1500;
  background: radial-gradient(circle at 30% 20%, var(--gold-soft), var(--gold) 55%, var(--gold-dim));
  box-shadow: 0 12px 30px rgba(212,175,55,.35), inset 0 2px 2px rgba(255,255,255,.4);
  transition: transform .1s;
}
.checkin-btn:active { transform: scale(.98); }
.checkin-btn:disabled { opacity: .6; cursor: progress; }
.checkin-btn .sub { display: block; font-size: 11px; font-weight: 600; letter-spacing: 1px; margin-top: 6px; color: #3a2f00; }

.status-line { margin-top: 12px; font-size: 13px; text-align: center; min-height: 18px; }
.status-line.ok { color: var(--green); }
.status-line.err { color: var(--red); }

/* KTA card */
.kta {
  background: linear-gradient(135deg, #15130c, #0c0c0d 60%);
  border: 1px solid var(--gold-dim);
  border-radius: 16px; padding: 16px; position: relative; overflow: hidden;
}
.kta::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(212,175,55,.18), transparent 70%);
}
.kta .head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.kta .photo {
  width: 64px; height: 64px; border-radius: 10px; flex: 0 0 64px;
  background: linear-gradient(180deg, #2a2a2e, #141416);
  border: 1px solid var(--gold-dim); display: grid; place-items: center;
  font-size: 22px; font-weight: 800; color: var(--gold);
}
.kta .meta b { font-size: 17px; }
.kta .meta small { color: var(--muted); display:block; font-size: 12px; margin-top:2px;}
.kta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.kta-grid .k { font-size: 10px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.kta-grid .v { font-size: 14px; color: var(--text); margin-top: 2px; }

/* history list */
.hist { list-style: none; }
.hist li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.hist li:last-child { border-bottom: none; }
.hist .when { color: var(--text); }
.hist .loc { color: var(--muted); font-size: 12px; }

/* Dashboard */
.cards-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.stat { text-align: left; }
.stat .num { font-size: 32px; font-weight: 900; color: var(--gold); line-height: 1; }
.stat .lbl { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; margin-top: 8px; }
.stat.green .num { color: var(--green); }
.stat.grey .num { color: var(--grey); }

.dash-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }  /* susun vertikal: peta full width atas, tabel full width bawah */
#map { height: 560px; border-radius: 12px; border: 1px solid var(--line); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { width: auto; min-width: 150px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--gold-soft); font-size: 11px; letter-spacing: .5px; text-transform: uppercase; position: sticky; top: 0; background: var(--charcoal-2); }
.tbl-wrap { max-height: 520px; overflow: auto; }
.avatar { width: 30px; height: 30px; border-radius: 7px; background: linear-gradient(180deg,#2a2a2e,#141416); border: 1px solid var(--gold-dim); display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--gold); }
.row-name { display: flex; align-items: center; gap: 9px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 20px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pill.on { background: rgba(53,199,89,.14); color: var(--green); }
.pill.on .dot { background: var(--green); }
.pill.off { background: rgba(255,69,58,.12); color: var(--red); }
.pill.off .dot { background: var(--grey); }

.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

@media (max-width: 900px) {
  .cards-row { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  #map { height: 360px; }
}

/* ---- Leaflet popup: tema emas-hitam ---- */
.lh-popup .leaflet-popup-content-wrapper {
  background: linear-gradient(180deg, #1a1a1c, #232326);
  color: var(--text);
  border: 1px solid var(--gold-dim);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.55);
}
.lh-popup .leaflet-popup-content { margin: 14px 16px; line-height: 1.4; }
.lh-popup .leaflet-popup-tip { background: #232326; border: 1px solid var(--gold-dim); }
.lh-popup a.leaflet-popup-close-button { color: var(--gold-soft); }

.lh-pop-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lh-pop-avatar {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 10px;
  background: linear-gradient(180deg, #2a2a2e, #141416);
  border: 1px solid var(--gold-dim); display: grid; place-items: center;
  font-size: 15px; font-weight: 800; color: var(--gold);
}
.lh-pop-id { flex: 1; min-width: 0; }
.lh-pop-id b { font-size: 15px; color: var(--text); display: block; }
.lh-pop-id small { font-size: 11px; color: var(--muted); }

.lh-pop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.lh-pop-grid .k, .lh-pop-foot .k {
  display: block; font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
}
.lh-pop-grid .v, .lh-pop-foot .v { display: block; font-size: 13px; color: var(--text); margin-top: 1px; }

.lh-pop-foot {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
.lh-popup .pill { margin-left: auto; }

/* ---- MarkerCluster: tema emas-hitam ---- */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background: rgba(212,175,55,.25);
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #1a1500; font-weight: 800; border: 1px solid #1a1500;
}
.marker-cluster span { line-height: 30px; }

/* ---- Search box (dashboard) ---- */
.filters { align-items: center; }
.search-box { display: flex; gap: 8px; }
.search-box input {
  width: 230px; padding: 10px 12px; font-size: 14px;
  background: #121214; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
}
.search-box input:focus { border-color: var(--gold); outline: none; }
.search-box .btn { padding: 10px 16px; }
.search-msg { font-size: 12px; font-weight: 600; margin-left: 4px; }
.search-msg.ok { color: var(--green); }
.search-msg.err { color: var(--red); }
.search-msg.warn { color: var(--gold-soft); }

/* ============ PRODUKSI: tambahan ============ */
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: rgba(255,69,58,.12); }

.topbar .who { font-size: 12px; color: var(--muted); }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 6px; flex-wrap: wrap; }
.pager button {
  min-width: 36px; padding: 7px 10px; font-size: 13px; cursor: pointer;
  background: #121214; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
}
.pager button:hover:not(:disabled) { border-color: var(--gold); }
.pager button.active { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #1a1500; border: none; font-weight: 800; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .info { font-size: 12px; color: var(--muted); }

/* Admin table actions */
td.actions { white-space: nowrap; }
td.actions .btn { margin-right: 6px; }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none;
  align-items: flex-start; justify-content: center; padding: 30px 14px; z-index: 1000; overflow: auto;
}
.modal-bg.show { display: flex; }
.modal {
  width: 100%; max-width: 480px;
  background: linear-gradient(180deg, var(--charcoal) 0%, var(--charcoal-2) 100%);
  border: 1px solid var(--gold-dim); border-radius: 14px; padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
}
.modal h3 { color: var(--gold-soft); font-size: 16px; margin-bottom: 14px; letter-spacing: .5px; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #15130c; border: 1px solid var(--gold-dim); color: var(--gold-soft);
  padding: 12px 20px; border-radius: 10px; font-size: 13px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 2000; display: none; max-width: 90%;
}
.toast.show { display: block; }
.toast.err { border-color: var(--red); color: var(--red); }
.toast.ok { border-color: var(--green); color: var(--green); }

.file-help { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.import-result { font-size: 13px; margin-top: 10px; line-height: 1.6; }

.kta .photo img, .avatar img, .lh-pop-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs .tab {
  padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: #121214; color: var(--muted);
}
.tabs .tab.active { border-color: var(--gold); color: var(--gold); }
