:root {
  color-scheme: light;
  font-family: "Geist", "Segoe UI", system-ui, sans-serif;
  color: #272420;
  background: #f7f6f3;
  line-height: 1.55;
  --muted: #625d55;
  --line: #eaeaea;
  --strong-line: #d9d5ce;
  --paper: #fff;
  --ink: #242420;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, select, textarea, input:not([type="file"]) {
  color: inherit;
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  background: var(--paper);
}
button { padding: .55rem .85rem; cursor: pointer; font-weight: 600; }
button:hover:not(:disabled) { background: #f6f5f2; }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary:hover:not(:disabled) { background: #45433e; border-color: #45433e; }
button:disabled, select:disabled { opacity: .48; cursor: not-allowed; }
:focus-visible, .visually-hidden:focus-visible + label { outline: 2px solid #386555; outline-offset: 3px; }
.shell { width: min(100% - 3rem, 76rem); margin-inline: auto; padding-block: 4.25rem 5rem; }
.page-heading { margin-bottom: 2.35rem; }
h1, h2, h3, p { margin: 0; }
h1 { font: 500 clamp(2.8rem, 6vw, 4.75rem)/1.03 Georgia, serif; letter-spacing: -.045em; }
.page-heading p { margin-top: .7rem; color: var(--muted); }
h2 { font-size: 1.28rem; line-height: 1.25; letter-spacing: -.025em; }
h3 { font-size: .96rem; font-weight: 650; }
.workspace { display: grid; grid-template-columns: minmax(0, 17rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
.card { min-width: 0; padding: 1.55rem; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.document h2 { margin-bottom: 1.1rem; }
.review { min-height: 12rem; }
.section-heading { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.actions button { font-size: .84rem; }
.muted, .status, small { color: var(--muted); }
#detected-type { margin-top: .25rem; font-size: .84rem; }
.status { margin-block: .8rem; font-size: .9rem; }
.notice { padding: .55rem .7rem; border-radius: 6px; background: #f6f4ee; margin-block: .7rem; font-size: .84rem; overflow-wrap: anywhere; }
.error { background: #fdebeb; color: #8e302e; }
.upload { padding: 1rem .5rem; border: 1px dashed var(--strong-line); border-radius: 8px; text-align: center; background: #fbfaf8; }
.upload label { display: inline-block; font-weight: 650; cursor: pointer; text-decoration: underline; text-underline-offset: .22em; text-decoration-color: #aaa397; }
.upload label:hover { text-decoration-color: var(--ink); }
.upload input:disabled + label { opacity: .48; cursor: not-allowed; }
.upload small, #billing-help { display: block; margin-top: .3rem; font-size: .76rem; }
.scan { width: 100%; margin-top: .9rem; }
figure { margin: .85rem 0 0; }
figure img { display: block; width: 100%; max-height: 24rem; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #faf9f7; }
figcaption { margin-top: .35rem; overflow-wrap: anywhere; color: var(--muted); font-size: .8rem; }
details { border-top: 1px solid var(--line); margin-top: .9rem; padding-top: .7rem; }
summary { display: flex; align-items: start; justify-content: space-between; gap: .5rem; list-style: none; cursor: pointer; font-weight: 600; font-size: .88rem; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--muted); }
details[open] > summary::after { content: "−"; }
details p, details button, details textarea { margin-top: .65rem; }
.options { display: grid; gap: .3rem; margin-top: .65rem; font-size: .84rem; }
.options select { width: 100%; padding: .4rem; margin-bottom: .4rem; }
.metadata, .totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr)); gap: 1rem; margin-block: 1rem 1.3rem; }
.metadata section, .totals section { min-width: 0; background: #f8f7f4; border: 1px solid var(--line); border-radius: 8px; padding: .8rem; }
dl { margin: .45rem 0 0; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: .5rem; align-items: baseline; margin-top: .3rem; }
dt { color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
dd { margin: 0; font-size: .82rem; overflow-wrap: anywhere; }
.table-scroll { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: .55rem; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: .84rem; }
caption { text-align: left; }
th, td { padding: .55rem .65rem; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
thead th { background: #f8f7f4; color: var(--muted); font-size: .75rem; font-weight: 600; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
.item-number { min-width: 3rem; }
.item-name { min-width: 8.5rem; }
.numeric { font-variant-numeric: tabular-nums; }
.uncertain { display: inline; padding: .13rem .25rem; border-radius: 3px; color: #704600; background: #fbf3db; }
.uncertain small { color: inherit; white-space: nowrap; }
.validation { font-size: .82rem; overflow-wrap: anywhere; }
.validation ul { padding-left: 1.2rem; margin: .4rem 0 .65rem; }
.validation li + li { margin-top: .22rem; }
.edit-field { display: block; width: 100%; min-width: 4rem; padding: .25rem .35rem; font-size: .82rem; }
.item-name .edit-field { min-width: 8rem; }
.uncertain-field { background: #fbf3db !important; }
textarea, pre { width: 100%; padding: .6rem; font: .8rem/1.5 ui-monospace, monospace; }
textarea { display: block; resize: vertical; }
pre { overflow: auto; max-height: 16rem; background: #f8f7f4; border-radius: 6px; }
.usage { margin-top: 1rem; color: var(--muted); font-size: .8rem; }
.usage details { margin-top: .45rem; }
.usage-table { min-width: 35rem; }
.usage-table td:nth-child(n+3) { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 49rem) {
  .shell { width: min(100% - 2rem, 47rem); padding-block: 2.6rem; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  figure img { max-height: 19rem; }
}
@media (max-width: 25rem) {
  .shell { width: calc(100% - 1rem); }
  .card { padding: .9rem; }
}

#confidence, #edit-help { font-size: .76rem; margin-top: .3rem; }
#items thead th, #verification-items thead th { overflow-wrap: normal; min-width: 4rem; }
.numeric { white-space: nowrap; }
@media (max-width: 49rem) {
  #items, #verification-items, #items tbody, #verification-items tbody { display: block; }
  #items thead, #verification-items thead { display: none; }
  #items tr, #verification-items tr {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .7rem 1rem; padding: 1rem; border-bottom: 1px solid var(--line);
  }
  #items tr:last-child, #verification-items tr:last-child { border-bottom: 0; }
  #items td, #items tbody th, #verification-items td, #verification-items tbody th {
    display: flex; flex-direction: column; min-width: 0; padding: 0;
    border: 0; white-space: normal; overflow-wrap: anywhere;
  }
  #items td::before, #verification-items td::before {
    content: attr(data-label); font-size: .7rem; color: var(--muted); font-weight: 400;
  }
  #items .item-name, #verification-items .item-name { grid-column: 1 / -1; order: -1; font-size: .98rem; }
  #items .item-note, #verification-items .item-note { grid-column: 1 / -1; }
  #items .item-number, #verification-items .item-number { display: none; }
  #items .edit-field, #verification-items .edit-field { min-width: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  #result { animation: appear .2s ease-out; }
  @keyframes appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
}

.usage-table th { white-space: nowrap; overflow-wrap: normal; }
.usage-table td:first-child, .usage-table td:nth-child(n+3) { white-space: nowrap; }
