:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --red-primary: #dc2626;
  --red-hover: #b91c1c;
  --red-glow: rgba(220, 38, 38, 0.4);
  --yellow: #f59e0b;
  --green: #10b981;
  --blue: #3b82f6;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  margin: 0;
  padding: 0;
}

/* Warga Mobile Viewport Lock (100% No-Scroll, Native App Experience) */
body.page-warga {
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden !important;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  touch-action: none;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
}

body.page-warga .topbar {
  flex-shrink: 0;
  height: 52px;
  padding: 8px 16px;
}

body.page-warga .container {
  max-width: 500px;
  width: 100%;
  margin: 0 auto;
  padding: 6px 12px 10px 12px;
  flex: 1;
  height: calc(100dvh - 52px);
  max-height: calc(100dvh - 52px);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

body.page-warga #loginSection {
  max-height: calc(100dvh - 70px);
  overflow-y: auto;
  margin: auto 0;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

body.page-warga #appSection {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  flex: 1;
}

body.page-warga .gps-bar {
  flex-shrink: 0;
  min-height: 32px;
  padding: 4px 10px;
  margin-bottom: 6px;
}

body.page-warga .tabs {
  flex-shrink: 0;
  min-height: 40px;
  margin-bottom: 8px;
}

/* PANIC TAB NO-SCROLL VIEWPORT */
body.page-warga #tab-panic.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  flex: 1;
  height: 100%;
  overflow: hidden !important;
  padding: 0;
  margin: 0;
  touch-action: none;
  overscroll-behavior: none;
}

