:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #64717c;
  --line: #d8e0e6;
  --panel: rgba(255, 255, 255, 0.95);
  --panel-solid: #ffffff;
  --sole-primary: #00acd8;
  --sole-secondary: #cb007b;
  --accent: #00acd8;
  --accent-strong: #007fa1;
  --danger: #c2410c;
  --warning: #b45309;
  --ok: #15803d;
  --shadow: 0 16px 48px rgba(19, 32, 38, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: #eef3f4;
  overflow: hidden;
}

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

.app-shell,
.map-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
}

.map-layer {
  background: #dfe8ea;
}

.map {
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: #dfe8ea;
}

.topbar {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.brand,
.topbar-actions,
.filter-rail,
.status-chip,
.sheet {
  pointer-events: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 1 auto;
  max-width: 150px;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid rgba(130, 151, 160, 0.45);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
}

.brand > svg {
  display: block;
  width: 100%;
  max-width: 150px;
  max-height: 100px;
  height: auto;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.icon-button,
.text-button {
  border: 1px solid rgba(130, 151, 160, 0.5);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
}

.icon-button svg,
.text-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

.icon-button.primary,
.text-button.primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--sole-primary), #0790b6);
  color: white;
}

.icon-button.active {
  border-color: var(--sole-secondary);
  background: var(--sole-secondary);
  color: white;
}

.text-button.danger {
  border-color: rgba(203, 0, 123, 0.35);
  background: rgba(203, 0, 123, 0.08);
  color: #a00062;
}

.text-button.share {
  grid-column: 1 / -1;
  border-color: rgba(0, 172, 216, 0.35);
  background: rgba(0, 172, 216, 0.08);
  color: var(--accent-strong);
}

.text-button:disabled,
.icon-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.menu-button,
.drawer-head,
.drawer-backdrop {
  display: none;
}

.control-drawer,
.drawer-content {
  display: contents;
}

