:root {
  --bg: #ba8500;
  --card: #6a4c00;
  --muted: #94a3b8;
  --text: #e5e7eb;
  --primary: #ffac53;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #e5f50b;
  --input-bg: #523b00;
  --border: #374151;
}
.env-live {
  --bg: #111827;
  --card: #1f2937;
  --input-bg: #374151;
  --primary: #3b82f6;
}
.env-dev {
  --bg: #ba8500;
  --card: #6a4c00;
  --input-bg: #523b00;
  --primary: #ffac53;
}
.env-qa {
  --bg: #14532d;
  --card: #166534;
  --input-bg: #15803d;
  --primary: #4ade80;
}
.env-review {
  --bg: #1e3a8a;
  --card: #1e40af;
  --input-bg: #2563eb;
  --primary: #60a5fa;
}
* { box-sizing: border-box; }
[v-cloak] { display: none !important; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); cursor: pointer; text-decoration: none; }
a:focus, a:focus-visible, button:focus, button:focus-visible, .btn:focus, .btn:focus-visible { outline: none; box-shadow: none; }

/* Main layout */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar-env-label {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}
.env-login-title {
  font-size: 22px;
  letter-spacing: 0.02em;
}
.sidebar { background: var(--card); border-right: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; }
.sidebar-header { flex-shrink: 0; margin-bottom: 20px; }
.menu-title { font-weight: 700; margin: 6px 0 10px; color: var(--muted); font-size: 12px; flex-shrink: 0; }
.menu { flex: 1; overflow-y: auto; margin-bottom: 20px; padding-right: 4px; }
.menu::-webkit-scrollbar { width: 4px; }
.menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.menu a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); margin-bottom: 4px; }
.menu a.active, .menu a:hover { background: rgba(255, 255, 255, 0.1); }

/* Sidebar: collapsible groups (범용 토글) */
.menu-group { margin-bottom: 4px; }
.menu-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  margin-bottom: 4px;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  border: none;
  background: transparent;
  font: inherit;
  text-align: left;
}
.menu-group-toggle:hover,
.menu-group-toggle:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}
.menu-group-toggle.active { background: rgba(255, 255, 255, 0.1); }
.menu-group-label { flex: 1; min-width: 0; }
.menu-chevron {
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  transition: transform 0.2s ease;
}
.menu-chevron.open { transform: rotate(180deg); }
.menu-sub { margin-left: 12px; }
.menu-sub a { padding-left: 10px; }
.sidebar .menu-item-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.sidebar-footer { flex-shrink: 0; padding-top: 16px; border-top: 1px solid var(--border); }
/* min-width:0 — 그리드 1fr 열이 자식 min-content에 늘어나며 잘리는 현상 방지 */
.content { padding: 20px; flex: 1; min-width: 0; overflow-x: auto; }

/* Sidebar specific */
.sidebar .btn { width: 100%; font-size: 13px; padding: 8px 12px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; width: 100%; max-width: 400px; }
.card.wide { max-width: 800px; }
.card.full { max-width: 100%; }
.title { font-size: 22px; margin: 0 0 16px; font-weight: 700; }
.muted { color: var(--muted); font-size: 12px; }
.field { margin-bottom: 14px; }
.label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.input, .select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); color: var(--text); box-sizing: border-box; }
.input-group { position: relative; width: 100%; display: flex; align-items: center; }
.input-group .input { padding-right: 40px; }
.input-group .toggle-password {
  position: absolute; right: 10px; cursor: pointer; color: var(--muted);
  user-select: none; display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
}
.input-group .toggle-password:hover { color: var(--text); }
textarea { min-height: 100px; resize: vertical; }
.row { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; }
.col { display: flex; flex-direction: column; flex: 1; }

.btn { padding: 10px 14px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; transition: background 0.2s; }
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn.success { background: var(--success); border-color: var(--success); color: white; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.1); }
.btn-sm, .btn.sm { padding: 6px 10px; font-size: 12px; }

.error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.success-text { color: var(--success); font-size: 13px; margin-top: 6px; }
.primary-text { color: var(--primary); font-size: 13px; margin-top: 6px; }

