:root {
  --bg: #f4f6f9; --card: #fff; --text: #1f2933; --muted: #6b7785; --line: #e1e6ec;
  --primary: #2457c5; --primary-d: #1b449c; --inc: #1a7f4b; --exp: #c0392b; --warn: #d98a00;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: baseline; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.pad { padding: 16px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 3px rgba(15, 23, 42, .04); position: sticky; top: 0; z-index: 10; }
.topbar .brand { display: flex; align-items: center; gap: 10px; color: #0f172a; font-weight: 700; font-size: 17px; white-space: nowrap; text-decoration: none; }
.topbar .brand img { height: 36px; width: auto; display: block; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a { color: #475569; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.topbar nav a:hover { background: #f1f5f9; color: #0f172a; text-decoration: none; }
.topbar nav a.on { background: #e8effd; color: var(--primary); font-weight: 600; text-decoration: none; }
.topbar .me { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.topbar .me a { color: #0f172a; }
.topbar .me small { color: var(--muted); }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font: inherit; }
button.link:hover { color: var(--text); }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
main.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 680px; margin-left: auto; margin-right: auto; }
.card.login { width: 380px; padding: 32px 28px; }
.login-logo { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto 28px; }
.login-title { display: flex; align-items: center; gap: 8px; font-size: 18px; color: #0f172a; margin-bottom: 18px; }
.login-title svg { color: #2563eb; flex: none; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.success { background: #e5f5ec; color: #145c37; }
.flash.error { background: #fdecea; color: #922b21; }
.flash ul { margin: 0; padding-left: 18px; }

label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
label.check { font-weight: 400; display: flex; gap: 6px; align-items: center; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #cbd3dc; border-radius: 6px; font: inherit; background: #fff; }
input[type=checkbox], input[type=radio] { display: inline; width: auto; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b8cbf2; border-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
fieldset.group { border: 1px solid #dde3ea; border-radius: 8px; padding: 10px 14px 2px; margin: 0 0 12px; }
fieldset.group legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
fieldset.group input[type=date] { max-width: 220px; }
.seg { display: flex; gap: 16px; margin-bottom: 12px; }
.seg label { font-size: 15px; display: flex; gap: 6px; align-items: center; }

button, .btn { display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid #cbd3dc; background: #fff; color: var(--text); font: inherit; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
button:hover, .btn:hover { background: #f0f3f7; }
.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-d); }
.ok { background: var(--inc); border-color: var(--inc); color: #fff; }
.danger { background: #fff; border-color: var(--exp); color: var(--exp); }
.block { width: 100%; }
button.small, .btn.small { padding: 4px 8px; font-size: 12px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.card .actions { margin: 16px 0 0; }
form.inline { display: inline; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { margin: 0; min-width: 140px; flex: 1; }
.filter-buttons { display: flex; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; color: inherit; }
.stat span { color: var(--muted); font-size: 12px; }
.stat b { font-size: 20px; font-variant-numeric: tabular-nums; }
.link-stat:hover { border-color: var(--primary); text-decoration: none; }

.summary { display: flex; gap: 20px; margin: 0 0 12px; flex-wrap: wrap; }
.bulk { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.bulk input { width: 280px; margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f7f9fb; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #fafbfd; }
tr.dim td { color: #9aa5b1; }
.r { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
td.desc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inc { color: var(--inc); }
.exp { color: var(--exp); }

.tag, .badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.income { background: #e5f5ec; color: var(--inc); }
.tag.expense { background: #fdecea; color: var(--exp); }
.badge.pending { background: #fff4d6; color: #8a5a00; }
.badge.approved { background: #e5f5ec; color: #145c37; }
.badge.rejected { background: #eceff3; color: #6b7785; }
.badge.p-active { background: #e6eefc; color: var(--primary); }
.badge.p-planned { background: #f1ecfb; color: #5b3a9b; }
.badge.p-hold { background: #fff4d6; color: #8a5a00; }
.badge.p-done { background: #eceff3; color: #6b7785; }

.bar { position: relative; height: 18px; background: #eceff3; border-radius: 9px; overflow: hidden; min-width: 120px; }
.bar i { position: absolute; inset: 0 auto 0 0; background: #7fa4e8; width: 0; }
.bar.warn i { background: #f0b542; }
.bar.over i { background: #e57367; }
.bar span { position: relative; font-size: 11px; padding-left: 8px; line-height: 18px; }

dl.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.pre { white-space: pre-wrap; }
.review { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.review h2 { width: 100%; }
.review input[name=review_note] { flex: 1; min-width: 200px; margin: 0; }
.pager { display: flex; gap: 6px; justify-content: center; margin: 16px 0; }
.pager a, .pager b { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.pager b { background: var(--primary); color: #fff; border-color: var(--primary); }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px; }
  main { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .bulk { flex-wrap: wrap; }
  .bulk input { width: 100%; }
}

/* ===== 기성 관리 ===== */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1, .page-head .actions { margin: 0; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.rev { display: inline-block; padding: 1px 8px; border-radius: 10px; background: #e8effd; color: var(--primary); font-size: 12px; font-weight: 700; vertical-align: middle; }
.dday { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 8px; background: #eef2f6; color: #475569; font-size: 11px; font-weight: 700; }
.dday.over { background: #fdecea; color: var(--exp); }
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.h-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.history p { margin: 4px 0 8px; }
table.changes th, table.changes td { padding: 6px 10px; font-size: 13px; }
table.changes td.before { color: #9a3412; background: #fff7ed; text-decoration: line-through; text-decoration-color: rgba(154, 52, 18, .35); }
table.changes td.after { color: #14532d; background: #f0fdf4; }