.filter-rail {
  position: fixed;
  top: calc(max(14px, env(safe-area-inset-top)) + 150px);
  left: 14px;
  z-index: 4;
  display: flex;
  gap: 8px;
  max-width: min(560px, calc(100vw - 28px));
  padding: 8px;
  border: 1px solid rgba(130, 151, 160, 0.45);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.drawer-actions {
  display: none;
}

.select-control {
  display: grid;
  gap: 3px;
}

.range-control {
  display: grid;
  grid-template-columns: minmax(118px, 160px) auto;
  gap: 3px 8px;
  align-items: center;
}

.select-control span,
.range-control span,
.report-form span,
.detail-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.range-control span {
  grid-column: 1 / -1;
}

.range-control input {
  width: 100%;
  padding: 0;
  accent-color: var(--accent);
}

.range-control output {
  min-width: 54px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  outline: none;
}

select {
  min-width: 148px;
  height: 34px;
  padding: 0 32px 0 10px;
}

input,
textarea {
  padding: 10px 11px;
}

textarea {
  resize: none;
}

.status-chip {
  position: fixed;
  top: calc(max(14px, env(safe-area-inset-top)) + 225px);
  left: 14px;
  z-index: 4;
  max-width: calc(100vw - 28px);
  padding: 7px 10px;
  border: 1px solid rgba(130, 151, 160, 0.45);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
}

.toast-stack {
  position: fixed;
  top: calc(max(14px, env(safe-area-inset-top)) + 260px);
  left: 14px;
  z-index: 6;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}

.toast {
  padding: 10px 12px;
  border: 1px solid rgba(130, 151, 160, 0.45);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 760;
}

.toast.error {
  border-left-color: var(--danger);
}

.official-contacts {
  position: fixed;
  left: 14px;
  bottom: 16px;
  z-index: 4;
  display: grid;
  gap: 6px;
  width: min(300px, calc(100vw - 468px));
  min-width: 240px;
  padding: 10px;
  border: 1px solid rgba(130, 151, 160, 0.45);
  border-left: 4px solid var(--sole-secondary);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.official-contacts h2 {
  margin: 0;
  font-size: 13px;
  line-height: 1.2;
}

.official-contact {
  display: grid;
  gap: 1px;
  padding-top: 6px;
  border-top: 1px solid rgba(130, 151, 160, 0.24);
}

.official-contact strong {
  font-size: 12px;
}

.official-contact span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.official-contact a {
  width: fit-content;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.official-contact a:focus-visible,
.official-contact a:hover {
  color: var(--sole-secondary);
  text-decoration: underline;
}

.official-contact small {
  color: #7c2d12;
  font-size: 10px;
  line-height: 1.3;
}

.proximity-alert {
  --risk-drawer-offset: 16px;
  position: fixed;
  top: calc(max(14px, env(safe-area-inset-top)) + 154px);
  right: 16px;
  z-index: 6;
  display: block;
  width: min(380px, calc(100vw - 32px));
  max-height: min(360px, calc(100vh - 232px));
  overflow: visible;
  transition: transform 180ms ease, bottom 180ms ease;
}

.proximity-alert.collapsed {
  transform: translateX(calc(100% + var(--risk-drawer-offset)));
}

.proximity-alert.hidden {
  display: none;
}

.proximity-panel {
  display: grid;
  gap: 10px;
  width: 100%;
  max-height: min(360px, calc(100vh - 232px));
  padding: 12px;
  border: 1px solid rgba(185, 28, 28, 0.45);
  border-left: 5px solid #d92d20;
  border-radius: 8px;
  background: rgba(255, 245, 245, 0.97);
  color: #7f1d1d;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.proximity-toggle {
  position: absolute;
  top: 10px;
  left: -52px;
  z-index: 1;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(185, 28, 28, 0.45);
  border-radius: 8px;
  background: #d92d20;
  color: #ffffff;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.proximity-toggle svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.5;
}

.proximity-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--sole-secondary);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  line-height: 16px;
  text-align: center;
}

.proximity-alert:not(.collapsed) .proximity-toggle {
  top: 8px;
  right: 8px;
  left: auto;
  background: #ffffff;
  color: #991b1b;
  box-shadow: none;
}

.proximity-alert:not(.collapsed) .proximity-head {
  padding-right: 48px;
}

.proximity-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.proximity-head strong {
  font-size: 14px;
  line-height: 1.2;
}

.proximity-head span {
  color: #991b1b;
  font-size: 12px;
  font-weight: 800;
}

.proximity-list {
  display: grid;
  gap: 7px;
  overflow: auto;
}

.proximity-item {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 56px;
  padding: 9px 10px;
  border: 1px solid rgba(220, 38, 38, 0.28);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.proximity-item strong {
  color: #7f1d1d;
  font-size: 13px;
  line-height: 1.25;
}

.proximity-item span {
  color: #991b1b;
  font-size: 12px;
  font-weight: 700;
}

.sheet {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  width: min(420px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 152px));
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(130, 151, 160, 0.45);
  border-radius: 8px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: max-height 180ms ease, transform 180ms ease;
}

.sheet-handle {
  display: none;
}

.sheet-view {
  display: none;
  min-height: 0;
  padding: 16px;
}

.sheet-view.active {
  display: flex;
  flex-direction: column;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.sheet h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.sheet p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.report-list {
  display: grid;
  gap: 8px;
  min-height: 96px;
  overflow: auto;
}

.history-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.history-head h2 {
  margin: 0;
  font-size: 14px;
}

.history-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-list {
  display: grid;
  gap: 7px;
  max-height: 130px;
  overflow: auto;
}

.history-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.history-item strong {
  font-size: 13px;
}

.history-item span {
  color: var(--muted);
  font-size: 12px;
}

.report-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 74px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: left;
  cursor: pointer;
}

.report-dot {
  width: 10px;
  height: 38px;
  border-radius: 5px;
  background: var(--accent);
}

.report-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.report-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.report-badge {
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(0, 172, 216, 0.12);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.empty-state {
  display: grid;
  min-height: 110px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.detail-grid div {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.detail-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
}

.detail-copy {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink) !important;
  line-height: 1.45;
}

.detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.detail-actions div {
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.detail-actions span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-actions strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.report-form {
  gap: 10px;
}

.report-form label {
  display: grid;
  gap: 5px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 780;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 38, 0.42);
}

.modal-backdrop.hidden {
  display: none;
}

.help-modal {
  width: min(520px, 100%);
  max-height: min(680px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid rgba(130, 151, 160, 0.45);
  border-radius: 8px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.help-head h2 {
  margin: 0;
  font-size: 18px;
}

.help-copy {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.help-section {
  display: grid;
  gap: 10px;
}

.help-section h3,
.help-section h4 {
  margin: 0;
  color: var(--ink);
  line-height: 1.25;
}

.help-section h3 {
  font-size: 15px;
}

.help-section h4 {
  padding-top: 4px;
  font-size: 13px;
}

.help-copy p {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.disclaimer-section {
  max-height: 300px;
  padding: 12px;
  border: 1px solid rgba(203, 0, 123, 0.18);
  border-left: 4px solid var(--sole-secondary);
  border-radius: 8px;
  background: #fff7fb;
  overflow: auto;
}

.disclaimer-section p {
  color: #3d2a34;
  font-size: 12px;
}

.maplibregl-popup-content {
  padding: 10px;
  border-radius: 8px;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.sole-map-marker {
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  cursor: pointer;
  transform: translateY(-2px);
}

.sole-map-marker.create {
  cursor: grab;
}

.sole-map-marker.create:active {
  cursor: grabbing;
}

@media (max-width: 720px) {
  .topbar {
    left: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    justify-content: space-between;
    max-width: calc(100vw - 20px);
    overflow: visible;
  }

  .brand {
    flex: 0 1 auto;
    max-width: min(150px, calc(100vw - 150px));
    font-size: 14px;
    line-height: 1.05;
    overflow: hidden;
  }

  .brand > svg {
    max-height: 84px;
  }

  .topbar-actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px;
    max-width: calc(100vw - 160px);
    overflow: hidden;
  }

  .topbar-actions .icon-button {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
  }

  .menu-button {
    display: grid;
  }

  .topbar-actions > a,
  #autoRefreshButton,
  #helpButton {
    display: none;
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 12;
    display: block;
    background: rgba(23, 32, 38, 0.36);
  }

  .drawer-backdrop.hidden {
    display: none;
  }

  .control-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 10px;
    z-index: 13;
    display: flex;
    flex-direction: column;
    width: min(340px, calc(100vw - 20px));
    padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
    border: 1px solid rgba(130, 151, 160, 0.45);
    border-radius: 0 8px 8px 0;
    background: var(--panel-solid);
    box-shadow: var(--shadow);
    transform: translateX(calc(-100% - 16px));
    transition: transform 160ms ease;
    pointer-events: auto;
  }

  .control-drawer.open {
    transform: translateX(0);
  }

  .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
  }

  .drawer-head strong {
    font-size: 16px;
  }

  .drawer-content {
    display: grid;
    gap: 12px;
    min-height: 0;
    padding-top: 12px;
    overflow: auto;
  }

  .drawer-actions {
    display: grid;
    gap: 8px;
  }

  .drawer-actions .text-button {
    width: 100%;
    justify-content: flex-start;
    box-shadow: none;
  }

  .drawer-actions .text-button.active {
    border-color: var(--sole-secondary);
    background: rgba(203, 0, 123, 0.1);
    color: #a00062;
  }

  .filter-rail {
    position: static;
    display: grid;
    gap: 10px;
    max-width: none;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .select-control,
  .range-control {
    width: 100%;
  }

  select {
    min-width: 0;
  }

  .status-chip {
    top: auto;
    bottom: calc(46vh + 14px);
    left: 10px;
    max-width: calc(100vw - 20px);
    transition: bottom 180ms ease;
  }

  .toast-stack {
    top: auto;
    bottom: calc(46vh + 50px);
    left: 10px;
    width: calc(100vw - 20px);
    transition: bottom 180ms ease;
  }

  .proximity-alert {
    --risk-drawer-offset: 10px;
    top: auto;
    right: 10px;
    bottom: calc(46vh + 92px);
    width: calc(100vw - 20px);
    max-height: none;
    transition: transform 180ms ease, bottom 180ms ease;
  }

  .proximity-panel {
    max-height: 132px;
  }

  .proximity-toggle {
    left: -50px;
  }

  .official-contacts {
    position: static;
    display: grid;
    width: auto;
    min-width: 0;
    box-shadow: none;
  }

  .sheet {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 46vh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }

  .sheet-handle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    padding: 8px 14px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff, #f7fbfc);
    color: var(--accent-strong);
    font-weight: 850;
    box-shadow: none;
  }

  .sheet-grip {
    position: absolute;
    top: 7px;
    left: 50%;
    width: 48px;
    height: 4px;
    border-radius: 999px;
    background: #c8d3da;
    transform: translateX(-50%);
  }

  .sheet-handle svg {
    width: 17px;
    height: 17px;
    color: var(--sole-secondary);
  }

  .sheet.collapsed {
    max-height: 52px;
  }

  .sheet.collapsed .sheet-view {
    display: none;
  }

  .sheet.collapsed .sheet-handle {
    min-height: 52px;
    border-bottom: 0;
  }

  .sheet.collapsed .sheet-handle svg {
    transform: rotate(180deg);
  }

  body.sheet-collapsed .status-chip {
    bottom: 66px;
  }

  body.sheet-collapsed .toast-stack {
    bottom: 104px;
  }

  body.sheet-collapsed .proximity-alert {
    bottom: 146px;
  }

  .sheet-view {
    padding: 12px 14px 16px;
    overflow: auto;
  }

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

  .detail-actions {
    grid-template-columns: 1fr;
  }

  .range-control {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 480px) {
  .brand {
    max-width: min(150px, calc(100vw - 150px));
    padding: 8px;
  }

  .brand > svg {
    max-height: 78px;
  }

  .topbar-actions .icon-button {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .topbar-actions {
    max-width: 126px;
  }

  .sheet h1 {
    font-size: 16px;
  }

  .report-item {
    grid-template-columns: 10px minmax(0, 1fr);
  }

  .report-badge {
    grid-column: 2;
    justify-self: start;
  }
}