.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
h2 { margin: 0 0 12px 0; }

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); padding: 10px; text-align: left; font-size: 14px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid #374151; vertical-align: middle; }
.badge.online { color: #10b981; border-color: #10b981; }
.badge.offline { color: #f97316; border-color: #f97316; }
.badge.blocked { color: var(--danger); border-color: var(--danger); }

/* Utility Classes */
.wrap { padding: 20px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex-end { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.flex-center { display: flex; justify-content: center; align-items: center; gap: 8px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }

/* Language Selector */
.lang-selector {
  display: flex;
  gap: 8px;
}
.lang-selector button {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
  opacity: 0.8;
}
.lang-selector button:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  opacity: 1;
}

.btn-sm, .btn.sm { padding: 6px 10px; font-size: 12px; height: 28px; display: inline-flex; align-items: center; justify-content: center; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-success { background: var(--success); border-color: var(--success); color: white; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }

/* Table row highlight */
tr.row-failed { background: rgba(239, 68, 68, 0.12); }
tr.row-failed:hover { background: rgba(239, 68, 68, 0.16); }
tr.row-failed td:first-child { border-left: 3px solid var(--danger); }

.row-success { color: var(--success); }
.row-primary { color: var(--primary); }

/* Status select */
.status-select { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; font-size: 12px; height: 28px; vertical-align: middle; }
.status-select:disabled { opacity: 0.6; }
.status-select option { color: black; }

/* Action buttons in list */
.btn-block { border-color: var(--warning); color: var(--warning); }
.btn-block:hover:not(:disabled) { background-color: rgba(229, 245, 11, 0.1); }
.btn-block[data-state="unblock"] { border-color: var(--success); color: var(--success); }
.btn-block[data-state="unblock"]:hover:not(:disabled) { background-color: rgba(34, 197, 94, 0.12); }
.btn-delete { border-color: var(--danger); color: var(--danger); }
.btn-delete:hover:not(:disabled) { background-color: rgba(239, 68, 68, 0.12); }

/* Controls layout */
.controls { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:12px; align-items: flex-end; }
.controls .input, .controls .select { width: auto; height: 32px; padding: 4px 8px; font-size: 13px; }
.controls label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.controls .btn { height: 32px; padding: 0 16px; }

/* Grid & Layout */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.header-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 4px; margin-top: 20px; flex-wrap: wrap; }
.pagination .page-info { font-size: 14px; color: var(--muted); margin: 0 8px; }
.pagination .page-numbers { display: flex; gap: 4px; }
.pagination .btn.sm { min-width: 32px; padding: 0 8px; }
.pagination .btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* Modal */
.modal-backdrop {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  /* 공통 알림/확인 모달은 화면별 편집 모달(z-index: 9999)보다 항상 위에 표시한다. */
  background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 10000;
  padding: 20px;
}
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  width: 100%; max-width: 450px; padding: 24px; box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  max-height: calc(100vh - 40px); display: flex; flex-direction: column;
}
.modal-header { margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 12px; flex-shrink: 0; }
.modal-header h3 { margin: 0; font-size: 18px; color: var(--primary); }
.modal-body { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; overflow-y: auto; flex: 1; padding-right: 4px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--border); padding-top: 16px; flex-shrink: 0; }

/* 공통 모달: 기간 충돌 등 경고형 안내 */
.admin-common-modal.is-warn .modal-header { text-align: center; border-bottom: 0; margin-bottom: 12px; padding-bottom: 0; }
.admin-common-modal.is-warn .admin-common-modal-title { color: var(--text); font-size: 16px; font-weight: 700; }
.admin-common-modal-warn {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 12px;
  text-align: center;
  color: var(--danger);
  font-weight: 700;
  line-height: 1.5;
  white-space: pre-wrap;
}
.admin-common-modal.is-warn .admin-common-modal-message {
  text-align: center;
  line-height: 1.7;
}
.admin-common-modal-footer.is-alert { justify-content: center; }

/* Popup layout stabilization */
body.popup-page {
  min-width: 0;
  overflow-x: hidden;
}
body.popup-page .popup-wrap {
  width: min(1200px, calc(100vw - 40px));
  min-width: 0;
  margin: 0 auto;
}
body.popup-page .table-scroll {
  min-width: 0;
  overflow-x: auto;
}
body.popup-page table th,
body.popup-page table td {
  min-width: 0;
  overflow: hidden;
}
body.popup-page table input,
body.popup-page table select,
body.popup-page table textarea {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}
body.popup-page table td > * {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
body.popup-page table td .reward-cell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
body.popup-page table td .reward-cell .btn-search,
body.popup-page table td .reward-cell .reserve-reward-search-btn,
body.popup-page table td .reward-cell .mail-reward-search-btn {
  flex: 0 0 32px;
}
body.popup-page table td .reward-cell input {
  flex: 1 1 auto;
  width: calc(100% - 38px) !important;
  max-width: calc(100% - 38px) !important;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 2000;
  flex-direction: column; gap: 12px;
}
.loading-overlay .spinner {
  width: 40px; height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: common-spin 0.8s linear infinite;
}
.loading-overlay .loading-text {
  color: #fff; font-size: 16px; font-weight: 500;
}
@keyframes common-spin {
  to { transform: rotate(360deg); }
}
.chip-container { 
  background: var(--input-bg); 
  border: 1px solid var(--border); 
  border-radius: 8px; 
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
}
.chip {
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chip .remove-btn {
  cursor: pointer;
  color: var(--danger);
  font-weight: bold;
  font-size: 14px;
}
.chip .remove-btn:hover { color: #ff6b6b; }

.status-active { background-color: var(--success); color: #fff; }
.status-reserved { background-color: var(--warning); color: #000; }
