/* 연간 가계부 엑셀 양식. 형제 도구(/budget-excel/)와 같은 색·글꼴. 노랑 = 예산, 초록 = 내역·합계 흐름 — 선과 배경으로 구조를 읽힌다 */
:root {
  --font: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --bg: #f5f4ef; --paper: #fff; --sunk: #efeee8; --ink: #1c1b17; --ink-2: #57544a; --line: #dcd8cc;
  --accent: #1f6f4a; --accent-ink: #fff; --accent-soft: #e2f1e8;
  --budget: #d9a514; --budget-soft: #fff4cc; --out: #b4442b;
  --radius: 14px; color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12130f; --paper: #1b1c17; --sunk: #23241e; --ink: #ecebe4; --ink-2: #b0ad9f; --line: #34352d;
    --accent: #4cc48a; --accent-ink: #08140d; --accent-soft: #1c3326; --budget: #e6b93c; --budget-soft: #3a3214; --out: #f0866c; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 12px; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.6; overflow-x: hidden; word-break: keep-all; overflow-wrap: anywhere; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--paper); padding: 12px; min-height: 44px; z-index: 9; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap, .hero, .foot { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.hero { padding-top: 22px; padding-bottom: 4px; }
.eyebrow { margin: 0; color: var(--accent); font-weight: 700; font-size: 14px; }
h1 { font-size: clamp(24px, 6.4vw, 40px); line-height: 1.25; margin: 4px 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 16px; margin: 16px 0 4px; }
.muted { color: var(--ink-2); font-size: 14px; font-weight: 400; }
.small { font-size: 13px; }
a { color: var(--accent); }
.lede { margin: 14px 0; color: var(--ink-2); max-width: 46em; }

/* 받기 */
.get { background: var(--paper); border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: var(--radius); padding: 14px; margin: 10px 0 0; }
.btn { min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { border-style: dashed; color: var(--ink-2); font-weight: 500; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.big { width: 100%; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; line-height: 1.3; }
.btn-main { font-size: 19px; }
.btn-sub { font-size: 13px; font-weight: 500; opacity: .9; }
.get-meta { margin: 8px 0 0; font-size: 14px; color: var(--ink-2); }
.get-meta #range { color: var(--ink); font-weight: 700; }
.get-alt { margin: 0; }
.get-alt a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; }
.msg { margin: 0; font-size: 14px; color: var(--accent); min-height: 0; }
/* 빈 안내는 눈에만 안 보이게(display:none 이면 접근성 트리에서 빠져 첫 안내를 화면낭독기가 놓친다) */
.msg:empty { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.kakao { margin: 8px 0 0; padding: 8px 10px; border-left: 3px solid var(--budget); background: var(--budget-soft); font-size: 14px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }

/* 시트 탭 줄: 엑셀 아래쪽 탭처럼 한 선 위에 놓인다 */
.tabs { list-style: none; margin: 10px 0 14px; padding: 0 0 0 2px; display: flex; flex-wrap: wrap; gap: 4px 3px; border-top: 2px solid var(--line); counter-reset: t; }
.tabs li { font-size: 13px; padding: 2px 8px 3px; background: var(--sunk); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 7px 7px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabs li.sum { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 700; }
.tabs li.first { box-shadow: inset 0 -3px 0 var(--accent); }

.sheets { display: grid; gap: 16px; }
.mini { margin: 0; min-width: 0; }
.mini figcaption { font-size: 15px; margin-bottom: 6px; }
.ms { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 11px; color: var(--ink-2); background: var(--paper); }
.ms > div, .ms-row { display: grid; min-width: 0; }
.ms > .ms-rows { display: block; }
.ms span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 3px 5px; }
.annual .ms-head, .annual .ms-row { grid-template-columns: 4.6em 4.2em 1fr 3em; }
.month .ms-head, .month .ms-row { grid-template-columns: 4.6em 1fr 1fr 1fr; }
.month .ms-head.in { grid-template-columns: 1fr 1fr 1.3fr 1.2fr 1fr; }
.ms-head { background: var(--accent-soft); color: var(--ink); font-weight: 700; border-bottom: 2px solid var(--accent); }
.ms-row { border-bottom: 1px solid var(--line); }
.ms-row span + span { border-left: 1px solid var(--line); }
.ms-row.more span { grid-column: 1 / -1; }
.ms .y { background: var(--budget-soft); box-shadow: inset 3px 0 0 var(--budget); color: var(--ink); }
.ms-head .y { box-shadow: inset 3px 0 0 var(--budget); }
.mcols { display: grid; grid-template-columns: repeat(12, 1fr); padding: 0 !important; }
.mcols i { display: block; border-left: 1px solid var(--line); min-height: 100%; }
.ms-head .mcols i { border-left-color: var(--accent); opacity: .5; }
.ms-row .mcols i { background: linear-gradient(var(--accent), var(--accent)) center / 2px 40% no-repeat; opacity: .35; }
.ms-tot { background: var(--sunk); border-top: 1px solid var(--ink-2); font-weight: 700; color: var(--ink); }
.ms-tot.rate { border-top: 1px dashed var(--line); }
.ms-gap { height: 8px; background: var(--bg); border-top: 1px solid var(--line); }
.ms-lines i { display: block; height: 14px; border-bottom: 1px dashed var(--line); margin: 0 5px; }
.ms-more { padding: 3px 5px; font-size: 11px; }
.facts { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.facts li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; }
.ln { display: block; height: 0; margin-top: 11px; border-top: 4px solid; border-radius: 2px; }
.ln.y { border-color: var(--budget); } .ln.g { border-color: var(--accent); } .ln.k { border-color: var(--ink-2); border-top-style: double; }

/* 쓰는 법 */
.step-list { list-style: none; margin: 0; padding: 0; counter-reset: s; display: grid; gap: 10px; }
.step-list li { counter-increment: s; position: relative; padding: 2px 0 2px 44px; min-height: 34px; }
.step-list li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--accent); color: var(--accent); font-weight: 800; display: grid; place-items: center; }
.step-list b { display: block; }

/* 설정 */
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-2); min-width: 0; }
input, select { font: inherit; font-size: 16px; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); width: 100%; min-width: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input:disabled { background: var(--sunk); color: var(--ink-2); }
.period { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { margin: 0 0 8px; }
.cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cat { display: grid; grid-template-columns: minmax(0, 1fr) 6.2em 44px; grid-template-areas: "name kind del" "bud bud del"; gap: 6px 6px; padding: 8px 8px 8px 10px; border: 1px solid var(--line); border-left: 4px solid var(--out); border-radius: 10px; background: var(--paper); }
.cat.saving { border-left-color: var(--budget); }
.cat.income { border-left-color: var(--accent); }
.cat .c-name { grid-area: name; } .cat .c-kind { grid-area: kind; } .cat .c-bud { grid-area: bud; } .cat .c-del { grid-area: del; }
.cat .c-bud { flex-direction: row; align-items: center; gap: 8px; }
.cat .c-bud span { white-space: nowrap; font-size: 13px; }
.cat.income .c-bud { display: none; }
.cat.income { grid-template-areas: "name kind del"; }
.c-del { min-width: 44px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--ink-2); cursor: pointer; font: inherit; font-size: 14px; padding: 0; }
.c-del:disabled { opacity: .35; cursor: not-allowed; }
.cat-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; }
#cat-note { margin: 4px 0 12px; }
#dl2 { width: 100%; }
#msg2 { margin-top: 8px; }

