:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #152033;
  --muted: #607089;
  --border: #dfe6ef;
  --primary: #0f6fff;
  --primary-dark: #084eb8;
  --danger: #c62828;
  --success: #167a3a;
  --shadow: 0 24px 70px rgba(21, 32, 51, 0.12);
  --radius: 22px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #e9f1ff, transparent 36rem), var(--bg);
  color: var(--text);
}

.page {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0;
}

.form-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 0;
}

.card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(223, 230, 239, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.form-card { width: min(760px, calc(100% - 32px)); }

.card-header {
  padding: 28px 28px 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

h2 { margin: 0 0 12px; font-size: 24px; }

.lead {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

form { padding: 22px 28px 28px; }

.field { margin-bottom: 18px; }

.name-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 14px;
}

input, select, button {
  font: inherit;
}

input[type="text"], input[type="password"], select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 56px;
  background-color: #fff !important;
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='8' viewBox='0 0 14 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23152033' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-position: right 16px center !important;
  background-size: 14px 8px !important;
  background-repeat: no-repeat;
}

select::-ms-expand {
  display: none;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 111, 255, 0.12);
}

.file-control {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.file-control:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 111, 255, 0.12);
}

.file-control.is-dragging {
  border-color: var(--primary);
  background: #f3f8ff;
  box-shadow: 0 0 0 4px rgba(15, 111, 255, 0.12);
}

.file-control__input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-control__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin: 0;
  padding: 8px 14px;
  border-radius: 10px;
  background: #e9eef6;
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}

.file-control__button:hover {
  background: #dce5f2;
}

.file-control__name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.help {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

button, .button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: white;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

button:hover, .button:hover { background: var(--primary-dark); }
button.secondary { background: #e9eef6; color: var(--text); }
button.secondary:hover { background: #dce5f2; }
button.danger { background: var(--danger); }
button.success { background: var(--success); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.message {
  display: none;
  margin: 0 28px 20px;
  padding: 14px 16px;
  border-radius: 14px;
  font-weight: 700;
}
.message.show { display: block; }
.message.error { background: #ffebee; color: #9d1b1b; }
.message.success { background: #e9f8ee; color: #0b662b; }

.hidden { display: none !important; }

.status-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(21, 32, 51, 0.48);
  backdrop-filter: blur(5px);
}

.status-dialog {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(223, 230, 239, 0.95);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.status-dialog h2 {
  margin: 14px 0 8px;
  font-size: 26px;
}

.status-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.status-dialog button {
  margin-top: 20px;
}

.status-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 50%;
}

.status-icon--loading {
  border: 5px solid #dce5f2;
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

.status-icon--success {
  display: grid;
  place-items: center;
  background: var(--success);
}

.status-icon--success::before {
  content: "";
  width: 22px;
  height: 12px;
  border: solid #fff;
  border-width: 0 0 4px 4px;
  transform: rotate(-45deg) translate(1px, -2px);
}

.status-icon--error {
  position: relative;
  background: var(--danger);
}

.status-icon--error::before,
.status-icon--error::after {
  content: "";
  position: absolute;
  top: 24px;
  left: 14px;
  width: 24px;
  height: 4px;
  border-radius: 99px;
  background: #fff;
}

.status-icon--error::before { transform: rotate(45deg); }
.status-icon--error::after { transform: rotate(-45deg); }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.location-box {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}

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

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

#pickerMap, #publicMap {
  width: 100%;
  min-height: 360px;
}

#pickerMap { min-height: 300px; }

.map-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.map-toolbar {
  position: relative;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.map-toolbar h1 { font-size: 22px; letter-spacing: -0.03em; }
.map-toolbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.map-toolbar select { width: min(280px, 100%); }
#publicMap { min-height: calc(100vh - 82px); }

.bank-marker-icon {
  background: transparent;
  border: 0;
}

.bank-marker-icon span {
  position: relative;
  display: block;
  width: 24px;
  height: 24px;
  margin: 0 auto;
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: var(--bank-color);
  box-shadow: 0 3px 10px rgba(21, 32, 51, 0.32);
  transform: rotate(-45deg);
}

.bank-marker-icon span::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(21, 32, 51, 0.14);
}

.popup-card { width: 230px; }
.popup-image-button {
  display: block;
  width: 100%;
  min-height: 0;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: zoom-in;
  overflow: hidden;
}
.popup-image-button:hover { background: transparent; }
.popup-card img { width: 100%; max-height: 210px; object-fit: cover; display: block; }
.popup-card strong { display: block; font-size: 15px; }
.popup-card span { display: block; color: #607089; font-size: 13px; margin-top: 2px; }

.image-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: grid;
  place-items: center;
  padding: 56px 20px 24px;
  background: rgba(10, 16, 28, 0.86);
}

.image-overlay img {
  max-width: min(1100px, 100%);
  max-height: calc(100vh - 96px);
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  object-fit: contain;
}

.image-overlay__close {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 44px;
  min-height: 44px;
  padding: 0 0 5px 0;
  border-radius: 50%;
  background: #fff;
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

.image-overlay__close:hover { background: #e9eef6; }

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.admin-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 34px rgba(21,32,51,0.08);
}
.admin-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.admin-item__body { padding: 16px; }
.admin-item__meta { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 8px 0 14px; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 720px) {
  .page { width: min(100% - 20px, 1080px); padding: 16px 0; }
  .form-card { width: calc(100% - 20px); }
  .name-fields { grid-template-columns: 1fr; gap: 0; }
  .card-header, form { padding-left: 18px; padding-right: 18px; }
  .message { margin-left: 18px; margin-right: 18px; }
  .map-toolbar { align-items: stretch; flex-direction: column; }
  #publicMap { min-height: calc(100vh - 148px); }
}
