/* 공용 부품 — 부품 하나에 모양 하나. 버튼·입력·카드는 --r/--r-lg 네모 모서리, 배지만 알약형.
   화면 이름(.dashboard-…)을 넣지 않는다. 모바일 먼저, min-width 로 넓힌다(600 · 960 · 1280). */

/* ── 버튼 ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h-md); padding: 0 var(--space-5);
  border: 1px solid transparent; border-radius: var(--r);
  font-size: var(--text-base); font-weight: 600; line-height: 1; text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 18px; height: 18px; }
.btn-sm { min-height: var(--control-h-sm); padding: 0 var(--space-4); font-size: var(--text-md); }
.btn-lg { min-height: var(--control-h-lg); padding: 0 var(--space-6); font-size: var(--text-lg); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--sub); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); color: var(--danger-hover); }
.btn:disabled, .btn.is-loading { opacity: .55; cursor: not-allowed; transform: none; }
.inline-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-2); }
.table td > a:only-child:not(.cell-link) { display: inline-flex; align-items: center; min-height: 40px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--primary-ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: inherit; }

/* ── 입력 ─────────────────────────────── */
.form { display: grid; gap: var(--space-5); }
.form-grid { display: grid; gap: var(--space-5); }
@media (min-width: 600px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form-actions { display: grid; gap: var(--space-2); }
.form-actions-end { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-2); }
.field { display: grid; gap: var(--space-2); min-width: 0; }
.field-label { font-size: var(--text-md); font-weight: 600; color: var(--ink); }
.field-opt { font-weight: 400; color: var(--muted); }
.field-hint { font-size: var(--text-sm); color: var(--muted); line-height: 1.5; display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.field-error { font-size: var(--text-sm); color: var(--danger); line-height: 1.5; }
.field-error.is-ok { color: var(--success); }
.field-static { min-height: var(--control-h-md); display: flex; align-items: center; padding: 0 var(--space-4); background: var(--surface-2); border-radius: var(--r); color: var(--sub); }
.input {
  width: 100%; min-height: var(--control-h-md); padding: 0 var(--space-4);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
  font-size: var(--text-base); transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); opacity: 1; }
.input:hover { border-color: #9AA4B3; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(42, 79, 214, .18); }
.input[readonly] { background: var(--surface-2); color: var(--sub); }
.input.is-error { border-color: var(--danger); }
.input.is-error:focus { box-shadow: 0 0 0 3px rgba(196, 43, 43, .16); }
.textarea { padding: var(--space-3) var(--space-4); min-height: 96px; resize: vertical; line-height: var(--leading-normal); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 52px; }
.input-icon-btn {
  position: absolute; top: 2px; right: 2px; width: 44px; height: calc(var(--control-h-md) - 4px);
  display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: var(--r-sm); cursor: pointer;
}
.input-icon-btn:hover, .input-icon-btn.is-on { color: var(--ink); }
.input-row { display: flex; gap: var(--space-2); }
.input-row > .input, .input-row > .input-wrap { flex: 1; min-width: 0; }
.input-row > .btn { flex: none; }

/* 체크 칸 */
.check { display: flex; align-items: flex-start; gap: var(--space-3); min-height: 40px; padding: var(--space-2) 0; cursor: pointer; font-size: var(--text-md); }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box { flex: none; width: 22px; height: 22px; margin-top: 1px; display: grid; place-items: center; border: 1.5px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: transparent; transition: background-color .15s, border-color .15s; }
.check-box .icon { width: 16px; height: 16px; stroke-width: 2.6; }
.check input:checked + .check-box { background: var(--primary); border-color: var(--primary); color: #fff; }
.check input:focus-visible + .check-box { outline: 2px solid var(--focus); outline-offset: 2px; }
.check-label { line-height: 1.5; padding-top: 1px; }

/* 스위치 */
.switch-list { display: grid; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) 0; border-top: 1px solid var(--line); cursor: pointer; }
.switch-row:first-child { border-top: 0; }
.switch-text { display: grid; gap: 2px; }
.switch-label { font-weight: 600; }
.switch { appearance: none; flex: none; position: relative; width: 48px; height: 28px; margin: 0; background: var(--line-strong); border-radius: var(--r-full); cursor: pointer; transition: background-color .2s var(--ease); }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease); }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(20px); }

