.admin-body {
  background: #f5f7fa;
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-overflow-scrolling: touch;
}

html:has(.admin-body) {
  overflow: auto;
  height: auto;
}

.admin-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 12px calc(32px + env(safe-area-inset-bottom, 0px));
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
}

.admin-copyright {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: #999;
  line-height: 1.5;
}

.admin-header {
  margin-bottom: 24px;
}

.admin-back {
  color: var(--blue);
  text-decoration: none;
  font-size: 14px;
  display: inline-block;
  margin-bottom: 12px;
}

.admin-header h1 {
  font-size: 18px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  line-height: 1.25;
}

.admin-logo {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.admin-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.admin-card {
  background: white;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.admin-card h2 {
  font-size: 16px;
  margin: 8px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.admin-form label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 500;
  color: #444;
}

.site-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.site-home-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  background: #eef6ff;
  border: 1px solid #d6e8fb;
  border-radius: 8px;
}

.site-home-icon svg {
  width: 22px;
  height: 22px;
}

.site-name-row input {
  flex: 1;
  min-width: 0;
  margin-top: 0 !important;
}

.name-quality-row,
.camera-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  margin-bottom: 4px;
}

.name-field {
  width: 100%;
  max-width: 100%;
  margin-bottom: 0 !important;
}

.risk-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  align-items: flex-start;
}

.template-field {
  flex: 0 0 38%;
  min-width: 0;
  margin-bottom: 0 !important;
}

.risk-row .risk-field {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  margin-bottom: 0 !important;
}

.risk-field input,
.risk-field textarea,
.template-field select {
  margin-top: 6px;
}

.admin-form textarea.camera-risk-input {
  display: block;
  width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.35;
  font-family: inherit;
  box-sizing: border-box;
}

.option-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  align-items: stretch;
}

.quality-field {
  flex: 1 1 38%;
  width: auto;
  min-width: 92px;
  font-size: 12px;
  font-weight: 500;
  color: #444;
}

.type-field {
  flex: 1 1 62%;
  width: auto;
  min-width: 128px;
}

.quality-field span {
  display: block;
  margin-bottom: 4px;
}

.quality-toggle {
  display: flex;
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.quality-opt,
.housing-opt {
  flex: 1 1 50%;
  border: none;
  background: #fff;
  padding: 10px 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  color: #888;
  cursor: pointer;
  min-height: 44px;
}

.quality-opt + .quality-opt,
.housing-opt + .housing-opt {
  border-left: 1px solid #ddd;
}

.housing-opt.active,
.quality-opt.active[data-quality="2K"] {
  background: var(--blue);
  color: #fff;
}

.housing-opt.active[data-housing="Dome"] {
  background: #22c55e;
  color: #fff;
}

.quality-opt.active[data-quality="4K"] {
  background: #facc15;
  color: #222;
}

.admin-form input[type="text"],
.admin-form select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.25;
  min-height: 44px;
  box-sizing: border-box;
}

.admin-form input[type="file"] {
  display: block;
  margin-top: 6px;
  font-size: 14px;
}

.btn {
  display: inline-block;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  min-height: 44px;
}

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-primary:active {
  background: var(--blue-dark);
}

.btn-secondary {
  background: #eee;
  color: #333;
  margin-right: 8px;
  margin-bottom: 8px;
}

.btn-danger {
  background: #ff4d4f;
  color: white;
}

.file-btn {
  cursor: pointer;
}

.photo-preview {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  max-height: 200px;
}

.photo-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  background: #111;
}

.sites-admin-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-site {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.admin-site-header {
  background: #f8f9fa;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-site-header h3 {
  font-size: 15px;
}

.admin-site-actions {
  display: flex;
  gap: 8px;
}

.admin-site-actions button {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 6px;
  cursor: pointer;
}

.admin-site-actions .delete-btn {
  color: #ff4d4f;
  border-color: #ffccc7;
}

.admin-cameras {
  padding: 8px;
}

.admin-camera {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-bottom: 1px solid #f0f0f0;
}

.admin-camera:last-child {
  border-bottom: none;
}

.admin-camera img {
  width: 80px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  background: #222;
}

.admin-camera-info {
  flex: 1;
}

.admin-camera-info strong {
  font-size: 14px;
  display: block;
}

.admin-camera-info small {
  color: var(--text-muted);
  font-size: 12px;
}

.admin-danger-zone {
  border: 1px dashed #ffccc7;
}

.admin-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.admin-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin: -8px 0 16px;
  line-height: 1.5;
}

.camera-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 16px 0;
}

.camera-upload-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fafbfc;
  overflow: hidden;
}

.photo-field {
  position: relative;
}

.camera-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.camera-row-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
}

.remove-row-btn {
  border: none;
  background: none;
  color: #ff4d4f;
  font-size: 13px;
  cursor: pointer;
  padding: 8px 10px;
  min-height: 44px;
}

.camera-form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.camera-form-actions .btn {
  width: 100%;
  margin: 0;
}

.photo-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.photo-actions .btn {
  flex: 1;
  margin: 0;
  min-width: 0;
  padding: 12px 8px;
  font-size: 14px;
}

.photo-field span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #444;
}

.camera-photo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.upload-instructions {
  font-size: 13px;
  font-style: italic;
  color: #b0b0b0;
  line-height: 1.5;
  margin: 6px 0 4px;
}

.camera-upload-row .photo-preview {
  margin-top: 10px;
}

body.landcam-open {
  overflow: hidden;
}

.landcam-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: #000;
}

.landcam-overlay.hidden {
  display: none;
}

.landcam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.landcam-rotate {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.55);
}

.landcam-overlay.is-portrait .landcam-rotate {
  display: flex;
}

.landcam-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  z-index: 2;
}

.landcam-shutter {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: #fff;
  color: transparent;
  font-size: 0;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}

.landcam-shutter:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

@media (orientation: portrait) {
  .landcam-shutter {
    right: auto;
    top: auto;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
  }
}

@media (min-width: 480px) {
  .admin-container {
    padding: 24px 16px 48px;
  }

  .admin-header h1 {
    font-size: 22px;
    gap: 10px;
  }

  .admin-logo {
    height: 42px;
  }

  .admin-card {
    padding: 20px;
  }

  .name-field {
    width: 50%;
    max-width: 50%;
  }

  .camera-form-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .camera-form-actions .btn {
    width: auto;
    flex: 1 1 auto;
  }
}

@media (min-width: 720px) {
  .quality-field {
    flex: 0 0 12.5%;
    width: 12.5%;
    min-width: 0;
  }

  .type-field {
    flex: 0 0 30%;
    width: 30%;
    min-width: 0;
  }
}
