:root {
  --ink: #0b1b2b;
  --ink-soft: #526979;
  --teal: #00bfa6;
  --teal-deep: #007f70;
  --teal-soft: #e9f7f6;
  --blue: #3d5afe;
  --orange: #ff7a45;
  --red: #ff4d4f;
  --green: #2ecc71;
  --surface: #ffffff;
  --line: #d6e5e8;
  --shadow: 0 18px 50px rgba(11, 27, 43, 0.18);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink);
  background: #f5f9f9;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

#map {
  position: fixed;
  inset: 0;
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: var(--teal-soft);
  color: var(--ink-soft);
  font-weight: 700;
  letter-spacing: .02em;
}
#loading[hidden] { display: none; }

#topbar {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.brand {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px 9px 10px;
  border: 1px solid rgba(214, 229, 232, .9);
  border-radius: 15px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 26px rgba(11, 27, 43, .12);
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.01em;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}
.brand img {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: block;
}
.brand b { color: var(--teal-deep); font-weight: 800; }

.top-actions {
  pointer-events: auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ghost {
  border: 1px solid rgba(214, 229, 232, .95);
  border-radius: 13px;
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  padding: 9px 13px;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(11, 27, 43, .10);
  backdrop-filter: blur(12px);
}
.ghost:hover { border-color: var(--teal); color: var(--teal-deep); }
.ghost.admin {
  background: #fff8ef;
  border-color: #ffd9b8;
  color: #9a4b12;
}
.ghost.admin span {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
}

#googleButton {
  min-height: 38px;
  display: flex;
  align-items: center;
}
#googleButton[hidden] { display: none; }
#googleButton > div { display: block !important; }

#userChip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 8px 22px rgba(11, 27, 43, .10);
  font-size: 12.5px;
  font-weight: 700;
  max-width: 260px;
}
#userChip[hidden] { display: none; }
#userChip img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--teal-soft);
}
#userName {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link {
  border: 0;
  background: none;
  color: var(--ink-soft);
  padding: 0;
  font-size: 11.5px;
  text-decoration: underline;
}
.link:hover { color: var(--red); }

#toolbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  gap: 5px;
  padding: 6px;
  border: 1px solid rgba(214, 229, 232, .95);
  border-radius: 18px;
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 62px;
  padding: 8px 10px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 700;
}
.tool span { font-size: 19px; line-height: 1; }
.tool:hover { background: var(--teal-soft); color: var(--teal-deep); }
.tool.active { background: var(--teal); color: #04231f; }
.tool.active span { filter: grayscale(1) brightness(.3); }

#hint {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  z-index: 25;
  max-width: 88vw;
  padding: 7px 14px;
  border: 1px solid rgba(214, 229, 232, .9);
  border-radius: 999px;
  background: rgba(255, 255, 255, .93);
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(11, 27, 43, .10);
  backdrop-filter: blur(10px);
}

.side-panel, .drawer {
  position: fixed;
  z-index: 35;
  top: 76px;
  right: 14px;
  width: min(380px, calc(100vw - 28px));
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, .98);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  animation: slideIn .18s ease;
}
.side-panel[hidden], .drawer[hidden] { display: none; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

.panel-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.panel-head > div { min-width: 0; flex: 1; }
.eyebrow {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--teal-deep);
  margin-bottom: 3px;
}
h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.03em;
  line-height: 1.1;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 15px;
}
.icon-btn:hover { color: var(--red); border-color: var(--red); }

.coords {
  margin: 10px 0 14px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  color: var(--ink-soft);
}

