/* ==========================================================================
   zNet CCTV — control room theme (dark)
   ========================================================================== */
:root {
  --bg: #080B11;
  --bg-grad-1: rgba(34, 211, 238, 0.10);
  --bg-grad-2: rgba(99, 102, 241, 0.12);
  --panel: rgba(20, 27, 38, 0.86);
  --panel-solid: #141B26;
  --panel-2: rgba(30, 39, 54, 0.75);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --txt: #E8EEF7;
  --muted: #8B98AB;
  --accent: #22D3EE;
  --accent-2: #6366F1;
  --ok: #22C55E;
  --warn: #F59E0B;
  --bad: #EF4444;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 12% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(800px 480px at 95% 5%, var(--bg-grad-2), transparent 60%),
    radial-gradient(700px 500px at 60% 110%, rgba(34, 211, 238, 0.06), transparent 65%);
  z-index: 0;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.ta-right { text-align: right; }
[hidden] { display: none !important; }

/* --------------------------------------------------------------- app shell */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 22, 32, 0.9), rgba(10, 14, 20, 0.75));
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15) inset, 0 10px 24px rgba(34,211,238,0.28);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 11px 9px; border-radius: 4px;
  background: #04121A; box-shadow: 0 0 0 2px rgba(255,255,255,0.7) inset;
}
.brand-text { font-weight: 700; font-size: 17px; letter-spacing: 0.02em; }
.brand-text span { color: var(--accent); }
.brand-lg { padding: 0; justify-content: center; }

.nav { display: flex; flex-direction: column; gap: 16px; }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
  padding: 0 14px 4px; font-size: 10.5px; font-weight: 750;
  letter-spacing: 0.13em; text-transform: uppercase; color: #6C7A90;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; position: relative;
  padding: 10px 13px; border-radius: 11px;
  color: var(--muted); font-weight: 520; font-size: 14.5px;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nav-item:hover { color: var(--txt); background: rgba(255,255,255,0.05); text-decoration: none; }
