/* Dashboard — light operations console */

/* ---------- login ---------- */
.loginScreen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 22px; background:
    radial-gradient(1200px 600px at 80% -10%, #e7e9ff 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #e3f4ee 0%, transparent 55%),
    var(--bg);
}
.loginCard { width: min(420px, 100%); padding: 30px 28px; }
.loginMark {
  width: 46px; height: 46px; border-radius: 13px; background: var(--brand-600); color: #fff;
  font-weight: 800; font-size: 22px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px; box-shadow: var(--shadow-2);
}
.loginMark span { color: #c7c4ff; }
.loginTitle { font-size: 24px; margin: 6px 0; }
.loginSub { font-size: 13px; margin: 0 0 18px; }
.pwWrap { position: relative; }
.pwToggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 6px 8px; border-radius: 8px; }
.loginScreen .btn-block { margin-top: 16px; }
.loginErr { color: var(--bad-600); font-size: 13px; min-height: 18px; margin: 10px 0 0; font-weight: 600; }

/* ---------- app shell ---------- */
.app { max-width: 1180px; margin: 0 auto; padding: 0 18px 60px; }
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 18px;
  padding: 14px 4px; background: linear-gradient(var(--bg), rgba(236,239,245,.86));
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brandMark {
  width: 38px; height: 38px; border-radius: 11px; background: var(--brand-600); color: #fff;
  font-weight: 800; font-size: 18px; display: flex; align-items: center; justify-content: center;
}
.brandMark span { color: #c7c4ff; }
.brandMark.hasImage, .loginMark.hasImage {
  background-size: cover;
  background-position: center;
  color: transparent;
}
.brandMark.hasImage span, .loginMark.hasImage span { display: none; }
.brandName { font-weight: 700; font-size: 15px; }
.brandSub { font-size: 10px; }
.tabs { display: flex; gap: 4px; margin-left: 8px; background: var(--surface-2); padding: 4px; border-radius: var(--r-sm); border: 1px solid var(--line); }
.tab {
  appearance: none; border: none; background: transparent; cursor: pointer;
  font-family: var(--font-ui); font-weight: 600; font-size: 14px; color: var(--ink-500);
  padding: 8px 16px; border-radius: 8px; transition: all .15s ease;
}
.tab:hover { color: var(--ink-900); }
.tab.is-active { background: var(--surface); color: var(--brand-700); box-shadow: var(--shadow-1); }
.topActions { margin-left: auto; }

/* ---------- panels ---------- */
.panel { display: none; padding-top: 22px; }
.panel.is-active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panelHead { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.panelTitle { font-size: 20px; }
.storeSearchCard { padding: 14px 16px; margin-bottom: 12px; }

/* ---------- stat cards ---------- */
.statGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow-1); }
.stat .k { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-400); font-weight: 700; }
.stat .v { font-family: var(--font-mono); font-size: 30px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.stat.accent .v { color: var(--brand-600); }
.stat.ok .v { color: var(--ok-600); }
.stat.bad .v { color: var(--bad-600); }

/* ---------- live grid ---------- */
.liveGrid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; }
.cardHead { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.cardHead h3 { font-size: 15px; }

/* feed = signature element: monospace telemetry stream */
.feed { max-height: 560px; overflow: auto; }
.feedRow { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.feedRow:last-child { border-bottom: none; }
.feedTime { font-family: var(--font-mono); font-size: 13px; color: var(--ink-500); }
.feedWho { font-weight: 600; font-size: 14px; }
.feedWhere { font-size: 12.5px; color: var(--ink-400); margin-top: 1px; }
.feedRow.in { box-shadow: inset 3px 0 0 var(--ok-600); }
.feedRow.out { box-shadow: inset 3px 0 0 var(--bad-600); }

.visits { max-height: 560px; overflow: auto; padding: 6px 0; }
.visit { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.visit:last-child { border-bottom: none; }
.visitTop { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.visitWho { font-weight: 600; font-size: 14px; }
.visitStore { font-size: 12.5px; color: var(--ink-400); }
.visitTime { font-family: var(--font-mono); font-size: 12px; color: var(--ink-500); margin-top: 4px; }

/* ---------- tables ---------- */
.tableWrap { overflow: hidden; }
.tableWrap .tbl { display: table; }
.coordCell { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-500); }
.rowActions { display: flex; gap: 6px; justify-content: flex-end; }
.iconBtn {
  appearance: none; border: 1px solid var(--line-strong); background: var(--surface);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; color: var(--ink-500);
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
}
.iconBtn:hover { background: var(--surface-2); color: var(--ink-900); }
.iconBtn.danger:hover { color: var(--bad-600); border-color: var(--bad-600); }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .liveGrid { grid-template-columns: 1fr; }
  .statGrid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tab { flex: 1; text-align: center; }
  .topActions { margin-left: auto; }
  .tableWrap { overflow-x: auto; }
  .tbl { min-width: 640px; }
}

/* ---------- filters ---------- */
.filterBar { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; padding: 14px 16px; margin-bottom: 14px; }
.filterBar .field label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-400); }

