/* Mobile dashboard (static/js/mobile-dashboard-component.js). Every rule is scoped to
 * html.ccm-mode, which the mobile layout sets, so the desktop view is unaffected. */
html.ccm-mode, html.ccm-mode body {
  background: #040a17;
  color: #cfe8ff;
  -webkit-text-size-adjust: 100%;
}
html.ccm-lock, html.ccm-lock body { overflow: hidden !important; }
html.ccm-mode [hidden] { display: none !important; }

.ccm-app {
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  font-family: 'Rajdhani', system-ui, sans-serif;
  font-size: 15px;
  background: radial-gradient(130% 70% at 50% 0%, #0a1c38 0%, #061026 50%, #03060f 100%);
}
.ccm-app button { font: inherit; color: inherit; }

/* App bar */
.ccm-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px;
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  background: rgba(4, 12, 28, .94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 200, 255, .18);
}
.ccm-logo { width: 30px; height: 34px; object-fit: contain; flex: none; }
.ccm-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.05; }
.ccm-title strong { font-size: 17px; letter-spacing: 2px; color: #eaf7ff; white-space: nowrap; }
.ccm-title span { font-size: 11.5px; letter-spacing: 1px; color: #6f97bd; white-space: nowrap; }
.ccm-live {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px; font: 600 11px/1 'IBM Plex Mono', monospace; letter-spacing: 1px;
  color: #1fe6a0; border: 1px solid rgba(31, 230, 160, .35); background: rgba(31, 230, 160, .07);
}
.ccm-live i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: ccBlink 1.8s infinite; }
.ccm-live.off { color: #ff4d5e; border-color: rgba(255, 77, 94, .35); background: rgba(255, 77, 94, .07); }
.ccm-live.off i { animation: none; }
.ccm-bell {
  position: relative; display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; background: rgba(255, 80, 94, .08);
  border: 1px solid rgba(255, 80, 94, .3); color: #ffb4bb; cursor: pointer;
}
.ccm-bell b, .ccm-tab b {
  position: absolute; top: 3px; right: 3px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: #ff4d5e; color: #fff; font: 700 11px/18px 'IBM Plex Mono', monospace; text-align: center;
}

/* Content */
.ccm-main {
  max-width: 880px; margin: 0 auto;
  padding: 12px max(12px, env(safe-area-inset-right)) 16px max(12px, env(safe-area-inset-left));
}
.ccm-stack { display: flex; flex-direction: column; gap: 12px; }
.ccm-card {
  padding: 12px 14px; background: linear-gradient(160deg, rgba(10, 26, 52, .78), rgba(6, 16, 34, .7));
  border: 1px solid rgba(0, 200, 255, .16); border-top: 2px solid #00d9ff;
}
.ccm-card h2 { margin: 0 0 8px; font-size: 14px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: #9fd4f5; }
.ccm-empty { margin: 6px 0; color: #7fa8c9; font-size: 14px; }
.ccm-note { margin: 4px 0 10px; color: #7fa8c9; font-size: 13px; line-height: 1.35; }

/* KPI */
.ccm-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ccm-kpi {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; min-height: 76px;
  background: linear-gradient(160deg, rgba(8, 24, 48, .85), rgba(6, 14, 32, .7));
  border: 1px solid rgba(0, 200, 255, .16); border-top: 3px solid;
}
.ccm-kpi.wide { grid-column: 1 / -1; }
.ccm-kpi-label { font: 600 10.5px/1.25 'IBM Plex Mono', monospace; letter-spacing: .8px; color: #7fa8c9; }
.ccm-kpi-value { font-size: 26px; font-weight: 700; line-height: 1; margin-top: auto; }
.ccm-kpi-value small { display: block; margin: 2px 0 0 !important; }
.ccm-kpi.wide .ccm-kpi-value small { display: inline; margin-left: 8px !important; }
.ccm-kpi.wide .ccm-kpi-value { font-size: 40px; }
.ccm-kpi-value small { margin-left: 6px; font-size: 14px; font-weight: 600; color: #9fc3e0; }

/* Rows (attention list, alerts, unplaced cameras) */
.ccm-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px;
  padding: 8px 4px; text-align: left; cursor: pointer;
  background: transparent; border: 0; border-bottom: 1px solid rgba(0, 140, 220, .12);
}
.ccm-row:last-child { border-bottom: 0; }
.ccm-row svg { flex: none; color: #5f86b0; }
.ccm-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ccm-row-main strong { font-size: 15.5px; font-weight: 700; color: #eaf7ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccm-row-main span { font-size: 13px; color: #8fb3d1; }
.ccm-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.ccm-bar-sev { flex: none; align-self: stretch; width: 4px; border-radius: 2px; }

/* Gauges */
.ccm-gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ccm-gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ccm-gauge span { font: 600 11px/1.2 'IBM Plex Mono', monospace; letter-spacing: .8px; color: #7fa8c9; text-align: center; }

/* Sensors (simulated) */
.ccm-sensors summary { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; list-style: none; }
.ccm-sensors summary::-webkit-details-marker { display: none; }
.ccm-sensors summary h2 { margin: 0; }
.ccm-sensors summary::after { content: '▾'; margin-left: auto; color: #6f97bd; }
.ccm-sensors[open] summary::after { content: '▴'; }
.ccm-badge {
  padding: 2px 8px; font: 700 11px/1.5 'IBM Plex Mono', monospace; letter-spacing: 1px;
  color: #ffb12e; border: 1px solid rgba(255, 177, 46, .5); background: rgba(255, 177, 46, .1);
}
.ccm-sensor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; opacity: .8; }
.ccm-sensor { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 6px 0; border-bottom: 1px dashed rgba(0, 200, 255, .12); }
.ccm-sensor span { font-size: 13px; color: #a9c8e2; }
.ccm-sensor strong { font: 600 15px 'IBM Plex Mono', monospace; }
.ccm-sensor small { margin-left: 3px; font-size: 10px; color: #6f97bd; }

/* Buttons */
.ccm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ccm-btn {
  display: grid; place-items: center; min-height: 48px; padding: 0 14px;
  font-weight: 700; font-size: 15px; letter-spacing: 1px; text-decoration: none; text-align: center;
  color: #cfe8ff; background: rgba(0, 200, 255, .06); border: 1px solid rgba(0, 200, 255, .35); cursor: pointer;
}
.ccm-btn.primary { color: #04101f; background: #00d9ff; border-color: #00d9ff; }
.ccm-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #6f97bd; font-size: 13px; }
.ccm-link { min-height: 44px; padding: 0 4px; background: none; border: 0; color: #4fc3ff !important; text-decoration: underline; cursor: pointer; }
.ccm-icon-btn { display: grid; place-items: center; width: 44px; height: 44px; flex: none; background: none; border: 0; color: #9fc3e0; cursor: pointer; }

/* Camera list (reuses the desktop card) */
.ccm-search {
  width: 100%; min-height: 46px; padding: 0 14px; font: 15px 'IBM Plex Mono', monospace;
  color: #cfe8ff; background: rgba(4, 14, 30, .85); border: 1px solid rgba(0, 200, 255, .3); outline: none;
}
.ccm-search:focus { border-color: #00e5ff; }
.ccm-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.ccm-chips::-webkit-scrollbar { display: none; }
.ccm-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  font-weight: 700; font-size: 14px; letter-spacing: .5px; cursor: pointer;
  background: rgba(4, 14, 30, .8); border: 1px solid rgba(0, 200, 255, .22); color: #9fc3e0;
}
.ccm-chip b { font: 600 12px 'IBM Plex Mono', monospace; color: #6f97bd; }
.ccm-chip.on { background: rgba(0, 229, 255, .14); border-color: #00e5ff; color: #eaf7ff; }
.ccm-chip.on b { color: #00e5ff; }
.ccm-cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 600px) { .ccm-cards { grid-template-columns: 1fr 1fr; } }
.ccm-card-wrap { min-width: 0; }
/* desktop card: video area 16:9 and readable text on a phone */
.ccm-cards .cc-clickable > div:first-child { height: auto !important; aspect-ratio: 16 / 9; }
.ccm-cards .cc-clickable > div:first-child > div:last-child > span:first-child { font-size: 14px !important; }
.ccm-cards .cc-clickable > div:first-child > div:last-child > span:last-child { font-size: 11px !important; }
.ccm-cards .cc-clickable > div:first-child > div:first-child > span:first-child { font-size: 12px !important; padding: 2px 7px !important; }
.ccm-cards .cc-clickable > div:last-child > div > div:nth-child(1) { font-size: 10.5px !important; }
.ccm-cards .cc-clickable > div:last-child > div > div:nth-child(2) { font-size: 19px !important; }
.ccm-cards .cc-clickable > div:last-child > div > div:nth-child(3) { font-size: 11px !important; }
.ccm-cards .cc-clickable > div:last-child > div { padding: 7px 9px 8px !important; }

/* Map */
.ccm-map {
  position: relative; overflow: hidden; width: 100%;
  height: clamp(320px, calc(100svh - 56px - 76px - 120px - env(safe-area-inset-bottom)), 130vw);
  background: radial-gradient(120% 120% at 50% 45%, #08203f 0%, #05122a 55%, #030a18 100%);
  border: 1px solid rgba(0, 200, 255, .2); border-top: 2px solid #00d9ff;
  -webkit-user-select: none; user-select: none;
}
@media (max-height: 500px) and (orientation: landscape) {
  .ccm-map { height: clamp(220px, calc(100svh - 56px - 76px - 12px - env(safe-area-inset-bottom)), 130vw); }
}
.ccm-map-box { position: absolute; top: 50%; left: 50%; transform-origin: center; z-index: 2; }
.ccm-map-box img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none;
  filter: drop-shadow(0 0 2px rgba(0, 229, 255, .55));
}
.ccm-seg { position: absolute; top: 8px; left: 8px; z-index: 12; display: flex; border: 1px solid rgba(0, 200, 255, .35); }
.ccm-seg button {
  min-height: 40px; padding: 0 12px; font-weight: 700; font-size: 13.5px; letter-spacing: .5px; cursor: pointer;
  background: rgba(4, 14, 30, .88); border: 0; color: #9fc3e0;
}
.ccm-seg button.on { background: #00d9ff; color: #04101f; }
.ccm-zoom { position: absolute; right: 8px; bottom: 8px; z-index: 12; display: flex; flex-direction: column; gap: 6px; }
.ccm-zoom button {
  width: 46px; height: 46px; font-size: 20px; cursor: pointer;
  background: rgba(4, 14, 30, .9); border: 1px solid rgba(0, 200, 255, .35); color: #9fd4f5;
}
.ccm-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: #9fc3e0; }
.ccm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ccm-legend i { width: 10px; height: 10px; border-radius: 50%; }

/* Bottom sheet (map selection) */
.ccm-sheet {
  position: fixed; z-index: 70; left: 8px; right: 8px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; padding: 10px 12px 12px;
  background: linear-gradient(160deg, rgba(10, 28, 56, .98), rgba(6, 16, 34, .98));
  border: 1px solid rgba(0, 200, 255, .35); border-top: 2px solid #00d9ff;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .5);
  animation: ccmUp .18s ease-out;
}
@keyframes ccmUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.ccm-sheet-head { display: flex; align-items: center; gap: 10px; }
.ccm-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: rgba(0, 200, 255, .1); }
.ccm-tile { display: flex; flex-direction: column; gap: 2px; padding: 8px; background: rgba(6, 16, 34, .95); border-bottom: 2px solid; min-width: 0; }
.ccm-tile-label { font: 600 10.5px 'IBM Plex Mono', monospace; letter-spacing: .6px; color: #6f97bd; }
.ccm-tile-value { font: 700 18px 'IBM Plex Mono', monospace; }
.ccm-tile-sub { font-size: 11.5px; color: #8fb3d1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bottom tabs */
.ccm-tabs {
  position: fixed; z-index: 60; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: rgba(4, 12, 28, .96);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 200, 255, .2);
}
.ccm-tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 64px; background: none; border: 0; cursor: pointer; color: #6f97bd;
  font-size: 12.5px; font-weight: 700; letter-spacing: .6px;
}
.ccm-tab span { text-transform: uppercase; letter-spacing: 1px; font-size: 12px; }
.ccm-tab.on { color: #00e5ff; box-shadow: inset 0 2px 0 #00e5ff; }
.ccm-tab b { top: 6px; right: calc(50% - 26px); }
.ccm-tab b.dim { background: #3f5d7a; }

/* Camera popup (Jp) full screen */
html.ccm-mode [role="dialog"][aria-label^="Kamera "] {
  padding: 0 !important; place-items: stretch !important; background: #040a17 !important;
}
html.ccm-mode [role="dialog"][aria-label^="Kamera "] > div {
  width: 100% !important; max-height: none !important; height: 100% !important;
  clip-path: none !important; border: 0 !important; overflow-y: auto; overscroll-behavior: contain;
}
html.ccm-mode .dual-camera-dialog-header {
  position: sticky; top: 0; z-index: 3; background: #071a33;
  padding-top: calc(10px + env(safe-area-inset-top)) !important;
}
html.ccm-mode .dual-camera-dialog-header { padding-right: 60px !important; min-height: 56px; }
html.ccm-mode .dual-camera-dialog-header > span:nth-child(3) { display: none; }   /* "Tekan Esc untuk menutup" */
html.ccm-mode .dual-camera-dialog-header > button[aria-label="Tutup"] {
  position: absolute; right: 8px; top: calc(6px + env(safe-area-inset-top));
  min-width: 44px; min-height: 44px; margin: 0 !important;
}
html.ccm-mode .dual-camera nav button { min-height: 44px; padding: 0 14px; font-size: 14px; }
html.ccm-mode .dual-camera-dialog-body { padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important; }

/* Report widget: opened from the Ringkasan tab instead of the floating button */
html.ccm-mode .cthm-report-fab { display: none !important; }
html.ccm-mode .cthm-report-card {
  left: 10px !important; right: 10px !important; width: auto !important;
  bottom: calc(80px + env(safe-area-inset-bottom)) !important;
  max-height: calc(100svh - 170px); overflow-y: auto;
}

/* Desktop view forced on a small screen: way back to the mobile view */
.ccm-back-mobile {
  position: fixed; z-index: 100000; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  min-height: 44px; padding: 0 16px; font: 700 14px 'Rajdhani', sans-serif; letter-spacing: 1px;
  color: #04101f; background: #00d9ff; border: 0; box-shadow: 0 4px 16px rgba(0, 0, 0, .5); cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  html.ccm-mode *, html.ccm-mode *::before, html.ccm-mode *::after { animation: none !important; transition: none !important; }
}

/* Alerts + event log under the map */
.ccm-anchor { scroll-margin-top: calc(64px + env(safe-area-inset-top)); }
.ccm-h { display: flex; align-items: center; gap: 8px; }
.ccm-count {
  min-width: 24px; height: 22px; padding: 0 7px; border-radius: 11px; text-align: center;
  font: 700 12.5px/22px 'IBM Plex Mono', monospace; color: #9fc3e0; background: rgba(0, 200, 255, .12);
}
.ccm-count.hot { color: #fff; background: #ff4d5e; }
.ccm-ok {
  display: flex; align-items: center; gap: 10px; padding: 12px; font-size: 15px; color: #9fe8c9;
  background: rgba(31, 230, 160, .07); border: 1px solid rgba(31, 230, 160, .25);
}
.ccm-ok span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(31, 230, 160, .18); font-weight: 700; }
.ccm-alert {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 72px; margin-bottom: 8px; padding: 10px 10px 10px 12px;
  text-align: left; cursor: pointer; color: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--sev) 16%, transparent), rgba(6, 16, 34, .6));
  border: 1px solid color-mix(in srgb, var(--sev) 45%, transparent); border-left: 4px solid var(--sev);
}
.ccm-alert:last-child { margin-bottom: 0; }
.ccm-alert > svg { flex: none; color: #9fc3e0; }
.ccm-alert-icon {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; font-size: 21px;
  background: color-mix(in srgb, var(--sev) 22%, transparent); border: 1px solid var(--sev);
}
.ccm-alert-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.ccm-alert-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ccm-alert-top strong { font-size: 16.5px; line-height: 1.2; color: #f2f9ff; }
.ccm-alert-top em {
  flex: none; padding: 2px 8px; font: 700 11px/1.5 'IBM Plex Mono', monospace; font-style: normal;
  letter-spacing: 1px; text-transform: uppercase; color: #04101f; background: var(--sev);
}
.ccm-alert-cam { font-size: 14.5px; font-weight: 700; color: #cfe8ff; }
.ccm-alert-meta { font: 12.5px 'IBM Plex Mono', monospace; color: #8fb3d1; }
.ccm-timeline { list-style: none; margin: 0; padding: 0; }
.ccm-timeline button {
  display: grid; grid-template-columns: 62px 14px minmax(0, 1fr); align-items: start; gap: 8px; width: 100%;
  min-height: 52px; padding: 8px 2px; text-align: left; cursor: pointer; color: inherit;
  background: none; border: 0; border-bottom: 1px solid rgba(0, 140, 220, .12);
}
.ccm-timeline li:last-child button { border-bottom: 0; }
.ccm-timeline time { font: 600 12.5px/20px 'IBM Plex Mono', monospace; color: #7fa8c9; }
.ccm-timeline i { width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: var(--sev); box-shadow: 0 0 8px var(--sev); }
.ccm-tl-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ccm-tl-main strong { font-size: 15px; line-height: 1.25; color: #eaf7ff; }
.ccm-tl-main span { font-size: 13px; color: #8fb3d1; }
.ccm-more { display: block; margin: 6px auto 0; }

/* ADMIN tab: admin page in a frame filling the screen between the bars */
.ccm-main.admin { padding-top: 8px; padding-bottom: 0; }
.ccm-admin { display: flex; flex-direction: column; gap: 8px; }
.ccm-admin-bar { display: flex; align-items: center; gap: 8px; }
.ccm-admin-bar strong { flex: 1; font-size: 15px; letter-spacing: 1.5px; text-transform: uppercase; color: #9fd4f5; }
.ccm-btn.small { min-height: 40px; padding: 0 12px; font-size: 13.5px; }
.ccm-admin-frame {
  position: relative;
  height: calc(100svh - 56px - 76px - 64px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  min-height: 360px; border: 1px solid rgba(0, 200, 255, .22); background: #0b1220;
}
.ccm-admin-frame iframe { display: block; width: 100%; height: 100%; border: 0; background: #0b1220; }
.ccm-admin-note {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center; color: #9fc3e0; background: #0b1220;
}
.ccm-admin-note strong { font-size: 18px; color: #eaf7ff; }
.ccm-admin-note p { margin: 0; max-width: 320px; font-size: 14.5px; line-height: 1.4; }
.ccm-admin-note .ccm-btn { min-width: 160px; }

