/* 영수증 정리 — 공통 스타일 (파란색 계열, 단순한 패널 구성) */

:root {
  --blue-50:  #eff5ff;
  --blue-100: #dbe8ff;
  --blue-200: #bcd4fe;
  --blue-500: #2f6fe4;
  --blue-600: #2459c9;
  --blue-700: #1d47a3;
  --ink:      #1b2433;
  --ink-2:    #4a5568;
  --ink-3:    #7a8699;
  --line:     #e2e8f0;
  --line-2:   #d3dbe7;
  --bg:       #f4f7fb;
  --white:    #ffffff;
  --green:    #16794c;
  --green-bg: #e6f6ee;
  --amber:    #9a5b00;
  --amber-bg: #fff4dc;
  --red:      #c4302b;
  --red-bg:   #fdecec;
  --gray-bg:  #eef1f5;
  --radius:   14px;
  --shadow:   0 1px 2px rgba(16, 32, 64, .04), 0 4px 16px rgba(16, 32, 64, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
/* 로그인 확인 전에는 화면을 감춤 */
body.is-loading main, body.is-loading .action-bar, body.is-loading .nav, body.is-loading .header-user { visibility: hidden; }
button { font: inherit; cursor: pointer; }

/* ---------- 머리글 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 24px;
}
.brand { font-size: 18px; font-weight: 800; color: var(--blue-600); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 600;
}
.nav a:hover { background: var(--blue-50); text-decoration: none; }
.nav a.is-active { color: var(--blue-600); background: var(--blue-50); }
.header-user { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 14px; }
.header-user button {
  border: 1px solid var(--line-2); background: var(--white); color: var(--ink-2);
  border-radius: 8px; padding: 6px 10px; font-size: 13px;
}

/* ---------- 본문 ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 32px 20px 120px; }
.page--wide { max-width: 1280px; }

.intro { margin-bottom: 20px; }
.intro__title { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
.intro__lead { color: var(--ink-2); margin: 0; }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel__title {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; margin: 0 0 18px;
}
.panel__title .spacer { flex: 1; }
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--blue-500); color: var(--white); font-size: 14px; font-weight: 700;
}

/* ---------- 입력칸 ---------- */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field__label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field__help { font-size: 13px; color: var(--ink-3); margin: 6px 0 0; }
.field__error { font-size: 13px; color: var(--red); margin: 6px 0 0; }
.field__error:empty { display: none; }
.req { color: var(--red); margin-left: 2px; }

.input, select.input, textarea.input {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--white); color: var(--ink); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 12px 14px; resize: vertical; }
select.input { appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237a8699' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.input:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }
.input.is-invalid { border-color: var(--red); background: #fffafa; }
.input--sm { height: 38px; font-size: 14px; }
.input[readonly] { background: var(--gray-bg); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
.row > .field { margin-bottom: 0; }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue-500); }

/* ---------- 버튼 ---------- */
.btn-main, .btn-ghost, .btn-soft {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 46px; padding: 0 20px; border-radius: 12px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.btn-main { background: var(--blue-500); color: var(--white); }
.btn-main:hover { background: var(--blue-600); text-decoration: none; }
.btn-main:disabled { background: var(--blue-200); cursor: not-allowed; }
.btn-ghost { background: var(--white); border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--blue-500); color: var(--blue-600); text-decoration: none; }
.btn-soft { background: var(--blue-50); color: var(--blue-600); }
.btn-soft:hover { background: var(--blue-100); text-decoration: none; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn-block { width: 100%; }

.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
}
.action-bar__inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.action-bar__inner--wide { max-width: 1280px; }
.action-bar__info { flex: 1; color: var(--ink-2); font-size: 14px; }

/* ---------- 안내 ---------- */
.notice {
  border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px;
  background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-100);
}
.notice--error { background: var(--red-bg); color: var(--red); border-color: #f6caca; }
.notice--warn  { background: var(--amber-bg); color: var(--amber); border-color: #f5dfae; }
.notice--ok    { background: var(--green-bg); color: var(--green); border-color: #c4e8d4; }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge--needs_review { background: var(--amber-bg); color: var(--amber); }
.badge--ai_ok        { background: var(--blue-50); color: var(--blue-600); }
.badge--approved     { background: var(--green-bg); color: var(--green); }
.badge--skipped      { background: var(--gray-bg); color: var(--ink-3); }
.badge--error        { background: var(--red-bg); color: var(--red); }
.badge--pending      { background: var(--gray-bg); color: var(--ink-3); }
.badge--processing   { background: var(--blue-100); color: var(--blue-700); }
.badge--done         { background: var(--green-bg); color: var(--green); }

.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

/* ---------- 업로드 ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 150px; padding: 24px; text-align: center; cursor: pointer;
  border: 2px dashed var(--blue-200); border-radius: var(--radius); background: var(--blue-50);
  color: var(--blue-700); transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.is-over { background: var(--blue-100); border-color: var(--blue-500); }
.dropzone strong { font-size: 16px; }
.dropzone input { display: none; }

.file-list { list-style: none; margin: 14px 0 0; padding: 0; }
.file-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.file-row:last-child { border-bottom: 0; }
.file-row__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-row__state { font-size: 13px; color: var(--ink-2); text-align: right; }
.file-row .progress { grid-column: 1 / -1; height: 4px; }

.progress { height: 10px; background: var(--blue-50); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--blue-500); border-radius: 999px; transition: width .4s; }
.progress-block { margin-bottom: 16px; }
.progress-block__head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.progress-block__head strong { font-weight: 700; }

.stats { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; color: var(--ink-2); margin-bottom: 4px; }
.stats b { color: var(--ink); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.card {
  display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--white); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-50); text-decoration: none; }
.card__top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card__vendor { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__meta { font-size: 13px; color: var(--ink-3); }
.card__total { font-weight: 700; }

.batch-list { list-style: none; margin: 0; padding: 0; }
.batch-list li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.batch-list li:last-child { border-bottom: 0; }
.batch-list .grow { flex: 1; }

/* ---------- 검토 ---------- */
.review { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 20px; align-items: start; }
.viewer {
  position: sticky; top: 76px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.viewer__bar {
  display: flex; gap: 6px; align-items: center; padding: 10px 12px;
  border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-2);
}
.viewer__bar .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer__body { height: calc(100vh - 190px); min-height: 420px; overflow: auto; background: #e9eef5; display: flex; justify-content: center; align-items: flex-start; }
.viewer__body img { max-width: 100%; transform-origin: top center; transition: transform .2s; margin: 12px; background: var(--white); }
.viewer__body iframe { width: 100%; height: 100%; border: 0; background: var(--white); }

.review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.review-head h1 { font-size: 20px; margin: 0; }
.review-head .grow { flex: 1; }

.ai-note { font-size: 13px; color: var(--ink-2); background: var(--gray-bg); border-radius: 10px; padding: 10px 12px; margin-top: 6px; }
.ratio { font-size: 13px; color: var(--blue-600); font-weight: 700; margin-top: 6px; }

.money .input { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 목록 ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data th { font-size: 13px; color: var(--ink-3); font-weight: 600; background: #f8fafd; position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:hover td { background: #f8fbff; }
table.data tr.group td { background: var(--blue-50); font-weight: 700; color: var(--blue-700); }
table.data .vendor { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.issues { font-size: 12px; color: var(--amber); max-width: 280px; }

.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- 로그인 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { display: block; text-align: center; font-size: 22px; margin-bottom: 6px; }
.login-card .intro__lead { text-align: center; margin-bottom: 22px; }

/* ---------- 알림 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--ink); color: var(--white); padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.18); max-width: calc(100% - 40px);
}
.toast--error { background: var(--red); }

/* ---------- 처리 중 모달 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px);
}
.modal__box {
  width: 100%; max-width: 420px; text-align: center;
  background: var(--white); border-radius: 18px; padding: 32px 28px 24px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
}
.modal__title { font-size: 19px; font-weight: 800; margin: 18px 0 6px; letter-spacing: -.01em; }
.modal__text { margin: 0 0 16px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.modal__sub { margin: 12px 0 0; font-size: 13px; color: var(--ink-3); min-height: 1.2em; }
.modal__actions { display: flex; gap: 8px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }

.spinner {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 50%;
  border: 5px solid var(--blue-100); border-top-color: var(--blue-500);
  animation: spin .9s linear infinite;
}
.spinner--sm {
  display: inline-block; width: 16px; height: 16px; border-width: 2px; margin: 0 8px 0 0;
  vertical-align: -3px;
}
.done-mark {
  width: 56px; height: 56px; margin: 0 auto; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--green-bg); color: var(--green); font-size: 28px; font-weight: 800;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.linkbtn { background: none; border: 0; padding: 0; color: var(--blue-600); font-weight: 700; text-decoration: underline; }

/* ---------- 작은 화면 ---------- */
@media (max-width: 980px) {
  .review { grid-template-columns: 1fr; }
  .viewer { position: static; }
  .viewer__body { height: 60vh; }
}
@media (max-width: 640px) {
  .page { padding: 20px 14px 120px; }
  .panel { padding: 18px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .intro__title { font-size: 22px; }
  .site-header__inner { gap: 10px; padding: 0 14px; }
  .header-user span { display: none; }
  .nav a { padding: 8px; }
}