/* OTHER TABS SCROLLABLE INTERNALLY */
body.page-warga #tab-report, 
body.page-warga #tab-history {
  overflow-y: auto !important;
  flex: 1;
  height: 100%;
  padding-bottom: 24px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shield-icon {
  font-size: 28px;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info {
  text-align: right;
  display: flex;
  flex-direction: column;
}

.user-blok {
  color: var(--yellow);
  font-weight: bold;
}

/* CONTAINER */
.container {
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}

.container-wide {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
}

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.login-card {
  margin-top: 30px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

/* FORMS */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.input-control {
  width: 100%;
  background: #090d16;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-control:focus {
  border-color: var(--red-primary);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.95rem;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-block { width: 100%; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { opacity: 0.9; }

.btn-danger { background: var(--red-primary); color: #fff; }
.btn-danger:hover { background: var(--red-hover); }

.btn-warning { background: var(--yellow); color: #000; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-outline:hover { background: var(--bg-card-hover); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 6px; cursor: pointer; }
.btn-xs { padding: 4px 8px; font-size: 0.75rem; border-radius: 4px; cursor: pointer; }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

/* GPS STATUS */
.gps-bar {
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.gps-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.gps-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot-green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red-primary); }

/* TABS */
.tabs {
  display: flex;
  gap: 6px;
  background: #090d16;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 4px;
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--bg-card);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* PANIC BUTTON GIANT */
.panic-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  height: 100%;
  width: 100%;
  overflow: hidden;
  margin: 0;
  padding: 4px 0;
}

.panic-instruction {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 8px 0;
  text-align: center;
  line-height: 1.3;
  max-width: 320px;
}

.panic-btn-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: auto;
}

.btn-panic-giant {
  width: min(50vw, 30vh, 180px);
  height: min(50vw, 30vh, 180px);
  border-radius: 50%;
  background: radial-gradient(circle, #ef4444 0%, #b91c1c 80%, #7f1d1d 100%);
  border: 5px solid #fecaca;
  color: #fff;
  cursor: pointer;
  position: relative;
  box-shadow: 0 0 35px var(--red-glow), 0 8px 20px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  outline: none;
  transition: transform 0.1s;
}

.btn-panic-giant:active {
  transform: scale(0.95);
}

.panic-text {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.panic-sub {
  font-size: clamp(0.75rem, 2.5vw, 1rem);
  font-weight: bold;
  letter-spacing: 4px;
  color: #fecaca;
}

.pulse-ring {
  position: absolute;
  top: -15px;
  left: -15px;
  right: -15px;
  bottom: -15px;
  border: 2px solid var(--red-primary);
  border-radius: 50%;
  animation: pulse 2s infinite ease-out;
  pointer-events: none;
}

.ring-2 {
  animation-delay: 1s;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1.3); opacity: 0; }
}

.panic-countdown {
  margin-top: 20px;
  background: #450a0a;
  border: 1px solid var(--red-primary);
  padding: 16px;
  border-radius: 8px;
}

.countdown-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.alert-success-banner {
  margin-top: 25px;
  background: #064e3b;
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.alert-icon { font-size: 28px; }

/* CATEGORY GRID */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cat-chip {
  cursor: pointer;
  position: relative;
}

.cat-chip input {
  position: absolute;
  opacity: 0;
}

.cat-chip span {
  display: block;
  background: #090d16;
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: center;
  transition: all 0.2s;
}

.cat-chip input:checked + span {
  background: #7f1d1d;
  border-color: var(--red-primary);
  color: #fff;
  font-weight: bold;
}

/* MAP */
.map-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.coords-badge {
  font-size: 0.75rem;
  background: #090d16;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--yellow);
}

.map-container {
  height: 220px;
  border-radius: 8px;
  border: 1px solid var(--border);
  z-index: 10;
}

.admin-map-container {
  height: 380px;
  border-radius: 8px;
  border: 1px solid var(--border);
  z-index: 10;
}

/* INCIDENT LIST & CARDS */
.incident-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.incident-card {
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.incident-panic {
  border-left: 5px solid var(--red-primary);
  background: rgba(220, 38, 38, 0.08);
}

.incident-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.incident-badge {
  background: var(--bg-card-hover);
  font-size: 0.75rem;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 4px;
}

.incident-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.incident-notes {
  font-size: 0.85rem;
  margin: 6px 0;
  color: #e2e8f0;
}

.maps-link {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--blue);
  text-decoration: none;
  margin-top: 4px;
}
.maps-link:hover { text-decoration: underline; }

.wa-status-text {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* BADGES */
.badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}
.badge-green { background: #065f46; color: #a7f3d0; }
.badge-red { background: #991b1b; color: #fecaca; }
.badge-blue { background: #1e40af; color: #bfdbfe; }

/* CHIPS & DEMO */
.demo-hints {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 15px;
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.chip {
  background: var(--bg-card-hover);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.chip:hover { background: var(--blue); }

.text-link {
  color: var(--blue);
  font-size: 0.85rem;
  text-decoration: none;
}
.text-link:hover { text-decoration: underline; }

/* ADMIN OVERLAY */
.admin-auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

/* ADMIN GRID */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  min-width: 0;
}

.grid-2col > * {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 768px) {
  .grid-2col {
    grid-template-columns: 100%;
    gap: 16px;
  }
  .container-wide {
    padding: 10px 8px;
    max-width: 100vw;
    box-sizing: border-box;
  }
  .card {
    padding: 14px 12px;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* DIRECTORY LIST (MOBILE FRIENDLY LIST CARDS) */
.directory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.directory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  box-sizing: border-box;
  max-width: 100%;
}

.directory-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.directory-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.directory-badge {
  background: #f59e0b;
  color: #000;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.directory-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.directory-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.directory-pin {
  background: #1e293b;
  color: #38bdf8;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.incident-feed-scroll {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.live-dot-pulse {
  color: var(--red-primary);
  font-size: 0.8rem;
  font-weight: bold;
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* RADIO STACK */
.radio-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-option {
  display: flex;
  gap: 12px;
  background: #090d16;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
}
.radio-option:hover { background: var(--bg-card-hover); }

/* QR BOX */
.qr-box {
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.qr-image-wrapper {
  margin-top: 12px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.qr-img {
  width: 180px;
  height: 180px;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.wa-log-feed {
  max-height: 440px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-card {
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-size: 0.8rem;
}

.log-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: var(--yellow);
}

.log-text {
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.75rem;
  color: #cbd5e1;
}

/* TABLES */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: #090d16;
  color: var(--text-muted);
}

/* UTILITIES */
/* TICKER RUNNING TEXT */
.ticker-bar {
  display: flex;
  align-items: center;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #090d16;
  font-size: 0.88rem;
  height: 42px;
}

.ticker-bar.ticker-alert {
  background: #450a0a;
  border-color: var(--red-primary);
  box-shadow: 0 0 15px rgba(220, 38, 38, 0.35);
}

.ticker-bar.ticker-safe {
  background: #064e3b;
  border-color: var(--green);
}

.ticker-badge {
  padding: 0 14px;
  height: 100%;
  display: flex;
  align-items: center;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.ticker-alert .ticker-badge {
  background: var(--red-primary);
  color: #fff;
  animation: blink 1.2s infinite;
}

.ticker-safe .ticker-badge {
  background: var(--green);
  color: #fff;
}

.ticker-content-wrapper {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  padding: 0 12px;
  position: relative;
}

.ticker-marquee {
  display: inline-block;
  white-space: nowrap;
  animation: marquee 25s linear infinite;
  font-weight: 700;
}

.ticker-marquee:hover {
  animation-play-state: paused;
}

@keyframes marquee {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

/* SUB TABS INSIDE SETTINGS */
.sub-tabs {
  display: flex;
  gap: 8px;
  background: #090d16;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.sub-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 12px;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.sub-tab-btn.active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.subtab-pane { display: none; }
.subtab-pane.active { display: block; }

.ml-1 { margin-left: 6px; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.text-warning { color: var(--yellow); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
