:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #b45309;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --ok: #059669;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; flex-direction: column; height: 100%; }

header.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 {
  margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap;
}
.brand .sub {
  color: var(--muted); font-size: 12px; white-space: nowrap;
  border: none; padding: 0; margin: 0; border-radius: 0;
}
.spacer { flex: 1 1 auto; }

.banner {
  padding: 8px 16px; font-size: 13px;
  background: #fef3c7; color: #78350f; border-bottom: 1px solid #fde68a;
}
.banner a { color: inherit; }

.body { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }

aside {
  width: 320px; flex: 0 0 320px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
aside .scroll { overflow-y: auto; padding: 14px; }
aside .section { margin-bottom: 16px; }
aside .section h2 {
  margin: 0 0 8px; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); font-weight: 700;
}

#map { flex: 1 1 auto; min-width: 0; }

label.field { display: block; margin-bottom: 10px; }
label.field span {
  display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600;
}
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}

button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 12px; border-radius: 8px;
}
button:hover { background: #f1f5f9; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.07); }
button.danger { color: var(--danger); border-color: #fecaca; }
button.danger:hover { background: #fef2f2; }
button.ok { color: var(--ok); border-color: #a7f3d0; }
button.ok:hover { background: #ecfdf5; }
button.small { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1 1 0; min-width: 0; }
.row > .fixed { flex: 0 0 auto; }

.addr-results {
  border: 1px solid var(--line); border-radius: 8px;
  margin-bottom: 10px; max-height: 190px; overflow-y: auto;
}
.addr-results .result { padding: 8px 10px; }
.addr-results .result:last-child { border-bottom: none; }
.addr-results .m { margin-top: 0; }

.typelist { display: flex; flex-direction: column; gap: 6px; }
.typelist label {
  display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer;
}
.typelist input { margin: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }

.results { border-top: 1px solid var(--line); }
.result {
  padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.result:hover { background: #f8fafc; }
.result .t { font-weight: 600; display: flex; align-items: center; gap: 7px; }
.result .m { color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty { padding: 24px 14px; color: var(--muted); text-align: center; }

.count { font-size: 12px; color: var(--muted); padding: 0 14px 10px; }

.basemap-toggle {
  position: absolute; left: 10px; top: 10px; z-index: 3;
  background: var(--panel); box-shadow: var(--shadow);
  padding: 7px 12px; border-radius: 8px;
}

.fab {
  position: absolute; right: 16px; bottom: 24px; z-index: 4;
  box-shadow: var(--shadow); padding: 11px 16px; border-radius: 999px;
}

.modal-back {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal.wide { max-width: 760px; }
.modal h2 { margin: 0; font-size: 16px; }
.modal .head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.modal .content { padding: 18px; }
.modal .foot {
  padding: 14px 18px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
}
.hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.msg { padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.msg.err { background: #fef2f2; color: #991b1b; }
.msg.good { background: #ecfdf5; color: #065f46; }

.pickbar {
  position: absolute; left: 50%; transform: translateX(-50%); top: 16px; z-index: 40;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 999px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; font-size: 13px;
}
.pickbar button { background: transparent; border-color: #475569; color: #fff; }
.pickbar button:hover { background: #1e293b; }

.maplibregl-popup-content {
  font: inherit; padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow);
}
.pop .t { font-weight: 700; display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.pop .m { color: var(--muted); font-size: 12px; }
.pop .n { margin-top: 6px; font-size: 13px; }
.pop .acts { margin-top: 10px; display: flex; gap: 6px; }

.sub {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px;
}
.sub .t { font-weight: 600; display: flex; align-items: center; gap: 7px; }
.sub .m { color: var(--muted); font-size: 12px; margin-top: 3px; }
.sub .acts { margin-top: 10px; display: flex; gap: 6px; }

.field > .label {
  display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600;
}
.photo-preview { margin-bottom: 8px; }
.photo-preview img, .sub-photo img {
  display: block; width: 100%; max-height: 220px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line); margin-bottom: 6px;
}
.sub-photo img { max-width: 320px; margin: 8px 0 0; }
.photo-msg { font-size: 12px; color: var(--muted); margin-top: 4px; }
.photo-msg:empty { display: none; }
.pop-photo img {
  display: block; width: 100%; max-height: 180px; object-fit: cover;
  border-radius: 6px; margin-top: 8px;
}

.mobile-toggle { display: none; }

@media (max-width: 760px) {
  aside {
    position: absolute; inset: 0 0 0 0; width: auto; flex: none; z-index: 20;
  }
  aside[hidden] { display: none; }
  .mobile-toggle { display: inline-block; }
  .brand { flex-direction: column; align-items: flex-start; gap: 0; }
  .brand .sub { font-size: 11px; white-space: normal; }
  header.topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  header.topbar button { padding: 7px 10px; font-size: 13px; white-space: nowrap; }
  .brand h1 { font-size: 15px; }
  .modal { max-height: 92vh; }
  .pickbar { width: calc(100% - 24px); justify-content: space-between; }
}
