@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

/* 색은 Verix 홈페이지(Verix/css/style.css) 토큰을 따른다 */
:root {
  --navy: #101B33;
  --navy-2: #18264A;
  --blue: #2456E6;
  --blue-h: #2E63F7;
  --blue-soft: #E8EEFD;
  --cyan: #22C3E6;
  --mint: #19C6A6;
  --paper: #F6F7F9;
  --card: #FFFFFF;
  --ink: #12151C;
  --body: #4A5160;
  --muted: #8A91A0;
  --line: #E3E6EB;
  --line-2: #EEF0F3;
  --income: #2456E6;
  --expense: #E0663D;
  --asset: #7A5AF8;
  --warn: #B7791F;
  --warn-bg: #FFF6E5;
  --danger: #D63B3B;
  --ok: #138A72;
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r-sm: 6px; --r-md: 8px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 27, 51, .06), 0 4px 16px rgba(16, 27, 51, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans); color: var(--ink); background: var(--paper);
  font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum";
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.income { color: var(--income); }
.expense { color: var(--expense); }
.asset { color: var(--asset); }

/* ───── 레이아웃 ───── */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--navy); color: #fff; padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.side .brand img { height: 30px; }
.side .brand span { font-size: 12px; color: #B9C0CE; border-left: 1px solid #2B3754; padding-left: 10px; letter-spacing: .04em; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  color: #B9C0CE; padding: 10px 12px; border-radius: var(--r-md); display: flex; gap: 10px; align-items: center;
  font-weight: 500; text-decoration: none;
}
.side nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.side nav a:hover { background: var(--navy-2); color: #fff; }
.side nav a.on { background: var(--blue); color: #fff; }
.side .ctx { background: var(--navy-2); border-radius: var(--r-md); padding: 10px; display: grid; gap: 6px; }
.side .ctx label { font-size: 11px; color: #8E98AE; letter-spacing: .04em; }
.side .ctx select { width: 100%; background: #0B1428; border: 1px solid #2B3754; color: #fff; border-radius: var(--r-sm); padding: 7px 8px; }
.side .foot { margin-top: auto; font-size: 12px; color: #8E98AE; padding: 0 8px; display: grid; gap: 6px; }
.side .foot button { background: none; border: 1px solid #2B3754; color: #B9C0CE; border-radius: var(--r-sm); padding: 6px 10px; cursor: pointer; text-align: left; }
.side .foot button:hover { color: #fff; border-color: #4A5878; }

main { padding: 28px 32px 80px; min-width: 0; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 모바일 상단바·하단 탭 */
.topbar, .tabbar { display: none; }

/* ───── 컴포넌트 ───── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card h2 { font-size: 15px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.kpi { padding: 18px 20px; }
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600;
  font-size: 13.5px; white-space: nowrap; color: var(--ink); text-decoration: none;
}
.btn:hover { border-color: #C9CED7; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-h); }
.btn.income { color: var(--income); border-color: #C5D3FA; background: var(--blue-soft); }
.btn.expense { color: var(--expense); border-color: #F6CDBE; background: #FDF0EB; }
.btn.danger { color: var(--danger); border-color: #F3C7C7; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn svg { width: 16px; height: 16px; }

.field { display: grid; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--body); }
.field > span em { font-style: normal; color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; height: 38px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 0 11px; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 70px; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36, 86, 230, .12); }
input.amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
input[readonly] { background: var(--paper); color: var(--body); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; font-size: 13px; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); }

.seg { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg button.on[data-v=income] { color: var(--income); }
.seg button.on[data-v=expense] { color: var(--expense); }
.seg button.on[data-v=asset] { color: var(--asset); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--body); white-space: nowrap; }
.badge.income { background: var(--blue-soft); color: var(--income); }
.badge.expense { background: #FDF0EB; color: var(--expense); }
.badge.asset { background: #F1EDFE; color: var(--asset); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: #E4F7F2; color: var(--ok); }
.badge.lock { background: var(--navy); color: #fff; }

.notice { border-radius: var(--r-md); padding: 12px 14px; font-size: 13px; background: var(--blue-soft); color: #1C3E9E; line-height: 1.6; }
.notice.warn { background: var(--warn-bg); color: #7A5310; }
.notice b { font-weight: 700; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 6px; }

/* ───── 표 ───── */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #FBFBFC; position: sticky; top: 0; }
table.list td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover td { background: #F8FAFF; }
table.list tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; padding-top: 12px; }
table.list .desc { max-width: 280px; }
table.list .desc div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.list .desc small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip { display: inline-flex; gap: 3px; align-items: center; color: var(--body); font-size: 12px; }
.clip svg { width: 14px; height: 14px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select, .toolbar input { width: auto; height: 34px; }
.toolbar input[type=search] { min-width: 200px; flex: 1; }

/* 막대 */
.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 110px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--expense); border-radius: 99px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .legend { display: flex; gap: 14px; font-size: 12px; color: var(--body); margin-bottom: 6px; }
.chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.checklist { display: grid; gap: 8px; }
.checklist a { display: flex; justify-content: space-between; align-items: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--r-md); color: var(--ink); text-decoration: none; }
.checklist a:hover { border-color: var(--blue); }
.checklist a.clean { color: var(--muted); }

/* ───── 모달 ───── */
.modal-back { position: fixed; inset: 0; background: rgba(16, 27, 51, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: var(--r-lg); width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(16, 27, 51, .3); }
.modal.wide { max-width: 980px; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal header h2 { font-size: 16px; }
.modal .body { padding: 20px 22px; display: grid; gap: 16px; }
.modal footer { display: flex; justify-content: space-between; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: #FBFBFC; border-radius: 0 0 var(--r-lg) var(--r-lg); flex-wrap: wrap; }
.modal footer .right { display: flex; gap: 8px; margin-left: auto; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px; }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.file { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; position: relative; background: var(--paper); }
.file a { display: block; aspect-ratio: 1; background: #fff center/cover no-repeat; }
.file .pdf { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--danger); font-size: 13px; height: 100%; }
.file .nm { font-size: 11px; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file .del { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(16,27,51,.75); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; }
.file.pending { border-style: dashed; border-color: var(--blue); }
.drop { border: 1.5px dashed #C5CCD8; border-radius: var(--r-md); padding: 14px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: var(--r-md); font-size: 13.5px; z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }
.toast.error { background: var(--danger); }

.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.report-list { display: grid; gap: 10px; }
.report-item { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); }
.report-item .ico { width: 40px; height: 40px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); display: flex; align-items: center; justify-content: center; flex: none; }
.report-item .ico svg { width: 20px; height: 20px; }
.report-item .txt { flex: 1; min-width: 0; }
.report-item .txt b { display: block; font-size: 14px; }
.report-item .txt span { font-size: 12.5px; color: var(--muted); }
ol.guide { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--body); font-size: 13.5px; }

/* ───── 로그인 ───── */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: var(--navy); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(34,195,230,.25), transparent 65%); }
.auth-hero img { height: 40px; align-self: flex-start; }
.auth-hero h1 { font-size: 34px; line-height: 1.3; margin-top: 40px; letter-spacing: -0.02em; }
.auth-hero h1 em { font-style: normal; color: var(--cyan); }
.auth-hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; color: #B9C0CE; }
.auth-hero li::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--mint); margin-right: 10px; vertical-align: 2px; }
.auth-hero .copy { font-size: 12px; color: #5B6270; position: relative; z-index: 1; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form form { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.auth-form h2 { font-size: 22px; }
.auth-form .sub { color: var(--muted); margin: -6px 0 6px; font-size: 13px; }
.auth-form .btn { height: 44px; font-size: 15px; }
.auth-form .err { color: var(--danger); font-size: 13px; min-height: 18px; }
.auth-form .switch { text-align: center; font-size: 13px; color: var(--muted); }

/* ───── 반응형 ───── */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; padding: 10px 16px; align-items: center; gap: 10px; }
  .topbar img { height: 24px; }
  .topbar select { margin-left: auto; width: auto; max-width: 46vw; height: 32px; background: #0B1428; color: #fff; border-color: #2B3754; font-size: 13px; }
  .topbar select.year { max-width: 92px; margin-left: 0; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11px; color: var(--muted); text-decoration: none; }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a.on { color: var(--blue); }
  main { padding: 18px 16px 96px; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 100px 1fr 90px; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 24px; }
  .auth-hero h1 { font-size: 24px; margin-top: 20px; }
  .auth-hero ul, .auth-hero .copy { display: none; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  /* 거래 표 → 카드 */
  table.list.cards thead { display: none; }
  table.list.cards, table.list.cards tbody, table.list.cards tr, table.list.cards td { display: block; width: 100%; }
  table.list.cards tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
  table.list.cards td { border: 0; padding: 0; }
  table.list.cards td.c-date { grid-column: 1; font-size: 12px; color: var(--muted); }
  table.list.cards td.c-kind { grid-column: 2; grid-row: 1; text-align: right; }
  table.list.cards td.desc { grid-column: 1; max-width: none; }
  table.list.cards td.c-total { grid-column: 2; grid-row: 2 / span 2; align-self: center; font-size: 15px; font-weight: 700; }
  table.list.cards td.c-hide { display: none; }
  table.list.cards td.c-flags { grid-column: 1; }
  table.list.cards tfoot tr { display: flex; justify-content: space-between; }
  table.list.cards tfoot td.c-hide { display: none; }
}
.m-only { display: none; }
@media (max-width: 860px) { .m-only { display: inline; } }
