:root {
  --ink: #18202a;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #ffffff;
  --smoke: #f5f7fa;
  --red: #d71920;
  --red-dark: #aa1016;
  --green: #148447;
  --gold: #e0ad25;
  --blue: #1967d2;
  --shadow: 0 16px 40px rgba(18, 24, 33, .18);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
#map {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  background: var(--smoke);
}

#map {
  z-index: 1;
}

.toolbar {
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 500;
  width: min(320px, calc(100vw - 36px));
  display: grid;
  gap: 10px;
}

.tool-button {
  min-height: 54px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
}

.tool-button.primary {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.tool-button:hover {
  transform: translateY(-1px);
}

.icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(24, 32, 42, .08);
  font-size: 20px;
}

.primary .icon {
  background: rgba(255, 255, 255, .18);
}

.status {
  margin: 0;
  padding: 11px 13px;
  border-radius: 8px;
  background: rgba(24, 32, 42, .88);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.35;
}

.brand {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 500;
  width: min(160px, 32vw);
  margin: 0;
}

.brand img {
  width: 100%;
  display: block;
  border-radius: 8px;
  background: rgba(0, 0, 0, .82);
  padding: 7px;
  box-shadow: var(--shadow);
}

.dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(13, 18, 27, .58);
}

.hydrant-form,
.list-dialog {
  background: var(--paper);
  color: var(--ink);
}

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

.dialog-head h1 {
  margin: 0;
  font-size: 24px;
}

.dialog-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 20px 0;
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(215, 25, 32, .12);
}

.preview-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px;
  padding: 18px 20px 0;
  align-items: center;
}

.image-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--smoke);
  color: var(--muted);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 700;
  text-align: center;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.coordinate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.small-button,
.secondary-button,
.save-button,
.delete-button {
  min-height: 40px;
  border-radius: 7px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.save-button {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.save-button:hover,
.tool-button.primary:hover {
  background: var(--red-dark);
}

.delete-button {
  margin-right: auto;
  background: #fff0f0;
  color: var(--red-dark);
  border-color: #f0b4b4;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 20px 20px;
}

.hydrant-list {
  padding: 16px 20px 20px;
  display: grid;
  gap: 10px;
}

.hydrant-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.hydrant-card img,
.hydrant-thumb {
  width: 72px;
  aspect-ratio: 1;
  border-radius: 7px;
  object-fit: cover;
  background: var(--smoke);
  border: 1px solid var(--line);
}

.hydrant-thumb {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.hydrant-card h2 {
  margin: 0 0 5px;
  font-size: 17px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.badge.ok {
  background: var(--green);
}

.badge.bad {
  background: var(--red-dark);
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.leaflet-popup-content {
  min-width: 210px;
}

.popup-title {
  margin: 0 0 8px;
  font-size: 16px;
}

.popup-photo {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  border-radius: 7px;
  margin: 4px 0 8px;
}

.popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.popup-actions button,
.popup-actions a {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
  text-decoration: none;
  font-weight: 700;
}

@media (max-width: 720px) {
  .toolbar {
    top: auto;
    bottom: 14px;
    left: 14px;
    right: 14px;
    width: auto;
  }

  .tool-button {
    min-height: 48px;
  }

  .brand {
    width: 116px;
    right: 12px;
    top: 12px;
  }

  .form-grid,
  .preview-row {
    grid-template-columns: 1fr;
  }

  .hydrant-card {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .hydrant-card img,
  .hydrant-thumb {
    width: 58px;
  }

  .card-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
