/* ============================================================
   MEGA-style Theme
   - Primary: Mega Yellow #FFCC00
   - Ink:     Jet Black  #1A1A1A
   - Accent:  Hot Pink   #FF2D87  (point color, 메가커피 보조톤)
   ============================================================ */

:root {
  --mega-yellow: #FFCC00;
  --mega-yellow-dark: #E6B800;
  --mega-yellow-soft: #FFF6CC;
  --ink: #1A1A1A;
  --ink-soft: #3a3a3a;
  --gray-line: #e5e5e7;
  --gray-bg: #f5f5f5;
  --pink: #FF2D87;
  --pink-soft: #ffe1ee;
  --danger: #E11D2A;
  --success: #1c7c33;
}

* { box-sizing: border-box; }

html, body {
  /* 가로 스크롤 차단 — 그림자/배지가 미세하게 넘쳐도 화면이 흔들리지 않게 */
  overflow-x: hidden;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
  margin: 0;
  background: var(--gray-bg);
  color: var(--ink);
  font-weight: 500;
  letter-spacing: -0.01em;
  -webkit-text-size-adjust: 100%; /* 모바일에서 자동 텍스트 확대 방지 */
}

/* ── Nav: 노란 바 + 굵은 워드마크 ── */
.nav {
  background: var(--mega-yellow);
  border-bottom: 3px solid var(--ink);
  box-shadow: 0 2px 0 rgba(0,0,0,0.04);
}
.nav-inner {
  max-width: 1100px; margin: 0 auto; padding: 14px 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.brand {
  font-weight: 900; font-size: 22px; letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
  text-transform: uppercase;
  line-height: 1.2;
  word-break: keep-all;
}
.brand-sub {
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em;
  margin-left: 6px;
  padding: 3px 8px;
  background: var(--ink); color: var(--mega-yellow);
  border-radius: 999px;
  vertical-align: middle;
  text-transform: uppercase;
  white-space: nowrap;
  display: inline-block;
}
.nav-links { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.nav-links a {
  color: var(--ink); text-decoration: none; font-weight: 700;
  font-size: 14px;
}
.nav-links a:hover { color: var(--pink); }

/* 관리자 드롭다운 */
.nav-dropdown { position: relative; }
.nav-dropdown > summary {
  list-style: none; cursor: pointer; color: var(--ink);
  user-select: none; font-weight: 700; font-size: 14px;
}
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown > summary:hover { color: var(--pink); }
.nav-dropdown[open] > summary { color: var(--pink); }
.dropdown-menu {
  position: absolute; top: calc(100% + 8px); left: 0;
  background: var(--ink); border: 2px solid var(--ink); border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  min-width: 150px; padding: 6px 0; z-index: 50;
  display: flex; flex-direction: column;
}
.dropdown-menu a {
  padding: 10px 14px; color: #fff; text-decoration: none;
  font-size: 14px; font-weight: 600;
}
.dropdown-menu a:hover { background: var(--mega-yellow); color: var(--ink); }

/* 인라인 체크박스 라벨 */
.check-inline {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: var(--mega-yellow-soft);
  border-radius: 20px; border: 2px solid var(--mega-yellow);
  cursor: pointer; font-weight: 600;
}
.check-inline input { margin: 0; }

/* 신청 결과 인라인 텍스트 */
.order-current { margin-left: 8px; color: var(--success); font-weight: 600; }
.order-current strong { color: var(--ink); background: var(--mega-yellow); padding: 2px 8px; border-radius: 6px; }

/* 마감 시각 배지 */
.close-time {
  font-size: 13px; font-weight: 800; color: var(--ink);
  background: var(--mega-yellow); padding: 4px 12px; border-radius: 999px;
  margin-left: 8px; vertical-align: middle;
  border: 2px solid var(--ink);
  white-space: nowrap;
  display: inline-block;
}

/* 별도 주문 표시 */
.badge-late {
  display: inline-block; margin-left: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px;
  background: var(--pink); color: #fff; font-weight: 800;
  letter-spacing: 0.02em;
}
.row-late { background: var(--pink-soft); }
.row-late td:first-child { border-left: 4px solid var(--pink); }

.badge-takeout {
  display: inline-block; margin-left: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px;
  background: var(--success); color: #fff; font-weight: 800;
  letter-spacing: 0.02em;
}

/* ── 헤더 그룹 선택 ── */
.nav-group-select {
  font-weight: 700; font-size: 13px;
  border: 2px solid var(--ink); border-radius: 6px;
  padding: 3px 6px; background: #fff; color: var(--ink);
  cursor: pointer; max-width: 140px;
}

/* ── 그룹 관리 그리드 ── */
.table.groups-table th { text-align: center; }
.table.groups-table td { vertical-align: middle; }
.table.groups-table tbody td:nth-child(2),
.table.groups-table tbody td:nth-child(3),
.table.groups-table tbody td:nth-child(4) { text-align: center; }
.table.groups-table .inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.table.groups-table input[type="text"] { min-width: 120px; }
.group-admins-label { display: inline-block; margin-right: 8px; font-size: 13px; }
.admin-multi-select {
  min-width: 260px; font-size: 13px;
  border: 2px solid var(--gray-line); border-radius: 6px; padding: 4px;
}

/* ── 모달(dialog) ── */
.modal {
  border: 2px solid var(--ink); border-radius: 10px;
  padding: 18px 20px; min-width: 320px; max-width: 90vw;
  box-shadow: 4px 4px 0 var(--ink);
  background: #fff; color: var(--ink);
}
.modal::backdrop { background: rgba(0,0,0,0.35); }
.modal h3 { font-size: 16px; font-weight: 800; }

/* 비밀번호 초기화 폼 */
.reset-pw-form { display: inline-flex; gap: 4px; align-items: center; }
.reset-pw-form input { width: 110px; font-size: 13px; padding: 4px 6px; }
.reset-pw-form button { padding: 4px 10px; font-size: 13px; }
.muted { color: #6b6b6b; font-size: 14px; font-weight: 500; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

/* ── 카드: 굵은 검정 테두리 한 줄 강조 ── */
.card {
  background: #fff; border-radius: 16px; padding: 22px;
  margin-bottom: 16px;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.card h2 {
  margin: 0 0 18px; font-size: 20px; font-weight: 900;
  letter-spacing: -0.02em;
  display: inline-block;
  border-bottom: 4px solid var(--mega-yellow);
  padding-bottom: 4px;
}
/* 제목 옆 배지가 있을 때: h2 자체 밑줄은 제거하고 제목 텍스트(span.h2-title)만 강조 */
.card h2:has(.h2-title) {
  display: block;
  border-bottom: none;
  padding-bottom: 0;
}
.card h2 .h2-title {
  display: inline-block;
  border-bottom: 4px solid var(--mega-yellow);
  padding-bottom: 4px;
  margin-right: 8px;
}
/* 게시판 형식 테이블: 컬럼 헤더 + 데이터 셀 중앙 정렬 (메뉴 컬럼만 좌측 정렬) */
.table.users-table th,
.table.menus-table th,
.table.summary-table th,
.table.order-table th,
.table.history-table th,
.table.users-table td,
.table.menus-table td,
.table.summary-table td,
.table.order-table td,
.table.history-table td {
  text-align: center;
}
/* 메뉴 컬럼은 좌측 정렬 (가독성). 옵션/합계 등 colspan 행은 제외 */
.table.menus-table td:nth-child(2),
.table.summary-table .summary-main-row td:nth-child(1),
.table.order-table .order-main-row td:nth-child(2),
.table.history-table td:nth-child(2) {
  text-align: left;
}

/* 로그인/회원가입 등 비로그인 화면 상단 워드마크 */
.auth-brand {
  max-width: 400px; margin: 56px auto 0; padding: 0 20px;
  text-align: center;
}
.auth-brand-main {
  font-size: 30px; font-weight: 900;
  letter-spacing: -0.03em; color: var(--ink);
  line-height: 1.1;
}
.auth-brand-sub {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 12px;
  background: var(--ink); color: var(--mega-yellow);
  font-size: 12px; font-weight: 800;
  letter-spacing: 0.04em;
  border-radius: 999px;
  text-transform: uppercase;
}

.auth-card {
  max-width: 400px; margin: 24px auto 60px; background: #fff;
  padding: 36px 32px; border-radius: 18px;
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--mega-yellow);
}
.auth-card h1 {
  margin: 0 0 24px; font-size: 28px; font-weight: 900;
  letter-spacing: -0.03em;
}
.auth-card h1::after {
  content: ""; display: block; width: 48px; height: 5px;
  background: var(--mega-yellow); margin-top: 8px; border-radius: 3px;
}
.auth-card label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.auth-card label input { display: block; width: 100%; margin-top: 6px; }

/* ── 인풋 ── */
input[type=text], input[type=password], input[type=number], select, textarea {
  padding: 10px 12px; border: 2px solid var(--ink); border-radius: 8px;
  font-size: 14px; background: #fff; font-family: inherit;
  font-weight: 500;
}
input[type=text]:focus, input[type=password]:focus,
input[type=number]:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-soft);
}

/* ── 버튼 ── */
button, .btn-primary, .btn-secondary, .btn-danger {
  padding: 10px 18px; border: 2px solid var(--ink); border-radius: 999px;
  cursor: pointer; font-size: 14px; font-weight: 800;
  font-family: inherit;
  transition: transform .05s ease;
}
button:active, .btn-primary:active, .btn-secondary:active, .btn-danger:active {
  transform: translateY(1px);
}
.btn-primary { background: var(--mega-yellow); color: var(--ink); }
.btn-primary:hover { background: var(--mega-yellow-dark); }
.btn-secondary { background: #fff; color: var(--ink); text-decoration: none; display: inline-block; }
.btn-secondary:hover { background: var(--gray-bg); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b8121d; }
.btn-icon {
  padding: 0; width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle;
}
.btn-icon + .btn-icon, form + .btn-icon, .btn-icon + form { margin-left: 4px; }
.btn-icon svg { display: block; }
.user-actions { text-align: center; white-space: nowrap; }
.user-actions form + form { margin-left: 4px; }
.btn-link {
  background: none; color: var(--ink); padding: 0; cursor: pointer;
  border: none; font-weight: 700; text-decoration: underline;
}
.btn-link:hover { color: var(--pink); }

/* ── 알림 박스 ── */
.error, .flash.error {
  background: #ffe5e7; color: var(--danger); padding: 12px 16px;
  border-radius: 10px; margin-bottom: 12px; font-weight: 600;
  border-left: 5px solid var(--danger);
}
.success, .flash.success {
  background: #e3f7e8; color: var(--success); padding: 12px 16px;
  border-radius: 10px; margin-bottom: 12px; font-weight: 600;
  border-left: 5px solid var(--success);
}
.warning {
  background: var(--mega-yellow-soft); color: var(--ink); padding: 12px 16px;
  border-radius: 10px; margin-bottom: 12px; font-weight: 600;
  border-left: 5px solid var(--mega-yellow);
}

.budget-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.big { font-size: 26px; font-weight: 900; margin-top: 4px; letter-spacing: -0.02em; }
.primary { color: var(--ink); background: var(--mega-yellow); padding: 2px 10px; border-radius: 6px; display: inline-block; }
/* 초과/음수 표시 (인원관리 잔여 음수, 예산관리 월 누적 사용 초과) */
.text-over { color: var(--danger); font-weight: 900; }
.text-over-label {
  display: inline-block; margin-left: 6px;
  padding: 2px 8px; font-size: 11px; font-weight: 800;
  background: var(--danger); color: #fff; border-radius: 999px;
  letter-spacing: 0.04em;
}
/* 모바일에서만 역할 라벨을 단축 표시 (슈퍼관리자→슈, 관리자→관, 사용자→사) */
.role-short-only { display: none; }
/* 비밀번호 초기화: 모바일 전용 버튼은 기본 숨김 (≤600px에서만 노출) */
.reset-pw-form-mobile { display: none; }
/* 인원 관리: 모바일 전용 예산 줄 (기본 숨김) */
.budget-row { display: none; }
/* 주문 내역: 모바일 전용 옵션 줄 (기본 숨김) */
.options-row { display: none; }
/* 주문 요약: 모바일 전용 사이즈업 옵션 줄 (기본 숨김) */
.summary-opt-row { display: none; }
/* 신청자별 주문 목록: 일일 합계 행 내부 (라벨/금액 좌우 정렬) — 데스크탑·모바일 공통 */
.daily-total-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
@media (max-width: 600px) {
  /* role-label: 원본 텍스트(.role-full)는 숨기고 data-short 로 단축 라벨만 표시 */
  .role-label {
    display: inline-block;
    padding: 4px 8px;
    line-height: 1.2; min-width: 26px; text-align: center;
  }
  .role-label .role-full { display: none; }
  .role-label::before {
    content: attr(data-short);
    font-size: 12px; font-weight: 800;
  }
  /* role-select 의 폭은 단축 라벨에 맞춰 축소 */
  .role-select { min-width: 0; width: auto; padding: 6px 4px; }

  /* 비밀번호 초기화: 데스크탑 폼 숨기고, 버튼 전용 모바일 폼 노출 */
  .reset-pw-form-full { display: none; }
  .reset-pw-form-mobile { display: inline-block; }

  /* 인원 관리: 한도/사용/선물/잔여를 두번째 줄로 분리 */
  .users-table-wrap .table { min-width: 0; }
  .users-table .budget-col,
  .users-table .budget-cell { display: none; }
  .users-table .budget-row { display: table-row; }
  .users-table .budget-row td {
    padding: 4px 10px 12px;
    border-bottom: 2px solid var(--gray-line);
    background: #fafafa;
  }
  .users-table .budget-row td span {
    display: inline-flex; align-items: center; gap: 4px;
    margin-right: 12px;
    font-size: 12px;
    white-space: nowrap;
  }
  .users-table .budget-row td span em {
    font-style: normal;
    color: #6b6b6b; font-weight: 600; font-size: 11px;
  }
  /* 메인 user-row 의 td 하단 보더 제거 (budget-row 와 시각적으로 한 사용자) */
  .users-table .user-row td { border-bottom: none; padding-bottom: 6px; }
  .users-table th { font-size: 11px; padding: 8px 6px; }
  .users-table td { padding: 8px 6px; }

  /* 신청자별 주문 목록: 샷추가/사이즈업을 두번째 줄로 분리 */
  .order-table-wrap .table { min-width: 0; }
  .order-table .options-col,
  .order-table .options-cell { display: none; }
  .order-table .options-row { display: table-row; }
  .order-table .options-row td {
    padding: 4px 10px 10px;
    border-bottom: 1px solid var(--gray-line);
    background: #fafafa;
    font-size: 12px;
  }
  .order-table .options-row.row-late td { background: var(--pink-soft); }
  .order-table .options-row td span em {
    font-style: normal;
    color: #6b6b6b; font-weight: 600; font-size: 11px;
    margin-right: 4px;
  }
  /* main row 의 td 하단 보더 제거 (options-row 와 시각적으로 한 주문) */
  .order-table .order-main-row td { border-bottom: none; padding-bottom: 6px; }

  /* 일일 합계 행: 모바일에서도 테이블 너비와 동일하게 (colspan=5 단일 셀 + flex inner) */
  .order-table .daily-total-cell { padding: 0; background: transparent; }
  .order-table .daily-total-inner {
    background: var(--mega-yellow-soft);
    border-top: 2px solid var(--ink);
    padding: 14px 12px;
    font-size: 15px;
    font-weight: 800;
  }
  .order-table .daily-total-inner strong { font-size: 16px; font-weight: 900; }

  /* 주문 요약 테이블: 사이즈업 컬럼을 두번째 줄로 분리 */
  .summary-table .summary-opt-col,
  .summary-table .summary-opt-cell { display: none; }
  .summary-table .summary-opt-row { display: table-row; }
  .summary-table .summary-opt-row td {
    padding: 4px 10px 10px;
    border-bottom: 1px solid var(--gray-line);
    background: #fafafa;
    font-size: 12px;
  }
  .summary-table .summary-opt-row td span em {
    font-style: normal;
    color: #6b6b6b; font-weight: 600; font-size: 11px;
    margin-right: 4px;
  }
  .summary-table .summary-main-row td { border-bottom: none; padding-bottom: 6px; }
}

/* ── 메뉴 아이템 ── */
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border: 2px solid var(--ink); border-radius: 12px;
  margin-bottom: 8px; cursor: pointer; background: #fff;
  transition: background .1s ease, transform .05s ease;
}
.menu-item:hover { background: var(--mega-yellow-soft); }
.menu-item:has(input[type=radio]:checked) {
  background: var(--mega-yellow);
  box-shadow: 3px 3px 0 var(--ink);
  transform: translate(-1px, -1px);
}
.menu-item input[type=radio] { margin: 0; accent-color: var(--ink); }
.menu-name { flex: 1; font-weight: 700; }
.menu-price { font-weight: 900; color: var(--ink); }

#menu-list.disabled { opacity: 0.4; pointer-events: none; }
.skip-row { display: block; padding: 10px 0; font-weight: 700; }

.menu-controls {
  position: sticky; top: 0; z-index: 5;
  background: #fff; padding: 14px 0; margin-bottom: 10px;
  border-bottom: 2px solid var(--ink);
}
#menu-search {
  width: 100%; padding: 12px 16px; font-size: 15px;
  border: 2px solid var(--ink); border-radius: 999px; margin-bottom: 12px;
  font-weight: 500;
}
#menu-search:focus {
  outline: none; border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-soft);
}

