:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface2: #f0f2f5; --text: #1b2330; --muted: #5f6b7a; --line: #dfe3e9;
  --accent: #1f5fd0; --accent-soft: #e6eefc; --ok: #1a7f4b; --ok-soft: #e3f4ea; --warn: #b45309; --warn-soft: #fdf1dc;
  --bad: #c62828; --bad-soft: #fde8e8; --legal: #c62828; --info-soft: #e8f1fb;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 30, 50, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #171d26; --surface2: #1e2631; --text: #e6eaf0; --muted: #96a2b3; --line: #2b3544;
    --accent: #6ea0ff; --accent-soft: #1b2b49; --ok: #55c58a; --ok-soft: #14301f; --warn: #f0b255; --warn-soft: #34270f;
    --bad: #ff7b7b; --bad-soft: #3a1a1a; --legal: #ff7b7b; --info-soft: #172840; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --surface: #171d26; --surface2: #1e2631; --text: #e6eaf0; --muted: #96a2b3; --line: #2b3544;
  --accent: #6ea0ff; --accent-soft: #1b2b49; --ok: #55c58a; --ok-soft: #14301f; --warn: #f0b255; --warn-soft: #34270f;
  --bad: #ff7b7b; --bad-soft: #3a1a1a; --legal: #ff7b7b; --info-soft: #172840; --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h2 { font-size: 20px; margin-bottom: 4px; }
