:root {
  --ink: #13243a;
  --muted: #6e7c8f;
  --line: #dce4ed;
  --bg: #f4f7fa;
  --panel: #ffffff;
  --navy: #173b5f;
  --blue: #2a6f97;
  --blue-soft: #e7f1f8;
  --mint: #dff3ea;
  --green: #237a57;
  --amber: #b7791f;
  --amber-soft: #fff3d6;
  --red: #b93d4a;
  --red-soft: #fde9ec;
  --shadow: 0 10px 30px rgba(21, 54, 82, .08);
  --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
body:not(.authenticated) .app-shell { display: none; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #2d7197 0, transparent 34%), linear-gradient(145deg, #102d49, #173b5f 55%, #225b7d); }
body.authenticated .login-screen { display: none; }
.login-card { width: min(430px, 100%); background: rgba(255,255,255,.98); border: 1px solid rgba(255,255,255,.7); border-radius: 22px; padding: 30px; box-shadow: 0 30px 80px rgba(3,18,31,.34); }
.login-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.login-brand .brand-mark { color: white; background: var(--navy); }
.login-brand strong { display: block; }
.login-brand span { color: var(--muted); display: block; font-size: 11px; margin-top: 3px; }
.login-copy { padding: 26px 0 18px; }
.login-copy h1 { margin: 6px 0 8px; font-size: 28px; }
.login-copy > p:last-child { color: var(--muted); margin: 0; font-size: 13px; }
.login-form { padding: 0; display: grid; gap: 14px; }
.login-form .btn { width: 100%; padding: 12px; }
.login-error { color: var(--red); min-height: 18px; margin: -3px 0 0; font-size: 12px; }
.login-hint { margin: 18px 0 0; border-radius: 9px; padding: 10px; text-align: center; background: #f1f5f8; color: var(--muted); font-size: 11px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 242px 1fr; }
.sidebar { background: linear-gradient(180deg, #173b5f 0%, #112f4d 100%); color: white; padding: 26px 18px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 28px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: #fff; color: var(--navy); font-size: 22px; font-weight: 800; }
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; color: #adc5d9; font-size: 11px; margin-top: 4px; letter-spacing: .06em; }
nav { display: grid; gap: 5px; }
nav button { border: 0; color: #c4d5e2; background: transparent; border-radius: 10px; padding: 12px 13px; text-align: left; font-weight: 650; display: flex; gap: 12px; align-items: center; }
nav button span { width: 20px; text-align: center; font-size: 17px; }
nav button:hover, nav button.active { background: rgba(255,255,255,.11); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 16px 10px 2px; color: #adc5d9; font-size: 12px; border-top: 1px solid rgba(255,255,255,.12); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #6ed3a8; margin-right: 7px; box-shadow: 0 0 0 4px rgba(110,211,168,.12); }
main { min-width: 0; padding: 0 34px 48px; }
.topbar { height: 118px; display: flex; justify-content: space-between; align-items: center; }
.topbar h1 { font-size: 26px; margin: 5px 0 0; letter-spacing: -.04em; }
.eyebrow { color: var(--blue); text-transform: uppercase; letter-spacing: .1em; font-size: 11px; font-weight: 800; margin: 0; }
.top-actions, .toolbar-right { display: flex; align-items: center; gap: 10px; }
.profile-trigger { border: 1px solid var(--line); background: white; border-radius: 12px; padding: 6px 10px 6px 7px; display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 12px; font-weight: 750; }
.profile-trigger:hover { border-color: #9fb9cb; box-shadow: 0 4px 13px rgba(30,59,85,.08); }
.profile-avatar { width: 30px; height: 30px; border-radius: 10px; display: inline-grid; place-items: center; color: white; background: linear-gradient(135deg,var(--blue),var(--navy)); font-weight: 850; }
.profile-avatar.large { width: 58px; height: 58px; border-radius: 17px; font-size: 22px; }
.btn { border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; font-weight: 750; text-decoration: none; display: inline-flex; justify-content: center; align-items: center; }
.btn.primary { color: white; background: var(--blue); box-shadow: 0 7px 16px rgba(42,111,151,.2); }
.btn.ghost { color: var(--ink); background: white; border-color: var(--line); }
.btn.danger { color: var(--red); border-color: #efc6cc; }
.view { display: none; }
.view.active { display: block; }
.hero-strip { background: linear-gradient(100deg, #173b5f, #245c7d); color: white; padding: 20px 24px; border-radius: var(--radius); margin-bottom: 18px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow); }
.hero-strip span { display: block; color: #b9cfde; font-size: 12px; margin-bottom: 5px; }
.hero-strip strong { font-size: 20px; }
.hero-strip p { margin: 0; color: #d7e5ee; font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric-grid.small { grid-template-columns: repeat(3, 1fr); }
.metric { background: white; border: 1px solid #e6ebf1; border-radius: 14px; padding: 18px; box-shadow: 0 6px 20px rgba(30,59,85,.05); position: relative; overflow: hidden; }
.metric::after { content: ""; position: absolute; width: 62px; height: 62px; border-radius: 50%; background: var(--blue-soft); right: -22px; top: -22px; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; font-size: 24px; margin-top: 9px; letter-spacing: -.035em; }
.metric small { color: var(--muted); display: block; margin-top: 7px; }
.metric.good strong { color: var(--green); }
.metric.warn strong { color: var(--amber); }
.grid-2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; margin-bottom: 18px; }
.panel { background: var(--panel); border: 1px solid #e4eaf0; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px; }
.panel-head { padding: 20px 22px 14px; display: flex; align-items: center; justify-content: space-between; }
.panel h2 { margin: 0; font-size: 17px; letter-spacing: -.03em; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.text-btn { border: 0; background: none; color: var(--blue); font-weight: 750; }
.compact-list { padding: 0 20px 18px; }
.compact-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 2px; border-bottom: 1px solid #edf1f4; align-items: center; }
.compact-item:last-child { border-bottom: 0; }
.compact-item strong { display: block; font-size: 13px; }
.compact-item small { color: var(--muted); font-size: 11px; display: block; margin-top: 3px; }
.compact-item .amount { font-weight: 800; font-variant-numeric: tabular-nums; }
.chart { min-height: 230px; padding: 12px 22px 22px; display: flex; align-items: flex-end; gap: 11px; }
.bar-group { flex: 1; display: flex; height: 190px; align-items: flex-end; justify-content: center; gap: 4px; border-bottom: 1px solid var(--line); position: relative; }
.bar { width: 14px; min-height: 2px; border-radius: 5px 5px 0 0; background: var(--blue); }
.bar.expense { background: #d6a34a; }
.bar-group label { position: absolute; bottom: -24px; font-size: 10px; color: var(--muted); }
.chart-legend { display: flex; gap: 14px; padding: 0 22px 18px; color: var(--muted); font-size: 11px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }
.validation-grid { padding: 0 20px 20px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.validation { background: #f8fafc; border: 1px solid var(--line); border-radius: 11px; padding: 13px; }
.validation strong { display: block; font-size: 12px; }
.validation span { display: inline-block; margin-top: 8px; color: var(--green); font-size: 11px; font-weight: 800; }
.validation.fail span { color: var(--red); }
.toolbar { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.search-box { display: flex; align-items: center; background: #f6f8fa; border: 1px solid var(--line); border-radius: 9px; padding: 0 11px; min-width: 300px; }
.search-box input { border: 0; outline: 0; background: transparent; padding: 10px 8px; width: 100%; }
input, select, textarea { border: 1px solid #ccd7e2; border-radius: 8px; padding: 9px 10px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #4d8bb0; box-shadow: 0 0 0 3px rgba(77,139,176,.12); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { background: #f6f8fa; color: #5e6c7d; text-align: left; font-weight: 750; white-space: nowrap; }
th, td { padding: 12px 14px; border-bottom: 1px solid #edf1f4; }
td { white-space: nowrap; }
tbody tr:hover { background: #fafcfd; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-foot { padding: 13px 18px; color: var(--muted); font-size: 11px; }
.row-action { border: 1px solid var(--line); background: white; color: var(--blue); border-radius: 7px; padding: 5px 8px; font-size: 11px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 800; }
.badge.good { color: var(--green); background: var(--mint); }
.badge.warn { color: var(--amber); background: var(--amber-soft); }
.badge.danger { color: var(--red); background: var(--red-soft); }
.ledger-summary { padding: 15px 18px; display: flex; gap: 28px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.ledger-summary span { color: var(--muted); font-size: 11px; }
.ledger-summary strong { display: block; color: var(--ink); font-size: 17px; margin-top: 5px; }
.field { display: grid; gap: 6px; }
.field.inline { grid-template-columns: auto minmax(230px, 360px); align-items: center; }
.field label { color: #536276; font-size: 11px; font-weight: 750; }
.vat-grid { grid-template-columns: 1fr 1fr; }
.upload-panel { text-align: center; padding: 44px 24px; border-style: dashed; }
.upload-panel h2 { font-size: 20px; }
.upload-panel p { color: var(--muted); max-width: 560px; margin: 10px auto 20px; line-height: 1.7; }
.upload-icon { margin: 0 auto 15px; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); font-size: 24px; }
.hidden { display: none !important; }
.settings-grid { grid-template-columns: 1fr 1fr; }
dl { padding: 0 22px 20px; margin: 0; }
dl div { display: grid; grid-template-columns: 145px 1fr; border-bottom: 1px solid #edf1f4; padding: 12px 0; }
dt { color: var(--muted); font-size: 12px; }
dd { margin: 0; font-weight: 700; font-size: 13px; }
.settings-actions { padding: 0 22px 22px; display: grid; gap: 12px; }
.password-form { padding: 0 22px 22px; display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)) auto; gap: 12px; align-items: end; }
.security-create { padding: 0 22px 20px; display: grid; grid-template-columns: minmax(160px, 240px) 1fr auto; gap: 14px; align-items: end; border-bottom: 1px solid var(--line); }
.security-create.user-create { grid-template-columns: repeat(4, minmax(120px, 1fr)) auto; }
.permission-checks { display: flex; flex-wrap: wrap; gap: 7px; }
.permission-checks label { display: inline-flex; align-items: center; gap: 5px; background: #f3f7fa; border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; color: #536276; font-size: 11px; font-weight: 700; }
.permission-checks input { margin: 0; }
.security-list { padding: 14px 22px 20px; display: grid; gap: 12px; }
.group-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; grid-template-columns: minmax(140px, 210px) 1fr auto; gap: 14px; align-items: center; }
.group-actions, .user-actions { display: flex; gap: 7px; }
.mini-input { min-width: 110px; max-width: 150px; }
.settings-actions p { color: var(--muted); line-height: 1.6; font-size: 11px; }
.audit-list { padding: 0 22px 20px; }
.audit-item { display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; padding: 11px 0; border-bottom: 1px solid #edf1f4; font-size: 12px; }
.audit-item time { color: var(--muted); }
.modal { position: fixed; inset: 0; background: rgba(15,31,47,.55); display: none; align-items: center; justify-content: center; padding: 22px; z-index: 50; backdrop-filter: blur(3px); }
.modal.open { display: flex; }
.modal-card { width: min(960px, 100%); max-height: calc(100vh - 44px); overflow: auto; background: white; border-radius: 18px; box-shadow: 0 30px 80px rgba(4,19,32,.28); }
.profile-card { width: min(680px, 100%); }
.account-card { width: min(650px, 100%); }
.form-note { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.profile-summary { padding: 22px 24px; display: flex; align-items: center; gap: 14px; background: #f7fafc; }
.profile-summary strong { display: block; font-size: 18px; }
.profile-summary span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.profile-tabs { padding: 0 24px; display: flex; gap: 20px; border-bottom: 1px solid var(--line); }
.profile-tabs button { border: 0; background: transparent; padding: 14px 2px 11px; color: var(--muted); font-weight: 750; font-size: 12px; border-bottom: 3px solid transparent; }
.profile-tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }
.profile-pane { display: none; }
.profile-pane.active { display: block; }
.profile-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
.profile-meta div { background: #f6f8fa; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.profile-meta span { display: block; color: var(--muted); font-size: 10px; }
.profile-meta strong { display: block; margin-top: 5px; font-size: 12px; }
.security-notice { display: grid; gap: 4px; padding: 13px; margin-bottom: 15px; color: #38596d; background: var(--blue-soft); border-radius: 10px; font-size: 12px; }
.security-notice span { color: var(--muted); font-size: 11px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 22px 24px 14px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 4px 0 0; font-size: 20px; }
.icon-btn { border: 0; background: #f3f6f8; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; }
form { padding: 20px 24px 24px; }
.form-grid { display: grid; gap: 12px; margin-bottom: 13px; }
.form-grid.four { grid-template-columns: repeat(4, 1fr); }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
.line-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 9px; }
.line-head h3 { margin: 0; font-size: 14px; }
.journal-lines { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.journal-line { display: grid; grid-template-columns: minmax(220px, 1fr) 160px 160px 38px; gap: 8px; padding: 9px; border-bottom: 1px solid var(--line); }
.journal-line:last-child { border-bottom: 0; }
.journal-line input { text-align: right; }
.remove-line { border: 0; background: #f7ecee; color: var(--red); border-radius: 7px; }
.totals { display: flex; justify-content: flex-end; gap: 20px; align-items: center; padding: 12px 0 18px; font-size: 12px; }
.totals strong { margin-left: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.toast { position: fixed; right: 24px; bottom: 24px; background: #18344d; color: white; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); transform: translateY(30px); opacity: 0; pointer-events: none; transition: .25s; z-index: 80; font-size: 13px; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }
.empty { color: var(--muted); text-align: center; padding: 32px !important; }
@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 82px 1fr; }
  .sidebar { padding: 22px 12px; }
  .brand div:not(.brand-mark), nav button { font-size: 0; justify-content: center; }
  nav button span { font-size: 18px; }
  .sidebar-foot { display: none; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { height: auto; position: static; padding: 12px; }
  .brand { display: none; }
  nav { grid-template-columns: repeat(4, 1fr); }
  nav button { font-size: 0; padding: 9px; }
  main { padding: 0 14px 30px; }
  .topbar { height: 92px; }
  .top-actions .ghost { display: none; }
  .profile-trigger #userChip, .profile-trigger > span:last-child { display: none; }
  .metric-grid, .metric-grid.small, .grid-2, .validation-grid { grid-template-columns: 1fr; }
  .hero-strip { display: block; }
  .hero-strip p { margin-top: 10px; }
  .toolbar { display: grid; }
  .search-box { min-width: 0; }
  .form-grid.four, .form-grid.two { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .journal-line { grid-template-columns: 1fr 1fr; }
  .journal-line select { grid-column: 1 / -1; }
  .password-form { grid-template-columns: 1fr; }
  .security-create, .security-create.user-create, .group-card { grid-template-columns: 1fr; }
}
