* { box-sizing: border-box; }

body {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  color: #111;
  background: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button, input, select { font: inherit; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid #ccc;
}

nav { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
nav button { padding: 0; border: 0; background: transparent; color: #06c; text-decoration: underline; cursor: pointer; }

main { min-width: 0; }
h1 { margin-top: 0; }
h2 { margin-top: 0; font-size: 1.25rem; }

.page-heading { margin-bottom: 24px; }
.page-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-description, .eyebrow, .helper-text, .section-description { color: #444; }
.eyebrow { margin: 0 0 4px; }
.project-required-notice { margin: 0; padding: 10px 12px; border: 1px solid #aaa; background: #f7f7f7; }
.required-mark { margin: 0 0.25rem; color: #a00; font-weight: 700; }
.project-section > .section-description { margin: 0 0 12px; }
.project-section > .field { margin: 12px 0; }
.project-section > .field:last-child { margin-bottom: 0; }
.input-required { border: 2px solid #a00; background: #fff6f6; }

.stack-form { display: grid; gap: 16px; }
fieldset, .surface-section, .summary-panel, .result-section, .auth-card {
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid #aaa;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

fieldset > legend { font-weight: 700; }
.summary-panel { margin-bottom: 16px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

label { display: block; }
.choice-list { margin: 16px 0; }
.choice-list strong { display: block; margin-bottom: 6px; }
.choice-list label { display: inline-block; margin: 0 12px 6px 0; }
.choice-list input { width: auto; }
.choice-option { display: inline-flex; align-items: center; margin: 0 12px 6px 0; }
.choice-option label { margin-right: 4px; }
input, select { max-width: 100%; padding: 5px; border: 1px solid #767676; border-radius: 0; background: #fff; }
input[type="number"], input[type="text"], input[type="date"], input[type="password"], select { width: 100%; }
input[type="checkbox"] { width: auto; }
.money-help { display: block; margin-top: 4px; color: #444; font-size: 0.875rem; }
.number-stepper { display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0; }
.number-stepper button { padding: 3px 6px; font-size: 0.875rem; }
.help-button { min-width: 1.5rem; min-height: 1.5rem; padding: 0 0.35rem; border-radius: 50%; font-weight: 700; line-height: 1; vertical-align: middle; }
dialog { max-width: min(32rem, calc(100vw - 32px)); padding: 16px; border: 1px solid #767676; color: #111; background: #fff; }
dialog::backdrop { background: rgb(0 0 0 / 0.25); }
dialog h2 { margin-top: 0; }
.repayment-figure { margin: 12px 0; }
.repayment-figure svg { display: block; width: 100%; max-width: 360px; height: auto; border: 1px solid #aaa; background: #fff; }
.repayment-comparison { display: grid; gap: 12px; }
.repayment-chart h3 { margin: 0; font-size: 1rem; }
.repayment-chart .repayment-figure { margin: 4px 0 0; }
button, .primary-link { padding: 5px 10px; border: 1px solid #767676; border-radius: 0; background: #eee; color: #111; cursor: pointer; text-decoration: none; }
button:hover, .primary-link:hover { background: #ddd; }
.danger-button { color: #a00; }

.entry-card {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #bbb;
  border-radius: 0;
  background: #fff;
}
.entry-card > legend { font-weight: 700; }
.entry-card > label { margin-top: 12px; }
.project-form .entry-card { margin: 12px 0 0; }
.project-form .entry-card .field { margin: 10px 0; }
.project-form .entry-card .field:last-of-type { margin-bottom: 12px; }
.project-form .auto-calculated { background: #f5f5f5; }

.ledger-section { min-width: 0; margin: 0; padding: 12px 16px 16px; border: 1px solid #aaa; }
.ledger-section > summary { cursor: pointer; }
.ledger-section > summary strong { font-size: 1.1rem; }
.ledger-section > summary span { color: #444; }
.ledger-table-wrap { overflow-x: auto; }
.ledger-table { min-width: 680px; }
.ledger-table th, .ledger-table td { padding: 6px; }
.ledger-table input, .ledger-table select { min-width: 110px; padding: 4px; }
.ledger-table input[type="date"] { min-width: 140px; }
.ledger-table .danger-button { padding: 4px 6px; white-space: nowrap; }

.sticky-action { position: static; margin: 16px 0 0; padding: 0; }
.secondary-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
[role="status"], [role="alert"] { min-height: 1.5em; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px; border: 1px solid #aaa; text-align: left; vertical-align: top; }
th { background: #eee; }
.summary-panel table { width: auto; }
.result-section { margin: 16px 0; }
.result-section > div, details.result-section > div { overflow-x: auto; }
.result-section li { margin: 4px 0; }

.auth-card { max-width: 440px; margin: 48px auto; }
.auth-card pre { overflow-x: auto; white-space: pre-wrap; }

@media (max-width: 640px) {
  body { padding: 12px; }
  header, .page-heading-row { display: block; }
  header > * + *, .page-heading-row > * + * { margin-top: 12px; }
  nav { gap: 10px; }
  .surface-section, .summary-panel, .result-section, .auth-card { padding: 12px; }
  .ledger-section { padding: 12px; }
  .repayment-figure svg { max-width: 100%; }
  .data-table, .result-section table { display: block; overflow-x: auto; }
}