.category-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-tab {
  background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 700;
  border: 2px solid var(--ink);
  cursor: pointer;
}
.cat-tab:hover { background: var(--mega-yellow-soft); }
.cat-tab.active { background: var(--ink); color: var(--mega-yellow); }
.cat-count {
  background: rgba(0,0,0,0.1); padding: 1px 7px; border-radius: 999px;
  font-size: 11px; margin-left: 5px; font-weight: 800;
}
.cat-tab.active .cat-count { background: var(--mega-yellow); color: var(--ink); }

.menu-group { margin-top: 16px; }
.menu-group-title {
  font-size: 14px; font-weight: 800; color: var(--ink);
  margin: 10px 0; padding-bottom: 6px;
  border-bottom: 2px dashed var(--mega-yellow);
  letter-spacing: -0.01em;
}
.menu-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.menu-grid .menu-item { margin-bottom: 0; }

/* 옵션 그룹 — 유료(샷·사이즈업) / 무료(시럽·포장) 각각 한 줄 */
.option-row {
  margin-top: 14px; padding: 14px;
  background: var(--mega-yellow-soft); border-radius: 12px;
  border: 2px solid var(--mega-yellow);
  display: flex; gap: 14px; align-items: center;
  flex-wrap: nowrap;
}
.option-item { flex: 1 1 0; min-width: 0; }
.option-item label {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: nowrap; white-space: nowrap;
  cursor: pointer;
}
.option-item select { margin: 0; }
.option-item .opt-help { font-size: 12px; }
.shot-badge {
  display: inline-block; padding: 3px 10px;
  background: var(--ink); color: var(--mega-yellow);
  border-radius: 999px; font-size: 12px; font-weight: 800;
  margin: 0 4px;
}

