/* ==========================================================================
   RiceGift — 공통 스타일 (파트너 사이트와 관리자 사이트가 함께 쓴다)
   구성: 기본값 / 공통 부품(버튼·입력·배지·카드) / 로그인 / 앱 틀 / 목록 / 상세 / 모달
   관리자 사이트는 이 파일 뒤에 office.css 를 불러 색과 일부 배치만 바꾼다.
   ========================================================================== */

:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --text: #17211c;
  --text-2: #3d4a43;
  --muted: #6b7770;
  --faint: #a3ada7;
  --border: #e2e7e4;
  --border-soft: #eef1ef;

  --primary: #1f7a4d;
  --primary-hover: #19663f;
  --primary-strong: #145233;
  --primary-soft: #e6f3ec;
  --primary-ring: rgba(31, 122, 77, 0.18);

  --accent: #d97706;
  --accent-hover: #b96205;
  --accent-soft: #fdf1dd;

  --ink: #10231a;
  --ink-2: #183126;

  --danger: #b42318;
  --danger-soft: #fdecea;
  --info: #175cd3;
  --info-soft: #eaf2fe;

  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 35, 26, 0.05);
  --shadow: 0 10px 30px rgba(16, 35, 26, 0.08);
  --shadow-lg: 0 24px 64px rgba(16, 35, 26, 0.22);

  --sidebar-width: 248px;
  --topbar-height: 64px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

html:has(dialog[open]) {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
}

h1,
h2,
h3,
p {
  margin: 0;
}