.sibling p { margin: 0; }
.guide details { border-top: 1px solid var(--line); padding: 4px 0; }
summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; }
details p { margin: 0 0 10px; color: var(--ink-2); }
.foot { padding-bottom: 32px; color: var(--ink-2); font-size: 14px; }
.foot a { display: inline-flex; align-items: center; min-height: 44px; }

/* 넓은 화면(1280px 이상)만 두 열. 1279px 까지는 좁은 화면 배치를 쓴다 */
@media (min-width: 1280px) {
  .wrap, .hero, .foot { max-width: 1180px; }
  .get { display: grid; grid-template-columns: 420px 1fr; grid-template-areas: "btn meta" "btn alt" "msg msg" "kakao kakao"; column-gap: 20px; align-items: center; }
  .get #dl { grid-area: btn; } .get-meta { grid-area: meta; margin: 0; } .get-alt { grid-area: alt; } .msg { grid-area: msg; } .kakao { grid-area: kakao; }
  .sheets { grid-template-columns: 1fr 1fr; }
  .cats { grid-template-columns: 1fr 1fr; }
  #dl2 { width: auto; }
}
@media (min-width: 600px) and (max-width: 1279px) {
  .sheets { grid-template-columns: 1fr 1fr; }
  .cats { grid-template-columns: 1fr 1fr; }
  .cat-actions { grid-template-columns: auto auto 1fr; }
}
@media (max-width: 380px) {
  .cat { grid-template-columns: minmax(0, 1fr) 5.6em 44px; }
  .annual .ms-head, .annual .ms-row { grid-template-columns: 4em 3.6em 1fr 2.6em; }
}