.row { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.row-between { justify-content: space-between; align-items: center; }
@media (max-width: 600px) {
  .row-between { justify-content: flex-start; }
  .row-between > h2 { flex: 1 1 100%; margin-bottom: 4px; }
}

.gift-form, .inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 관리자 선물 폼 — 항목별 라벨/입력/안내가 위→아래로 정렬 */
.admin-gift-form { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }
.gift-field { display: flex; flex-direction: column; gap: 6px; }
.gift-field > label { font-weight: 800; font-size: 14px; }
.gift-field > select, .gift-field > input { width: 100%; }
.gift-info { margin: 0; font-size: 13px; line-height: 1.4; }
.gift-info strong { color: var(--ink); background: var(--mega-yellow); padding: 1px 8px; border-radius: 6px; }

/* ── 테이블 ── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 12px 10px; text-align: left;
  border-bottom: 1px solid var(--gray-line);
  vertical-align: middle;
}
.table th {
  background: var(--ink); color: var(--mega-yellow);
  font-weight: 800; font-size: 13px; letter-spacing: 0.02em;
  text-transform: uppercase;
}
.table th:first-child { border-top-left-radius: 8px; }
.table th:last-child { border-top-right-radius: 8px; }
.table tbody tr:hover { background: var(--mega-yellow-soft); }
.table tfoot td { background: var(--gray-bg); font-weight: 800; }

/* ── 뱃지 ── */
.badge {
  padding: 3px 10px; border-radius: 999px; font-size: 11px;
  font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase;
}
.badge.super { background: var(--pink); color: #fff; }
.badge.admin { background: var(--ink); color: var(--mega-yellow); }
.badge.user { background: var(--mega-yellow); color: var(--ink); border: 1px solid var(--ink); }

/* ── 달력 ── */
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.calendar-header h2 { margin: 0; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow {
  background: var(--ink); color: var(--mega-yellow);
  padding: 10px; text-align: center;
  font-weight: 800; font-size: 13px;
  border-radius: 8px;
}
.cal-empty { background: transparent; min-height: 80px; }
.cal-day {
  background: #fff; border: 2px solid var(--ink); border-radius: 10px;
  padding: 8px; min-height: 84px; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 2px;
  position: relative;
  font-weight: 500;
}
.cal-day:hover { background: var(--mega-yellow-soft); }
.cal-day.today {
  background: var(--mega-yellow);
  box-shadow: 3px 3px 0 var(--ink);
}
.cal-day.past { background: var(--gray-bg); border-color: #c8c8c8; }
.cal-day.future { color: #bbb; cursor: not-allowed; border-color: #d8d8d8; }
.cal-day.future:hover { background: #fff; }
.cal-day.closed { background: #fdf0d8; }
.cal-num { font-weight: 800; font-size: 15px; }
.cal-stat { font-size: 12px; color: #555; font-weight: 600; }
.cal-day.today .cal-stat { color: var(--ink); }
.cal-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--pink); color: #fff;
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
  font-weight: 800;
}

/* 요일 헤더: 토(파랑) / 일(빨강) */
.cal-dow-sat { background: var(--ink); color: #6ec1ff; }
.cal-dow-sun { background: var(--ink); color: #ff7a8a; }

/* 토 / 일 / 공휴일 날짜 셀 */
.cal-sat .cal-num { color: #1f6fb8; }
.cal-sun .cal-num,
.cal-holiday .cal-num { color: #c8102e; }
.cal-sat, .cal-sun, .cal-holiday {
  background: #fafafa;
}
.cal-sat:hover, .cal-sun:hover, .cal-holiday:hover {
  background: #f0f0f0;
}
/* today 가 우선 — today 배경은 유지 */
.cal-day.today { background: var(--mega-yellow); }
.cal-day.today.cal-sat .cal-num,
.cal-day.today.cal-sun .cal-num,
.cal-day.today.cal-holiday .cal-num { color: var(--ink); }

/* 공휴일 명칭 라벨 */
.cal-holiday-name {
  font-size: 11px; font-weight: 700; color: #c8102e;
  line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-day.today .cal-holiday-name { color: var(--ink); }

/* 모바일 — 공휴일명 너무 길 때 줄임 처리는 위에서 처리됨 */
@media (max-width: 600px) {
  .cal-holiday-name { font-size: 9px; }
}

.summary {
  display: flex; gap: 24px; margin-top: 16px; padding: 14px 16px;
  background: var(--mega-yellow-soft); border-radius: 12px;
  border: 2px solid var(--mega-yellow);
}
.summary > div { font-weight: 700; }

/* ── 테이블 가로 스크롤 래퍼 ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap .table { min-width: 480px; }

/* ── 태블릿 (≤ 900px) ── */
@media (max-width: 900px) {
  .menu-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ── 모바일 (≤ 600px) ── */
@media (max-width: 600px) {
  input[type=text], input[type=password], input[type=number], select, textarea {
    font-size: 16px; /* iOS/Android 자동 줌인 방지 */
  }

  .container { padding: 16px 12px; }
  .card { padding: 16px 14px; box-shadow: 3px 3px 0 var(--ink); }
  .card h2 { font-size: 18px; margin-bottom: 14px; }

  .nav-inner { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 14px; }
  .nav-links { gap: 12px; font-size: 13px; }
  .brand { font-size: 20px; }
  .brand-sub { font-size: 11px; padding: 2px 7px; }

  .auth-card { margin: 16px auto 24px; padding: 26px 22px; box-shadow: 4px 4px 0 var(--mega-yellow); }
  .auth-brand { margin-top: 28px; padding: 0 16px; }
  .auth-brand-main { font-size: 24px; word-break: keep-all; }
  .auth-brand-sub { font-size: 11px; }

  .budget-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
  .big { font-size: 22px; word-break: break-all; }

  .menu-grid { grid-template-columns: 1fr; }
  .menu-controls { padding: 10px 0; }
  #menu-search { padding: 10px 14px; }

  /* 모바일에서도 두 옵션을 한 줄에 유지 — 도움말 텍스트 숨김, 폰트·여백 압축 */
  .option-row { padding: 10px; gap: 8px; }
  .option-item .opt-help { display: none; }
  .option-item label { gap: 4px; font-size: 13px; }
  .option-item .opt-name { font-size: 13px; }
  .option-item select { padding: 4px 6px; font-size: 13px; min-width: 0; }

  .calendar { font-size: 11px; gap: 3px; }
  .cal-day { min-height: 54px; padding: 4px 3px; border-radius: 6px; }
  .cal-stat.amount { display: none; }
  .cal-dow { padding: 6px 2px; font-size: 11px; }
  .cal-holiday-name { font-size: 9px; }

  .summary { flex-wrap: wrap; gap: 10px; padding: 12px; }

  .gift-form { flex-direction: column; align-items: stretch; }
  .gift-form input, .gift-form select, .gift-form button { width: 100%; }

  .form-stack { flex-direction: column; align-items: stretch; }
  .form-stack input, .form-stack select, .form-stack button { width: 100%; }

  .calendar-header { gap: 8px; flex-wrap: wrap; }
  .calendar-header h2 { font-size: 18px; flex: 1 1 100%; text-align: center; order: -1; }
  .calendar-header .btn-secondary { padding: 6px 12px; font-size: 13px; }

  /* row + 인라인 style="justify-content:space-between" 류가 좁은 화면에서 꼬이지 않도록 */
  .row { gap: 10px; }
  .row > h2 { flex: 1 1 100%; }

  /* 사용자 화면 오늘 신청 h2 + close-time 줄바꿈 정렬 */
  .card h2:has(.h2-title) .h2-title { margin-right: 4px; }
  .close-time { margin-left: 0; margin-top: 6px; font-size: 12px; padding: 3px 10px; }

  /* 비밀번호 초기화 폼 - 좁은 화면에서 input/button 폭 자동 */
  .reset-pw-form { flex-wrap: wrap; gap: 6px; }
  .reset-pw-form input { width: auto; flex: 1 1 100px; min-width: 100px; }

  /* 인라인 폼 일반 — 줄바꿈 친화 */
  .inline-form { flex-wrap: wrap; gap: 8px; }

  /* 플래시/경고 박스: 단어 단위 줄바꿈 */
  .error, .success, .warning { word-break: keep-all; }

  /* 그룹 관리 그리드 — 모바일: 작업 우측 상단, 자동마감·관리자에 라벨 */
  .table.groups-table thead { display: none; }
  .table.groups-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name    name"
      "members members"
      "autoclose autoclose"
      "admins  actions";
    row-gap: 8px;
    column-gap: 12px;
    padding: 12px 10px;
    border-bottom: 1px solid var(--gray-line);
  }
  .table.groups-table tbody td { padding: 0; border: none; }
  .table.groups-table tbody td:nth-child(1) { grid-area: name; text-align: left; }
  .table.groups-table tbody td:nth-child(2) { grid-area: members; text-align: left; }
  .table.groups-table tbody td:nth-child(3) { grid-area: autoclose; text-align: left; }
  .table.groups-table tbody td:nth-child(4) { grid-area: admins; text-align: left; }
  .table.groups-table tbody td:nth-child(5) {
    grid-area: actions; text-align: right;
    display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px;
  }
  .table.groups-table tbody td:nth-child(2)::before {
    content: "그룹 인원"; display: inline-block;
    font-size: 13px; font-weight: 700; color: var(--ink-soft);
    margin-right: 8px;
  }
  .table.groups-table tbody td:nth-child(3)::before {
    content: "자동마감"; display: inline-block;
    font-size: 13px; font-weight: 700; color: var(--ink-soft);
    margin-right: 8px;
  }
  .table.groups-table tbody td:nth-child(4)::before {
    content: "관리자"; display: inline-block;
    font-size: 13px; font-weight: 700; color: var(--ink-soft);
    margin-right: 8px;
  }
}

/* ── 좁은 폰 (≤ 400px) — 갤럭시 S25 360px 가로 기준 ── */
@media (max-width: 400px) {
  .container { padding: 14px 10px; }
  .card { padding: 14px 12px; box-shadow: 2px 2px 0 var(--ink); border-radius: 14px; }
  .card h2 { font-size: 17px; }

  .nav-inner { padding: 10px 12px; }
  .brand { font-size: 18px; }

  .auth-brand-main { font-size: 22px; }

  .big { font-size: 20px; }
  .budget-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* 메뉴 아이템: 이름과 가격 한 줄 정렬 — 한국어 이름이 길어도 줄바꿈 */
  .menu-item { padding: 12px; gap: 8px; }
  .menu-name { word-break: keep-all; }
  .menu-price { white-space: nowrap; }

  /* 달력 — 7개 셀이 360px에 빠듯하니 최소 폭 보장 */
  .calendar { gap: 2px; }
  .cal-day { min-height: 48px; padding: 3px 2px; border-radius: 5px; }
  .cal-num { font-size: 13px; }
  .cal-stat { font-size: 10px; }
  .cal-holiday-name { font-size: 8px; }
  .cal-dow { padding: 5px 1px; font-size: 10px; border-radius: 5px; }
  .cal-badge { font-size: 9px; padding: 1px 5px; }

  /* 카테고리 탭 — 두 줄로 깔끔하게 */
  .category-tabs { gap: 5px; }
  .cat-tab { padding: 6px 10px; font-size: 12px; }

  /* 사용자 정보 (currentUser.name) 가 길 때 줄바꿈 허용 */
  .nav-links .muted { word-break: break-word; }

  /* 버튼 폰트 살짝 축소 */
  button, .btn-primary, .btn-secondary, .btn-danger { padding: 9px 14px; font-size: 13px; }
  .btn-icon { padding: 0; width: 32px; height: 32px; }

  /* 마감 배지 — 한 줄 유지하되 크기 축소 */
  .close-time { font-size: 11px; padding: 2px 8px; }
}