/* display 를 정한 부품(버튼 등)도 hidden 속성으로 숨길 수 있게 한다. */
[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.mono {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
  letter-spacing: 0.02em;
}

.icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 브랜드 ---------- */
.brand {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-sub {
  font-weight: 600;
  color: var(--primary);
}

/* 접힌 사이드 메뉴에서만 보이는 줄임 표시. */
.brand-mini {
  display: none;
}

/* ---------- 버튼 ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: #ffffff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}

.button:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.button:active {
  transform: translateY(1px);
}

.button:focus-visible,
.icon-button:focus-visible,
.page-link:focus-visible,
.nav-item:focus-visible {
  outline: 3px solid var(--primary-ring);
  outline-offset: 2px;
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button .icon {
  width: 16px;
  height: 16px;
}

.button-accent {
  background: var(--accent);
  border-color: var(--accent);
}

.button-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button-dark {
  background: var(--ink);
  border-color: var(--ink);
}

.button-dark:hover {
  background: var(--ink-2);
  border-color: var(--ink-2);
}

.button-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
}

.button-ghost:hover {
  background: var(--surface-2);
  border-color: #cfd6d2;
}

.button-soft {
  background: var(--primary-soft);
  border-color: transparent;
  box-shadow: none;
  color: var(--primary-strong);
}

.button-soft:hover {
  background: #d6ebdf;
  border-color: transparent;
}

.button-danger {
  background: var(--danger);
  border-color: var(--danger);
}

.button-danger:hover {
  background: #912018;
  border-color: #912018;
}

.button-danger-soft {
  background: var(--danger-soft);
  border-color: transparent;
  box-shadow: none;
  color: var(--danger);
}

.button-danger-soft:hover {
  background: #fbd9d5;
  border-color: transparent;
}

/* 누를 수 없는 상태를 링크 모양(span)으로 보여줄 때. */
.button.is-disabled {
  opacity: 0.45;
  box-shadow: none;
  pointer-events: none;
}

.button-sm {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

/* 요청 처리 중: 글자 대신 회전하는 원을 보여준다. */
.button.is-busy {
  position: relative;
  color: transparent;
}

.button.is-busy::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--border-soft);
  color: var(--text);
}

/* ---------- 입력 ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 600;
}

.field-hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.field-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input::placeholder {
  color: var(--faint);
}

.field-input:hover {
  border-color: #cfd6d2;
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.field-input[readonly] {
  background: var(--surface-2);
  border-color: var(--border-soft);
  color: var(--text-2);
  box-shadow: none;
}

textarea.field-input {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

select.field-input {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7770' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.field-input-sm {
  width: auto;
  height: 34px;
  font-size: 0.85rem;
}

.field-input.field-strong {
  color: var(--primary-strong);
  font-size: 1.05rem;
  font-weight: 800;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group .field-input {
  flex: 1;
  min-width: 0;
}

.input-suffix {
  position: relative;
}

.input-suffix .field-input {
  padding-right: 34px;
  font-variant-numeric: tabular-nums;
}

.input-suffix > span {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.check {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  vertical-align: middle;
  cursor: pointer;
}

.check:disabled {
  cursor: default;
}

/* 켜고 끄는 스위치. 상태는 aria-checked 로 나타낸다. */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 0;
  background: none;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.switch-track {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  background: #cfd6d2;
  border-radius: 999px;
  transition: background-color 0.15s;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(16, 35, 26, 0.25);
  transition: transform 0.15s;
}

.switch[aria-checked="true"] {
  color: var(--primary-strong);
}

.switch[aria-checked="true"] .switch-track {
  background: var(--primary);
}

.switch[aria-checked="true"] .switch-track::after {
  transform: translateX(16px);
}

.switch:focus-visible {
  outline: 3px solid var(--primary-ring);
  outline-offset: 2px;
}

.switch:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* ---------- 배지 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  background: var(--border-soft);
  border-radius: 6px;
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-type-earn {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.badge-type-fee {
  background: #eceff3;
  color: #414b5a;
}

.badge-type-withdraw {
  background: var(--accent-soft);
  color: #8a4b03;
}

.badge-type-refund {
  background: var(--info-soft);
  color: var(--info);
}

.badge[class*="badge-status-"] {
  background: transparent;
  padding: 0;
  font-weight: 600;
}

.badge[class*="badge-status-"]::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.badge-status-normal {
  color: var(--primary-strong);
}

.badge.badge-status-normal::before {
  background: #2fa866;
}

.badge-status-pending {
  color: #8a4b03;
}

.badge.badge-status-pending::before {
  background: var(--accent);
}

.badge-status-canceled {
  color: var(--muted);
}

.badge-status-info {
  color: var(--info);
}

.badge.badge-status-info::before {
  background: var(--info);
}

.badge-status-danger {
  color: var(--danger);
}

.badge.badge-status-danger::before {
  background: var(--danger);
}

/* ---------- 카드 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* 카드 안에 폼을 넣을 때: 제목 / 입력칸 / 버튼 줄. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.card-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.card-head h3 {
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.card-head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.85rem;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 24px;
}

.card-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* 처리 결과(발행된 번호, 새 비밀번호 등)를 복사할 수 있게 보여주는 칸. */
.result-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-box textarea {
  width: 100%;
  min-height: 92px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.7;
  resize: vertical;
}

.result-box .button {
  align-self: flex-end;
}

/* ---------- 안내 상자 ---------- */
.alert,
.notice {
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.88rem;
}

.alert {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.2);
  color: var(--danger);
}

.notice {
  background: var(--accent-soft);
  border-color: rgba(217, 119, 6, 0.22);
  color: #7a4303;
}

.notice[data-kind="error"] {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.2);
  color: var(--danger);
}

.notice[data-kind="success"] {
  background: var(--primary-soft);
  border-color: rgba(31, 122, 77, 0.22);
  color: var(--primary-strong);
}

.notice[data-kind="info"] {
  background: var(--info-soft);
  border-color: rgba(23, 92, 211, 0.18);
  color: var(--info);
}

.guide {
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.guide h3 {
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 700;
}

.guide ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.75;
}

/* ==========================================================================
   로그인
   ========================================================================== */
.page-auth {
  background:
    radial-gradient(900px 480px at 85% -10%, rgba(31, 122, 77, 0.14), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(217, 119, 6, 0.1), transparent 60%),
    var(--bg);
}

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-title {
  text-align: center;
}

.auth-title .brand {
  font-size: 1.6rem;
}

