:root {
  --paper:    #f3ecd6;
  --paper-2:  #ece2c5;
  --paper-3:  #f8f1da;
  --ink:      #1a1410;
  --ink-2:    #2d251c;
  --ink-3:    #4a3f30;
  --muted:    #7a6d57;
  --rule:     #c5b288;
  --rule-2:   #b4a070;
  --stamp:    #a93324;
  --stamp-2:  #c4493a;
  --gold:     #8c6e1f;
  --sage:     #5d6a3b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Manrope", -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.08 0 0 0 0 0.06 0 0 0 0 0.04 0 0 0 0.22 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  mix-blend-mode: multiply;
  opacity: 0.5;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(120% 90% at 50% 20%, transparent 60%, rgba(60,40,15,0.18) 100%);
}

.rule        { border: 0; border-top: 1px solid var(--rule-2); margin: 24px 0; }
.rule-double {
  border: 0;
  height: 6px;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  margin: 24px 0 36px;
}
.rule-thin   { border: 0; border-top: 1px dashed var(--rule-2); margin: 18px 0; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.masthead, .controls, .formula-row, .tabs, .filter, .table-wrap, .summary {
  animation: riseIn 0.7s cubic-bezier(0.2,0.6,0.2,1) both;
}
.controls    { animation-delay: 0.05s; }
.formula-row { animation-delay: 0.08s; }
.tabs        { animation-delay: 0.12s; }
.filter      { animation-delay: 0.16s; }
.table-wrap  { animation-delay: 0.20s; }
.summary     { animation-delay: 0.25s; }

@media (max-width: 900px) {
  .sheet { padding: 36px 22px 64px; }
  .controls { grid-template-columns: repeat(2, 1fr); }
  .ctl { border-right: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2); }
  .ctl:nth-child(2n) { border-right: 0; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .stat { border-bottom: 1px solid var(--rule-2); }
  .stamp { display: none; }
  .masthead { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .controls, .summary { grid-template-columns: 1fr; }
  .ctl, .stat { border-right: 0; }
  td.sale { font-size: 22px; }
  table.ledger thead th, table.ledger tbody td { padding: 10px 8px; font-size: 12px; }
  .cell-edit input { width: 64px; }
  .tabs { gap: 22px; }
  .tab  { font-size: 20px; }
}
