/*
 * Gaya "formulir kerja": netral, rata, garis tepi tipis, satu warna aksen.
 * Tanpa gradien, tanpa bayangan dekoratif, tanpa efek kaca.
 */
:root {
  --bg: #f2f1ee;
  --surface: #ffffff;
  --sunken: #f7f6f3;
  --fg: #1d1b18;
  --fg-2: #3d3a35;
  --muted: #6b665e;
  --line: #d9d5cd;
  --line-strong: #b9b3a8;
  --accent: #0f5c4d;
  --accent-hover: #0b4a3e;
  --accent-fg: #ffffff;
  --accent-tint: #e5efec;
  --ok: #1f6b3a;
  --warn: #8a5a00;
  --warn-bg: #fbf3e0;
  --bad: #a3261c;
  --bad-bg: #fbeceb;
  --r: 6px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #1f1e1b;
    --sunken: #191816;
    --fg: #ebe8e2;
    --fg-2: #cfcac1;
    --muted: #9b958a;
    --line: #34312c;
    --line-strong: #4a463f;
    --accent: #5fb8a3;
    --accent-hover: #7ccab7;
    --accent-fg: #0d1f1b;
    --accent-tint: #1c2d29;
    --ok: #7cc995;
    --warn: #e0b25a;
    --warn-bg: #2b2414;
    --bad: #ec8b82;
    --bad-bg: #2e1b19;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 650; }
.ico { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -3px; }
.ico-sm { width: 15px; height: 15px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 0 16px; padding-top: env(safe-area-inset-top);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 650; }
.brand img { width: 22px; height: 22px; }
.brand small { font-weight: 400; color: var(--muted); margin-left: 6px; font-size: 13px; }
.appbar .spacer { flex: 1; }

.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
  min-height: 34px; padding: 0 8px; border-radius: var(--r);
  font-size: 14px; color: var(--fg-2);
}
.menu > summary:hover, .menu[open] > summary { background: var(--sunken); }
.menu > summary::-webkit-details-marker { display: none; }
.avatar {
  width: 26px; height: 26px; border-radius: 4px; display: grid; place-items: center;
  background: var(--accent-tint); color: var(--accent); font-weight: 700; font-size: 11px; letter-spacing: .02em;
}
.menu-name { font-weight: 550; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 220px; z-index: 1100;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
  padding: 4px 0;
}
.menu-head { padding: 8px 14px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head strong { display: block; font-weight: 600; }
.menu-head span { font-size: 12.5px; color: var(--muted); font-family: var(--mono); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 14px; border: 0; background: none; color: var(--fg);
  font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--sunken); }
.menu-item.danger { color: var(--bad); }

