/* ============================================================
   PatrolSatpam Web — Sistem Patroli Satpam
   Tema gelap mobile-first, aksen oranye/merah (identitas satpam)
   ============================================================ */

:root {
  --bg: #12141a;
  --bg-soft: #1a1d26;
  --bg-card: #20242f;
  --bg-card-2: #262b38;
  --border: #2e3442;
  --text: #e8eaf0;
  --text-dim: #9aa3b5;
  --text-faint: #6b7488;
  --accent: #ff7a1a;
  --accent-strong: #ff8c3a;
  --accent-dim: rgba(255, 122, 26, 0.14);
  --danger: #e03a3a;
  --danger-strong: #ff5252;
  --danger-dim: rgba(224, 58, 58, 0.14);
  --success: #2ecc71;
  --success-dim: rgba(46, 204, 113, 0.14);
  --info: #38bdf8;
  --info-dim: rgba(56, 189, 248, 0.14);
  --warn: #f5b942;
  --warn-dim: rgba(245, 185, 66, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --header-h: 60px;
  --nav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body { overflow-x: hidden; }

.hidden { display: none !important; }

/* ============ SPLASH ============ */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #232839 0%, var(--bg) 55%);
  transition: opacity 0.4s ease;
}
#splash.fade { opacity: 0; pointer-events: none; }
.splash-logo {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--bg-card);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
#splash h1 { margin-top: 20px; font-size: 22px; letter-spacing: 0.5px; }
#splash p { margin-top: 6px; font-size: 13px; color: var(--text-dim); }

/* ============ VIEWS ============ */
.view { min-height: 100%; }

/* ============ LOGIN ============ */
#view-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(255, 122, 26, 0.10), transparent 60%),
    radial-gradient(800px 400px at -10% 110%, rgba(224, 58, 58, 0.08), transparent 60%),
    var(--bg);
}
.login-wrap { width: 100%; max-width: 420px; }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
  width: 84px; height: 84px; margin: 0 auto 14px;
  border-radius: 24px;
  background: linear-gradient(145deg, var(--bg-card), var(--bg-card-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.login-brand h1 { font-size: 26px; letter-spacing: 0.5px; }
.login-brand p { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.login-card { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.3px; }

input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"], select, textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea { resize: vertical; min-height: 88px; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-option { position: relative; cursor: pointer; }
.mode-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.mode-box {
  display: flex; align-items: center; gap: 10px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  transition: all 0.2s;
}
.mode-option input:checked + .mode-box {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.mode-ico { font-size: 22px; }
.mode-txt { display: flex; flex-direction: column; line-height: 1.25; }
.mode-txt b { font-size: 12.5px; }
.mode-txt small { font-size: 10.5px; color: var(--text-dim); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 15px; font-weight: 700;
  padding: 13px 18px; cursor: pointer;
  transition: filter 0.15s, transform 0.1s, background 0.15s;
  color: var(--text);
  background: var(--bg-card-2);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #ff5f1a); color: #1a0e00; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: linear-gradient(135deg, #e03a3a, #b71c1c); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-success { background: linear-gradient(135deg, #27ae60, #1e8449); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); font-size: 13px; padding: 9px 14px; border-radius: var(--radius-sm); cursor: pointer; }
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }
.btn-block { width: 100%; }
.btn-label { letter-spacing: 1px; }

.btn-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(0,0,0,0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-demo {
  text-align: center; font-size: 12.5px; color: var(--text-dim);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.login-demo code { background: var(--bg-soft); padding: 3px 8px; border-radius: 6px; color: var(--accent); font-size: 12px; }
.login-settings { text-align: center; }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.45; }
.alert-danger { background: var(--danger-dim); color: var(--danger-strong); border: 1px solid rgba(224,58,58,0.35); }
.alert-success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(46,204,113,0.35); }
.alert-info { background: var(--info-dim); color: var(--info); border: 1px solid rgba(56,189,248,0.35); }
.alert-warn { background: var(--warn-dim); color: var(--warn); border: 1px solid rgba(245,185,66,0.35); }

/* ============ APP HEADER ============ */
#view-app { display: flex; flex-direction: column; height: 100vh; }
.app-header {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.mini-logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--bg-card);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.header-title { display: flex; flex-direction: column; line-height: 1.2; }
.header-title b { font-size: 15.5px; }
.header-title small { font-size: 11.5px; color: var(--text-dim); }
.header-right { display: flex; align-items: center; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700;
  padding: 5px 10px; border-radius: 999px;
  letter-spacing: 0.4px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip-gps { background: var(--bg-card); color: var(--text-faint); border: 1px solid var(--border); }
.chip-gps.on { color: var(--success); border-color: rgba(46,204,113,0.4); background: var(--success-dim); }
.chip-gps.sim { color: var(--warn); border-color: rgba(245,185,66,0.4); background: var(--warn-dim); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); }

/* ============ CONTENT ============ */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px calc(var(--nav-h) + 20px);
  scrollbar-width: thin;
}
.page-title { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.page-sub { font-size: 12.5px; color: var(--text-dim); margin-bottom: 16px; }

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: none; color: var(--text-faint);
  font-family: var(--font); font-size: 10.5px; font-weight: 600;
  cursor: pointer; letter-spacing: 0.2px;
}
.nav-item .nav-ico { font-size: 21px; line-height: 1; filter: grayscale(0.4); }
.nav-item.active { color: var(--accent); }
.nav-item.active .nav-ico { filter: none; }
.nav-item.active::before {
  content: ''; position: absolute; top: 0; left: 30%; right: 30%;
  height: 3px; border-radius: 0 0 4px 4px;
  background: var(--accent);
}
.nav-item { position: relative; }

/* ============ CHIP ROW (kategori/prioritas) ============ */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 9px 14px;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.chip-btn:hover { border-color: var(--text-faint); color: var(--text); }
.chip-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============ CARDS ============ */
.card-grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-card .stat-ico { font-size: 22px; }
.stat-card .stat-val { font-size: 24px; font-weight: 800; line-height: 1; }
.stat-card .stat-label { font-size: 11.5px; color: var(--text-dim); }
.stat-card.accent { background: linear-gradient(145deg, rgba(255,122,26,0.16), var(--bg-card)); border-color: rgba(255,122,26,0.35); }
.stat-card.danger { background: linear-gradient(145deg, rgba(224,58,58,0.16), var(--bg-card)); border-color: rgba(224,58,58,0.35); }
.stat-card.success { background: linear-gradient(145deg, rgba(46,204,113,0.14), var(--bg-card)); border-color: rgba(46,204,113,0.3); }
.stat-card.info { background: linear-gradient(145deg, rgba(56,189,248,0.12), var(--bg-card)); border-color: rgba(56,189,248,0.3); }

.shift-card {
  background: linear-gradient(135deg, rgba(255,122,26,0.18), var(--bg-card) 60%);
  border: 1px solid rgba(255,122,26,0.4);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; align-items: center; gap: 14px;
}
.shift-card .shift-ico {
  width: 52px; height: 52px; border-radius: 16px; flex-shrink: 0;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.shift-card .shift-info { flex: 1; min-width: 0; }
.shift-card .shift-title { font-weight: 800; font-size: 15.5px; }
.shift-card .shift-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.shift-card .shift-time { font-size: 13px; font-weight: 700; color: var(--accent); margin-top: 5px; font-family: var(--mono); }
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 800;
  padding: 3px 9px; border-radius: 999px; letter-spacing: 0.5px;
}
.badge-live { background: var(--success-dim); color: var(--success); }
.badge-idle { background: var(--bg-card-2); color: var(--text-faint); }
.badge-danger { background: var(--danger-dim); color: var(--danger-strong); }
.badge-warn { background: var(--warn-dim); color: var(--warn); }
.badge-info { background: var(--info-dim); color: var(--info); }

/* ============ CHECKPOINT LIST ============ */
.cp-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.cp-item:hover { border-color: var(--text-faint); }
.cp-item.inside { border-color: rgba(46,204,113,0.45); background: linear-gradient(90deg, rgba(46,204,113,0.08), var(--bg-card)); }
.cp-item.outside { border-color: rgba(245,185,66,0.4); }
.cp-ico {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: var(--bg-card-2);
}
.cp-item.inside .cp-ico { background: var(--success-dim); }
.cp-info { flex: 1; min-width: 0; }
.cp-name { font-weight: 700; font-size: 14px; }
.cp-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.cp-dist { text-align: right; flex-shrink: 0; }
.cp-dist b { font-size: 14px; font-family: var(--mono); }
.cp-dist span { display: block; font-size: 9.5px; letter-spacing: 0.4px; font-weight: 700; margin-top: 2px; }
.cp-item.inside .cp-dist b, .cp-item.inside .cp-dist span { color: var(--success); }
.cp-item.outside .cp-dist b, .cp-item.outside .cp-dist span { color: var(--warn); }

/* ============ GPS / MAP ============ */
.gps-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.gps-row { display: flex; justify-content: space-between; font-size: 12.5px; }
.gps-row .k { color: var(--text-dim); }
.gps-row .v { font-family: var(--mono); font-weight: 600; }
#map {
  width: 100%; height: 300px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  z-index: 1;
  background: var(--bg-soft);
}
.leaflet-container { font-family: var(--font); }
.route-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.route-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
}
.route-stat .k { font-size: 11px; color: var(--text-dim); }
.route-stat .v { font-size: 16px; font-weight: 800; margin-top: 3px; font-family: var(--mono); }

.sim-gps-box {
  background: var(--warn-dim);
  border: 1px dashed rgba(245,185,66,0.5);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12.5px; color: var(--warn);
}

/* ============ BUTTONS / ACTIONS ============ */
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ============ SOS ============ */
.sos-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px 0; }
.sos-button {
  width: 190px; height: 190px; border-radius: 50%;
  border: none; cursor: pointer;
  background: radial-gradient(circle at 32% 28%, #ff6b6b, #d32f2f 55%, #a11212);
  color: #fff;
  font-family: var(--font);
  font-weight: 900; font-size: 30px; letter-spacing: 4px;
  box-shadow: 0 0 0 10px rgba(211,47,47,0.25), 0 0 0 20px rgba(211,47,47,0.12), 0 14px 40px rgba(211,47,47,0.5);
  animation: sos-pulse 1.8s ease-in-out infinite;
  display: flex; align-items: center; justify-content: center;
  text-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
@keyframes sos-pulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(211,47,47,0.25), 0 0 0 16px rgba(211,47,47,0.10), 0 14px 40px rgba(211,47,47,0.5); }
  50% { box-shadow: 0 0 0 14px rgba(211,47,47,0.35), 0 0 0 28px rgba(211,47,47,0.14), 0 14px 40px rgba(211,47,47,0.55); }
}
.sos-hint { font-size: 13px; color: var(--text-dim); text-align: center; max-width: 300px; }
.sos-countdown {
  font-family: var(--mono); font-size: 44px; font-weight: 900;
  color: var(--danger-strong);
}
.sos-history-title { font-size: 14px; font-weight: 800; margin: 18px 0 10px; }

