* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: #f4f6f8;
  color: #1a1a1a;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  margin: 0.5rem 0.5rem 0;
  background: #1d6fe0;
  border-radius: 12px;
  padding: 0.45rem 0.7rem 0.45rem 1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}

.header-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
}

.logout {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fff;
  color: #e11d48;
  border-radius: 999px;
  padding: 0.38rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1;
}

.login-body {
  min-height: 100vh;
  height: auto;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e7ae6;
  position: relative;
}

.login-blob {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  pointer-events: none;
}

.login-blob-a {
  width: 340px;
  height: 340px;
  top: -120px;
  left: -90px;
}

.login-blob-b {
  width: 280px;
  height: 280px;
  right: -70px;
  bottom: -80px;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(780px, calc(100% - 2.5rem));
  min-height: 390px;
  display: grid;
  grid-template-columns: 300px 1fr;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(15, 60, 130, 0.22);
}

.login-brand {
  background: #1a6fd4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.login-mark {
  width: 132px;
  height: 132px;
  border-radius: 30px;
  background: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(12, 58, 120, 0.12);
}

.login-mark img {
  position: absolute;
  height: 108px;
  width: auto;
  max-width: none;
  left: 12px;
  top: 12px;
}

.login-form {
  padding: 2.15rem 2.3rem 1.8rem;
}

.login-form h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-form .login-lead {
  margin: 0.15rem 0 1.35rem;
  color: #8b97a8;
  font-size: 0.86rem;
}

.login-form label {
  display: block;
  margin-bottom: 0.95rem;
  font-size: 0.8rem;
  color: #3a4658;
}

.login-field {
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  height: 44px;
  padding: 0 0.75rem;
  border: 1px solid #e6eef5;
  border-radius: 8px;
  background: #f4f7fb;
}

.login-field svg {
  flex-shrink: 0;
  color: #94a3b8;
}

.login-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  color: #1a1a1a;
  outline: none;
}

.login-eye {
  border: 0;
  background: transparent;
  padding: 0;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
}

.login-form button[type="submit"] {
  width: 100%;
  height: 46px;
  margin-top: 0.45rem;
  border: 0;
  border-radius: 8px;
  background: #1f78e8;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.login-error {
  margin: 0 0 0.7rem;
  color: #b91c1c;
  font-size: 0.78rem;
}

@media (max-width: 680px) {
  .login-card {
    grid-template-columns: 1fr;
  }
}

.header-logo {
  display: block;
  height: 40px;
  width: auto;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0.5rem;
  padding: 0.5rem;
  padding-top: 0.45rem;
  flex: 1;
  min-height: 0;
}

.panel {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e0e4e8;
  min-height: 0;
}

.downloads {
  padding: 0.5rem;
  overflow-y: auto;
}

.download-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.download-card a {
  display: block;
  text-decoration: none;
  background: #2563eb;
  color: #fff;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  font-size: 0.72rem;
  line-height: 1.25;
  text-align: center;
  word-break: break-all;
}

.download-card a.disabled {
  background: #b8c0c8;
  pointer-events: none;
}

.map-panel {
  display: flex;
  flex-direction: column;
  padding: 0.35rem;
  min-height: 0;
}

.leaflet-control-filter {
  background: #fff;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  padding: 0;
}

.leaflet-control-filter select {
  display: block;
  width: 168px;
  height: 28px;
  padding: 0 0.35rem;
  border: none;
  border-radius: 2px;
  font-size: 0.72rem;
  background: #fff;
  cursor: pointer;
}

.leaflet-control-home {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  line-height: 30px;
  color: #333;
  background: #fff;
}

.map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

#map {
  flex: 1;
  min-height: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #dde3ea;
}

.district-legend {
  position: absolute;
  right: 10px;
  bottom: 26px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  padding: 0.5rem 0.65rem 0.55rem;
  font-size: 0.72rem;
  line-height: 1.2;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
  pointer-events: none;
}

.legend-header {
  font-weight: 600;
  font-size: 0.68rem;
  color: #64748b;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #e8ecf0;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(3, auto);
  column-gap: 0.65rem;
  row-gap: 0.2rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.legend-grid--mapping {
  grid-template-columns: 1fr;
  max-height: 200px;
  overflow-y: auto;
}

.legend-grid--mapping .legend-item span:last-child {
  white-space: normal;
  line-height: 1.25;
}

.leaflet-control-check label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  height: 28px;
  padding: 0 0.45rem;
  font-size: 0.72rem;
  background: #fff;
  cursor: pointer;
  user-select: none;
}

.leaflet-control-check input {
  margin: 0;
  cursor: pointer;
}

.location-label span {
  display: inline-block;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #111;
  border-radius: 6px;
  padding: 1px 6px;
  font-weight: 600;
  font-size: 10px;
  color: #111;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.location-label {
  background: transparent;
  border: none;
  box-shadow: none;
}

.khoroo-num span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid;
  border-radius: 50%;
  font-weight: 700;
  font-size: 11px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.khoroo-num {
  background: transparent;
  border: none;
  box-shadow: none;
}

.oc1-pin {
  background: transparent;
  border: none;
}

@media (max-width: 960px) {
  body {
    height: auto;
    overflow: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .map-wrap,
  #map {
    min-height: 60vh;
  }
}
