:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #7b8794;
  --line: #e4e7eb;
  --accent: #2f6fed;
  --up: #1f9d55;
  --down: #d64545;
  --warn: #b7791f;
  --radius: 14px;
  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; }
a { color: var(--accent); }
input, select, button { font: inherit; color: inherit; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }

/* 버튼 */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--down); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.icon-btn { border: 0; background: none; font-size: 20px; cursor: pointer; padding: 6px; }

/* 로그인 */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.login-card .logo { font-size: 48px; }
.login-card h1 { margin-bottom: 12px; }
.error { color: var(--down); min-height: 1.2em; margin: 0; font-size: 14px; }

/* 레이아웃 */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: var(--bg);
}
.topbar h1 { font-size: 20px; }
#content { padding: 0 12px calc(var(--tab-h) + var(--safe-b) + 20px); max-width: 860px; margin: 0 auto; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line);
}
.tabs button {
  flex: 1; border: 0; background: none; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.tabs button span { font-size: 20px; }
.tabs button.active { color: var(--accent); font-weight: 600; }
.banner { margin: 0 12px 10px; padding: 10px 12px; border-radius: 10px; background: #fff4e5; color: #8a4b00; font-size: 14px; }

/* 카드 */
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card h3 { font-size: 16px; margin-bottom: 6px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.section-title { font-size: 14px; color: var(--muted); margin: 18px 4px 8px; font-weight: 600; }
.hero { text-align: center; padding: 20px 16px; }
.hero .big { font-size: 30px; font-weight: 700; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 99px; background: #eef2ff; color: #3b4cc0; vertical-align: middle; }
.badge.tax { background: #fff1f0; color: #b42318; }
.badge.free { background: #ecfdf3; color: #067647; }
.badge.err { background: #fef3f2; color: #b42318; }
.badge.stored { background: #f2f4f7; color: #475467; }

/* 표 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.r, th.r { text-align: right; }

/* 거래 목록 */
.filters { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.filters select { flex: 1; min-width: 120px; }
.txn { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.txn:last-child { border-bottom: 0; }
.txn .main { min-width: 0; }
.txn .title { font-weight: 500; }
.txn .sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

/* 진행 막대 */
.bar { height: 8px; border-radius: 99px; background: #eef0f3; overflow: hidden; margin: 6px 0 2px; }
.bar > div { height: 100%; background: var(--accent); }
.bar.over > div { background: var(--down); }

/* 업로드 */
.drop {
  border: 2px dashed #c3cad5; border-radius: var(--radius); padding: 22px 16px; text-align: center;
  background: #fff; cursor: pointer;
}
.drop.drag { border-color: var(--accent); background: #f0f5ff; }
.doc-msg { white-space: pre-line; font-size: 13px; color: var(--muted); margin-top: 4px; }
.row-actions { display: flex; gap: 8px; margin-top: 8px; }

/* 모달 */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.modal-card { background: #fff; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + var(--safe-b)); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
@media (min-width: 700px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 18px; }
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 30;
  background: #1f2933; color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 14px; max-width: 90vw;
}
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