h3 { font-size: 16px; margin-bottom: 10px; }
h4 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); }
small, .muted { color: var(--muted); }
small { font-size: 12.5px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 14px; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: var(--surface2); white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; background: var(--surface2); }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 17px; letter-spacing: -.3px; }
.brand span { color: var(--accent); }
.spacer { flex: 1; }
.layout { max-width: 1180px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 18px; align-items: start; }
nav.side { position: sticky; top: 64px; display: flex; flex-direction: column; gap: 2px; }
nav.side button { text-align: left; border: 0; background: transparent; color: var(--text); padding: 9px 12px; border-radius: 8px; font: inherit; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
nav.side button:hover { background: var(--surface2); }
nav.side button.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
nav.side .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
main#view { min-width: 0; }
.page-head { margin-bottom: 14px; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 800; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12.5px; color: var(--muted); }
.kpi.bad { background: var(--bad-soft); border-color: transparent; } .kpi.bad .v { color: var(--bad); }
.kpi.ok { background: var(--ok-soft); border-color: transparent; } .kpi.ok .v { color: var(--ok); }
.kpi.warn { background: var(--warn-soft); border-color: transparent; } .kpi.warn .v { color: var(--warn); }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); position: relative; }
label.f.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
label.f > em { position: absolute; right: 10px; top: 28px; font-style: normal; color: var(--muted); font-size: 13px; pointer-events: none; }
input[type=number], input[type=text], input[type=date], select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; min-height: 38px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
td input[type=number], td input[type=text], td input[type=date], td select { min-height: 34px; padding: 5px 8px; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; }
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.badge.legal { background: var(--bad-soft); color: var(--legal); }
.badge.contract { background: var(--accent-soft); color: var(--accent); }
.badge.tip { background: var(--surface2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

.note { padding: 10px 12px; border-radius: 8px; font-size: 13.5px; margin: 8px 0; background: var(--info-soft); }
.note.warn { background: var(--warn-soft); } .note.bad { background: var(--bad-soft); } .note.ok { background: var(--ok-soft); }
.disc { font-size: 12.5px; color: var(--muted); border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .when { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); text-align: right; }
.list li.done .grow { text-decoration: line-through; color: var(--muted); }
.dday { font-weight: 700; font-variant-numeric: tabular-nums; }
.dday.over { color: var(--bad); }
.stepper { display: flex; gap: 6px; flex-wrap: wrap; }
.stepper .st { flex: 1; min-width: 110px; padding: 8px 10px; border-radius: 8px; background: var(--surface2); font-size: 13px; color: var(--muted); }
.stepper .st.on { background: var(--accent); color: #fff; font-weight: 700; }
.stepper .st.past { background: var(--accent-soft); color: var(--accent); }
.bar { height: 10px; border-radius: 6px; background: var(--surface2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.bad > i { background: var(--bad); } .bar.ok > i { background: var(--ok); }
.tablewrap { overflow-x: auto; }
.chartwrap { overflow-x: auto; }
svg.chart { width: 100%; min-width: 640px; height: auto; display: block; }
svg.chart text { fill: var(--muted); font-size: 11px; }
.plan-sheet { border: 1px solid var(--line); padding: 14px; border-radius: 8px; background: var(--surface); margin-bottom: 12px; }
.plan-sheet h4 { color: var(--text); }
details { margin: 8px 0; } summary { cursor: pointer; font-weight: 600; }
pre.json { background: var(--surface2); padding: 10px; border-radius: 8px; overflow: auto; font-size: 12px; }
#printArea { display: none; }
.tag-sample { background: var(--warn-soft); color: var(--warn); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px; }
  nav.side { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 6px; }
  nav.side button { white-space: nowrap; padding: 7px 11px; background: var(--surface); border: 1px solid var(--line); }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  th, td { padding: 7px 6px; font-size: 13px; }
}
@media print {
  body.pp #app { display: none; }
  body.pp #printArea { display: block; }
  body { background: #fff; color: #000; }
  #printArea { --text: #000; --muted: #444; --line: #bbb; --surface: #fff; --surface2: #eee; color: #000; }
  .plan-sheet { page-break-inside: avoid; }
}

/* ---- 원 단위 입력·단계별 화면·변경 이력 ---- */
.won-read { min-height: 1.3em; margin-top: 2px; color: var(--accent); font-size: 12.5px; font-weight: 600; }
td .won-read { font-size: 11.5px; }
td .u, .f .u { color: var(--muted); font-weight: 400; }
td .lb { display: none; }
input.won { text-align: right; font-variant-numeric: tabular-nums; }
.col { display: flex; flex-direction: column; gap: 10px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; padding: 4px; background: var(--surface2); border-radius: 10px; }
.seg button { flex: 1 1 auto; border: 0; background: transparent; color: var(--muted); padding: 9px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
nav.side .grp { margin: 12px 12px 2px; font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
nav.side .grp:first-child { margin-top: 0; }
ol.pw { list-style: none; display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; padding: 0; }
ol.pw button { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); padding: 7px 13px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; }
ol.pw button span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface2); font-size: 12px; }
ol.pw button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
ol.pw button.on span { background: var(--accent); color: #fff; }
ol.pw button.done span { background: var(--ok); color: #fff; }
.pnav { display: flex; justify-content: space-between; gap: 10px; margin: 4px 0 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.card.sub { padding: 14px; margin-bottom: 10px; background: var(--surface); }
.vend { display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; }
.card.welcome { border-color: var(--accent); background: var(--accent-soft); }
#projbar { gap: 6px; } #projbar select { width: auto; min-height: 32px; padding: 3px 8px; max-width: 180px; }
#saved { font-size: 12px; }
@media (max-width: 860px) { nav.side .grp { display: none; } .seg button { padding: 8px 10px; } }

.storenote { background: var(--info-soft); border-bottom: 1px solid var(--line); font-size: 12.5px; }
.storenote .in { max-width: 1180px; margin: 0 auto; padding: 6px 16px; }
.linkbtn { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0 4px; }
.card.guide { border-color: var(--accent); background: var(--accent-soft); }
.card.guide ul.steps { margin: 6px 0 0; padding-left: 1.2em; line-height: 1.7; }
.card.danger-zone { border-color: var(--bad); }

/* ---- 정리: 상단 바·안내 줄·카드 간격 ---- */
.topbar .in { justify-content: space-between; flex-wrap: nowrap; gap: 16px; }
.topbar .left, .topbar .right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .right { flex-wrap: wrap; justify-content: flex-end; }
.topbar a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.brand small { font-weight: 500; }
#projbar { display: inline-flex; gap: 6px; align-items: center; }
#projbar select { width: 150px; }
.btn.sm { min-height: 34px; display: inline-flex; align-items: center; }
.storenote { font-size: 12.5px; line-height: 1.5; }
.storenote .in { display: block; }
.card h3 { font-size: 16.5px; margin-bottom: 12px; }
.card { padding: 18px 20px; }
.grid { gap: 14px; }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.cardhead h3 { margin: 0; }
@media (max-width: 860px) { .topbar .in { flex-wrap: wrap; } .topbar .right { justify-content: flex-start; } }

/* ---- 달력 ---- */
.calwrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .calwrap { grid-template-columns: 1fr; } }
.calbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.calttl { font-size: 18px; min-width: 110px; text-align: center; }
.legend { margin-left: auto; font-size: 12px; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; padding: 0; }
.cal { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.cal .dows { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface2); }
.cal .dows div { padding: 7px 0; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.cal .cells { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cd { min-height: 96px; padding: 4px 5px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.cd:nth-child(7n+1) { border-left: 0; }
.cd.out { background: var(--surface2); cursor: default; opacity: .5; }
.cd:not(.out):hover { background: var(--accent-soft); }
.cd.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.cd .dn { font-size: 12.5px; font-weight: 700; width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 50%; }
.cd.sun .dn { color: var(--bad); } .cd.sat .dn { color: var(--accent); }
.cd.today .dn { background: var(--accent); color: #fff; }
.cd .more { font-size: 11px; color: var(--muted); }
.ev { display: block; width: 100%; text-align: left; border: 0; padding: 2px 6px; border-radius: 5px; font: inherit; font-size: 11.5px; line-height: 1.35; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.legal { background: var(--bad-soft); color: var(--bad); }
.ev.contract { background: var(--accent-soft); color: var(--accent); }
.ev.tip { background: var(--surface2); color: var(--muted); }
.ev.done { opacity: .5; text-decoration: line-through; }
.ev.on { outline: 2px solid var(--accent); }
i.ev { display: inline-block; width: 10px; padding: 0; }
.card.detail { position: sticky; top: 74px; }
dl.dl { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 6px 10px; margin: 10px 0; font-size: 14px; }
dl.dl dt { color: var(--muted); font-size: 12.5px; padding-top: 1px; } dl.dl dd { margin: 0; }
@media (max-width: 560px) { .cd { min-height: 58px; } .ev { font-size: 0; padding: 4px; height: 8px; border-radius: 4px; } }
