:root {
  --paper: #f4f1e9;
  --paper-deep: #ebe6da;
  --surface: #fffdf8;
  --ink: #17211d;
  --muted: #69716c;
  --line: #d9d5ca;
  --dark: #1b2924;
  --dark-soft: #263a32;
  --accent: #dbff69;
  --asset: #3778c2;
  --asset-soft: #eaf3ff;
  --liability: #c17b18;
  --liability-soft: #fff3dd;
  --equity: #7658b5;
  --equity-soft: #f1ecff;
  --revenue: #31805f;
  --revenue-soft: #e7f6ef;
  --expense: #b4504d;
  --expense-soft: #fbeceb;
  --shadow: 0 18px 50px rgba(44, 50, 46, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --sidebar: 306px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: white;
  background: var(--dark);
  border-radius: 8px;
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  color: white;
  background: rgba(27, 41, 36, 0.97);
  border-bottom: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  line-height: 1.05;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--dark);
  background: var(--accent);
  border-radius: 11px;
  font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .03em; }
.brand small { margin-top: 4px; color: #b9c5bf; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }

.topbar-actions { display: flex; gap: 10px; }

.quiet-button {
  padding: 9px 14px;
  color: #dce4df;
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  cursor: pointer;
}

.quiet-button:hover, .quiet-button:focus-visible { color: white; border-color: rgba(255,255,255,.5); }
.quiet-button.emphasis { color: var(--dark); background: var(--accent); border-color: var(--accent); font-weight: 700; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - 76px); }

.sidebar {
  position: sticky;
  top: 76px;
  height: calc(100vh - 76px);
  overflow-y: auto;
  padding: 34px 24px 28px;
  background: var(--dark);
  color: white;
  border-top: 1px solid rgba(255,255,255,.08);
}

