/* =====================================================================
   KOKOPICK 바우처 · 공통 베이스 & 컴포넌트
   tokens.css 다음에 로드하세요.
   ===================================================================== */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* 숫자·코드는 고정폭 + tabular */
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- 브랜드 로고 ---------- */
.logo {
  width: 152px; height: 20px;
  background: url('../img/logo.png') no-repeat left center / contain;
}
.logo-mark {
  width: 12px; height: 12px; display: inline-block;
  background: url('../img/logo-mark.png') no-repeat center / contain;
}

/* ---------- 타이포 ---------- */
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
.sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 var(--sp-5); }
.section-label {
  font-size: 11.5px; font-weight: 600; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .05em; margin: var(--sp-5) 0 var(--sp-2);
}
.caption { font-size: 11.5px; color: var(--ink-faint); line-height: 1.6; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-btn);
  font-family: var(--font-display); font-weight: 600; font-size: 13.5px;
  padding: 12px 18px; cursor: pointer; width: 100%;
  transition: filter .12s ease, transform .12s ease;
}
.btn:hover  { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost   { background: var(--bg-alt); color: var(--ink); }
.btn-sm      { width: auto; padding: 8px 14px; font-size: 12.5px; }

/* ---------- 폼 ---------- */
.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px;
  border-radius: var(--radius-btn); border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink);
  font-family: var(--font-mono); font-size: 14px;
}
.field textarea { font-family: var(--font-body); font-size: 13.5px; line-height: 1.6; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.field input[readonly] { background: var(--bg-alt); color: var(--ink-soft); }
.field .split { display: flex; gap: 8px; }
.field .split select { flex: 0 0 104px; }
.field .split input  { flex: 1; min-width: 0; }
.field .unit { position: relative; display: flex; align-items: center; }
.field .unit input { padding-right: 34px; }
.field .unit span {
  position: absolute; right: 12px; font-family: var(--font-mono);
  font-size: 13px; color: var(--ink-faint);
}
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); margin-bottom: 18px; }
.form-grid.g3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .field { margin-bottom: 0; }
.form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 860px) { .form-grid.g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .form-grid, .form-grid.g3 { grid-template-columns: 1fr; } }

.form-card {
  border: 1px solid var(--line); border-radius: 14px;
  padding: var(--sp-5); background: var(--bg); margin-bottom: var(--sp-6);
}
.form-section {
  font-size: 11px; font-weight: 700; color: var(--accent);
  letter-spacing: .07em; text-transform: uppercase;
  margin: 0 0 11px; display: flex; align-items: center; gap: 8px;
}
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 카드 / 안내 ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow); padding: var(--sp-5);
}
.note {
  display: flex; gap: 9px; align-items: flex-start;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 11px; padding: 10px 13px; font-size: 12px; line-height: 1.6; margin-bottom: 18px;
}
.note svg { width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; margin-top: 1px; }

/* ---------- 칩(상태 배지) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  padding: 3px 9px; border-radius: var(--radius-pill); letter-spacing: .02em;
}
.chip-ok     { background: var(--ok-bg);     color: var(--ok); }
.chip-warn   { background: var(--warn-bg);   color: var(--warn); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-info   { background: var(--accent-soft); color: var(--accent); }

/* ---------- 테이블 ---------- */
.table-wrap { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; background: var(--paper); }
th, td { text-align: left; padding: 11px 14px; font-size: 13px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--bg-alt); font-size: 11.5px; font-weight: 600; color: var(--ink-soft); letter-spacing: .02em; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.empty-row td { color: var(--ink-faint); text-align: center; padding: 22px 10px; font-size: 12.5px; }

/* 행 안에서 상세를 여는 링크 버튼 */
.rowlink {
  background: none; border: none; padding: 0; font-family: var(--font-body); font-size: inherit;
  color: var(--accent); font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

/* ---------- 검색 필터 바 ---------- */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 15px; margin-bottom: var(--sp-4);
}
.filter-bar .fb { display: flex; flex-direction: column; gap: 5px; }
.filter-bar label { font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.filter-bar input, .filter-bar select {
  padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--paper); color: var(--ink); font-family: var(--font-mono); font-size: 12.5px;
}
.filter-bar input[type="search"] { min-width: 190px; font-family: var(--font-body); }
.filter-bar .fb-actions { display: flex; gap: 8px; margin-left: auto; }
.filter-bar .btn { width: auto; padding: 9px 16px; font-size: 12.5px; }
.filter-sum { font-size: 12px; color: var(--ink-soft); margin: 0 0 var(--sp-3); }
.filter-sum b { color: var(--ink); font-family: var(--font-mono); }

/* ---------- 모달 ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(10,14,24,.55);
  display: none; align-items: center; justify-content: center; padding: 24px; z-index: 60;
}
.modal-back.is-on { display: flex; }
.modal {
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 86vh;
  overflow-y: auto; padding: 22px 24px 24px;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.modal-close {
  background: var(--bg-alt); border: none; border-radius: 9px;
  width: 30px; height: 30px; cursor: pointer; color: var(--ink); font-size: 15px;
}
.mrow {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.mrow:last-child { border-bottom: none; }
.mrow span:first-child { color: var(--ink-soft); white-space: nowrap; }
.mrow span:last-child  { font-family: var(--font-mono); font-weight: 600; text-align: right; }
.msec {
  font-size: 11px; font-weight: 700; color: var(--accent);
  letter-spacing: .07em; text-transform: uppercase; margin: 16px 0 8px;
}

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  background: var(--ink); color: var(--paper); border-radius: var(--radius-pill);
  padding: 10px 18px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease; z-index: 80;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 접근성 ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