/* ---------- map ---------- */
.mapCard { margin-bottom: 14px; overflow: hidden; position: relative; }
.mapTools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mapToggles { display: flex; gap: 12px; }
.mapTgl { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-700); cursor: pointer; }
.mapTgl input { accent-color: var(--brand-600); }
.map { height: 420px; width: 100%; background: var(--surface-2); }
body.dark .map .leaflet-tile { filter: brightness(.74) contrast(1.08) saturate(.82); }
.mapCard.fs { position: fixed; inset: 12px; z-index: 7000; margin: 0; box-shadow: var(--shadow-3); }
.mapCard.fs .map { height: calc(100vh - 84px); }
.pickMap { height: 220px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); margin-top: 8px; }

/* leaflet marker chips */
.mk { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.mk-in { background: var(--ok-600); }
.mk-out { background: var(--bad-600); }
.mk-store { background: var(--brand-600); border-radius: 4px; transform: rotate(45deg); }
.mkStorePretty {
  width: 20px;
  height: 20px;
  border-radius: 999px 999px 999px 4px;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.34);
  display: grid;
  place-items: center;
}
.mkStorePretty span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.95);
  display: block;
}
.mk-store-active { background: #86efac; }
.mk-store-hold { background: #fde68a; }
.mk-store-blacklist { background: #9ca3af; }
.storeClusterIcon {
  width: 32px;
  height: 32px;
  box-sizing: border-box;
  border-radius: 999px;
  background: rgba(15,23,42,.92);
  color: #f8fafc;
  border: 2px solid rgba(148,163,184,.76);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(2,6,23,.32);
}
.mk-sales {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--sales-color);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.45);
}
.mk-sales span {
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.55);
}
.myLocPin {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #38bdf8;
  border: 3px solid #fff;
  box-shadow: 0 0 0 7px rgba(56,189,248,.24), 0 2px 10px rgba(0,0,0,.42);
}
.locateMapControl { margin-right: 12px !important; margin-bottom: -8px !important; }
.locateMapDot {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.28);
  cursor: pointer;
  position: relative;
}
.locateMapDot::before {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 999px;
  background: #1a73e8;
  box-shadow: 0 0 0 5px rgba(26,115,232,.16);
}
.locateMapDot::after {
  content: "";
  position: absolute;
  left: 20px;
  top: 5px;
  width: 2px;
  height: 32px;
  background: rgba(26,115,232,.20);
  transform: rotate(45deg);
}
.locateMapDot.is-loading::before { animation: pulseLoc 1s ease-in-out infinite; }
.locateMapDot.is-on::before { background: #0ea5e9; }
@keyframes pulseLoc { 50% { transform: scale(.72); opacity: .62; } }
.mapLegend {
  position: absolute;
  left: 14px;
  bottom: 4px;
  z-index: 500;
  max-width: min(680px, calc(100% - 28px));
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(15,23,42,.78);
  color: #f8fafc;
  box-shadow: 0 12px 30px rgba(0,0,0,.24);
  backdrop-filter: blur(12px);
}
.mapLegend.legend-empty { display: none; }
.mapLegend.is-collapsed {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  overflow: hidden;
  align-items: center;
  justify-content: center;
}
.map .leaflet-bottom.leaflet-right .leaflet-control-attribution {
  margin-right: 58px;
  margin-bottom: -2px;
  opacity: .72;
}
.mapLegend.is-collapsed .legendTitle,
.mapLegend.is-collapsed .legendList { display: none; }
.legendMinBtn {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.24);
  background: rgba(255,255,255,.12);
  color: #fff;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.mapLegend.is-collapsed .legendMinBtn {
  width: 42px;
  height: 42px;
  border: 0;
  background: rgba(15,23,42,.92);
  color: #38bdf8;
  font-size: 20px;
}
.legendTitle {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(255,255,255,.74);
  padding-top: 2px;
}
.legendList {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-height: 74px;
  overflow: auto;
}
.legItem {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}
.legItem i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.72);
  flex: 0 0 auto;
}
.pillBtn { cursor: pointer; border: 0; font-family: inherit; }
.photoModalCard { width: min(780px, 100%); }
.photoModalBody { margin-top: 14px; }
.attendancePhotoPreview {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: var(--r);
  background: #000;
}
.dangerSummary {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-700);
}
.dangerSummary b { color: var(--ink-900); }
.dangerCheck {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
}
.btn-danger {
  background: var(--bad-600);
  border-color: var(--bad-600);
  color: #fff;
}
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }
.infoBody { margin-top: 14px; font-size: 14px; line-height: 1.5; color: var(--ink-700); }
.infoGrid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.infoGrid > div { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-sm); padding: 12px; }
.infoGrid b { display: block; font-size: 20px; color: var(--ink-900); }
.infoGrid span { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-500); }
.brandSettingsCard { padding: 18px; }
.brandPreview { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.brandPreview img { width: 58px; height: 58px; border-radius: 14px; object-fit: cover; border: 1px solid var(--line); background: var(--surface-2); }
.brandPreviewName { font-size: 20px; font-weight: 800; color: var(--ink-900); }
.brandPreviewSub { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-500); }
.brandForm { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.brandForm .grow { grid-column: 1 / -1; }
.iconUploadGrid { display: grid; gap: 8px; }
.iconUploadRow {
  display: grid;
  grid-template-columns: 110px auto auto minmax(120px, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.iconUploadRow span { font-weight: 800; color: var(--ink-900); }
.iconUploadRow em { font-style: normal; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 680px) { .brandForm { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .iconUploadRow { grid-template-columns: 1fr 1fr; } .iconUploadRow em { grid-column: 1 / -1; } }
.leaflet-popup-content { font-family: var(--font-ui); font-size: 13px; }
.leaflet-popup-content b { font-weight: 700; }
.leaflet-popup.storePopup .leaflet-popup-content-wrapper {
  border-radius: 18px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(8,12,24,.96), rgba(22,28,45,.94));
  box-shadow: 0 22px 48px rgba(2,6,23,.38);
  color: #f8fafc;
}
.leaflet-popup.storePopup .leaflet-popup-tip { background: rgba(18,24,38,.96); }
.leaflet-popup.storePopup .leaflet-popup-content { margin: 0; min-width: 260px; }
.storePopupBody { min-width: 246px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.storePopupName { font-size: 16px; font-weight: 900; line-height: 1.18; padding-right: 28px; }
.storePopupCode {
  width: fit-content; max-width: 100%; border-radius: 999px; padding: 4px 9px;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.07);
  font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase;
}
.storePopupMeta { font-size: 12px; font-weight: 650; color: rgba(203,213,225,.82); line-height: 1.45; }
.storePopupMeta a { color: #7dd3fc; font-weight: 850; text-decoration: none; }
.storePopupBody .unknownTools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.storeClusterPopup .clusterCsvLink {
  width: fit-content; border: 0; border-radius: 999px; padding: 7px 12px;
  background: rgba(99,102,241,.22); color: #eef2ff; font-weight: 900; cursor: pointer;
}
.clusterStoreList { max-height: 220px; overflow: auto; padding-right: 4px; display: grid; gap: 4px; }
.clusterStoreItem { font-size: 12.5px; font-weight: 700; color: rgba(248,250,252,.92); }
.clusterStoreItem span { opacity: .72; }

/* ---------- avg box ---------- */
.avgBox { padding: 6px 0; max-height: 240px; overflow: auto; }
.avgRow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 18px; border-bottom: 1px solid var(--line); }
.avgRow:last-child { border-bottom: none; }
.avgStore { font-size: 13.5px; font-weight: 600; }
.avgBar { flex: 1; height: 6px; border-radius: 4px; background: var(--surface-2); margin: 0 10px; overflow: hidden; }
.avgBar > i { display: block; height: 100%; background: var(--brand-500); }
.avgVal { font-family: var(--font-mono); font-size: 13px; color: var(--ink-700); white-space: nowrap; }

.feedRow { cursor: pointer; }
.feedRow:hover { background: var(--surface-2); }
.visit { cursor: pointer; }
.visit:hover { background: var(--surface-2); }

/* ---------- dark theme ---------- */
body.dark {
  --bg: #0a0e17; --surface: #121826; --surface-2: #1a2233;
  --line: #232c40; --line-strong: #2e3950;
  --ink-900: #eef2fb; --ink-700: #c4cce0; --ink-500: #8a93ad; --ink-400: #6b748f;
}
body.dark .topbar { background: linear-gradient(var(--bg), rgba(10,14,23,.86)); }
body.dark .tab.is-active { background: var(--surface); color: #c7c4ff; }
body.dark .stat .v { }
body.dark .map { background: #0b0f18; }

/* unknown-store recommendation in feed */
.unknownLine { margin-top: 5px; font-size: 12px; color: var(--ink-500); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.linkBtn { appearance: none; border: none; background: none; color: var(--brand-600); font-weight: 600; font-size: 12px; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.linkBtn:hover { background: var(--brand-50); }

/* viewer (read-only) mode hides mutating controls */
body.is-viewer .rowActions, body.is-viewer .iconBtn { display: none !important; }

/* reminder banner */
.reminder { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--warn-50); color: var(--warn-700); border: 1px solid #f3d9a6; border-radius: var(--r);
  padding: 12px 16px; margin-bottom: 14px; font-size: 14px; }
.reminder[hidden] { display: none !important; }
body.dark .reminder { background: #2a1f08; color: #f3c772; border-color: #4a3712; }

/* duplicate-store warning */
.dupWarn { background: var(--bad-50); border: 1px solid #f3c0c0; border-radius: var(--r); padding: 12px 16px; margin-bottom: 14px; }
body.dark .dupWarn { background: #2a1212; border-color: #5a2222; }
.dupHead { font-weight: 700; color: var(--bad-700); margin-bottom: 8px; font-size: 14px; }
.dupRow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.iconBtn[href] { text-decoration: none; font-size: 12px; width: auto; padding: 0 8px; }

/* red overlap badge on map (toko beririsan) */
.overlapBadge { background: var(--bad-600); color: #fff; font-weight: 800; font-size: 11px;
  min-width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 9px;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); padding: 0 4px; }
#roleChip { letter-spacing: .04em; }