.auth-lead {
  margin: 8px 0 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.auth-help {
  margin-top: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-card .alert {
  margin-bottom: 20px;
}

.auth-title + .alert {
  margin-top: 24px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form .field-input,
.form .button {
  height: 46px;
}

.form > .button {
  margin-top: 4px;
}

/* ==========================================================================
   앱 틀: 사이드 메뉴 + 상단 바
   ========================================================================== */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease-out;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px 14px;
  background: linear-gradient(180deg, var(--ink) 0%, #0c1a14 100%);
  color: #c9d8cf;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 10px;
  text-decoration: none;
}

.sidebar-brand .brand {
  color: #ffffff;
}

.sidebar-brand .brand-sub {
  color: #6fd39c;
}

/* 메뉴가 화면보다 길면 메뉴 부분만 스크롤한다. */
.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  margin: 26px -6px 12px;
  padding: 0 6px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

/* 메뉴 묶음의 제목. */
.nav-section {
  margin-top: 14px;
  padding: 0 12px 2px;
  color: #71867b;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* 처리할 것이 있는 메뉴의 건수. */
.nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0 6px;
  background: var(--accent);
  border-radius: 999px;
  color: #ffffff;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.nav-item {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: #a7b9ae;
  font-size: 0.93rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-item.is-active {
  background: var(--primary);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  color: #ffffff;
}

.sidebar-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
}

.avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--primary);
  border-radius: 10px;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 800;
}

.sidebar-user {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.sidebar-user strong,
.sidebar-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user strong {
  color: #ffffff;
  font-size: 0.88rem;
}

.sidebar-user span {
  color: #8fa397;
  font-size: 0.76rem;
}

.sidebar-backdrop {
  display: none;
}

.shell-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.topbar-menu {
  margin-left: -8px;
}

.topbar-title {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-left: auto;
}

.topbar-clock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.topbar-clock .icon {
  width: 15px;
  height: 15px;
}

/* 전체화면 버튼: 상태에 따라 아이콘 하나만 보인다. */
.fullscreen-exit,
.is-fullscreen .fullscreen-enter {
  display: none;
}

.is-fullscreen .fullscreen-exit {
  display: block;
}

/* ---------- 내 메뉴 (프로필 수정 / 비밀번호 변경 / 로그아웃) ---------- */
.user-menu {
  position: relative;
}

.user-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 5px;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 0.88rem;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.user-menu-button::-webkit-details-marker {
  display: none;
}

.user-menu-button:hover,
.user-menu[open] .user-menu-button {
  background: var(--border-soft);
}

.user-menu-button:focus-visible {
  outline: 3px solid var(--primary-ring);
  outline-offset: 2px;
}

.user-menu-button .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 0.82rem;
}

.user-menu-button > .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
  transition: transform 0.15s;
}

.user-menu[open] .user-menu-button > .icon {
  transform: rotate(180deg);
}

.user-menu-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 224px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.user-menu-head {
  display: flex;
  flex-direction: column;
  margin-bottom: 6px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border-soft);
  line-height: 1.4;
}

.user-menu-head strong,
.user-menu-head span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-head strong {
  font-size: 0.92rem;
}

.user-menu-head span {
  color: var(--muted);
  font-size: 0.78rem;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--text-2);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.user-menu-item:hover,
.user-menu-item:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.user-menu-item .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.user-menu-panel form {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
}

/* ---------- 접힌 사이드 메뉴 (넓은 화면에서만): 아이콘만 남긴다 ---------- */
@media (min-width: 901px) {
  .nav-min {
    --sidebar-width: 76px;
  }

  .nav-min .brand-full,
  .nav-min .nav-item > span,
  .nav-min .nav-section > span,
  .nav-min .sidebar-user {
    display: none;
  }

  .nav-min .brand-mini {
    display: inline;
  }

  .nav-min .sidebar-brand {
    justify-content: center;
    padding: 0;
  }

  .nav-min .nav-item {
    justify-content: center;
    padding: 12px 0;
  }

  /* 묶음 제목 자리에는 가는 구분선만 둔다. */
  .nav-min .nav-section {
    flex: none;
    height: 1px;
    margin: 8px 10px;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
  }

  .nav-min .nav-count {
    position: absolute;
    top: 3px;
    right: 5px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    font-size: 0.64rem;
  }

  .nav-min .sidebar-foot {
    justify-content: center;
    padding: 8px 0;
    background: none;
    border-color: transparent;
  }
}