/* ── 배지 ─────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 10px; border-radius: var(--r-full); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--sub); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-primary { background: var(--primary-soft); color: var(--primary-ink); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ── 알림 상자 ─────────────────────────── */
.alert { display: flex; gap: var(--space-3); padding: var(--space-4); border-radius: var(--r); background: var(--surface-2); color: var(--ink); font-size: var(--text-md); line-height: 1.55; }
.alert .icon { margin-top: 1px; }
.alert-title { display: block; margin-bottom: 2px; }
.alert-info { background: var(--primary-soft); }
.alert-info .icon { color: var(--primary-ink); }
.alert-success { background: var(--success-soft); }
.alert-success .icon { color: var(--success); }
.alert-warn { background: var(--warn-soft); }
.alert-warn .icon { color: var(--warn); }
.alert-danger { background: var(--danger-soft); }
.alert-danger .icon { color: var(--danger); }

/* ── 카드 · 묶음 ───────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); min-width: 0; }
@media (min-width: 600px) { .card { padding: var(--space-6); } }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-head .card-title { margin-bottom: 0; }
.card-head-pad { padding: var(--space-5) var(--space-5) 0; }
@media (min-width: 600px) { .card-head-pad { padding: var(--space-6) var(--space-6) 0; } }
.card-title { font-size: var(--text-lg); font-weight: 700; line-height: var(--leading-tight); margin-bottom: var(--space-4); }
.card-title .count { margin-left: var(--space-2); font-size: var(--text-md); font-weight: 500; color: var(--muted); }
.card-sub { margin: calc(var(--space-2) * -1) 0 var(--space-4); color: var(--sub); font-size: var(--text-md); }
.card-narrow { max-width: 560px; }
.card-quiet { background: transparent; box-shadow: none; }
.stack { display: grid; gap: var(--space-5); align-content: start; }
.split { display: grid; gap: var(--space-5); margin-top: var(--space-5); }
.split:first-child { margin-top: 0; }
@media (min-width: 960px) { .split { grid-template-columns: 1fr 1fr; } .split-detail { grid-template-columns: 5fr 6fr; } }

/* 줄 목록 */
.rows { display: grid; }
.row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) 0; border-top: 1px solid var(--line); min-height: 56px; }
.row:first-child { border-top: 0; padding-top: 0; }
.row-main { display: grid; gap: 2px; min-width: 0; }
.row-sub { font-size: var(--text-sm); color: var(--muted); }
.row-link { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); width: 100%; color: inherit; text-decoration: none; }
.row-link:hover strong { color: var(--primary-ink); text-decoration: underline; }

/* 키-값 */
.kv { display: grid; }
.kv > div { display: grid; grid-template-columns: 112px 1fr; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); align-items: center; }
.kv > div:first-child { border-top: 0; padding-top: 0; }
.kv dt { color: var(--muted); font-size: var(--text-md); }
.kv dd { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.kv-note { width: 100%; font-size: var(--text-sm); color: var(--sub); }
.kv dd .badge { white-space: normal; padding-top: 3px; padding-bottom: 3px; line-height: 1.4; }
@media (max-width: 599px) { .kv > div { grid-template-columns: 1fr; gap: var(--space-1); } }

/* 숫자 칸 */
.stats { display: grid; gap: var(--space-4); margin-bottom: var(--space-5); }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat { position: relative; display: grid; gap: var(--space-1); padding: var(--space-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); color: inherit; text-decoration: none; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
a.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow); color: inherit; }
.stat-label { font-size: var(--text-md); font-weight: 600; color: var(--sub); }
.stat-value { font-size: var(--text-3xl); font-weight: 700; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: var(--text-sm); color: var(--muted); }
.stat-danger .stat-value { color: var(--danger); }

