*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── Auth gate ─────────────────────────────────────────────── */
#auth-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
}
#auth-gate h1 { font-size: 22px; font-weight: 700; }
#auth-gate p  { color: #666; }

/* ── Top bar ────────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: #1a1a2e;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}
#topbar .brand { font-weight: 700; font-size: 16px; letter-spacing: .5px; }
#topbar .user-info { font-size: 12px; color: #aaa; }

/* ── Tab nav ────────────────────────────────────────────────── */
#tabnav {
  display: flex;
  gap: 2px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0 16px;
}
.tab-btn {
  padding: 12px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn.active { color: #1a1a2e; border-bottom-color: #1a1a2e; }
.tab-btn:hover:not(.active) { color: #333; background: #f5f5f5; }

/* ── Content area ───────────────────────────────────────────── */
#content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 24px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Cards & sections ───────────────────────────────────────── */
.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #1a1a2e;
}

.card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e8e8e8;
  padding: 16px;
  margin-bottom: 10px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-meta {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
  line-height: 1.6;
}

.card-note {
  margin-top: 8px;
  font-size: 13px;
  color: #444;
  background: #f9f9f9;
  border-left: 3px solid #ddd;
  padding: 6px 10px;
  border-radius: 0 6px 6px 0;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-visible  { background: #e8f5e9; color: #2e7d32; }
.badge-hidden   { background: #fff3e0; color: #e65100; }
.badge-removed  { background: #fce4ec; color: #b71c1c; }
.badge-pending  { background: #ede7f6; color: #4527a0; }
.badge-report   { background: #e3f2fd; color: #0d47a1; }
/* Age badges from `expiryBadgeHtml`. Both classes are defined here on purpose —
   `utils.js badgeHtml()` falls back to a `.badge-neutral` that has no rule,
   which renders an invisible pill. Do not repeat that. */
.badge-expiry-soon { background: #fff8e1; color: #ff6f00; }
.badge-expiry-past { background: #ffebee; color: #b71c1c; }

/* ── Action buttons ─────────────────────────────────────────── */
.action-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

button {
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: opacity .15s;
}
button:hover { opacity: .85; }
button:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background: #1a1a2e; color: #fff; }
.btn-restore   { background: #43a047; color: #fff; }
.btn-remove    { background: #e53935; color: #fff; }
.btn-hide      { background: #f57c00; color: #fff; }
.btn-neutral   { background: #e0e0e0; color: #333; }
.btn-danger    { background: #b71c1c; color: #fff; }
.btn-google    { background: #4285f4; color: #fff; font-size: 14px; padding: 10px 20px; }
.btn-apple     { background: #000; color: #fff; font-size: 14px; padding: 10px 20px; }
.btn-link      { background: none; color: #4285f4; padding: 4px; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

/* ── Auth gate: email/password form ─────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  width: 260px;
  color: #999;
  font-size: 12px;
  gap: 8px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #ddd;
}
.auth-email-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 260px;
}
.auth-email-form input {
  padding: 9px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}
.auth-email-form input:focus {
  outline: none;
  border-color: #4285f4;
}
.auth-email-form .btn-primary { padding: 10px 20px; font-size: 14px; }

/* ── Search inputs ──────────────────────────────────────────── */
.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

input[type=text] {
  flex: 1;
  min-width: 220px;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
input[type=text]:focus { border-color: #1a1a2e; }

/* ── Reports sub-list ───────────────────────────────────────── */
.reports-toggle {
  font-size: 12px;
  color: #1a73e8;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
  text-decoration: underline;
}

.report-list {
  margin-top: 10px;
  display: none;
  border-top: 1px solid #eee;
  padding-top: 10px;
}
.report-list.open { display: block; }

.report-item {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #555;
  padding: 4px 0;
  border-bottom: 1px dashed #eee;
}
.report-item:last-child { border-bottom: none; }

/* ── Dev tools ──────────────────────────────────────────────── */
.devtools-section {
  margin-bottom: 24px;
}
.devtools-section .section-title { font-size: 14px; color: #555; }

.devtools-uid-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.devtools-uid-row label { font-size: 12px; color: #666; white-space: nowrap; }

.log-box {
  background: #1a1a2e;
  color: #a8ff78;
  font-family: monospace;
  font-size: 12px;
  padding: 12px;
  border-radius: 8px;
  min-height: 60px;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 10px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Empty / loading / error states ────────────────────────── */
.state-msg {
  text-align: center;
  color: #999;
  padding: 40px 20px;
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #ccc;
  border-top-color: #1a1a2e;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  background: #fce4ec;
  color: #b71c1c;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 13px;
}

/* ── Workout detail inline ──────────────────────────────────── */
.workout-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.detail-item { font-size: 12px; color: #666; }
.detail-item strong { display: block; color: #333; font-size: 13px; }

/* ── User profile card ──────────────────────────────────────── */
.user-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e8e8e8;
  margin-bottom: 12px;
}
.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.user-info-block .nickname { font-weight: 600; font-size: 15px; }
.user-info-block .uid      { font-size: 11px; color: #888; font-family: monospace; word-break: break-all; }

/* ── Rink edit full-page ────────────────────────────────────── */
.rink-edit-page { max-width: 720px; margin: 0 auto; padding: 0 0 40px; }

.rink-edit-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e0e0e0;
}
.rink-edit-header h2 { margin: 0; font-size: 20px; }

.rink-edit-body { padding: 20px 0; }

.rink-edit-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid #eee;
  margin-top: 8px;
}

/* ── Form elements (modal) ──────────────────────────────────── */
.form-group {
  margin-bottom: 14px;
}

.form-group > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #444;
  margin-bottom: 5px;
}

.form-group input[type=text],
.form-group input[type=number],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
}
.form-group input:disabled,
.form-group select:disabled {
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: #1a1a2e; }

.form-group textarea { font-family: monospace; resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-hint {
  display: block;
  font-size: 11px;
  color: #aaa;
  margin-top: 3px;
}

.required { color: #e53935; }

.checkbox-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 400;
  color: #333;
  cursor: pointer;
}

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-row label { font-size: 12px; color: #666; }
select {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  outline: none;
}

/* ── Dashboard stat grid ────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  padding: 18px 12px;
  text-align: center;
}

.stat-card-warn {
  border-color: #ffb74d;
  background: #fff8f0;
}

.stat-icon { font-size: 22px; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: #1a1a2e; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: #888; }

/* ── Samples tab ────────────────────────────────────────────────── */
.samples-variant-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.variant-chip {
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 11px;
  min-width: 130px;
}

.variant-chip code {
  font-size: 10px;
  color: #888;
  margin-bottom: 2px;
}

.variant-chip span {
  color: #333;
  font-weight: 500;
}

/* ── Modal tabs ─────────────────────────────────────────────────── */
.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f8f8;
  padding: 0 16px;
  overflow-x: auto;
}

.modal-tab-btn {
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  border-radius: 0;
}
.modal-tab-btn.active { color: #1a1a2e; border-bottom-color: #1a1a2e; }
.modal-tab-btn:hover:not(.active) { color: #333; background: #efefef; }

.modal-tab-panel { display: none; }
.modal-tab-panel.active { display: block; }

/* ── Business hours editor ──────────────────────────────────────── */
.bh-day-row {
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.bh-day-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #f8f9fa;
  cursor: pointer;
  user-select: none;
}

.bh-day-label {
  font-weight: 600;
  font-size: 13px;
  width: 28px;
  color: #1a1a2e;
}

.bh-day-closed-label {
  font-size: 12px;
  color: #e53935;
  font-weight: 500;
}

.bh-day-summary {
  font-size: 12px;
  color: #888;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bh-day-body {
  padding: 10px 12px;
  border-top: 1px solid #efefef;
}

.bh-session-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.bh-session-row input[type=text] {
  flex: 1;
  min-width: 130px;
  padding: 6px 9px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}
.bh-session-row input[type=text]:focus { border-color: #1a1a2e; }

.bh-session-row input[type=time] {
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  background: #fff;
}
.bh-session-row input[type=time]:focus { border-color: #1a1a2e; }

.bh-session-remove {
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
}
.bh-session-remove:hover { color: #e53935; background: #fce4ec; }

.bh-add-session-btn {
  font-size: 12px;
  padding: 5px 12px;
  margin-top: 4px;
}

/* ── Closure chips ──────────────────────────────────────────────── */
.closure-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.closure-preset-btn {
  padding: 4px 12px;
  border: 1px solid #c5d8f8;
  border-radius: 14px;
  background: #f0f4ff;
  color: #1a73e8;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
}
.closure-preset-btn:hover { background: #dce8ff; border-color: #1a73e8; }

.closure-preset-exclusive {
  background: #fff3e0;
  border-color: #ffcc80;
  color: #e65100;
}
.closure-preset-exclusive:hover { background: #ffe0b2; border-color: #e65100; }

.closure-custom-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  margin-top: 4px;
}

.chip-list-scroll {
  max-height: 120px;
  overflow-y: auto;
}

.closure-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f0f4ff;
  border: 1px solid #c5d8f8;
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 12px;
  color: #1a1a2e;
}

.closure-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 13px;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
}
.closure-chip-remove:hover { color: #e53935; }

.closure-date-add-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

/* ── Rink calendar ──────────────────────────────────────────────── */
.rink-calendar-wrap {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 14px;
}

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-nav-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
}

.cal-nav-btn {
  background: none;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  line-height: 1.4;
}
.cal-nav-btn:hover { background: #efefef; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #999;
  padding: 3px 0 6px;
}
.cal-dow:first-child { color: #e53935; }
.cal-dow:last-child  { color: #1a73e8; }

.cal-day {
  text-align: center;
  padding: 6px 2px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: opacity .1s;
  line-height: 1.3;
}
.cal-day:hover { opacity: .75; }

.cal-day--empty { cursor: default; }
.cal-day--empty:hover { opacity: 1; }

/* 운영시간 달력 */
.cal-day--open   { background: #e3f0ff; color: #1a73e8; font-weight: 600; }
.cal-day--closed { background: #fce4ec; color: #e53935; font-weight: 600; }
.cal-day--unset  { background: #fff;    color: #aaa;    border: 1px solid #eee; }

/* 휴관일 달력 */
.cal-day--holiday   { background: #fce4ec; color: #e53935; font-weight: 600; }
.cal-day--normal    { background: #fff;    color: #333;    border: 1px solid #eee; }
.cal-day--today     { outline: 2px solid #1a73e8; outline-offset: -2px; }

/* 통합 달력 — closureDates 직접 지정 날짜 (빨간 테두리로 요일 휴무와 구분) */
.cal-day--closure-date { background: #fce4ec; color: #b71c1c; font-weight: 700; border: 2px solid #e53935; }
.cal-day--closure-date:hover { background: #ef9a9a; }

.cal-legend {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #666;
}
.cal-legend-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Amenity list ───────────────────────────────────────────────── */
.amenity-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.amenity-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.amenity-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 400;
  color: #333;
  cursor: pointer;
  width: 140px;
  flex-shrink: 0;
}
.amenity-item input[type=checkbox] { flex-shrink: 0; }

.amenity-note {
  flex: 1;
  padding: 5px 9px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 12px;
  color: #333;
  outline: none;
  background: #fafafa;
  display: none;
}
.amenity-note.visible {
  display: block;
}
.amenity-note:focus { border-color: #1a1a2e; background: #fff; }

/* ── Photo thumbnails ───────────────────────────────────────────── */
.photo-thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 24px;
}

.photo-thumb-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.photo-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-thumb-remove:hover { background: #e53935; }

.photo-thumb-uploading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #f5f5f5;
  padding: 4px;
}
.photo-upload-label {
  font-size: 10px;
  color: #666;
  text-align: center;
  word-break: break-all;
  line-height: 1.2;
}
.photo-upload-progress {
  width: 0%;
  height: 4px;
  background: #1a73e8;
  border-radius: 2px;
  transition: width 0.15s ease;
  align-self: stretch;
}
.photo-thumb-error { background: #fde8e8; }
.photo-thumb-error .photo-upload-label { color: #c62828; }

.photo-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  border: 2px dashed #ccc;
  border-radius: 8px;
  margin-top: 8px;
  background: #fafafa;
}
.photo-drop-zone.drag-over {
  border-color: #1a73e8;
  background: #e8f0fe;
}

/* ── Bulk select toolbar ────────────────────────────────────────── */
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #e8f0fe;
  border: 1px solid #c5d8f8;
  border-radius: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: #1a73e8;
  margin-right: 4px;
}

.bulk-cb {
  width: 16px;
  height: 16px;
  margin-right: 10px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #1a73e8;
}

/* ── Pricing tier rows ──────────────────────────────────────────── */
.pricing-tier-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.pricing-tier-row input[type=text],
.pricing-tier-row input[type=number] {
  padding: 6px 9px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  background: #fff;
}
.pricing-tier-row input[type=text]:focus,
.pricing-tier-row input[type=number]:focus { border-color: #1a1a2e; }

/* ── Admin footer ───────────────────────────────────────────── */
.admin-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 24px;
  border-top: 1px solid #e8e8e8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-footer p {
  margin: 0;
  font-size: 12px;
  color: #999;
}

.admin-footer a {
  color: #1a73e8;
  text-decoration: none;
}
.admin-footer a:hover { text-decoration: underline; }