.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px 0 12px;
  background: var(--primary-soft);
  border-radius: 999px;
  color: var(--primary-strong);
  font-size: 0.85rem;
  white-space: nowrap;
}

.balance-chip .icon {
  width: 16px;
  height: 16px;
}

.balance-chip strong {
  font-variant-numeric: tabular-nums;
}

.main {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
}

/* 화면 아래 가운데에 띄운다. 위쪽에 두면 목록의 버튼(등록·삭제)을 가린다. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(460px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 12px 16px;
  background: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  color: #ffffff;
  font-size: 0.9rem;
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}

.toast .icon {
  color: #6fd39c;
}

.toast-error {
  background: var(--danger);
}

.toast.is-leaving {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-desc {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- 대시보드 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
}

.stat .button {
  margin-left: auto;
}

.stat-icon,
.empty-icon,
.modal-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

.stat-icon .icon {
  width: 22px;
  height: 22px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

/* ---------- 준비 중 / 빈 목록 ---------- */
.empty-icon {
  width: 56px;
  height: 56px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 50%;
  color: var(--faint);
}

.empty-icon .icon {
  width: 24px;
  height: 24px;
}

.empty-page {
  padding: 80px 24px;
  text-align: center;
}

.empty-page h2 {
  margin-top: 16px;
  font-size: 1.15rem;
}

.empty-page p {
  margin-top: 6px;
  color: var(--muted);
}

/* ==========================================================================
   목록: 검색 조건 + 표
   ========================================================================== */
.filter {
  margin-bottom: 16px;
  padding: 20px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px 16px;
}

.filter-wide {
  grid-column: span 5;
}

/* 조건이 몇 개뿐인 검색: 한 줄에 오른쪽으로 붙인다. */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px 16px;
}

.filter-row .field {
  flex: 0 1 190px;
}

.filter-buttons {
  display: flex;
  gap: 8px;
}

.filter-buttons .button:first-child {
  flex: 1;
}

.filter-buttons .button-ghost {
  flex: none;
  width: 42px;
  padding: 0;
}

.table-card {
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
}

.per-page {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.table-count {
  color: var(--muted);
  font-size: 0.85rem;
}

.table-count strong {
  color: var(--text);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: min(300px, 100%);
}

.search-box > .icon {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--faint);
  pointer-events: none;
}

.search-box .field-input {
  width: 100%;
  padding: 0 34px;
}

/* 브라우저 기본 지우기(x) 대신 아래 .search-clear 를 쓴다. */
.search-box .field-input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  position: absolute;
  right: 3px;
  width: 28px;
  height: 28px;
}

.search-clear .icon {
  width: 14px;
  height: 14px;
}

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

/* 칸 안에서 줄이 바뀌지 않게 두고, 화면이 좁으면 표 영역만 가로로 스크롤한다. */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  white-space: nowrap;
}