/* 진행 막대 */
.meter { height: 8px; margin-top: var(--space-4); background: var(--surface-2); border-radius: var(--r-full); overflow: hidden; }
.meter-bar { display: block; height: 100%; width: var(--pct, 0%); background: var(--primary); border-radius: inherit; transition: width .4s var(--ease); }

/* ── 빈 상태 ───────────────────────────── */
.empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-8) var(--space-5); text-align: center; }
.empty-mark { position: relative; width: 56px; height: 56px; display: grid; place-items: center; margin-bottom: var(--space-2); color: var(--primary); background: var(--primary-soft); border-radius: var(--r-lg); }
.empty-mark .icon { width: 28px; height: 28px; }
.empty-title { font-size: var(--text-lg); font-weight: 700; }
.empty-desc { max-width: 36em; color: var(--sub); font-size: var(--text-md); }
.empty-action { margin-top: var(--space-3); }

/* ── 표(PC) → 카드(모바일) ─────────────── */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-md); table-layout: auto; }
.table th { text-align: left; font-size: var(--text-sm); font-weight: 600; color: var(--muted); white-space: nowrap; }
.table th, .table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFBFC; }
.cell-link { display: grid; gap: 2px; min-height: 40px; align-content: center; color: inherit; text-decoration: none; }
.cell-link:hover strong { color: var(--primary-ink); text-decoration: underline; }
.cell-sub { display: block; font-size: var(--text-sm); color: var(--muted); white-space: nowrap; }
.cell-break { overflow-wrap: anywhere; min-width: 12em; }
@media (max-width: 959px) {
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--line); }
  .table-cards td { display: grid; grid-template-columns: 76px 1fr; gap: var(--space-3); align-items: center; padding: var(--space-1) 0; border: 0; }
  .table-cards td::before { content: attr(data-label); font-size: var(--text-sm); color: var(--muted); }
  .table-cards td:first-child { grid-template-columns: 1fr; padding-bottom: var(--space-2); }
  .table-cards td:first-child::before { display: none; }
  .table-cards td > * { justify-self: start; }
}
@media (min-width: 960px) {
  .table th:first-child, .table td:first-child { padding-left: var(--space-6); }
  .table th:last-child, .table td:last-child { padding-right: var(--space-6); }
}

