:root {
  font-family: Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: var(--canvas);
  --ink: #20343c; --muted: #718187; --brand: #173c43; --accent: #147d75;
  --accent-soft: #e8f4f0; --canvas: #f3f6f5; --surface: #ffffff; --line: #dce5e2;
  --nav-text: #b7cccd; --nav-hover: #224b51; --nav-active: #d7ee91;
  --success: #137568; --warning: #9b681d; --warning-soft: #fbf2df;
  --error: #b13f45; --error-soft: #fbecee; --focus: #20a392;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
  --caption: 11px; --small: 12px; --body: 13px; --h4: 16px; --h3: 20px; --h2: 28px; --h1: 32px;
  --r1: 4px; --r2: 8px; --r3: 12px; --shadow: 0 8px 32px #173c4310;
  --sidebar: 224px; --control: 36px; --motion: 140ms;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; min-height: var(--control); padding: var(--s2) var(--s4); border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface); font-weight: 600; transition: background var(--motion), border-color var(--motion); }
button:hover { border-color: var(--accent); background: var(--accent-soft); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
button.danger { color: var(--error); }
button.text { background: transparent; border-color: transparent; color: var(--accent); padding-inline: var(--s2); }
button.small { min-height: var(--s8); padding: var(--s1) var(--s3); font-size: var(--small); }
a { color: var(--accent); text-decoration: none; }
input, select, textarea { width: 100%; min-height: var(--control); padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--r1); background: var(--surface); }
input[type="checkbox"] { min-height: auto; width: auto; }
input[readonly] { color: var(--muted); background: var(--canvas); }
textarea { min-height: 96px; resize: vertical; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
label { display: grid; gap: var(--s2); font-size: var(--small); font-weight: 600; }
h1,h2,h3,h4,p { margin: 0; }
h1 { font-size: var(--h2); letter-spacing: -.04em; font-weight: 750; }
h2 { font-size: var(--h3); letter-spacing: -.025em; }
h3 { font-size: var(--h4); }
h4 { font-size: var(--body); }
small,.muted { color: var(--muted); font-size: var(--small); }
.boot { min-height: 100vh; display: grid; align-content: center; justify-items: center; gap: var(--s6); }
.brand-mark { display: grid; place-items: center; width: var(--s10); height: var(--s10); border-radius: var(--r3); font-size: var(--h2); font-weight: 800; color: var(--brand); background: var(--nav-active); }
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0,1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: var(--s8) var(--s4) var(--s5); background: var(--brand); color: var(--surface); }
.brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s3) var(--s8); }
.brand strong { font-size: var(--h3); letter-spacing: .08em; color: var(--surface); }
.brand small { display: block; margin-top: var(--s1); color: var(--nav-text); font-size: var(--caption); letter-spacing: .12em; }
.nav-label { padding: var(--s5) var(--s3) var(--s2); color: var(--nav-text); font-size: var(--caption); letter-spacing: .08em; }
.nav { display: grid; gap: var(--s1); }
.nav a { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); color: var(--nav-text); border-radius: var(--r2); font-weight: 500; }
.nav a:hover { background: var(--nav-hover); color: var(--surface); }
.nav a.active { background: var(--nav-active); color: var(--brand); font-weight: 750; }
.nav-icon { width: var(--s5); height: var(--s5); stroke: currentColor; fill: none; stroke-width: 1.6; flex-shrink: 0; }
.sidebar-footer { margin-top: auto; padding: var(--s6) var(--s3) 0; color: var(--nav-text); font-size: var(--caption); line-height: 1.8; }
.workspace { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s4) var(--s8); border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-path { color: var(--muted); font-size: var(--small); }
.topbar-path strong { color: var(--ink); font-weight: 500; margin-left: var(--s2); }
.account { display: flex; align-items: center; gap: var(--s3); }
.avatar { display: grid; place-items: center; width: var(--s8); height: var(--s8); background: var(--accent-soft); color: var(--accent); border-radius: 50%; font-weight: 700; }
.main { padding: var(--s8); max-width: 1800px; margin: auto; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: var(--s5); margin-bottom: var(--s6); }
.eyebrow { color: var(--accent); font-size: var(--caption); font-weight: 750; letter-spacing: .14em; margin-bottom: var(--s2); }
.description { color: var(--muted); margin-top: var(--s3); line-height: 1.7; }
.actions { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: var(--s5) var(--s6); gap: var(--s4); border-bottom: 1px solid var(--line); }
.card-body { padding: var(--s6); }
.stats { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: var(--s4); margin-bottom: var(--s6); }
.stat { padding: var(--s6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); }
.stat:first-child { background: var(--brand); border-color: var(--brand); color: var(--surface); }
.stat .stat-label { font-size: var(--small); color: var(--muted); display: flex; justify-content: space-between; }
.stat:first-child .stat-label { color: var(--nav-text); }
.stat-value { margin: var(--s5) 0 var(--s2); font-size: var(--h2); font-weight: 750; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: var(--small); font-weight: 400; color: inherit; margin-left: var(--s1); }
.stat-note { font-size: var(--caption); color: var(--muted); }
.stat:first-child .stat-note { color: var(--nav-text); }
.two-col { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,1fr); gap: var(--s6); }
.stack { display: grid; gap: var(--s6); }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s3); padding: var(--s4) var(--s6); border-bottom: 1px solid var(--line); }
.toolbar input[type="search"] { min-width: 240px; }
.toolbar label { min-width: 140px; }
.toolbar .grow { flex: 1; }
.table-wrap { overflow: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; font-size: var(--small); }
th { background: var(--canvas); font-size: var(--caption); color: var(--muted); font-weight: 650; }
th,td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); height: var(--s12); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: var(--s12) var(--s6); line-height: 1.8; }
.table-foot { display: flex; justify-content: space-between; gap: var(--s4); padding: var(--s3) var(--s6); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--caption); }
.badge { display: inline-flex; align-items: center; padding: var(--s1) var(--s2); border-radius: var(--r1); color: var(--accent); background: var(--accent-soft); font-size: var(--caption); font-weight: 650; }
.badge.warning { color: var(--warning); background: var(--warning-soft); }
.badge.error { color: var(--error); background: var(--error-soft); }
.cancelled { color: var(--muted); text-decoration: line-through; }
.grid-table td { padding: 0; height: auto; }
.grid-table td input,.grid-table td select { min-width: 120px; border: 1px solid transparent; border-radius: 0; background: transparent; padding: var(--s3); min-height: var(--s12); }
.grid-table td input:focus,.grid-table td select:focus { outline-offset: -2px; background: var(--surface); }
.grid-table td.wide input { min-width: 180px; }
.grid-table td.numeric input { text-align: right; min-width: 112px; }
.grid-table td.row-action { padding: var(--s1) var(--s2); }
.grid-table th small { display: block; font-size: var(--caption); font-weight: 400; margin-top: var(--s1); }
.grid-table output { display: block; padding: 0 var(--s3) var(--s2); color: var(--accent); text-align: right; font-size: var(--caption); }
.grid-table .cell-error { background: var(--error-soft); }
.grid-table .cell-error output { color: var(--error); }
.grid-table tr.dirty { box-shadow: inset 3px 0 var(--warning); }
.grid-table tr.saved { box-shadow: inset 3px 0 var(--success); }
.tabs { display: flex; gap: var(--s1); padding: var(--s1); background: var(--canvas); border-radius: var(--r2); width: fit-content; }
.tabs button { background: transparent; border-color: transparent; }
.tabs button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.help { padding: var(--s3) var(--s4); margin-bottom: var(--s4); color: var(--muted); background: var(--accent-soft); border-radius: var(--r2); font-size: var(--small); line-height: 1.7; }
.error-box { color: var(--error); background: var(--error-soft); border-radius: var(--r2); padding: var(--s3) var(--s4); line-height: 1.6; margin-bottom: var(--s4); }
.error-box:empty { display: none; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); padding: var(--s4) var(--s6); border-bottom: 1px solid var(--line); }
.list-item:last-child { border: 0; }
.list-item small { display: block; margin-top: var(--s1); }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.quick-actions button { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: var(--s4); text-align: left; font-weight: 500; }
.quick-actions span { color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--s5); }
.form-grid .full { grid-column: 1/-1; }
.form-section { padding-bottom: var(--s6); margin-bottom: var(--s6); border-bottom: 1px solid var(--line); }
.form-section h3 { margin-bottom: var(--s5); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s6); }
.narrow { max-width: 680px; }
dialog { width: min(1040px,calc(100vw - var(--s8))); max-height: calc(100vh - var(--s8)); padding: 0; border: 1px solid var(--line); border-radius: var(--r3); color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: #102f3870; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); padding: var(--s5) var(--s6); border-bottom: 1px solid var(--line); }
.dialog-body { padding: var(--s6); }
.dialog-head h2 { font-size: var(--h3); }
.totals { display: flex; justify-content: flex-end; gap: var(--s6); padding: var(--s5); background: var(--canvas); border-top: 1px solid var(--line); }
.totals span { display: grid; gap: var(--s2); font-size: var(--small); color: var(--muted); }
.totals strong { color: var(--ink); font-size: var(--h4); font-variant-numeric: tabular-nums; }
.totals span:last-child strong { color: var(--accent); }
.sheet-formula { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.sheet-formula strong { min-width: var(--s10); color: var(--accent); }
.sheet-table .row-number { background: var(--canvas); color: var(--muted); padding: var(--s3); text-align: center; min-width: var(--s12); }
.sheet-table input { min-width: 160px; }
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-story { background: var(--brand); color: var(--surface); padding: var(--s12); display: flex; flex-direction: column; justify-content: space-between; }
.login-story h1 { font-size: clamp(var(--h1),4vw,56px); line-height: 1.4; letter-spacing: -.045em; }
.login-story p { color: var(--nav-text); line-height: 1.9; margin-top: var(--s6); }
.login-panel { display: grid; place-items: center; padding: var(--s8); }
.login-form { width: min(100%,360px); display: grid; gap: var(--s5); }
.login-form h2 { font-size: var(--h2); }
#notice { position: fixed; bottom: var(--s6); left: 50%; transform: translateX(-50%); z-index: 20; max-width: calc(100% - var(--s8)); background: var(--brand); color: var(--surface); border-radius: var(--r2); box-shadow: var(--shadow); padding: var(--s3) var(--s5); }
#notice:empty { display: none; }
#print-output { display: none; }
.print-head { display: flex; justify-content: space-between; align-items: end; padding-bottom: var(--s6); border-bottom: 2px solid var(--brand); margin-bottom: var(--s6); }
.print-head h1 { font-size: var(--h2); }
.print-meta { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-bottom: var(--s6); line-height: 1.7; }
.print-note { margin-top: var(--s6); color: var(--muted); line-height: 1.8; }
.print-preview { background: var(--surface); padding: var(--s8); border: 1px solid var(--line); border-radius: var(--r2); }
@media (max-width:1100px) {
  :root { --sidebar: 192px; }
  .main { padding: var(--s6); }
  .stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width:720px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: var(--s4); }
  .brand { padding: 0 0 var(--s4); }
  .brand small,.sidebar-footer,.nav-label { display: none; }
  .nav { display: flex; overflow-x: auto; padding-bottom: var(--s1); }
  .nav a { flex-shrink: 0; padding: var(--s2) var(--s3); }
  .nav-icon { width: var(--s4); height: var(--s4); }
  .topbar { padding: var(--s3) var(--s4); }
  .topbar-path,.account .role { display: none; }
  .account { width: 100%; justify-content: flex-end; }
  .main { padding: var(--s5) var(--s4); }
  .page-head { align-items: start; flex-direction: column; gap: var(--s4); }
  h1 { font-size: var(--h3); }
  .stats { gap: var(--s3); }
  .stat { padding: var(--s4); }
  .stat-value { font-size: var(--h3); }
  .card-head,.toolbar { padding: var(--s4); }
  .toolbar label,.toolbar .grow { min-width: 0; width: 100%; }
  .toolbar input[type="search"] { min-width: 0; }
  .form-grid { grid-template-columns: 1fr; gap: var(--s4); }
  .dialog-body { padding: var(--s4); }
  .totals { gap: var(--s4); padding: var(--s4); flex-wrap: wrap; }
  .login { display: block; }
  .login-story { padding: var(--s8); min-height: 240px; }
  .login-story h1 { font-size: var(--h2); }
  .login-story .login-bottom { display: none; }
  .login-panel { padding: var(--s10) var(--s6); }
}
@media print {
  @page { size: A4; margin: 14mm; }
  :root { --ink: #111111; --muted: #555555; --line: #bbbbbb; --surface: #ffffff; --canvas: #ffffff; }
  body > * { display: none !important; }
  body > #print-output { display: block !important; }
  #print-output { font-size: 10pt; }
  #print-output table { white-space: normal; font-size: 9pt; table-layout: auto; }
  #print-output th,#print-output td { padding: var(--s2); height: auto; }
  #print-output thead { display: table-header-group; }
  #print-output tfoot { display: table-footer-group; }
  #print-output tr { break-inside: avoid; }
  #print-output .print-head { break-after: avoid; }
  #print-output .totals { break-inside: avoid; }
  dialog::backdrop { display: none; }
}