.eyebrow, .module-kicker {
  color: #65706a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.sidebar .eyebrow { color: var(--accent); }
.sidebar h1 { margin: 13px 0 12px; font-size: clamp(27px, 2.4vw, 38px); line-height: 1.03; letter-spacing: -.045em; }
.sidebar-intro p { margin: 0; color: #aebbb4; font-size: 13px; line-height: 1.55; }

.module-nav { display: grid; gap: 6px; margin: 30px 0; }

.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  color: #c7d0cb;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
}

.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item[aria-current="page"] { color: white; background: var(--dark-soft); box-shadow: inset 3px 0 0 var(--accent); }
.nav-index { color: #7f9087; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.nav-item[aria-current="page"] .nav-index { color: var(--accent); }
.nav-label { font-size: 13px; font-weight: 650; line-height: 1.25; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 12px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.1); }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: #99a9a0; font-size: 10px; }
.legend i { width: 7px; height: 7px; border-radius: 50%; }
.asset-dot { background: var(--asset); }
.liability-dot { background: var(--liability); }
.equity-dot { background: var(--equity); }
.revenue-dot { background: var(--revenue); }
.expense-dot { background: var(--expense); }

.study-area { min-width: 0; padding: 44px clamp(22px, 5vw, 76px) 30px; }

.welcome-panel {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  align-items: end;
  max-width: 1040px;
  margin: 0 auto 24px;
}

.welcome-panel h2 { margin: 7px 0 7px; font-size: clamp(33px, 5vw, 58px); line-height: 1.03; letter-spacing: -.035em; }
.welcome-panel p { max-width: 680px; margin: 0; color: var(--muted); }
.module-stat { flex: 0 0 auto; min-width: 124px; padding: 16px; text-align: right; border-left: 1px solid var(--line); }
.module-stat strong, .module-stat span { display: block; }
.module-stat strong { font-size: 31px; line-height: 1; }
.module-stat span { margin-top: 5px; color: var(--muted); font-size: 11px; }

.recordkeeping-standard {
  max-width: 1040px;
  display: grid;
  grid-template-columns: 38px minmax(0,1fr) auto;
  gap: 14px;
  align-items: start;
  margin: 0 auto 20px;
  padding: 17px 18px;
  background: #e7efe8;
  border: 1px solid #c7d7ca;
  border-radius: var(--radius-md);
}

.standard-icon { display: grid; width: 34px; height: 34px; place-items: center; color: white; background: var(--revenue); border-radius: 50%; font-weight: 800; }
.recordkeeping-standard p { margin: 2px 0 0; color: #4f6357; font-size: 13px; }
.recordkeeping-standard details { font-size: 12px; }
.recordkeeping-standard summary { padding: 5px 0; color: #315844; font-weight: 800; cursor: pointer; }
.recordkeeping-standard details p { max-width: 420px; padding-top: 8px; }

.module-content { max-width: 1040px; margin: 0 auto; }

.content-card {
  overflow: clip;
  margin-bottom: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 0 rgba(30, 40, 35, .02);
}

.content-card[open] { box-shadow: var(--shadow); }

.content-card > summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr) 38px;
  gap: 18px;
  align-items: center;
  padding: 21px 22px;
  list-style: none;
  cursor: pointer;
}

.content-card > summary::-webkit-details-marker { display: none; }
.content-card > summary:hover { background: #fbf8f1; }
.summary-title { display: block; font-size: 17px; font-weight: 780; line-height: 1.28; letter-spacing: -.015em; }
.summary-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; font-weight: 500; }
.summary-toggle { display: grid; width: 36px; height: 36px; place-items: center; background: var(--paper); border-radius: 50%; font-size: 20px; transition: transform .2s ease; }
.content-card[open] .summary-toggle { transform: rotate(45deg); }

.card-body { padding: 3px clamp(20px, 4vw, 46px) 38px; border-top: 1px solid var(--line); }
.card-body > :first-child { margin-top: 30px; }
.card-body h1, .card-body h2, .card-body h3, .card-body h4 { letter-spacing: -.025em; line-height: 1.2; }
.card-body h1 { font-size: 29px; }
.card-body h2 { margin-top: 35px; font-size: 23px; }
.card-body h3 { margin-top: 28px; font-size: 18px; }
.card-body h4 { margin-top: 24px; font-size: 16px; }
.card-body p, .card-body li { color: #3f4843; }
.card-body strong { color: var(--ink); }
.card-body blockquote { margin: 22px 0; padding: 15px 18px; color: #284338; background: #edf4ee; border-left: 4px solid var(--revenue); border-radius: 0 12px 12px 0; }
.card-body blockquote p { margin: 0; color: inherit; }
.card-body code { padding: .12em .35em; background: var(--paper); border-radius: 5px; }
.card-body pre { overflow-x: auto; padding: 17px; color: #e7eee9; background: var(--dark); border-radius: 13px; }
.card-body pre code { padding: 0; color: inherit; background: transparent; }
.card-body hr { margin: 35px 0; border: 0; border-top: 1px solid var(--line); }

.math-display {
  max-width: 100%;
  overflow-x: auto;
  margin: 18px 0;
  padding: 8px 4px 12px;
  text-align: center;
  scrollbar-width: thin;
}

.math-display mjx-container { margin: 0 !important; }

.card-body table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.table-scroll { width: 100%; overflow-x: auto; margin: 22px 0; border: 1px solid var(--line); border-radius: 12px; }
.table-scroll table { margin: 0; }
.card-body th, .card-body td { padding: 10px 13px; text-align: left; border-bottom: 1px solid #e7e3da; vertical-align: top; }
.card-body th { color: #59635d; background: #f4f1e9; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.card-body td[align="right"], .card-body th[align="right"] { text-align: right; }
.card-body tr:last-child td { border-bottom: 0; }

.entry-documentation {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(110px, .7fr) minmax(260px, 2fr);
  gap: 1px;
  overflow: hidden;
  margin: 22px 0 -23px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 11px 11px 0 0;
  font-size: 11px;
}

.entry-documentation span { padding: 9px 11px; color: #56625c; background: #f7f4ed; }
.entry-documentation b { display: block; margin-bottom: 2px; color: var(--ink); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.entry-documentation + .table-scroll { border-radius: 0 0 12px 12px; }
.journal-table th:last-child, .journal-table td:last-child { border-left: 1px solid #ece7dc; }

.posting-documentation { margin: -9px 0 20px; padding: 8px 11px; color: #53625b; background: #edf2ed; border-radius: 0 0 9px 9px; font-size: 11px; }
.posting-documentation b { color: #2d5140; }

.card-body pre.t-account {
  padding: 22px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 10px 24px rgba(44, 50, 46, .06);
  font-size: 13px;
  line-height: 1.55;
}

.statement-scroll {
  padding: clamp(16px, 3vw, 28px);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(44, 50, 46, .06);
}

.financial-statement-table th {
  color: var(--ink);
  background: transparent;
  border-bottom: 1px solid var(--ink);
}

.financial-statement-table td { border-bottom: 0; }
.financial-statement-table td:first-child { min-width: 260px; }
.financial-statement-table td:not(:first-child),
.financial-statement-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.financial-statement-table .statement-subtotal-row td:not(:first-child) { border-top: 1px solid currentColor; }
.financial-statement-table .statement-subtotal-row { font-weight: 700; }
.financial-statement-table .statement-final-row { font-weight: 800; }
.financial-statement-table .statement-final-row td:not(:first-child) { border-bottom: 4px double currentColor; }

.content-card.recognition { border-left: 4px solid var(--asset); }
.content-card.example { border-left: 4px solid var(--equity); }
.content-card.framework { border-left: 4px solid var(--revenue); }
.content-card.closing { border-left: 4px solid var(--expense); }

.accounting-statement { padding: clamp(22px, 4vw, 42px); background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(45,52,48,.06); }
.statement-heading { margin-bottom: 28px; text-align: center; line-height: 1.3; }
.statement-heading strong, .statement-heading span { display: block; }
.statement-heading strong { font-size: 17px; letter-spacing: .04em; }
.statement-heading span { font-size: 13px; }
.statement-table { min-width: 620px !important; }
.statement-table td { border: 0; padding: 5px 10px; }
.statement-table .major td { padding-top: 18px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.statement-table .section td { padding-top: 12px; font-weight: 750; }
.statement-table .account td:first-child { padding-left: 30px; }
.statement-table .amount { width: 170px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.statement-table .subtotal td { padding-top: 8px; font-weight: 700; }
.statement-table .subtotal .amount { border-top: 1px solid currentColor; }
.statement-table .final-total td { padding-top: 13px; font-weight: 800; }
.statement-table .final-total .amount { border-bottom: 4px double currentColor; }
.statement-check { display: flex; justify-content: center; gap: 9px; margin-top: 25px; padding: 12px; color: #285c43; background: var(--revenue-soft); border-radius: 10px; font-weight: 700; }

.loading-card { min-height: 180px; padding: 36px; background: var(--surface); border-radius: var(--radius-md); }
.loading-line { display: block; width: 72%; height: 16px; margin-bottom: 16px; background: #e6e2d8; border-radius: 8px; animation: pulse 1.2s infinite alternate; }
.loading-line.short { width: 44%; }
@keyframes pulse { to { opacity: .45; } }

.error-card { padding: 28px; color: #792f2e; background: var(--expense-soft); border: 1px solid #edc3c1; border-radius: var(--radius-md); }

.site-footer { max-width: 1040px; display: flex; justify-content: space-between; gap: 18px; margin: 55px auto 0; padding-top: 18px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }

@media (max-width: 880px) {
  .topbar { height: 66px; padding: 0 16px; }
  .brand small { display: none; }
  .quiet-button { display: none; }
  .quiet-button.emphasis { display: block; padding: 8px 11px; font-size: 11px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 22px 18px 14px; }
  .sidebar-intro, .legend { display: none; }
  .module-nav { display: flex; gap: 7px; margin: 0; overflow-x: auto; scrollbar-width: none; }
  .nav-item { flex: 0 0 auto; width: auto; display: flex; padding: 9px 12px; background: rgba(255,255,255,.05); }
  .nav-item[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); }
  .nav-index { display: none; }
  .study-area { padding: 30px 17px 24px; }
  .welcome-panel { align-items: start; }
  .module-stat { display: none; }
  .recordkeeping-standard { grid-template-columns: 34px 1fr; }
  .recordkeeping-standard details { grid-column: 2; }
}

@media (max-width: 560px) {
  .welcome-panel h2 { font-size: 37px; }
  .recordkeeping-standard { padding: 14px; }
  .content-card > summary { padding: 17px 16px; }
  .summary-title { font-size: 15px; }
  .summary-hint { display: none; }
  .card-body { padding: 1px 17px 27px; }
  .card-body h1 { font-size: 24px; }
  .site-footer { display: grid; }
  .entry-documentation { grid-template-columns: 1fr 1fr; }
  .entry-documentation span:last-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
