* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, sans-serif; background: #f3f4f6; color: #111827; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 16px; background: #111827; color: #fff; }
.topbar a { color: #fff; text-decoration: none; }
main { display: grid; grid-template-rows: auto 1fr; min-height: calc(100vh - 49px); }
.panel { padding: 16px; background: #fff; border-bottom: 1px solid #e5e7eb; }
h1 { margin: 0 0 16px; font-size: 24px; }
h2 { margin: 0 0 14px; }
h3 { margin: 0 0 10px; font-size: 18px; }
p { margin: 8px 0; }
.status { color: #4b5563; font-size: 14px; }
#map { min-height: 55vh; height: 100%; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.78); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.hidden { display: none; }
.modal-content { position: relative; max-width: 960px; width: 100%; max-height: 92vh; background: #fff; border-radius: 16px; padding: 16px; text-align: center; overflow: auto; }
.modal-content img { max-width: 100%; max-height: 75vh; border-radius: 8px; }
.close { position: absolute; top: 8px; right: 12px; border: 0; background: transparent; font-size: 32px; line-height: 1; }
.admin-wrap { max-width: 1280px; margin: 0 auto; padding: 16px; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
label { display: block; margin: 10px 0 4px; font-weight: 600; }
input[type=text], input[type=password], input[type=number] { width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; }
select, input[type=file] { width: 100%; min-height: 42px; padding: 8px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; font: inherit; }
input[type=file]::file-selector-button { margin-right: 10px; border: 0; border-radius: 8px; padding: 8px 12px; background: #111827; color: #fff; font-weight: 700; cursor: pointer; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid #e5e7eb; vertical-align: top; }
.table-scroll { width: 100%; overflow-x: auto; }
.error { color: #b91c1c; }
.success { color: #047857; }
.muted, .field-help { color: #6b7280; font-size: 14px; }
.field-help { margin-top: 6px; line-height: 1.35; }
.small-img { max-width: 120px; max-height: 80px; border-radius: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.action-btn, a.action-btn, .button, button.primary, .primary, .inline-form button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border: 0; border-radius: 10px; padding: 10px 16px; background: #111827; color: #fff; font-weight: 800; font-size: 16px; line-height: 1.1; text-decoration: none; cursor: pointer; white-space: nowrap; box-shadow: inset 0 -1px 0 rgba(0,0,0,.18); }
.action-btn:hover, a.action-btn:hover, .button:hover, button.primary:hover, .primary:hover, .inline-form button:hover { filter: brightness(1.08); }
.danger, .action-btn.danger { background: #991b1b; color: #fff; }
.danger-large { min-height: 44px; padding: 10px 16px; }
.link-btn { display: inline-flex; align-items: center; min-height: 40px; background: #111827; color: white; padding: 8px 10px; border-radius: 8px; text-decoration: none; font-weight: 800; }
a.button { display: inline-flex; text-decoration: none; }
.inline-form { display: grid; gap: 8px; min-width: 260px; }
.form-row.full { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: end; }
.compact-form-row > div { min-width: 0; }
.form-actions { margin-top: 14px; display: flex; justify-content: flex-start; }
.save-area, .action-btn.save-area { background: #86efac; color: #052e16; }
.save-area:hover, .action-btn.save-area:hover { background: #bbf7d0; filter: none; }
.backup-grid { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(420px, 2fr) minmax(180px, .8fr); gap: 16px; align-items: stretch; }
.backup-panel { border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; background: #fafafa; min-height: 150px; }
.import-grid { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, .9fr); gap: 14px; align-items: start; }
.radio-group { display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 0; }
.radio-group label { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 999px; background: #fff; font-weight: 700; }
.radio-group input { width: auto; }
@media (max-width: 1050px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .backup-grid { grid-template-columns: 1fr 1fr; }
  .backup-panel:last-child { grid-column: 1 / -1; }
  .import-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .admin-wrap { padding: 10px; }
  .card { padding: 12px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 6px; }
  .form-grid, .backup-grid, .import-grid { grid-template-columns: 1fr; }
  .backup-panel:last-child { grid-column: auto; }
  .action-btn, a.action-btn, .button, button.primary, .primary, .inline-form button { width: 100%; }
  .radio-group { display: grid; grid-template-columns: 1fr; }
  table { font-size: 14px; min-width: 760px; }
  th, td { padding: 8px; }
  .small-img { max-width: 80px; }
  #adminMap { height: 360px !important; }
}
.image-thumb-button { border: 0; padding: 0; background: transparent; cursor: zoom-in; display: inline-flex; border-radius: 8px; }
.image-thumb-button:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
body.viewer-open { overflow: hidden; }
.image-viewer { position: fixed; inset: 0; z-index: 10000; display: grid; grid-template-rows: auto 1fr; background: rgba(17,24,39,.92); color: #fff; }
.image-viewer.hidden { display: none; }
.image-viewer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: #111827; border-bottom: 1px solid rgba(255,255,255,.12); }
.image-viewer-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.viewer-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; min-width: 44px; border: 0; border-radius: 10px; padding: 8px 12px; background: #fff; color: #111827; font-weight: 900; font-size: 18px; cursor: pointer; }
.viewer-close { background: #991b1b; color: #fff; font-size: 28px; line-height: 1; }
.image-viewer-stage { position: relative; overflow: hidden; min-height: 0; cursor: grab; touch-action: none; display: flex; align-items: center; justify-content: center; background: #030712; }
.image-viewer-stage.dragging { cursor: grabbing; }
.image-viewer-stage img { max-width: none; max-height: none; user-select: none; -webkit-user-drag: none; transform-origin: center center; will-change: transform; }
@media (max-width: 700px) {
  .image-viewer-toolbar { align-items: flex-start; flex-direction: column; }
  .image-viewer-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; }
  .viewer-btn { width: 100%; min-width: 0; }
}