/* ---------- layout ---------- */
.page { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.page.wide { max-width: 1320px; padding-bottom: 32px; }
.stack { display: grid; gap: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.section-title {
  display: flex; align-items: baseline; gap: 8px;
  margin: 0 0 12px; font-size: 15px; font-weight: 650;
}
.section-title .num { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.section-title .aside { margin-left: auto; font-size: 13px; font-weight: 500; }

/* ---------- form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r); border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--fg); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--sunken); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }

.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--fg-2); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .ico { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.input {
  width: 100%; min-height: 44px; padding: 0 12px;
  font: inherit; font-size: 16px; color: var(--fg);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
  outline: none;
}
.input:focus { border-color: var(--accent); outline: 2px solid var(--accent-tint); outline-offset: 0; }
.input-wrap > .ico + .input { padding-left: 36px; }
.input-wrap .reveal {
  position: absolute; right: 4px; height: 36px; padding: 0 10px; border: 0; border-radius: 4px;
  background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 13px;
}
.input-wrap .reveal:hover { color: var(--fg); background: var(--sunken); }
.input-wrap.has-reveal .input { padding-right: 76px; }

.alert { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); font-size: 14px; border: 1px solid; }
.alert .ico { margin-top: 2px; }
.alert-bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

/* ---------- gate & login ---------- */
.auth { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 12vh 16px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-weight: 650; }
.auth-brand img { width: 24px; height: 24px; }
.auth-card h1 { font-size: 20px; }
.auth-card .lead { color: var(--muted); margin: 4px 0 20px; font-size: 14.5px; }
.auth-step { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }
.auth-foot { margin-top: 16px; font-size: 13px; color: var(--muted); }

/* ---------- key/value sheet ---------- */
.sheet { margin: 0; display: grid; grid-template-columns: minmax(92px, max-content) 1fr; border-top: 1px solid var(--line); }
.sheet dt, .sheet dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); }
.sheet dt { color: var(--muted); font-size: 13.5px; padding-right: 14px; }
.sheet dd { font-weight: 550; word-break: break-word; }
.sheet dd.mono { font-weight: 500; font-variant-numeric: tabular-nums; }
.site-name { font-size: 19px; font-weight: 650; margin: 0 0 12px; }
.note { margin: 12px 0 0; font-size: 13.5px; color: var(--fg-2); }
.note b { font-weight: 600; }

/* ---------- location ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.badge.live .dot { animation: blink 1s steps(2, start) infinite; }

.acc { display: flex; align-items: baseline; gap: 6px; }
.acc-label { color: var(--muted); font-size: 13.5px; margin-right: 4px; }
.acc-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--mono); letter-spacing: -.02em; }
.acc-unit { color: var(--muted); font-size: 14px; }
.acc-sub { margin: 4px 0 10px; color: var(--fg-2); font-size: 13.5px; min-height: 1.5em; }

.progress { height: 4px; background: var(--sunken); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 14px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .9s linear; }
.progress.done > i { background: var(--ok); }

.coords { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 12px; }
.coord { padding: 8px 12px; }
.coord + .coord { border-left: 1px solid var(--line); }
.coord span { display: block; font-size: 12.5px; color: var(--muted); }
.coord strong { font-family: var(--mono); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }

.address { padding: 10px 12px; margin-bottom: 12px; border-left: 3px solid var(--accent); background: var(--sunken); }
.address span { display: block; font-size: 12.5px; color: var(--muted); }
.address span em { font-style: normal; }
.address strong { display: block; font-weight: 550; line-height: 1.45; margin-top: 2px; }
.address small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.map { height: 230px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--sunken); }
.map-empty { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }
.leaflet-container { font: inherit; }
.leaflet-bar, .leaflet-bar a { border-radius: 4px !important; }

.pin-me { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; outline: 1px solid rgba(0, 0, 0, .35); }
.pin-site { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; outline: 1px solid rgba(0, 0, 0, .35); }
.pin-site.active { background: #c2410c; width: 18px; height: 18px; margin: -2px 0 0 -2px; }

/* ---------- history ---------- */
.timeline { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.timeline li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.timeline strong { display: block; font-size: 14px; font-weight: 600; }
.timeline span { display: block; font-size: 13px; color: var(--muted); font-family: var(--mono); }
.timeline .tl-addr { font-family: inherit; color: var(--fg-2); }
.empty { padding: 14px 0; color: var(--muted); font-size: 14px; }
.empty .ico { display: none; }

/* ---------- bottom actions ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.actionbar-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: 2fr 3fr; gap: 8px; }
.actionbar .ico { display: none; }

/* ---------- toast (in-page) ---------- */
.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 2000;
  display: grid; justify-items: center; gap: 6px; padding: 0 16px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px; width: 100%; max-width: 528px;
  padding: 10px 14px; border-radius: var(--r); font-size: 14px;
  background: var(--fg); color: var(--bg);
}
.toast.ok .ico { color: #86d19f; }
.toast.bad .ico { color: #f3a39b; }
.toast.out { opacity: 0; transition: opacity .2s; }

/* ---------- desktop notice ---------- */
.notice h1 { font-size: 18px; margin-bottom: 6px; }
.notice p { color: var(--fg-2); margin: 0 0 12px; }
.url-box { font-family: var(--mono); font-size: 14px; padding: 10px 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; word-break: break-all; }

/* ---------- admin ---------- */
.page-head { margin: 4px 0 14px; }
.page-head h1 { font-size: 20px; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.stats {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 12px;
}
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { padding: 12px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
@media (min-width: 900px) { .stat { border-bottom: 0; } .stat:last-child { border-right: 0; } }
@media (max-width: 899px) { .stat:nth-child(2n) { border-right: 0; } .stat:nth-child(n+3) { border-bottom: 0; } }
.stat span { display: block; font-size: 13px; color: var(--muted); }
.stat strong { display: block; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; margin-bottom: 12px; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border: 0; background: var(--surface);
  font: inherit; font-size: 14px; font-weight: 550; color: var(--fg-2); cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button.active { background: var(--accent); color: var(--accent-fg); }
.segmented .ico { display: none; }
.toolbar form { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 420px; }
.toolbar .input { min-height: 36px; font-size: 14px; }
.toolbar .input-wrap { flex: 2 1 200px; }
.toolbar .input-wrap.narrow { flex: 1 1 110px; }
.toolbar .input-wrap > .ico { width: 15px; height: 15px; }
.export { display: flex; gap: 8px; }
.export .ico { display: none; }
@media (max-width: 720px) {
  .toolbar form .btn { flex: 1 1 0; }
  .export { flex: 1 1 100%; }
  .export .btn { flex: 1 1 0; }
  .segmented { width: 100%; }
  .segmented button { flex: 1 1 0; justify-content: center; }
}

.split { display: grid; gap: 12px; }
@media (min-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
  .split .map-card { position: sticky; top: 64px; height: calc(100dvh - 80px); }
}
.map-card { padding: 0; overflow: hidden; display: flex; }
.map-card .map { flex: 1; height: auto; min-height: 320px; border: 0; border-radius: 0; }

.table-card { padding: 0; overflow: hidden; }
.table-meta { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.table-meta .ico { display: none; }
.table-scroll { overflow: auto; max-height: calc(100dvh - 250px); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--sunken);
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted);
  padding: 8px 12px; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--sunken); }
tbody tr.active { background: var(--accent-tint); }
td .cell-main { color: var(--fg); }
td .cell-sub { font-size: 12.5px; color: var(--muted); }
td .cell-wrap { white-space: normal; min-width: 200px; max-width: 300px; }
.count-pill {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 13.5px; color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}

@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.table-scroll .empty { padding: 14px; }

/* ---------- confirmation dialog ---------- */
.confirm {
  width: min(560px, 100vw); max-width: 100vw; max-height: 92dvh; margin: auto auto 0; padding: 0;
  border: 1px solid var(--line-strong); border-bottom: 0; border-radius: var(--r) var(--r) 0 0;
  background: var(--surface); color: var(--fg); overflow: auto;
}
@media (min-width: 600px) { .confirm { margin: auto; border-bottom: 1px solid var(--line-strong); border-radius: var(--r); } }
.confirm::backdrop { background: rgba(20, 18, 15, .55); }
.confirm form { padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
.confirm h2 { font-size: 17px; }
.confirm-lead { margin: 4px 0 14px; font-size: 14px; color: var(--fg-2); }
.confirm .sheet dt { font-size: 13px; }
.confirm .sheet dd { font-size: 14.5px; }
.confirm-replace { margin: 12px 0 0; padding: 9px 12px; font-size: 13.5px; background: var(--warn-bg); color: var(--warn); border-radius: var(--r); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 16px; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--r); cursor: pointer; font-size: 14.5px; line-height: 1.45; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.confirm-actions { display: grid; grid-template-columns: 2fr 3fr; gap: 8px; }
