:root {
  --bg: #fff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --sidebar-w: 360px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px; color: var(--fg); background: var(--bg);
}

body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

#sidebar {
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

#sidebar header h1 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); font-size: 12px; }
.muted a { color: var(--muted); }

.filter-group h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}

/* Filter tree */
.host-block {
  margin-bottom: 6px;
}
.host-block label.host {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}
.host-block label.host:hover { background: #f3f4f6; }
.host-block .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.host-block .count {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 400;
}
.host-block .neutral-pill {
  font-size: 10px;
  padding: 1px 5px;
  background: #ede9fe;
  color: #6d28d9;
  border-radius: 3px;
  font-weight: 500;
  cursor: help;
  white-space: nowrap;
}

.status-pill {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
  cursor: help;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-authoritative  { background: #dcfce7; color: #166534; }
.status-alias          { background: #dbeafe; color: #1e40af; }
.status-osm-only       { background: #f3f4f6; color: #4b5563; }
.status-google-places  { background: #fce7f3; color: #be185d; }
.status-osm\+google    { background: #ccfbf1; color: #0f766e; }
.status-overture       { background: #e0e7ff; color: #4338ca; }
.status-osm\+overture  { background: #cffafe; color: #155e75; }
.status-partner-network { background: #ede9fe; color: #6d28d9; }
.status-auth-required  { background: #fef3c7; color: #92400e; }

.host-block .children {
  margin-left: 24px;
  border-left: 1px dashed var(--border);
  padding-left: 8px;
  margin-bottom: 4px;
}
.host-block .children label.child {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--muted);
}
.host-block .children label.child:hover { background: #f3f4f6; color: var(--fg); }
.host-block .children .dot { width: 7px; height: 7px; }

/* Search */
#search-form {
  display: flex;
  gap: 6px;
}
#search-input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
}
#search-input:focus { border-color: var(--accent); }
#search-go {
  padding: 0 12px;
  font-size: 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}
#search-go:hover { opacity: 0.9; }
#search-result {
  margin-top: 6px;
  font-size: 11px;
  min-height: 14px;
}
#search-result a { color: var(--accent); cursor: pointer; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
}

/* Edit form inside popup */
.popup .edit-toggle {
  margin-top: 6px;
  font-size: 11px;
}
.popup .edit-toggle a { color: var(--accent); cursor: pointer; }
.popup .edit-form {
  margin-top: 8px;
  padding: 8px;
  background: #f9fafb;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.popup .edit-form .courier-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.popup .edit-form label {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  user-select: none;
}
.popup .edit-form button {
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 3px;
  cursor: pointer;
  margin-right: 4px;
}
.popup .edit-form button.cancel {
  background: white;
  color: var(--fg);
  border-color: var(--border);
}
.popup .override-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  background: #fef9c3;
  color: #854d0e;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

/* Search marker */
.search-pin {
  background: var(--accent);
  border: 3px solid white;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  box-shadow: 0 0 0 2px var(--accent);
}

/* Service filters */
#service-filters label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}
#service-filters label:hover { background: #f3f4f6; }
#service-filters input { margin: 0; cursor: pointer; accent-color: var(--accent); }

input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

#sidebar footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
}

#map { height: 100vh; min-width: 0; }

/* Popup */
.popup { font-size: 13px; line-height: 1.5; min-width: 220px; }
.popup h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.popup .addr { color: var(--muted); margin-bottom: 8px; font-size: 12px; }
.popup .host-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.popup .badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.popup .badge {
  font-size: 11px; padding: 2px 6px; border-radius: 3px;
  background: #f3f4f6; color: #374151;
  font-weight: 500;
}
.popup .badge.primary { font-weight: 700; }
.popup .neutral {
  font-size: 11px;
  padding: 4px 6px;
  background: #ede9fe;
  color: #6d28d9;
  border-radius: 3px;
  margin-bottom: 8px;
}
.popup .services { font-size: 12px; margin-bottom: 4px; }
.popup .hours { font-size: 12px; margin-bottom: 6px; }
.popup .hours-today { font-size: 12px; margin-bottom: 4px; font-weight: 500; }
.popup .hours-today .muted { font-weight: 400; }
.popup .hours-table { width: 100%; border-collapse: collapse; font-size: 11px; color: var(--muted); }
.popup .hours-table td { padding: 1px 0; vertical-align: top; }
.popup .hours-table td.day { width: 70px; padding-right: 8px; }
.popup .hours-table td.slots { font-variant-numeric: tabular-nums; }
.popup .note { font-size: 11px; font-style: italic; margin-top: 4px; }
.popup .report-line { margin-top: 8px; font-size: 11px; padding-top: 6px; border-top: 1px solid var(--border); }
.popup .report-line a { color: var(--muted); }
.popup .save-status.saved { color: #16a34a; font-weight: 500; }

@media (max-width: 720px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #sidebar { max-height: 45vh; border-right: 0; border-bottom: 1px solid var(--border); }
  #map { height: 100%; }
}