/* ============ LIST ITEMS ============ */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  display: flex; gap: 12px; align-items: flex-start;
}
.list-item .li-ico {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--bg-card-2);
}
.list-item .li-body { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-item .li-sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; line-height: 1.5; }
.list-item .li-meta { font-size: 10.5px; color: var(--text-faint); margin-top: 5px; font-family: var(--mono); }
.list-item img.li-thumb {
  width: 54px; height: 54px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
  background: var(--bg-soft);
}
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-faint);
}
.empty-state .es-ico { font-size: 44px; margin-bottom: 12px; opacity: 0.6; }
.empty-state p { font-size: 13.5px; line-height: 1.6; }

/* ============ SEGMENTED (tabs) ============ */
.segmented {
  display: flex; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px; gap: 4px; margin-bottom: 16px;
}
.segmented button {
  flex: 1; border: none; background: transparent; color: var(--text-dim);
  font-family: var(--font); font-size: 13px; font-weight: 700;
  padding: 10px; border-radius: 8px; cursor: pointer;
}
.segmented button.active { background: var(--accent-dim); color: var(--accent); }

/* ============ SCAN ============ */
.scan-stage {
  position: relative;
  width: 100%; aspect-ratio: 4/3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.scan-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.scan-frame {
  width: 62%; aspect-ratio: 1;
  border: 3px solid rgba(255,122,26,0.85);
  border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
}
.scan-frame::after {
  content: ''; position: absolute; left: 8%; right: 8%; top: 0; height: 3px;
  background: var(--accent);
  border-radius: 3px;
  animation: scanline 2.2s ease-in-out infinite;
}
@keyframes scanline {
  0% { top: 4%; }
  50% { top: 94%; }
  100% { top: 4%; }
}
.scan-status {
  margin-top: 12px; text-align: center; font-size: 13px; color: var(--text-dim);
  min-height: 20px;
}
.scan-result-card { margin-top: 14px; }

/* ============ CONTROL ============ */
#view-control { display: flex; height: 100vh; }
.control-sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-brand {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.side-item {
  display: flex; align-items: center; gap: 12px;
  background: none; border: none; color: var(--text-dim);
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  padding: 12px 14px; border-radius: var(--radius-sm);
  cursor: pointer; text-align: left;
}
.side-item:hover { background: var(--bg-card); color: var(--text); }
.side-item.active { background: var(--accent-dim); color: var(--accent); }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }

.control-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.control-topbar {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
#control-content { padding-bottom: 30px; }

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.control-card h3 { font-size: 14px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

.officer-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.officer-row:last-child { border-bottom: none; }
.officer-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-card-2); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: var(--text);
}
.officer-row.online .officer-avatar { border-color: var(--success); }
.officer-row.online .dot-live { background: var(--success); box-shadow: 0 0 0 4px var(--success-dim); }
.officer-info { flex: 1; min-width: 0; }
.officer-info b { font-size: 13.5px; display: block; }
.officer-info small { font-size: 11.5px; color: var(--text-dim); }
.dot-live { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8, 9, 12, 0.75);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in 0.2s ease;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  animation: slide-up 0.25s ease;
}
@media (min-width: 640px) {
  .modal { border-radius: 20px; }
}
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } }
.modal h2 { font-size: 17px; font-weight: 800; margin-bottom: 14px; }
.modal .modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ============ TOAST ============ */
#toast-root {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
  width: calc(100% - 28px); max-width: 420px;
  pointer-events: none;
}
.toast {
  padding: 13px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; line-height: 1.45;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
}
@keyframes toast-in { from { transform: translateY(-14px); opacity: 0; } }
.toast.success { background: #1d4d33; color: #a5f3c4; border: 1px solid rgba(46,204,113,0.4); }
.toast.error { background: #4d1d1d; color: #ffb3b3; border: 1px solid rgba(224,58,58,0.45); }
.toast.info { background: #16324a; color: #b8e6ff; border: 1px solid rgba(56,189,248,0.4); }
.toast.warn { background: #4a3a16; color: #ffe7a8; border: 1px solid rgba(245,185,66,0.45); }

/* ============ SETTINGS ============ */
.settings-list { display: flex; flex-direction: column; gap: 14px; }
.setting-row { display: flex; flex-direction: column; gap: 6px; }
.setting-row .k { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.setting-row .v { font-size: 13.5px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--bg-card-2); border: 1px solid var(--border);
  cursor: pointer; transition: 0.2s;
}
.switch .slider::before {
  content: ''; position: absolute; width: 20px; height: 20px;
  border-radius: 50%; left: 2px; top: 2px;
  background: var(--text-dim); transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent-dim); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); background: var(--accent); }

/* ============ CAMERA CAPTURE ============ */
.capture-stage {
  position: relative; width: 100%; aspect-ratio: 4/3;
  background: #000; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
}
.capture-stage video { width: 100%; height: 100%; object-fit: cover; }
.capture-preview { width: 100%; border-radius: var(--radius); }

/* ============ RESPONSIVE ============ */
@media (min-width: 768px) {
  .app-content { max-width: 860px; margin: 0 auto; }
  #control-content { max-width: none; }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .card-grid.tight { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: 1fr; }
  .sos-button { width: 160px; height: 160px; font-size: 26px; }
}
@media (max-width: 768px) {
  .control-sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 150; transform: translateX(-100%); transition: transform 0.25s ease; }
  .control-sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
}

/* Scrollbar halus */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* Kode */
code, .mono { font-family: var(--mono); }