.edit-form { display: grid; gap: 11px; }
.edit-form[hidden] { display: none; }
.edit-form label {
  display: grid;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
}
.edit-form input[type=text], .edit-form select, .edit-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8fbfb;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
  resize: vertical;
}
.edit-form input:focus, .edit-form select:focus, .edit-form textarea:focus {
  border-color: var(--teal);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 191, 166, .13);
}
.optional { font-weight: 500; color: #8ba1ae; }
.consent {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: flex-start;
  gap: 8px !important;
  font-weight: 500 !important;
  font-size: 11px !important;
  line-height: 1.4;
  color: var(--ink-soft) !important;
  padding: 10px;
  border-radius: 11px;
  background: var(--teal-soft);
}
.consent input { margin-top: 2px; accent-color: var(--teal-deep); }
.form-error {
  display: none;
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #ffd6d3;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11.5px;
}
.form-error.show { display: block; }
.actions { display: flex; gap: 8px; margin-top: 2px; }
.btn {
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 800;
  border: 1px solid transparent;
}
.btn.primary { flex: 1; background: var(--teal); color: #04231f; }
.btn.primary:hover { filter: brightness(.96); }
.btn.primary:disabled { opacity: .55; cursor: progress; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-soft); box-shadow: none; }

.drawer {
  position: fixed;
  top: 76px;
  right: 14px;
  width: min(420px, calc(100vw - 28px));
}
.drawer-body {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}
.edit-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
}
.edit-card .card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.edit-card .card-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 800;
  line-height: 1.3;
}
.edit-card .card-sub {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.35;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
}
.chip.pending { background: #fff4e8; color: #9a4b12; border: 1px solid #ffd9b8; }
.chip.approved { background: #eafaf1; color: #117a45; border: 1px solid #b9efd0; }
.chip.rejected { background: #fff1f0; color: #b42318; border: 1px solid #ffd6d3; }
.chip.place { background: #e8f8f6; color: #007f70; border: 1px solid #bdece5; }
.chip.label { background: #eef1ff; color: #3046c9; border: 1px solid #ccd4ff; }
.card-meta {
  margin-top: 8px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10.5px;
  color: #78909c;
}
.card-note {
  margin-top: 8px;
  padding: 8px 9px;
  border-radius: 9px;
  background: #f6f9f9;
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.card-actions {
  display: flex;
  gap: 7px;
  margin-top: 10px;
}
.card-actions .btn { padding: 8px 10px; font-size: 11.5px; }
.card-actions .approve { background: #2ecc71; color: #04331b; }
.card-actions .reject { background: #fff1f0; color: #b42318; border-color: #ffd6d3; }
.card-actions .view { background: #f5f9f9; color: var(--ink-soft); border-color: var(--line); }
.empty {
  padding: 26px 12px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 12.5px;
}
.muted-link {
  color: var(--teal-deep);
  font-weight: 700;
  text-decoration: none;
}
.muted-link:hover { text-decoration: underline; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 150px;
  transform: translateX(-50%) translateY(10px);
  z-index: 50;
  max-width: 88vw;
  padding: 10px 15px;
  border-radius: 12px;
  background: rgba(11, 27, 43, .94);
  color: #fff;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: #7a271a; }

/* Keep the map's own controls clear of the cards on small screens. */
.maplibregl-ctrl-top-right { top: 62px; right: 6px; }
.maplibregl-ctrl-bottom-right { bottom: 96px; }

@media (max-width: 760px) {
  #topbar { top: 8px; left: 8px; right: 8px; gap: 7px; }
  .brand { padding: 7px 10px 7px 8px; font-size: 12px; }
  .brand img { width: 24px; height: 24px; }
  .brand b { display: none; }
  .top-actions { gap: 5px; }
  .ghost { padding: 8px 10px; font-size: 11.5px; }
  #userChip { max-width: 170px; }
  #userName { max-width: 70px; }
  #hint { bottom: 84px; font-size: 11px; }
  #toolbar { bottom: 10px; }
  .tool { min-width: 56px; padding: 7px 8px; }
  .side-panel, .drawer {
    top: auto;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: 74vh;
    bottom: 84px;
    border-radius: 18px;
    animation: sheetIn .18s ease;
  }
  @keyframes sheetIn {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: none; }
  }
  #toast { bottom: 140px; }
  .maplibregl-ctrl-top-right { top: 56px; }
  .maplibregl-ctrl-bottom-right { bottom: 132px; }
}

@media (max-width: 560px) {
  .brand span { display: none; }
  .brand { padding: 8px; }
}