/* 페이지 넘김 */
.pager { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--space-1); padding: var(--space-5); border-top: 1px solid var(--line); }
.pager-btn { min-width: 40px; height: 40px; display: inline-grid; place-items: center; padding: 0 var(--space-2); border-radius: var(--r); color: var(--sub); text-decoration: none; font-variant-numeric: tabular-nums; }
a.pager-btn:hover { background: var(--surface-2); color: var(--ink); }
.pager-btn.is-current { background: var(--ink); color: #fff; font-weight: 600; }
.pager-btn.is-disabled { opacity: .35; }

/* 거르기 줄 */
.filters { display: grid; gap: var(--space-4); align-items: end; margin-bottom: var(--space-5); }
@media (min-width: 600px) { .filters { grid-template-columns: 200px minmax(0, 1fr) auto; } }
.filters-actions { display: flex; gap: var(--space-2); }

/* ── 화면 머리 ─────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.page-head-text { display: grid; gap: var(--space-1); min-width: 0; }
.page-kicker { font-size: var(--text-sm); font-weight: 600; color: var(--primary-ink); letter-spacing: .02em; }
.page-title { font-size: var(--text-2xl); font-weight: 750; line-height: var(--leading-tight); letter-spacing: -.02em; }
@media (min-width: 960px) { .page-title { font-size: var(--text-3xl); } }
.page-sub { color: var(--sub); font-size: var(--text-base); }
.page-actions { display: flex; gap: var(--space-2); }

/* ── 토스트 ────────────────────────────── */
.toast-region { position: fixed; z-index: 90; left: var(--space-4); right: var(--space-4); bottom: var(--space-4); display: grid; gap: var(--space-2); justify-items: center; pointer-events: none; }
@media (min-width: 600px) { .toast-region { left: auto; right: var(--space-6); bottom: var(--space-6); justify-items: end; } }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--space-3); max-width: 420px; width: 100%; padding: var(--space-4); background: var(--ink); color: #fff; border-radius: var(--r); box-shadow: var(--shadow-lg); font-size: var(--text-md); line-height: 1.5; cursor: pointer;
  opacity: 0; transform: translateY(8px); transition: opacity .22s var(--ease), transform .22s var(--ease); }
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateY(4px); }
.toast .icon { color: #7EE0B5; }
.toast-error { background: #3A1414; }
.toast-error .icon { color: #FF9C9C; }

/* ── 확인 대화상자 ─────────────────────── */
.dialog { padding: 0; border: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
.dialog::backdrop { background: rgba(14, 19, 27, .48); }
.dialog[open] { animation: dlg-in .18s var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.dialog-box { display: grid; gap: var(--space-3); padding: var(--space-6); }
.dialog-title { font-size: var(--text-lg); font-weight: 700; line-height: 1.45; }
.dialog-body { color: var(--sub); font-size: var(--text-md); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-3); }

/* ── 툴팁 ─────────────────────────────── */
.tooltip { position: absolute; z-index: 95; left: 0; top: 0; transform: translate(var(--tip-x, 0), var(--tip-y, 0)); max-width: 260px; padding: 6px 10px; background: var(--ink); color: #fff; border-radius: var(--r-sm); font-size: var(--text-sm); line-height: 1.45; pointer-events: none; box-shadow: var(--shadow); }

/* ── 드롭존 ────────────────────────────── */
.dropzone { position: relative; display: grid; gap: var(--space-2); }
.dropzone-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dropzone-label { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); min-height: 120px; padding: var(--space-5); border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); color: var(--sub); text-align: center; cursor: pointer; transition: border-color .15s, background-color .15s; }
.dropzone-label .icon { width: 24px; height: 24px; color: var(--primary); }
.dropzone-label:hover, .dropzone.is-over .dropzone-label { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-input:focus-visible + .dropzone-label { outline: 2px solid var(--focus); outline-offset: 2px; }
.dropzone.has-file .dropzone-label { border-style: solid; border-color: var(--primary); color: var(--ink); }
.dropzone.is-error .dropzone-label { border-color: var(--danger); }

/* ── 자동완성 콤보박스(assets/js/combobox.js) ── */
.cbx { position: relative; }
.cbx-native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.cbx-input { padding-right: 44px; cursor: pointer; }
.cbx-caret { position: absolute; right: 14px; top: 50%; width: 10px; height: 10px; margin-top: -7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none; transition: transform .15s; }
.cbx.is-open .cbx-caret { transform: rotate(-135deg); margin-top: -2px; }
.cbx-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); max-height: 300px; overflow-y: auto; padding: var(--space-1); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow-lg); }
.cbx.is-up .cbx-list { top: auto; bottom: calc(100% + 4px); }
.cbx-opt { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-height: 44px; padding: var(--space-2) var(--space-3); border-radius: var(--r-sm); cursor: pointer; }
.cbx-opt.is-active { background: var(--surface-2); }
.cbx-opt[aria-selected="true"] { color: var(--primary-ink); font-weight: 600; }
.cbx-opt[aria-selected="true"]::after { content: ''; margin-left: auto; width: 6px; height: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); }
.cbx-opt[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.cbx-d { width: 100%; font-size: var(--text-sm); color: var(--muted); font-weight: 400; }
.cbx-group { padding: var(--space-2) var(--space-3) var(--space-1); font-size: var(--text-xs); font-weight: 600; color: var(--muted); }
.cbx-none { padding: var(--space-3); color: var(--muted); font-size: var(--text-md); }

/* ── 문자 인증 묶음 ────────────────────── */
.pv { display: grid; gap: var(--space-4); }
.pv-msg { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--sub); }
.pv-msg.is-ok { color: var(--success); }
.pv-msg .icon { width: 16px; height: 16px; }
.pv-send { min-width: 128px; }
