/* 공통 컴포넌트 — 카드 / 버튼 / 입력 / 테이블 / 칩 / 탭 / 드로어 / 토스트 / 진행률 / 빈 상태 */

/* ── 카드(섹션) ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-12);
  padding: var(--s-16) var(--s-24);
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.16px; }
.card-head .desc { color: var(--text-muted); font-size: 12px; max-width: 520px; text-align: right; line-height: 1.5; }
.card-body { padding: var(--s-24); display: flex; flex-direction: column; gap: var(--s-16); }
.card-body.tight { padding: var(--s-16) var(--s-24); }
.card-body.flush { padding: 0; }
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .chev { color: var(--gray-400); transition: transform .15s ease; width: 14px; height: 14px; display: inline-flex; }
details.card > summary .chev svg { width: 14px; height: 14px; }
details.card > summary .chev svg path { fill: currentColor; }
details.card[open] > summary .chev { transform: rotate(90deg); }
details.card:not([open]) > summary.card-head { border-bottom: 0; }
.head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* 숫자 카드 */
.stat-grid { display: grid; gap: var(--s-12); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: var(--s-16) 18px; box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 6px;
}
.stat-card .label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-card .value { font-size: 26px; font-weight: 800; letter-spacing: -0.26px; line-height: 1.2; }
.stat-card .sub { font-size: 12px; color: var(--text-muted); }
.stat-card.accent { background: var(--primary-tint); border-color: var(--orange-100); }
.stat-card.accent .value { color: var(--primary); }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-pressed); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-300); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-50); color: var(--text); }
.btn-danger { background: var(--error-tint); color: var(--error); }
.btn-danger:hover:not(:disabled) { background: #FBD4DB; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-xs); }
.btn-xs { height: 26px; padding: 0 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn .spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-secondary .spinner, .btn-ghost .spinner { border-color: var(--gray-200); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius-xs);
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--gray-50); color: var(--text); }
.actions { display: flex; gap: var(--s-8); flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }

/* ── 입력 ── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0 12px; height: 40px;
  font-size: 14px;
  outline: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--orange-50); }
.input::placeholder, .textarea::placeholder { color: var(--gray-400); }
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.55; font-family: var(--font); }
.textarea.mono { font-family: var(--font-mono); font-size: 12.5px; }
.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23717272' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input.sm, .select.sm { height: 34px; font-size: 13px; }
.form-grid { display: grid; gap: var(--s-16); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.row { display: flex; gap: var(--s-12); flex-wrap: wrap; align-items: flex-end; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-box .input { padding-left: 36px; }
.search-box .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--gray-400); }
.search-box .ico svg { width: 16px; height: 16px; }
.search-box .ico svg path { fill: currentColor; }

/* 안내 박스 */
.note { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 14px; font-size: 12.5px; color: var(--text-2); line-height: 1.65; }
.note.warn { background: var(--yellow-tint); border-color: #F8DDB5; color: #7A4B00; }
.note.danger { background: var(--error-tint); border-color: #F8C5CE; color: var(--error); }
.note.info { background: var(--info-tint); border-color: #C5E6F3; color: #1F6F8F; }

/* ── 테이블 ── */
.table-wrap { overflow: auto; border-radius: 0 0 var(--radius-card) var(--radius-card); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted);
  padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--gray-50); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.trunc { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb { width: 40px; height: 40px; border-radius: var(--radius-xs); object-fit: cover; background: var(--gray-100); flex-shrink: 0; }
.cell-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-title .t { font-weight: 600; }
.cell-title .s { font-size: 12px; color: var(--text-muted); }
.editable { cursor: text; border-bottom: 1px dashed var(--gray-300); }
.editable:hover { color: var(--primary); border-bottom-color: var(--primary); }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px var(--s-24); border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.pager .btns { display: flex; gap: 6px; }

/* ── 칩 / 탭 ── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700; white-space: nowrap;
  background: var(--gray-100); color: var(--text-2);
}
.chip.ok { background: var(--success-tint); color: #5E7A00; }
.chip.bad { background: var(--error-tint); color: var(--error); }
.chip.info { background: var(--info-tint); color: #1F6F8F; }
.chip.warn { background: var(--yellow-tint); color: #9A5A00; }
.chip.primary { background: var(--primary-tint); color: var(--primary); }
.chip.gray { background: var(--gray-100); color: var(--text-muted); }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--gray-50); border-radius: var(--radius-md); border: 1px solid var(--border); }
.tab { height: 30px; padding: 0 12px; border-radius: var(--radius-xs); border: 0; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-card); }
.toolbar { display: flex; gap: var(--s-12); align-items: center; flex-wrap: wrap; padding: var(--s-16) var(--s-24); border-bottom: 1px solid var(--border); }

/* ── 진행률 ── */
.progress { height: 8px; background: var(--gray-100); border-radius: var(--radius-full); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--primary); border-radius: var(--radius-full); transition: width .3s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }

/* ── 결과 박스 ── */
.result-box {
  display: none;
  background: var(--gray-950); color: #E6E7E8;
  border-radius: var(--radius-md); padding: 12px 14px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto;
}
.result-box.visible { display: block; }
.result-box.plain { font-family: var(--font); font-size: 13.5px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* ── 빈 상태 ── */
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 16px; color: var(--text-muted); font-size: 13px; text-align: center; }
.empty img { width: 44px; height: 44px; opacity: .6; }

/* ── 드로어 ── */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(18, 19, 20, .32); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 94vw); z-index: 41;
  background: var(--surface); box-shadow: var(--shadow-drawer);
  display: flex; flex-direction: column;
  animation: slideIn .18s ease;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-16) var(--s-24); border-bottom: 1px solid var(--border); }
.drawer-title { font-size: 16px; font-weight: 700; }
.drawer-body { padding: var(--s-24); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-24); }
.dsec { display: flex; flex-direction: column; gap: 10px; }
.dsec-title { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; justify-content: space-between; }
.dsec-title::after { content: ''; flex: 1; height: 1px; background: var(--border); margin-left: 10px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.kv b { color: var(--text-muted); font-weight: 600; }
.prose { font-size: 13.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; max-height: 320px; overflow: auto; }
.gallery { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-xs); border: 1px solid var(--border); }

/* ── 토스트 ── */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--gray-950); color: #fff;
  padding: 10px 14px; border-radius: var(--radius-md);
  font-size: 13px; box-shadow: var(--shadow-pop);
  animation: toastIn .18s ease;
  max-width: 420px;
}
.toast.err { background: var(--error); }
.toast.ok { background: #5E7A00; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── 유틸 ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-16); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-16); }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.sep { height: 1px; background: var(--border); }
.stack { display: flex; flex-direction: column; gap: var(--s-12); }
.inline { display: inline-flex; align-items: center; gap: 8px; }
.right { margin-left: auto; }
.text-primary { color: var(--primary); }
.text-error { color: var(--error); }
.text-success { color: #5E7A00; }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--gray-100); }
.star { color: var(--yellow); }
