:root {
  --bg: #f6f7f9;
  --panel: #fff;
  --text: #1d2228;
  --muted: #6b7380;
  --line: #dde1e6;
  --accent: #1f6feb;
  --danger: #c62828;
  font: 14px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); }
body { display: flex; flex-direction: column; }
h1 { font-size: 16px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
[hidden] { display: none !important; }

button, .button {
  font: inherit;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
button:hover, .button:hover { border-color: #b9c0c8; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
button.icon { border: 0; background: none; padding: 2px 6px; color: var(--muted); }
input, select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
input[type=checkbox], input[type=range] { padding: 0; vertical-align: middle; }
input[type=color] { padding: 2px; height: 32px; width: 100%; }
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
label > input:not([type=checkbox]):not([type=range]), label > select { display: block; width: 100%; margin-top: 3px; color: var(--text); font-size: 14px; }
label.check { color: var(--text); font-size: 14px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.right { margin-left: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

header {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
#projectName { color: var(--muted); }
header nav { margin-left: auto; display: flex; gap: 6px; align-items: center; }
#demoBanner { background: #fff4d6; border-bottom: 1px solid #f0d58a; padding: 6px 16px; font-size: 13px; }

main { flex: 1; display: flex; min-height: 0; }

#sidebar {
  width: 300px; flex-shrink: 0; overflow-y: auto;
  padding: 12px; background: var(--panel); border-right: 1px solid var(--line);
}
.search { position: relative; margin-bottom: 12px; }
.search input { width: 100%; }
#searchResults {
  position: absolute; z-index: 10; left: 0; right: 0; top: 100%;
  margin: 2px 0 0; padding: 4px 0; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
  max-height: 360px; overflow-y: auto;
}
#searchResults li { padding: 6px 10px; cursor: pointer; display: flex; gap: 8px; justify-content: space-between; }
#searchResults li:hover, #searchResults li.active { background: #eef4ff; }
#searchResults .kind { color: var(--muted); font-size: 12px; }

.empty { color: var(--muted); }
.prop { display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.prop:hover { background: #f8f9fb; }
.prop .swatch { width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0; margin-top: 2px; border: 1px solid rgba(0,0,0,.25); }
.prop .info { flex: 1; min-width: 0; }
.prop .label { font-weight: 600; overflow-wrap: anywhere; }
.prop .meta { color: var(--muted); font-size: 12px; }
.prop .delta { color: #8a5a00; }

#mapWrap { flex: 1; position: relative; display: flex; flex-direction: column; min-width: 0; }
#toolbar {
  display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center;
  padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line);
}
#toolbar .group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#toolbar label { display: inline-flex; gap: 4px; align-items: center; margin: 0 0 0 6px; font-size: 13px; color: var(--text); }
#toolbar input[type=range] { width: 80px; }
#toolbar .scale input { width: 80px; padding: 3px 6px; margin-top: 0; }
#toolbar button.active { background: #eef4ff; border-color: var(--accent); color: var(--accent); }
#map { flex: 1; min-height: 0; background: #e9ecef; }

#status {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  max-width: 80%; padding: 8px 14px; border-radius: 6px;
  background: rgba(29,34,40,.9); color: #fff; font-size: 13px; pointer-events: none;
}

.popup {
  min-width: 230px; max-width: 300px; padding: 10px 12px; font-size: 13px;
  background: #fff; border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.2);
}
.popup:empty { display: none; }
.popup .title { font-weight: 600; font-size: 14px; }
.popup > div { margin-bottom: 4px; }
.popup label { margin: 8px 0 0; }
.popup input:not([type=checkbox]) { width: 100%; }
.popup .row label { margin: 0; display: inline-flex; gap: 4px; align-items: center; color: var(--text); }

#printPanel { width: 290px; flex-shrink: 0; overflow-y: auto; padding: 14px; background: var(--panel); border-left: 1px solid var(--line); }
.hint { color: var(--muted); font-size: 12px; }

dialog { border: 0; border-radius: 10px; padding: 18px; width: min(440px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.3); }
.projects { list-style: none; margin: 0 0 8px; padding: 0; max-height: 50vh; overflow-y: auto; }
.projects button { width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 12px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 8px 4px; }
.projects button:hover { background: #f3f6fb; }
.projects .muted { font-size: 12px; }

.ol-scale-line { left: auto; right: 8px; bottom: 8px; }
.coords {
  top: auto; right: auto; left: 8px; bottom: 8px;
  padding: 2px 8px; border-radius: 4px;
  background: rgba(255,255,255,.85); color: var(--text);
  font-size: 12px; font-variant-numeric: tabular-nums; white-space: pre;
}
.coords:empty { display: none; }

/* ---------------------------------------------------------------- shared */

a.button { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
button.wide, a.wide { width: 100%; justify-content: center; }
code { background: #f1f3f5; padding: 1px 4px; border-radius: 4px; }
.notice { padding: 8px 12px; border-radius: 6px; font-size: 13px; margin: 0 0 12px; }
.notice.info { background: #e8f2ff; color: #11407a; }
.notice.error { background: #fdecec; color: #8a1c1c; }

.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::after { content: ' ▾'; color: var(--muted); }
.user-menu .menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 190px;
  display: flex; flex-direction: column; padding: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.15);
}
.user-menu .menu a, .user-menu .menu button {
  border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none; font: inherit; cursor: pointer;
}
.user-menu .menu a:hover, .user-menu .menu button:hover { background: #f3f6fb; }

/* ---------------------------------------------------------------- login page */

.auth-page { align-items: center; justify-content: center; padding: 24px 16px; overflow-y: auto; }
.auth-card { display: block; flex: none; width: min(400px, 100%); padding: 28px; background: var(--panel); border-radius: 12px; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.auth-card h1 { font-size: 20px; margin-bottom: 18px; }
.auth-card h2 { font-size: 16px; }
.auth-card .switch { text-align: center; margin: 14px 0 0; color: var(--muted); }
.auth-card .ms { width: 100%; justify-content: center; padding: 8px 12px; margin-bottom: 4px; }
.or { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0; }

/* ---------------------------------------------------------------- admin page */

.admin-page { overflow-y: auto; }
.admin-page header nav { align-items: center; }
.admin { display: block; flex: none; width: min(1100px, 100%); margin: 0 auto; padding: 20px 16px 48px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 14px; color: var(--muted); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.card h2:not(:first-child) { margin-top: 22px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.copy { display: flex; gap: 6px; margin-top: 3px; }
.copy input { flex: 1; color: var(--text); font-size: 13px; }
label.check.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0 0 0 auto; }
details { margin: 4px 0 12px; font-size: 13px; }
details summary { cursor: pointer; color: var(--accent); }
details ol { padding-left: 20px; }
.key { padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.key p { margin: -4px 0 8px; font-size: 12px; }

table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; font-size: 13px; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.pending { background: #fffaf0; }
table.list tr.disabled td:not(.actions) { color: var(--muted); }
table.list select { padding: 3px 6px; font-size: 13px; }
table.list .actions { text-align: right; white-space: nowrap; }
table.list .actions button { padding: 3px 9px; font-size: 12px; }
.status { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; }
.status.active { background: #e6f6ea; color: #1d6b33; }
.status.pending { background: #fff1d6; color: #8a5a00; }
.status.disabled { background: #fdecec; color: #8a1c1c; }
.tag { display: inline-block; padding: 0 6px; border-radius: 4px; background: #eef4ff; color: #11407a; font-size: 11px; }
@media (max-width: 760px) {
  table.list { display: block; overflow-x: auto; }
}
