:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --panel-2: #f1f1ef;
  --border: #e2e2de;
  --text: #1c1d1f;
  --muted: #6b6d72;
  --accent: #1f6feb;
  --hot: #c92a2a;
  --red: #e03131;
  --green: #2f9e44;
  --header-h: 48px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
button:hover { background: var(--panel-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
header { position: relative; z-index: 1001; height: var(--header-h); display: flex; align-items: center; gap: 16px; padding: 0 12px 0 16px; background: var(--panel); border-bottom: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06); }
.brand { font-size: 19px; color: var(--text); text-decoration: none; letter-spacing: -0.02em; }
.brand b { color: var(--hot); }
header .actions { display: flex; gap: 6px; margin-left: auto; }

/* ---------- map page ---------- */
.map-page { overflow: hidden; }
.map-page #map { position: absolute; top: var(--header-h); left: 0; right: 0; bottom: 0; background: #e8e6e1; }
.picking #map { cursor: crosshair; }
.leaflet-control-attribution { font-size: 10px; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #4a5568; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); vertical-align: middle; }
.dot.res { background: var(--accent); }
.pin { position: relative; width: 26px; height: 26px; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, 0.35); }
.pin svg { display: block; }
.pin b { position: absolute; top: -7px; right: -9px; background: #fff; color: var(--text); border-radius: 999px; padding: 0 5px; font-size: 10px; line-height: 15px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.cat-icon { vertical-align: -3px; flex: none; }

.legend { position: absolute; left: 12px; bottom: 24px; z-index: 1000; background: var(--panel); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; max-width: 260px; }
.legend label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.legend label.static { cursor: default; padding-left: 22px; }
.legend input { margin: 0; }
.legend #zoom-hint { font-size: 11px; }

/* ---------- right panel ---------- */
#panel { position: absolute; z-index: 1000; top: calc(var(--header-h) + 10px); right: 10px; max-height: calc(100% - var(--header-h) - 20px); width: 380px; background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); overflow-y: auto; padding: 18px; }
#panel .close { position: sticky; top: 0; float: right; margin: -6px -6px 0 8px; padding: 0 9px; font-size: 18px; line-height: 28px; border-radius: 50%; }
#panel h2 { margin: 0 0 4px; font-size: 18px; line-height: 1.3; }
#panel h4 { margin: 20px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
#panel p { margin: 8px 0; }
.eyebrow { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.status { margin: 12px 0; padding: 7px 10px; border-radius: 6px; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.status.bad { background: #fff0f0; color: var(--hot); }

.item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.feed .item { cursor: pointer; }
.feed .item:hover h3 { text-decoration: underline; }
.item h3 { margin: 4px 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.item .body { margin: 4px 0; white-space: pre-line; overflow-wrap: anywhere; }
.meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.place { font-size: 12px; color: var(--muted); }
.src { font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
td { padding: 4px 0; border-bottom: 1px solid var(--border); }
td:last-child { text-align: right; }
.bar { margin: 10px 0; }
.bar .label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.bar .track { height: 8px; background: var(--panel-2); border-radius: 4px; margin-top: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); }

/* ---------- dialog ---------- */
dialog { background: var(--panel); color: var(--text); border: 0; border-radius: 10px; box-shadow: var(--shadow); width: min(480px, calc(100% - 32px)); padding: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog h2 { margin: 0 0 14px; font-size: 18px; }
dialog label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; position: relative; }
dialog input, dialog select, dialog textarea { display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin: 0; }
.suggest { list-style: none; margin: 0; padding: 0; position: absolute; left: 0; right: 0; z-index: 5; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); max-height: 220px; overflow-y: auto; }
.suggest:empty { display: none; }
.suggest li { padding: 6px 8px; cursor: pointer; color: var(--text); }
.suggest li:hover { background: var(--panel-2); }
.suggest small { color: var(--muted); display: block; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 2000; box-shadow: var(--shadow); }

/* ---------- admin (shares header/buttons) ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: none; padding: 10px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- mobile: panel becomes a bottom sheet ---------- */
@media (max-width: 700px) {
  header { gap: 8px; padding: 0 8px 0 12px; }
  header .wide { display: none; }
  header .actions button { padding: 5px 8px; }
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 62%; border-radius: 14px 14px 0 0; }
  .legend { bottom: 16px; left: 8px; font-size: 12px; padding: 6px 10px; }
}