.nav-item.active {
  color: var(--txt);
  background: linear-gradient(90deg, rgba(34,211,238,0.16), rgba(99,102,241,0.10));
  border-color: rgba(34,211,238,0.28);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -18px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.nav-item.active svg { color: var(--accent); }
.nav-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ico { flex: none; color: #8494AB; }
.nav-item:hover .ico { color: var(--txt); }
.nav-badge {
  flex: none; min-width: 24px; text-align: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--muted); background: rgba(255,255,255,0.07); border: 1px solid var(--line);
}
.nav-badge.warn { color: #FCA5A5; border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.14); }
.nav-badge.ok { color: #86EFAC; border-color: rgba(34,197,94,0.35); background: rgba(34,197,94,0.12); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 10px; font-size: 13px; color: var(--muted);
  border: 1px dashed var(--line-strong);
}
.side-link:hover { color: var(--txt); background: rgba(255,255,255,0.04); text-decoration: none; }
.side-logout { gap: 9px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
  color: #05121A; font-weight: 750;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--muted); font-size: 12px; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 22px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 20, 0.6);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title h1 { font-size: 21px; }
.topbar-title p { font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stat-mini {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.stat-mini strong { color: var(--txt); font-variant-numeric: tabular-nums; }
.clock {
  font-family: var(--mono); font-size: 14px; letter-spacing: 0.06em;
  padding: 7px 14px; border-radius: 999px;
  background: rgba(34, 211, 238, 0.08); border: 1px solid rgba(34, 211, 238, 0.22);
  color: #B9F4FF;
}

.content { padding: 32px; display: flex; flex-direction: column; gap: 28px; }

/* ------------------------------------------------------------------- dots */
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #4B5563; }
.dot-ok { background: var(--ok); box-shadow: 0 0 10px rgba(34,197,94,0.8); }
.dot-bad { background: var(--bad); box-shadow: 0 0 10px rgba(239,68,68,0.7); }
.dot-live { background: var(--accent); box-shadow: 0 0 10px rgba(34,211,238,0.8); animation: pulse 1.8s infinite; }
.dot-idle { background: #4B5563; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ------------------------------------------------------------------ layout */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pill {
  padding: 9px 15px; border-radius: 999px; font-size: 13.5px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line);
}
.pill-warn { color: #FDE68A; border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.1); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 22px;
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(160%);
  padding: 22px;
  display: flex; flex-direction: column; gap: 18px;
}
.card-head h2 { font-size: 16.5px; }
.card-head p { font-size: 13px; margin-top: 4px; }
.card-flat { box-shadow: none; background: rgba(20, 27, 38, 0.5); }

.plain-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.plain-list strong { color: var(--txt); }

.empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 60px 24px; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
  background: rgba(20, 27, 38, 0.5);
}
.empty h3 { font-size: 16px; }
.empty-icon {
  width: 46px; height: 46px; border-radius: 14px;
  border: 2px dashed rgba(34,211,238,0.5);
  position: relative;
}
.empty-icon::after { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: rgba(34,211,238,0.35); }

/* ------------------------------------------------------------------ tiles */
.tile {
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(160%);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.tile:hover { border-color: var(--line-strong); }
.tile.is-live { border-color: rgba(34,211,238,0.32); }
.tile-head {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.tile-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tile-name { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-loc { font-size: 12px; }

.video-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #05080C;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 34px 34px;
}
.video-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; background: #05080C; }
.video-wrap-lg { aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; }
.video-state {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center; padding: 20px;
  background: rgba(5, 8, 12, 0.72);
  font-size: 13px; color: var(--muted);
}
.video-state.hide { display: none; }
.video-state-box { max-width: 90%; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.video-state.error .video-state-box { color: #FCA5A5; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(34,211,238,0.25); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tile-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-top: 1px solid var(--line);
  background: rgba(9, 13, 19, 0.55);
}
.tile-meta { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-actions { display: flex; gap: 6px; flex: none; }

.icon-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  border-radius: 9px; cursor: pointer;
  background: rgba(255,255,255,0.05); border: 1px solid var(--line);
  color: var(--muted); font-size: 13px; line-height: 1;
  transition: all 0.15s ease;
}
.icon-btn:hover { color: var(--txt); background: rgba(34,211,238,0.14); border-color: rgba(34,211,238,0.3); }

.badge {
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 650;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: rgba(255,255,255,0.06); border: 1px solid var(--line); color: var(--muted);
}
.badge-ok { color: #86EFAC; border-color: rgba(34,197,94,0.35); background: rgba(34,197,94,0.12); }
.badge-bad { color: #FCA5A5; border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.12); }
.badge-live { color: #A5F3FC; border-color: rgba(34,211,238,0.4); background: rgba(34,211,238,0.14); }
.badge-warn { color: #FDE68A; border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.12); }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 17px; border-radius: 11px;
  font-size: 14px; font-weight: 560; font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s ease; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: linear-gradient(135deg, #22D3EE, #6366F1);
  color: #04121A; font-weight: 700;
  box-shadow: 0 10px 26px rgba(34,211,238,0.25);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: rgba(255,255,255,0.05); border-color: var(--line); color: var(--txt);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn-danger { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #FCA5A5; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

.switch { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.switch input { accent-color: #22D3EE; width: 16px; height: 16px; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; margin: -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 12px 14px; font-size: 12px; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table th.ta-right, .table td.ta-right { text-align: right; }
.table td { padding: 13px 14px; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
.table tbody tr:hover { background: rgba(255,255,255,0.025); }
.table code { font-family: var(--mono); font-size: 12.5px; color: #A5F3FC; }
.cell-actions { display: flex; gap: 8px; justify-content: flex-end; }
.cell-strong { font-weight: 600; }
.cell-sub { font-size: 12.5px; color: var(--muted); display: block; }

/* ------------------------------------------------------------------- forms */
.form { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; color: var(--muted); }
.field > span { font-weight: 520; }
.field input[type="text"], .field input[type="password"], .field input[type="number"], .field select {
  width: 100%; padding: 11px 13px; border-radius: 11px;
  background: rgba(6, 10, 16, 0.75); border: 1px solid var(--line);
  color: var(--txt); font-family: inherit; font-size: 14px;
}
.field input:focus, .field select:focus {
  outline: none; border-color: rgba(34,211,238,0.55);
  box-shadow: 0 0 0 3px rgba(34,211,238,0.14);
}
.field input:disabled { opacity: 0.55; }
.field-inline { flex-direction: row; align-items: center; gap: 11px; }
.field-inline input { accent-color: #22D3EE; width: 17px; height: 17px; flex: none; }
.field-inline span { color: var(--txt); font-size: 13.5px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.45; }
.field textarea {
  width: 100%; padding: 11px 13px; border-radius: 11px;
  background: rgba(6, 10, 16, 0.75); border: 1px solid var(--line);
  color: var(--txt); font-family: inherit; font-size: 14px; resize: vertical;
}
.field textarea:focus { outline: none; border-color: rgba(34,211,238,0.55); box-shadow: 0 0 0 3px rgba(34,211,238,0.14); }
.form-foot, .modal-foot { display: flex; justify-content: flex-end; gap: 12px; }

/* ------------------------------------------------- pengaturan: baris berulang */
.repeat-list { display: flex; flex-direction: column; gap: 10px; }
.repeat-row {
  display: grid; grid-template-columns: 22px minmax(120px, 1fr) minmax(90px, 0.7fr) minmax(120px, 1fr) repeat(3, 32px);
  gap: 8px; align-items: center;
}
.repeat-row-step { grid-template-columns: 22px minmax(140px, 0.9fr) minmax(180px, 1.6fr) repeat(3, 32px); }
.repeat-row input {
  width: 100%; padding: 9px 11px; border-radius: 10px;
  background: rgba(6, 10, 16, 0.75); border: 1px solid var(--line);
  color: var(--txt); font-family: inherit; font-size: 13.5px;
}
.repeat-row input:focus { outline: none; border-color: rgba(34,211,238,0.55); box-shadow: 0 0 0 3px rgba(34,211,238,0.12); }
.repeat-handle { color: var(--muted); font-size: 13px; text-align: center; }
.repeat-foot { display: flex; justify-content: flex-start; }
@media (max-width: 720px) {
  .repeat-row, .repeat-row-step { grid-template-columns: 22px 1fr 32px 32px 32px; grid-auto-rows: auto; }
  .repeat-row input { grid-column: 2 / 6; }
  .repeat-row .repeat-handle { grid-row: 1 / 3; }
}

.alert {
  padding: 12px 15px; border-radius: 12px; font-size: 13.5px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--line); color: var(--txt);
}
.alert-error { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); color: #FCA5A5; }
.alert-warn { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.4); color: #FDE68A; }
.alert-ok { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.35); color: #86EFAC; }
.alert-info { background: rgba(34,211,238,0.1); border-color: rgba(34,211,238,0.3); color: #BAF3FF; }

/* ------------------------------------------------------------------ modals */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 6, 10, 0.78); backdrop-filter: blur(6px); }
.modal-body {
  position: relative;
  width: min(680px, 100%); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(22, 30, 42, 0.98), rgba(14, 19, 27, 0.98));
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  box-shadow: 0 30px 70px rgba(0,0,0,0.6);
  padding: 24px; display: flex; flex-direction: column; gap: 20px;
}
.modal-sm { width: min(420px, 100%); }
.modal-player { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-head strong { font-size: 16.5px; }
.modal-head small { display: block; font-size: 12.5px; margin-top: 3px; }
.modal-head-actions { display: flex; gap: 10px; }

/* ------------------------------------------------------- dashboard: header */
.dash-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.dash-head-left h2 { font-size: 20px; }
.dash-head-left p { font-size: 13px; margin-top: 3px; }
.dash-head-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.refresh-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px; font-size: 12.5px; color: var(--muted);
  background: rgba(34, 211, 238, 0.07); border: 1px solid rgba(34, 211, 238, 0.2);
}
.refresh-chip.stale { color: #FDE68A; border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.1); }

/* --------------------------------------------------- dashboard: statistik */
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 16px; }
.stat-card {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border-radius: var(--radius-lg);
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); backdrop-filter: blur(18px) saturate(160%);
}
.stat-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: 0.6;
}
.stat-card.is-bad::before { background: linear-gradient(90deg, #EF4444, #F59E0B); opacity: 0.85; }
.stat-ico {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  display: grid; place-items: center;
  background: rgba(34, 211, 238, 0.1); border: 1px solid rgba(34, 211, 238, 0.26); color: #A5F3FC;
}
.stat-ico svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.stat-ico svg .fill { fill: currentColor; stroke: none; }
.stat-ico.ok { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3); color: #86EFAC; }
.stat-ico.bad { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.32); color: #FCA5A5; }
.stat-ico.violet { background: rgba(99,102,241,0.13); border-color: rgba(99,102,241,0.32); color: #C7D2FE; }
.stat-body { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.stat-value { font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-hint { font-size: 11.5px; color: var(--muted); opacity: 0.85; }

/* ------------------------------------------------- dashboard: bilah filter */
.dash-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--radius-lg);
  background: rgba(20, 27, 38, 0.6); border: 1px solid var(--line);
}
.dash-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px; border-radius: 999px; cursor: pointer; font-family: inherit;
  font-size: 13px; color: var(--muted);
  background: rgba(255,255,255,0.04); border: 1px solid var(--line);
  transition: all 0.15s ease;
}
.chip:hover { color: var(--txt); border-color: var(--line-strong); }
.chip b {
  font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: rgba(255,255,255,0.08); color: inherit;
}
.chip.is-on { color: #05121A; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
.chip.is-on b { background: rgba(0,0,0,0.22); color: #04121A; }
.density { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); }
.density .icon-btn { height: 28px; min-width: 30px; font-size: 11px; letter-spacing: -1px; }
.density .icon-btn.is-on { color: var(--txt); background: rgba(34,211,238,0.16); border-color: rgba(34,211,238,0.4); }
.grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

/* ------------------------------------------------------- kartu kamera baru */
.tile-snap {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; opacity: 0.92;
}
.tile-overlay {
  position: absolute; inset: 0; padding: 10px 12px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 8px;
  pointer-events: none;
}
.tile-overlay .chip-live { align-self: flex-start; }
.chip-live {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 8px; font-size: 10.5px; font-weight: 750; letter-spacing: 0.07em;
  background: rgba(239, 68, 68, 0.92); color: #fff;
}
.chip-live .live-dot { background: #fff; box-shadow: none; }
.chip-clock {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 7px; color: #E8EEF7;
  background: rgba(6, 10, 16, 0.62); border: 1px solid rgba(255,255,255,0.08);
}
.tile-actions .icon-btn svg {
  width: 15px; height: 15px; display: block; margin: auto;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.tile-actions .icon-btn svg .fill { fill: currentColor; stroke: none; }
.tile-actions .icon-btn { display: grid; place-items: center; }
.tile[data-state="live"] .icon-btn[data-act="play"],
.tile[data-state="connecting"] .icon-btn[data-act="play"],
.tile[data-state="idle"] .icon-btn[data-act="stop"],
.tile[data-state="stopped"] .icon-btn[data-act="stop"] { opacity: 0.4; }
.tile.is-live .tile-snap { display: none; }

@media (max-width: 1100px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .dash-bar { padding: 12px; }
  .dash-bar-right { width: 100%; justify-content: space-between; }
}

/* -------------------------------------------------------------------- peta */
.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 470px;
  gap: 22px;
  align-items: start;
}
.map-card { padding: 14px; gap: 12px; }
.map-canvas {
  height: clamp(420px, calc(100vh - 300px), 700px);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0B1119;
}

/* chip daftar kamera di bawah peta */
.map-chips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 118px; overflow-y: auto; padding: 2px; }
.map-item {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
  font-size: 13px; transition: all 0.15s ease;
}
.map-item:hover { border-color: var(--line-strong); background: rgba(34, 211, 238, 0.1); }
.map-item.is-active { border-color: rgba(34,211,238,0.5); background: rgba(34, 211, 238, 0.14); }
.map-item strong { font-weight: 560; }

/* ------------------------------------------------- dinding video (map page) */
.wall-card { padding: 16px; gap: 14px; }
.wall-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wall-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 12px;
  max-height: calc(100vh - 250px);
  min-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}
.wall-tile {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: rgba(9, 13, 19, 0.6);
  transition: border-color 0.15s ease;
}
.wall-tile.is-live { border-color: rgba(34, 211, 238, 0.4); }
.wall-tile:hover { border-color: var(--line-strong); }
.wall-video {
  position: relative; aspect-ratio: 16 / 9; background: #05080C;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 26px 26px;
  cursor: zoom-in;
}
.wall-video video { width: 100%; height: 100%; object-fit: cover; display: block; background: #05080C; }
.wall-video img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; opacity: 0.85;
}
.wall-state {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center; padding: 8px;
  background: rgba(5, 8, 12, 0.72); font-size: 11.5px; color: var(--muted);
}
.wall-state.hide { display: none; }
.wall-state.error { color: #FCA5A5; }
.wall-state .spinner { width: 20px; height: 20px; }
.wall-foot {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; border-top: 1px solid var(--line);
  background: rgba(9, 13, 19, 0.75);
}
.wall-foot strong {
  font-size: 11.5px; font-weight: 560; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wall-foot .dot { width: 7px; height: 7px; }
.wall-btn {
  flex: none; min-width: 24px; height: 24px; padding: 0 5px;
  border-radius: 7px; cursor: pointer; font-size: 11px; line-height: 1;
  background: rgba(255,255,255,0.05); border: 1px solid var(--line); color: var(--muted);
}
.wall-btn:hover { color: var(--txt); background: rgba(34,211,238,0.16); border-color: rgba(34,211,238,0.35); }
.wall-badge {
  flex: none; font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 999px; color: var(--muted);
  background: rgba(255,255,255,0.06); border: 1px solid var(--line);
}
.wall-badge.live { color: #A5F3FC; border-color: rgba(34,211,238,0.4); background: rgba(34,211,238,0.14); }
.wall-badge.wait { color: #FDE68A; border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.12); }

.map-legend {
  display: flex; flex-wrap: wrap; gap: 16px;
  padding: 4px 6px 2px; font-size: 12.5px; color: var(--muted);
}
.map-legend span { display: inline-flex; align-items: center; gap: 7px; }

/* peta gelap: tile OSM standard dibalik warnanya agar sesuai tema control room */
.map-canvas .leaflet-tile-pane,
.pick-map .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(0.92) contrast(1.05) saturate(0.7); }
.leaflet-container { background: #0B1119; font-family: Inter, system-ui, sans-serif; }
.leaflet-control-attribution {
  background: rgba(8, 12, 18, 0.8) !important; color: #8B98AB !important;
  font-size: 10.5px !important; border-radius: 8px 0 0 0;
}
.leaflet-control-attribution a { color: #A5F3FC !important; }
.leaflet-bar a, .leaflet-bar a:hover {
  background: rgba(20, 27, 38, 0.95) !important; color: var(--txt) !important;
  border-bottom-color: var(--line) !important;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: rgba(20, 27, 38, 0.97); color: var(--txt);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow);
}
.leaflet-popup-content-wrapper { border-radius: 14px; }
.leaflet-popup-content { margin: 14px 16px; font-size: 13.5px; min-width: 210px; }
.leaflet-popup-close-button { color: var(--muted) !important; }
.cam-pop { display: flex; flex-direction: column; gap: 9px; }
.cam-pop strong { font-size: 14.5px; }
.cam-pop small { color: var(--muted); font-size: 12px; }
.cam-pop-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.cam-pop img { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #05080C; display: block; }
.cam-pop-actions { display: flex; gap: 8px; }
.cam-pop-actions .btn { flex: 1; padding: 7px 10px; font-size: 12.5px; }

/* penanda kamera */
.cam-marker { background: none; border: none; }
.cam-marker span {
  display: block; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.92);
  box-shadow: 0 4px 12px rgba(0,0,0,0.55);
  background: #64748B; transition: transform 0.15s ease;
}
.cam-marker:hover span { transform: scale(1.16); }
.cam-marker.is-live span { animation: pulse 1.6s infinite; }
.cam-marker-online span { background: var(--ok); }
.cam-marker-offline span { background: var(--bad); }
.cam-marker-live span { background: var(--accent); }
.cam-marker-unknown span { background: #64748B; }

/* pemilih titik di form kamera */
.pick-map { height: 240px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #0B1119; }
.pick-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pick-search {
  flex: 1 1 180px; min-width: 140px;
  padding: 8px 11px; border-radius: 10px;
  background: rgba(6, 10, 16, 0.75); border: 1px solid var(--line);
  color: var(--txt); font-family: inherit; font-size: 13px;
}
.pick-search:focus { outline: none; border-color: rgba(34,211,238,0.55); box-shadow: 0 0 0 3px rgba(34,211,238,0.14); }
.pick-coords { display: flex; justify-content: space-between; gap: 12px; align-items: center; font-size: 12px; }
.pick-coords code { font-family: var(--mono); font-size: 12px; color: #A5F3FC; }

@media (max-width: 1180px) {
  .map-layout { grid-template-columns: minmax(0, 1fr); }
  .map-canvas { height: clamp(320px, 52vh, 520px); }
  .wall-grid { max-height: none; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ------------------------------------------------------------------ toasts */
.toast-wrap { position: fixed; right: 24px; bottom: 24px; z-index: 80; display: flex; flex-direction: column; gap: 12px; }
.toast {
  min-width: 260px; max-width: 380px;
  padding: 13px 16px; border-radius: 12px; font-size: 13.5px;
  background: rgba(22, 30, 42, 0.97); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); animation: slideIn 0.2s ease;
}
.toast-ok { border-color: rgba(34,197,94,0.45); color: #86EFAC; }
.toast-bad { border-color: rgba(239,68,68,0.45); color: #FCA5A5; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------- login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 32px 20px; }
.login-bg {
  position: fixed; inset: 0;
  background:
    radial-gradient(760px 460px at 20% 10%, rgba(34,211,238,0.16), transparent 62%),
    radial-gradient(700px 460px at 85% 85%, rgba(99,102,241,0.18), transparent 62%);
}
.login-card {
  position: relative;
  width: min(420px, 100%);
  display: flex; flex-direction: column; gap: 18px;
  padding: 34px 30px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.55);
  backdrop-filter: blur(20px) saturate(170%);
}
.login-card h1 { font-size: 21px; text-align: center; }
.login-card > p { text-align: center; font-size: 13.5px; }
.login-foot { text-align: center; font-size: 12px; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 14px; overflow-x: auto; padding: 12px 14px; }
  .sidebar .brand { flex: none; }
  .sidebar .nav { flex-direction: row; gap: 10px; flex: 1; }
  .nav-group { flex-direction: row; gap: 4px; }
  .nav-label { display: none; }
  .nav-group + .nav-group { border-left: 1px solid var(--line); padding-left: 8px; }
  .nav-badge { min-width: 20px; padding: 1px 6px; font-size: 10.5px; }
  .nav-text { overflow: visible; }
  .side-link { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .user-chip { display: none; }
  .topbar { position: static; padding: 18px 20px; }
  .content { padding: 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
}
