:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #64748b;
  --line: #dbe4ee;
  --primary: #1f4e79;
  --pending: #94a3b8;
  --reached: #f59e0b;
  --completed: #16a34a;
  --blocked: #111827;
  --review: #0284c7;
  --issue: #dc2626;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Tahoma, sans-serif;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: #0f2740;
  color: white;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo-mark {
  width: 150px;
  height: 54px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: white;
  color: #0f2740;
  font-weight: 800;
  font-size: 11px;
  border: 1px solid rgba(255,255,255,.35);
  overflow: hidden;
}
.logo-mark img { width: 100%; height: 100%; object-fit: contain; }
.topbar h1 { margin: 0; font-size: 19px; white-space: normal; line-height: 1.15; }
.topbar p { margin: 4px 0 0; color: #cbd5e1; font-size: 12px; }
.header-actions { display: flex; gap: 8px; align-items: center; }
select, input, textarea, button {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 6px;
}
select, input {
  height: 36px;
  padding: 0 10px;
  background: white;
}
button {
  min-height: 36px;
  padding: 0 12px;
  background: white;
  cursor: pointer;
}
button.primary { background: var(--primary); color: white; border-color: var(--primary); }
button.success { background: var(--completed); color: white; border-color: var(--completed); }
button.warning { background: var(--reached); color: white; border-color: var(--reached); }
button.danger { background: var(--issue); color: white; border-color: var(--issue); }
button.dark { background: var(--blocked); color: white; border-color: var(--blocked); }
button.info { background: var(--review); color: white; border-color: var(--review); }
button:disabled { opacity: .55; cursor: not-allowed; }

.layout {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 300px 1fr 340px;
  gap: 12px;
  padding: 12px;
}
.panel {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; }
.card label { display: block; color: var(--muted); font-size: 12px; margin: 8px 0 4px; }
.card select, .card input { width: 100%; }
.mode-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.compact-row { margin-top: 8px; grid-template-columns: 1fr 1fr; }
.report-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.project-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.project-card input[type="file"] { height: auto; padding: 8px; }
.color-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.color-controls label {
  margin: 0;
  display: grid;
  gap: 4px;
}
.color-controls input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 3px;
}
.status { margin-top: 8px; font-size: 12px; }
.muted { color: var(--muted); }

.stats div, .surveyor-item, .point-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.stats div { padding: 6px 0; border-bottom: 1px solid #eef2f7; }
.stats div:last-child { border-bottom: 0; }
.surveyor-list, .point-list { display: flex; flex-direction: column; gap: 6px; }
.surveyor-item, .point-item {
  border: 1px solid #e5edf5;
  border-radius: 6px;
  padding: 8px;
  background: #fbfdff;
  cursor: pointer;
}
.surveyor-item.warning-row { border-color: #f59e0b; background: #fffbeb; }
.point-item { align-items: flex-start; flex-direction: column; }
.point-title { display: flex; justify-content: space-between; width: 100%; gap: 6px; }
.point-description-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
  max-width: 100%;
}
.description-box {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #e5edf5;
  border-radius: 6px;
  background: #fbfdff;
  color: #334155;
  white-space: normal;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-width: 64px;
  justify-content: center;
  height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  color: white;
  font-size: 11px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-inline-end: 6px;
}

.map-wrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.map-toolbar {
  position: absolute;
  z-index: 400;
  top: 12px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  direction: ltr;
}
.map-toolbar select {
  width: auto;
  min-width: 126px;
  height: 36px;
}
.map {
  width: 100%;
  height: 100%;
  background: #d8d6cf;
  direction: ltr;
}
.leaflet-container {
  direction: ltr;
  font-family: Arial, Tahoma, sans-serif;
}
.leaflet-tile,
.leaflet-tile-container img {
  max-width: none !important;
  max-height: none !important;
}
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}
.map .leaflet-control-attribution { font-size: 10px; }
.point-pin {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 3px solid var(--surveyor-color);
  background: var(--status-color);
  box-shadow: 0 0 0 2px rgba(255,255,255,.9), 0 2px 6px rgba(0,0,0,.35);
}
.surveyor-pin {
  min-width: 92px;
  transform: translate(-12px, -12px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 2px white, 0 -1px 2px white, 1px 0 2px white, -1px 0 2px white;
}
.surveyor-pin::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surveyor-color);
  border: 3px solid white;
  box-shadow: 0 0 0 3px rgba(255,255,255,.35), 0 2px 8px rgba(0,0,0,.45);
}
.leaflet-tooltip.point-tooltip,
.leaflet-tooltip.surveyor-tooltip {
  background: rgba(255,255,255,.9);
  border: 0;
  box-shadow: 0 1px 5px rgba(0,0,0,.25);
  color: #0f172a;
  font-weight: 700;
  font-size: 10px;
  padding: 2px 4px;
}
.leaflet-tooltip.surveyor-tooltip { font-size: 12px; }

.modal, .login-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: grid;
  place-items: center;
  z-index: 1000;
}
.modal.hidden, .login-modal.hidden { display: none; }
.modal-card, .login-card {
  width: min(520px, calc(100vw - 24px));
  background: white;
  border-radius: 8px;
  padding: 14px;
  border: 1px solid var(--line);
}
.login-card { display: flex; flex-direction: column; gap: 8px; }
.login-card .logo-mark { width: 260px; height: 136px; background: white; color: #0f2740; align-self: center; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head button { border: 0; font-size: 20px; }
.modal-body { margin: 12px 0; color: var(--muted); line-height: 1.6; }
textarea { width: 100%; min-height: 74px; padding: 10px; resize: vertical; }
.file-label { margin-top: 8px; }
.modal-actions { margin-top: 10px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.modal-actions button { padding: 0 6px; }

@media (max-width: 980px) {
  .topbar { height: auto; flex-direction: column; align-items: stretch; }
  .topbar h1 { white-space: normal; }
  .header-actions { flex-wrap: wrap; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .map-wrap { height: 62vh; min-height: 420px; }
  .point-panel { max-height: 55vh; }
  .modal-actions { grid-template-columns: repeat(2, 1fr); }
}
