/* 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; }
.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; }

/* ---------- 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); }
.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);
}
.mapLegend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  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; }
.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;
}
.leaflet-popup-content { font-family: var(--font-ui); font-size: 13px; }
.leaflet-popup-content b { font-weight: 700; }

/* ---------- 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; }
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; }