.table th {
  padding: 11px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.table th:first-child,
.table td:first-child {
  padding-left: 20px;
}

.table th:last-child,
.table td:last-child {
  padding-right: 20px;
}

/* 업체명처럼 길이를 알 수 없는 값은 잘라서 보여주고 전체는 title 로 확인한다. */
.cell-clip {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

/* 표 위에 도구 줄이 없을 때: 카드 테두리와 겹치는 윗선을 없앤다. */
.table-wrap-flush {
  border-top: 0;
}

/* 합계 줄 */
.table tfoot th,
.table tfoot td {
  padding: 14px 12px;
  background: var(--primary-soft);
  border-top: 1px solid rgba(31, 122, 77, 0.22);
  border-bottom: 0;
  color: var(--primary-strong);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: left;
}

/* 여러 칸을 합친 '통계' 제목은 가운데에 둔다. */
.table tfoot th[colspan] {
  text-align: center;
}

.table tfoot td.num {
  font-weight: 800;
  text-align: right;
}

.table tbody tr:hover td {
  background: #fafcfb;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.num-plus {
  color: var(--primary);
}

.num-minus {
  color: #c2410c;
}

.num-zero {
  color: var(--faint);
}

.table .num-zero,
.detail-item .num-zero {
  font-weight: 500;
}

.col-id {
  width: 64px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.table .col-action {
  width: 84px;
  text-align: center;
}

.table .col-check {
  width: 48px;
  padding-right: 4px;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.cell-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.table .table-empty {
  padding: 56px 16px;
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

.table-empty p {
  margin-top: 12px;
}

.table tbody tr:hover td.table-empty {
  background: transparent;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* 표 아래: 왼쪽에 '1 - 25 / 40' 범위, 오른쪽에 이전/다음. */
.table-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.table-range {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.pager {
  display: flex;
  gap: 6px;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

a.page-link:hover {
  background: var(--surface-2);
  border-color: #cfd6d2;
}

.page-link.is-current {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.page-link .icon {
  width: 16px;
  height: 16px;
}

.page-gap {
  color: var(--faint);
}

/* ==========================================================================
   상세
   ========================================================================== */
.detail {
  margin-bottom: 16px;
  overflow: hidden;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 -1px;
}

.detail-item {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}

.detail-item dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.detail-item dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.detail-item dd .badge {
  margin-right: 6px;
  vertical-align: 1px;
}

.detail-foot {
  display: flex;
  justify-content: flex-end;
  padding: 14px 20px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   모달
   ========================================================================== */
dialog.modal {
  width: 100%;
  max-width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  overflow: visible;
}

dialog.modal[open] {
  display: flex;
  animation: modal-in 0.2s ease-out;
}

dialog.modal::backdrop {
  background: rgba(12, 26, 20, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 18px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.modal-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.modal-icon-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 24px;
  overflow-y: auto;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.field-full {
  grid-column: 1 / -1;
}

.field-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

dialog.modal-wide {
  max-width: min(780px, calc(100vw - 32px));
}

dialog.modal-narrow {
  max-width: min(440px, calc(100vw - 32px));
}

.modal-icon-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.confirm-text {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.confirm-sub {
  margin-top: -8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   움직임
   ========================================================================== */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   화면 폭에 따른 조정
   ========================================================================== */
@media (max-width: 1180px) {
  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filter-wide {
    grid-column: span 2;
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    left: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
  }

  .sidebar-open .sidebar {
    transform: none;
  }

  .sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(12, 26, 20, 0.5);
  }

  .topbar {
    padding: 0 16px;
  }

  .card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .main {
    padding: 20px 16px;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .topbar-clock {
    display: none;
  }
}

@media (max-width: 600px) {
  .balance-chip-label,
  .user-menu-name,
  .topbar-fullscreen {
    display: none;
  }

  .user-menu-button {
    padding: 0 6px 0 5px;
  }

  .card-head,
  .card-body,
  .card-foot {
    padding-left: 18px;
    padding-right: 18px;
  }

  .page-actions,
  .page-actions .button {
    flex: 1;
  }

  .filter-grid,
  .field-grid,
  .field-grid-3,
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-row .field {
    flex: 1 1 100%;
  }

  .table-toolbar {
    flex-wrap: wrap;
  }

  .search-box {
    width: 100%;
  }

  .filter-wide {
    grid-column: auto;
  }

  .input-group {
    flex-direction: column;
  }

  /* 세로로 쌓일 때는 늘어나는 기준이 높이가 되므로, 입력칸이 납작해지지 않게 고정한다. */
  .input-group .field-input {
    flex: none;
  }

  .modal-body {
    padding: 18px;
  }

  .auth-card {
    padding: 28px 20px 22px;
  }
}
