:root {
  --brown-1: #8a5a30;
  --brown-2: #6b431f;
  --cream: #fbf3e3;
  --ink: #2c2016;
  --accent: #e8a33d;
  --accent-2: #3d7ae8;
  --danger: #c44536;
  --bg: #f3ede0;
  --card: #ffffff;
  --border: #e3d8bf;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.hidden { display: none !important; }
.muted { color: #777; font-size: 0.85rem; }

.btn {
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}
.btn-primary { background: var(--accent-2); color: #fff; }
.btn-secondary { background: #e7ddc9; color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }

/* Login */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #2b4a1f, #16240f);
}
.auth-card {
  background: var(--card);
  padding: 32px;
  border-radius: 14px;
  width: min(90vw, 360px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.auth-card h1 { margin-top: 0; font-size: 1.3rem; }
.auth-card label { display: block; font-size: 0.85rem; font-weight: 600; margin: 14px 0 6px; }
.auth-card input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}
.auth-card .btn { width: 100%; margin-top: 16px; }
.error-text { color: var(--danger); font-size: 0.85rem; margin-top: 10px; }

/* Header */
.admin-header {
  background: linear-gradient(180deg, var(--ink), #40301f);
  color: var(--cream);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-header h1 { margin: 0; font-size: 1.2rem; }
.header-actions { display: flex; gap: 10px; }
.header-actions .btn-secondary { background: rgba(255,255,255,0.12); color: var(--cream); }

.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 14px 24px 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  color: #777;
}
.tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); }

.tab-panel { padding: 24px; max-width: 1200px; margin: 0 auto; }

/* Stand list + detail split */
.panel-split {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}
.panel-list {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border);
}
.panel-list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-list-head h2 { margin: 0; font-size: 1rem; }
#admin-stand-list { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
#admin-stand-list li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
}
#admin-stand-list li:hover { background: #f6f0e0; }
#admin-stand-list li.active { background: #fdf0d8; border-color: var(--accent); }
#admin-stand-list .cat { display: block; font-size: 0.75rem; color: #888; }

#admin-zone-list { list-style: none; margin: 0; padding: 0; }
#admin-zone-list li {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 6px;
  background: #f9f5ea;
}
#admin-zone-list li:hover { background: #f6f0e0; }
#admin-zone-list li.active { background: #fdf0d8; outline: 2px solid var(--accent); outline-offset: -2px; }
.zone-hint { margin-top: 16px; font-size: 0.8rem; line-height: 1.5; }
#zf-size { width: 100%; }

.panel-detail {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid var(--border);
  min-height: 300px;
}
.empty-detail { color: #999; text-align: center; padding: 60px 20px; }

#stand-form label, #media-section label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 14px 0 6px;
  color: #444;
}
#stand-form input, #stand-form textarea {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.9rem;
}
#stand-form input[type="color"] { padding: 2px; height: 42px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.position-field {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.position-field legend { font-size: 0.85rem; font-weight: 600; padding: 0 6px; }
.request-mode-field {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.request-mode-field legend { font-size: 0.85rem; font-weight: 600; padding: 0 6px; }
#stand-form .request-mode-field .radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.88rem;
  margin-bottom: 8px;
  margin-top: 0;
  color: inherit;
  cursor: pointer;
}
#stand-form .request-mode-field .radio-label input { width: auto; margin: 0; }
#f-request-url-wrap { margin-top: 6px; }
#position-map { display: flex; justify-content: center; }
#position-canvas {
  background: linear-gradient(160deg, #9fd15a, #6fae3a);
  border-radius: 8px;
  cursor: crosshair;
  border: 3px solid var(--brown-1);
  max-width: 100%;
}
.position-values { text-align: center; margin-top: 8px; font-size: 0.85rem; color: #666; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.grid-snap-toggle { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.grid-snap-toggle input { cursor: pointer; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

#media-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.media-block { margin-bottom: 28px; }
.media-block h3 { margin-bottom: 10px; font-size: 0.95rem; }
.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.screenshot-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: #000;
}
.screenshot-item.is-preview { border-color: var(--accent-2); }
.screenshot-item img { width: 100%; height: 90px; object-fit: cover; display: block; }
.screenshot-item .remove-btn {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(196,69,54,0.9);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px; height: 24px;
  cursor: pointer;
  font-size: 0.8rem;
}
.screenshot-item .preview-btn {
  display: block;
  width: 100%;
  border: none;
  background: #e7ddc9;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 4px;
  cursor: pointer;
}
.screenshot-item.is-preview .preview-btn { background: var(--accent-2); color: #fff; }
.upload-label {
  display: inline-block;
  background: #e7ddc9;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}
.upload-label input { display: none; }

.import-export-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.import-export-bar .btn,
.import-export-bar .upload-label { flex: 1; text-align: center; font-size: 0.82rem; padding: 9px 10px; }

.danger-zone { border-top: 1px dashed var(--border); padding-top: 18px; }

table#requests-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
}
#requests-table th, #requests-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: top;
}
#requests-table th { background: #f6f0e0; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--cream);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.toast.error { background: var(--danger); }

@media (max-width: 860px) {
  .panel-split { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
