:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8ebf0;
  --dim: #949bab;
  --dimmer: #6b7280;
  --pos: #4ade80;
  --neg: #f87171;
  --warn: #fbbf24;
  --other: #f0a04b;      /* 환불 예상·잔고 조정 — 실제 입금과 확실히 구분되는 색 */
  --accent: #60a5fa;
  --accent-dim: #1e3a5f;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
               "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------------- layout */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(15,17,21,.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-in {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.brand { font-weight: 700; letter-spacing: -.02em; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.today-chip { font-size: 12px; color: var(--dim); }
.icon-link { font-size: 18px; color: var(--dim); }

.wrap {
  max-width: 760px; margin: 0 auto;
  padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: rgba(23,26,33,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: 9px 0 10px;
  font-size: 11px; color: var(--dimmer); display: flex;
  flex-direction: column; gap: 3px; align-items: center;
}
.tabbar a span { font-size: 17px; line-height: 1; }
.tabbar a.on { color: var(--accent); }

/* ---------------------------------------------------------------- blocks */

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card.tight { padding: 12px 14px; }
.card h2 {
  margin: 0 0 12px; font-size: 13px; font-weight: 600;
  color: var(--dim); letter-spacing: .02em;
  display: flex; align-items: center; justify-content: space-between;
}
.card h2 .sub { font-weight: 400; font-size: 11px; color: var(--dimmer); }

.flash {
  background: var(--accent-dim); border: 1px solid #2e5c94;
  color: #cfe4ff; padding: 10px 14px; border-radius: 10px;
  margin-bottom: 14px; font-size: 13px;
}

.hero { text-align: left; }
.hero .label { font-size: 12px; color: var(--dim); }
.hero .amount {
  font-size: 34px; font-weight: 700; letter-spacing: -.03em;
  margin: 2px 0 4px; font-variant-numeric: tabular-nums;
}
.hero .note { font-size: 12px; color: var(--dim); }

.acct-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.acct-row:last-child { border-bottom: none; }
.acct-name { font-size: 14px; }
.acct-kind { font-size: 11px; color: var(--dimmer); display: block; }
.acct-bal { font-variant-numeric: tabular-nums; font-weight: 600; }

.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.dim { color: var(--dim); }
.other { color: var(--other); }
h2.other-h { color: var(--other); }
.badge.b-adj { background: #2a2012; color: var(--other); border-color: #5c4423; }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.stat {
  background: var(--panel-2); border-radius: 10px; padding: 11px 12px;
}
.stat .k { font-size: 11px; color: var(--dim); }
.stat .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

.alert {
  border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 10px;
  border: 1px solid;
}
.alert.danger { background: #2a1416; border-color: #5c2226; color: #fca5a5; }
.alert.warn   { background: #2a2312; border-color: #5c4a1e; color: #fcd34d; }
.alert.ok     { background: #12241a; border-color: #1f4d33; color: #86efac; }

/* ---------------------------------------------------------------- lists */

.list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }
.item .main { min-width: 0; flex: 1; }
.item .t1 { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t2 { font-size: 11px; color: var(--dimmer); margin-top: 2px; }
.item .amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.badge {
  display: inline-block; font-size: 10px; padding: 2px 6px;
  border-radius: 5px; background: var(--panel-2); color: var(--dim);
  border: 1px solid var(--line); vertical-align: middle;
}
.badge.b-refund { background: #12241a; color: #86efac; border-color: #1f4d33; }
.badge.b-sched  { background: #1a1f2e; color: #93b4e8; border-color: #2c3a52; }
.badge.b-real   { background: #241a12; color: #e8b48c; border-color: #4d3320; }
.badge.b-over   { background: #2a1416; color: #fca5a5; border-color: #5c2226; }

/* ---------------------------------------------------------------- calendar */

.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cal-head h2 { margin: 0; font-size: 18px; color: var(--text); }
.cal-nav { display: flex; gap: 8px; }
.cal-nav a {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 11px; font-size: 13px;
}

.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; }
.cal-dow {
  text-align: center; font-size: 11px; color: var(--dimmer); padding-bottom: 4px;
}
.cal-dow.sat { color: #7aa7e0; }
.cal-dow.sun { color: #e07a8a; }

/* button 으로 만들었으므로 브라우저 기본 스타일을 눌러준다.
   font-size 는 셀 전용 값이라 font 단축속성(font: inherit)을 쓰면 안 된다. */
.cal-cell {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; min-height: 60px; padding: 4px 4px 5px;
  display: flex; flex-direction: column;
  font-family: inherit; font-size: 10px; line-height: 1.35;
  color: inherit; text-align: left; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.cal-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.past { opacity: .5; }
.cal-cell.holiday .cal-d { color: #e07a8a; }
.cal-cell.today { border-color: var(--accent); background: #14203a; }
.cal-cell.picked { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.short { border-color: #7f2a30; background: #241416; }
.cal-flow.other { color: var(--other); }
.cal-d { font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.cal-bal { margin-top: auto; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 10px; }
.cal-flow { font-size: 9px; line-height: 1.3; }
.cal-dot { display: inline-block; width: 4px; height: 4px; border-radius: 50%; margin-right: 2px; }

/* ---------------------------------------------------------------- forms */

form.stack { display: flex; flex-direction: column; gap: 10px; }
label.f { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
input, select, textarea, button {
  font-family: inherit; font-size: 15px;
}
input[type=text], input[type=number], input[type=date], input[type=password],
select, textarea {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 72px; }

.btn {
  display: inline-block; text-align: center; cursor: pointer;
  background: var(--accent); color: #08131f; border: none;
  border-radius: 10px; padding: 11px 16px; font-weight: 600; font-size: 14px;
}
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: #3a1a1d; color: #fca5a5; border: 1px solid #5c2226; }
.btn.mini { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn:active { opacity: .8; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

details.form-toggle > summary {
  cursor: pointer; list-style: none; font-size: 13px; color: var(--accent);
  padding: 9px 0;
}
details.form-toggle > summary::-webkit-details-marker { display: none; }
details.form-toggle[open] > summary { color: var(--dim); }

.seg { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { flex: 1; }
.seg input { display: none; }
.seg span {
  display: block; text-align: center; padding: 9px 0; font-size: 13px;
  background: var(--panel-2); color: var(--dim); cursor: pointer;
}
.seg input:checked + span { background: var(--accent); color: #08131f; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 11px; color: var(--dim); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- chat */

.chat-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.bubble {
  max-width: 88%; padding: 11px 14px; border-radius: 14px;
  font-size: 14px; white-space: pre-wrap; word-break: break-word; line-height: 1.6;
}
.bubble.user { align-self: flex-end; background: var(--accent); color: #08131f; border-bottom-right-radius: 4px; }
.bubble.ai   { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.thinking { color: var(--dim); font-style: italic; }

.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { min-height: 46px; max-height: 140px; }

.suggest { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 12px; }
.suggest button {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}

/* ---------------------------------------------------------------- auth */

.auth-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-box { width: 100%; max-width: 360px; }
.auth-box h1 { font-size: 21px; margin: 0 0 6px; }
.auth-box p.sub { color: var(--dim); font-size: 13px; margin: 0 0 20px; }
.err { color: var(--neg); font-size: 13px; margin-top: 8px; }

hr.sep { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.spacer { height: 8px; }
code.tok {
  display: block; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font-size: 12px;
  word-break: break-all; font-family: ui-monospace, monospace;
}

/* ------------------------------------------------- 오늘 입금 확인 */
.income-row {
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.income-row:last-of-type { border-bottom: none; }
.income-head { margin-bottom: 8px; }
.income-name { font-size: 15px; font-weight: 600; }
.income-act { display: flex; gap: 8px; align-items: center; }
.income-unit { font-size: 13px; color: var(--dim); min-width: 34px; }
.income-hint { margin-top: 5px; min-height: 15px; }
.income-btns { display: flex; gap: 6px; margin-top: 8px; }
.income-btns .btn { flex: 1; white-space: nowrap; }
.btn.income-mode.on { background: var(--accent-dim); color: #cfe4ff; border-color: #2e5c94; }
.income-amt {
  flex: 1; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); font-size: 16px; font-weight: 600;
  padding: 9px 10px; text-align: right;
  font-family: inherit;
}
.income-amt:focus { outline: none; border-color: var(--accent); }

/* ------------------------------------------------- 계좌 감시 */
.kv {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.kv:last-child { border-bottom: none; }
.kv span { color: var(--dim); white-space: nowrap; }
.kv code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 7px; word-break: break-all; text-align: right;
  -webkit-user-select: all; user-select: all;   /* 길게 눌러 한 번에 복사 */
}
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.chk input { width: 18px; height: 18px; }
