:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #172033;
  --muted: #64748b;
  --line: #d9e2ec;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --accent: #0f766e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 500;
}

.brand {
  font-size: 1.25rem;
  font-weight: 800;
}

.topbar nav {
  align-items: center;
  display: flex;
  gap: 12px;
}

.nav-form {
  margin: 0;
}

.topbar nav a,
.primary-link,
.report-button,
button,
.outline-button,
.danger-button {
  border-radius: 8px;
  font-weight: 700;
}

.topbar nav a {
  padding: 10px 12px;
}

.primary-link,
.report-button,
button[type="submit"] {
  background: var(--accent);
  color: white;
}

.link-button {
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
}

.text-link {
  color: var(--accent);
  font-weight: 800;
  text-align: center;
}

.messages {
  left: 50%;
  position: fixed;
  top: 76px;
  transform: translateX(-50%);
  z-index: 900;
}

.message {
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 8px;
  margin: 0;
  padding: 12px 16px;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  min-height: calc(100vh - 64px);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 28px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.35rem);
  letter-spacing: 0;
  line-height: 1.04;
  margin: 0 0 24px;
}

.stats {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  margin: 24px 0;
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stats strong {
  display: block;
  font-size: 1.8rem;
}

.stats span,
.legend-item p,
.popup span {
  color: var(--muted);
}

.legend {
  display: grid;
  gap: 10px;
  margin: 28px 0;
}

.legend-item {
  align-items: center;
  display: flex;
  gap: 10px;
}

.legend-item span {
  border: 2px solid #111827;
  border-radius: 999px;
  height: 18px;
  width: 18px;
}

.legend-item p {
  margin: 0;
}

.report-button {
  display: inline-flex;
  justify-content: center;
  padding: 14px 16px;
  width: 100%;
}

.outline-button,
.danger-button {
  align-items: center;
  border: 1px solid var(--line);
  display: inline-flex;
  justify-content: center;
  padding: 12px 14px;
}

.danger-button,
.danger-submit {
  background: #b91c1c;
  color: white;
}

.map-panel {
  min-height: calc(100vh - 64px);
  width: 100%;
}

.map-error {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-weight: 700;
  height: 100%;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.popup {
  display: grid;
  gap: 6px;
  max-width: 240px;
}

.popup p {
  margin: 0;
}

.popup-photo {
  border-radius: 8px;
  height: 120px;
  object-fit: cover;
  width: 100%;
}

.form-shell {
  margin: 0 auto;
  max-width: 760px;
  padding: 36px 20px 56px;
}

.form-header h1 {
  max-width: 680px;
}

.complaint-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  padding: 20px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-weight: 800;
}

input,
select,
textarea {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  padding: 12px 14px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.error {
  color: #b91c1c;
  font-weight: 700;
}

.form-actions {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin-top: 8px;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
  padding: 14px 16px;
}

button[type="button"] {
  background: #e2e8f0;
  color: var(--ink);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.muted {
  color: var(--muted);
}

.detail-shell,
.panel-shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 32px 20px 56px;
}

.detail-header,
.table-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.detail-actions {
  display: flex;
  gap: 10px;
}

.detail-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
}

.detail-card,
.panel-box,
.metric-grid div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-card,
.panel-box {
  padding: 20px;
}

.detail-card h2,
.panel-box h2 {
  margin-top: 0;
}

.detail-card dl {
  display: grid;
  gap: 8px;
  grid-template-columns: 120px 1fr;
  margin: 24px 0 0;
}

.detail-card dt {
  color: var(--muted);
  font-weight: 800;
}

.detail-card dd {
  margin: 0;
}

.detail-photo {
  border-radius: 8px;
  height: 100%;
  max-height: 420px;
  object-fit: cover;
  width: 100%;
}

.page-heading h1 {
  margin-bottom: 16px;
}

.metric-grid,
.chart-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.metric-grid {
  grid-template-columns: repeat(4, 1fr);
}

.metric-grid div {
  padding: 18px;
}

.metric-grid strong {
  display: block;
  font-size: 2rem;
}

.metric-grid span {
  color: var(--muted);
}

.chart-grid {
  grid-template-columns: 1fr 1fr;
}

.panel-box canvas {
  max-height: 320px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

td a {
  color: var(--accent);
  font-weight: 800;
}

.filter-form {
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, 1fr) auto auto;
  margin-bottom: 16px;
  padding: 16px;
}

.compact-field {
  gap: 6px;
}

.compact-field input,
.compact-field select {
  min-height: 48px;
}

@media print {
  .topbar,
  .messages,
  .no-print {
    display: none;
  }

  body {
    background: white;
  }

  .panel-shell {
    max-width: none;
    padding: 0;
  }

  .panel-box {
    border: 0;
    padding: 0;
  }
}

@media (max-width: 800px) {
  .topbar {
    padding: 0 14px;
  }

  .topbar nav {
    gap: 4px;
  }

  .topbar nav a {
    padding: 9px 8px;
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 22px 18px;
  }

  .map-panel {
    min-height: 62vh;
  }

  .form-actions,
  .stats,
  .metric-grid,
  .chart-grid,
  .detail-grid,
  .filter-form {
    grid-template-columns: 1fr;
  }

  .detail-header,
  .table-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-actions {
    flex-direction: column;
  }
}
