/* Sistem desain NeoTalk: tema terang, warna = status. */
:root {
  color-scheme: light;
  --bg: #F4F4F1;      /* Warm Off-white */
  --panel: #F4F4F1;
  --surface: #F4F4F1;
  --line: #D7D8D8;
  --text: #0F172A;    /* Deep Navy */
  --muted: #6E737C;
  --accent: #FF5500;  /* Energetic Orange (aksen merek) */
  --idle: #0F172A;    /* Siaga */
  --tx: #FF5500;      /* Bicara */
  --rx: #FF5500;      /* Menerima */
  --wait: #FE6A1F;    /* Menyambung */
  --off: #9FA2A7;     /* Terputus */
  --private: #BC440C; /* Panggilan pribadi */
  --sos: #DC2626;     /* Darurat */
  --ok: #16A34A;      /* Disetujui / online (status fungsional) */
  --radius: 10px;
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
.brand, .panel h2, .login-card .brand, h1, h2, h3, .ptt-main { font-family: "Outfit", "Plus Jakarta Sans", "Segoe UI", sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
:root { accent-color: var(--accent); }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.error { color: var(--sos); min-height: 1.2em; margin: 0; }

/* ---------- login ---------- */
.login { display: grid; place-items: center; height: 100%; }
.login-card { width: min(340px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.login-card input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 16px; }
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn-primary { background: var(--accent); color: #F4F4F1; border: 0; border-radius: 8px; padding: 11px; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }

/* ---------- layout ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand-icon { width: 30px; height: 30px; display: block; }
.spacer { flex: 1; }
.op { color: var(--muted); font-size: 14px; }
.pill { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.pill-ok { background: rgba(22,163,74,.16); color: var(--ok); }
.pill-wait { background: rgba(254, 106, 31,.16); color: var(--wait); }
.pill-off { background: rgba(110, 115, 124,.18); color: var(--muted); }

.grid { flex: 1; display: grid; grid-template-columns: 270px 1fr 310px; gap: 14px; padding: 14px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; overflow: auto; min-height: 0; }
.panel h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* ---------- channel ---------- */
.channel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.channel { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid transparent; cursor: pointer; }
.channel:hover { border-color: var(--line); }
.channel.current { border-color: var(--rx); background: rgba(255, 85, 0,.10); }
.channel .name { flex: 1; font-weight: 600; }
.channel .count { color: var(--muted); font-size: 13px; }
.live { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.channel.talking .live { background: var(--rx); box-shadow: 0 0 0 4px rgba(255, 85, 0,.22); }

/* ---------- kiri ---------- */
.side { display: flex; flex-direction: column; }
.mt { margin-top: 20px !important; }
.cur-name { color: var(--text); text-transform: none; letter-spacing: 0; font-weight: 600; margin-left: 4px; }

/* ---------- tengah ---------- */
.center { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.map-wrap { position: relative; isolation: isolate; z-index: 0; flex: 1; min-height: 240px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
#map { position: absolute; inset: 0; background: #EAEBE9; }
.legend { position: absolute; left: 10px; bottom: 10px; z-index: 500; display: flex; gap: 12px; padding: 6px 10px;
  background: rgba(244, 244, 241,.92); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 5px; }
.lg { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg-idle { background: var(--ok); } .lg-rx { background: var(--rx); } .lg-sos { background: var(--sos); } .lg-off { background: var(--off); }

/* Penanda HT di peta */
.ht-marker { display: flex; flex-direction: column; align-items: center; width: 30px; }
.ht-ico { width: 30px; height: 30px; border-radius: 50%; background: #FFFFFF; border: 2.5px solid currentColor; box-shadow: 0 1px 5px rgba(15, 23, 42,.55); display: flex; align-items: center; justify-content: center; color: var(--ok); } /* online = hijau (navy siaga tak terlihat di peta) */
.ht-ico svg { width: 19px; height: 19px; display: block; }
.ht-label { margin-top: 3px; padding: 1px 6px; border-radius: 4px; background: rgba(15, 23, 42,.9); color: #FFFFFF; font: 600 12px/1.4 'Plus Jakarta Sans', sans-serif; white-space: nowrap; }
.ht-marker.rx .ht-ico { color: var(--rx); animation: talkpulse 1.1s infinite; }
.ht-marker.off .ht-ico { color: #6B7280; }
.ht-marker.sos .ht-ico { color: var(--sos); animation: pulse 1s infinite; }
@keyframes talkpulse { 0% { box-shadow: 0 0 0 0 rgba(255, 85, 0,.7); } 100% { box-shadow: 0 0 0 18px rgba(255, 85, 0, 0); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.65); } 100% { box-shadow: 0 0 0 18px rgba(220,38,38,0); } }
/* Urut kolom tabel perangkat */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
th.sorted::after { content: " ▲"; font-size: .7em; }
th.sorted.desc::after { content: " ▼"; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-popup-content { font: 14px/1.5 'Segoe UI', sans-serif; margin: 12px 14px; }
.pop-title { font-weight: 700; font-size: 15px; }
.pop-row { color: var(--muted); }
.no-fix { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 500; }
.now { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: var(--radius); font-weight: 600; font-size: 18px; }
.now-dot { width: 12px; height: 12px; border-radius: 50%; background: currentColor; }
.now.idle { background: rgba(15, 23, 42,.08); color: var(--text); }
.now.rx { background: var(--rx); color: #F4F4F1; }
.now.tx { background: var(--tx); color: #F4F4F1; }

.members { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; align-content: start; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid transparent; cursor: pointer; }
.member .pos { margin-left: auto; font-size: 12px; color: var(--muted); }
.member .avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  font-size: 13px; background: var(--line); flex: none; }
.member .who { display: grid; min-width: 0; }
.member .who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .who span { font-size: 12px; color: var(--muted); }
.member.talking { border-color: var(--rx); background: rgba(255, 85, 0,.14); }
.member.talking .avatar { background: var(--rx); }
.member.me .avatar { background: var(--idle); }

.ptt-wrap { display: flex; align-items: center; gap: 24px; }
.ptt { flex: 1; height: 84px; border-radius: 16px; border: 0; background: var(--idle); color: #F4F4F1;
  display: grid; place-content: center; gap: 4px; user-select: none; touch-action: none; transition: background .08s; }
.ptt-main { font-size: 20px; font-weight: 800; letter-spacing: .04em; }
.ptt-sub { font-size: 13px; opacity: .85; }
.ptt.active { background: var(--tx); }
.ptt:disabled { background: var(--off); cursor: not-allowed; }
.vol { display: grid; gap: 6px; color: var(--muted); font-size: 13px; width: 150px; }

/* ---------- aktivitas ---------- */
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.feed li { display: grid; grid-template-columns: 54px 1fr; gap: 8px; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.feed .sos { color: var(--sos); font-weight: 700; }
.feed .tx { color: #BA430C; }

/* ---------- SOS ---------- */
.sos-bar { position: relative; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: var(--sos); color: #F4F4F1;
  font-weight: 700; font-size: 18px; animation: blink 1s steps(1) infinite; }
.sos-icon { background: #F4F4F1; color: var(--sos); border-radius: 6px; padding: 2px 8px; }
.sos-text { flex: 1; }
.btn-sos-ghost { background: transparent; color: #F4F4F1; border: 2px solid #F4F4F1; border-radius: 8px; padding: 6px 14px; font-weight: 700; }
.btn-sos { background: #F4F4F1; color: var(--sos); border: 0; border-radius: 8px; padding: 8px 18px; font-weight: 800; }
@keyframes blink { 50% { background: #991B1B; } }

/* ---------- gerbang audio ---------- */
/* Pengingat audio: kartu kecil di bawah, tidak menghalangi klik ke halaman (klik pertama mengaktifkan audio). */
.gate { position: fixed; left: 0; right: 0; bottom: 84px; z-index: 3000; display: flex; justify-content: center; pointer-events: none; }
.gate-card { pointer-events: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; width: min(360px, 92vw); text-align: center;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .25); }
.gate-card p { margin: 4px 0 10px; }
.gate-card h2 { margin-top: 0; }


/* ---------- panggilan pribadi ---------- */
.now.private { background: var(--private); color: #F4F4F1; }
.ptt-private { flex: 0 0 300px; background: var(--private); }
.ptt-private.active { background: var(--tx); }
.ptt-private a { color: #F4F4F1; }
.call-btn { margin-left: 6px; border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 6px; padding: 2px 7px; font-size: 13px; }
.call-btn:hover { border-color: var(--private); }
.feed .private { color: #BC440C; }

/* ---------- tab kolom kanan ---------- */
.right { display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tab { background: transparent; border: 0; color: var(--muted); padding: 8px 10px; font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--text); border-bottom-color: var(--rx); }
.tabpane { flex: 1; overflow: auto; min-height: 0; }
.badge { background: var(--private); color: #F4F4F1; border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 4px; }

/* rekaman */
#player { width: 100%; margin-bottom: 10px; height: 36px; }
.recs, .devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rec { display: grid; grid-template-columns: 32px 1fr auto; gap: 8px; align-items: center; padding: 8px;
  border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 13px; }
.rec:hover, .rec.playing { outline: 1px solid var(--rx); }
.rec .play { width: 28px; height: 28px; border-radius: 50%; background: var(--rx); color: #F4F4F1; display: grid; place-items: center; font-size: 11px; }
.rec .meta { display: grid; min-width: 0; }
.rec .meta b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec .meta span { color: var(--muted); font-size: 12px; }
.rec.private .play { background: var(--private); }
.rec .dur { color: var(--muted); font-variant-numeric: tabular-nums; }

/* perangkat */
.dev { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; padding: 8px 10px;
  border-radius: 8px; background: var(--surface); font-size: 13px; }
.dev .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); }
.dev.online .dot { background: var(--idle); }
.dev .meta { display: grid; min-width: 0; }
.dev .meta span { color: var(--muted); font-size: 12px; }
.dev.pending { outline: 1px solid var(--private); }
.btn-sm { border: 0; border-radius: 6px; padding: 5px 10px; font-weight: 700; font-size: 12px; color: #F4F4F1; background: var(--idle); }
.btn-sm.danger { background: transparent; color: var(--sos); border: 1px solid rgba(220,38,38,.4); }