:root {
  --ink: #17211d;
  --muted: #64716b;
  --line: #dde4df;
  --paper: #ffffff;
  --canvas: #f4f7f5;
  --green: #176548;
  --green-dark: #0c4933;
  --green-soft: #e8f3ed;
  --amber: #9c6400;
  --red: #a73737;
  --shadow: 0 18px 55px rgba(30, 54, 43, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 85% 0, #e5f0e9 0, transparent 32rem), var(--canvas); }
a { color: var(--green); }
.shell { width: min(1420px, calc(100% - 40px)); margin: 0 auto; }
.topbar { background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.topbar__content { height: 74px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand__mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--green); color: white; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.nav { display: flex; align-items: center; gap: 22px; font-size: 14px; }
.nav a, .link-button { color: var(--ink); text-decoration: none; }
.nav form { margin: 0; }
.nav__user { color: var(--muted); padding-left: 22px; border-left: 1px solid var(--line); }
.link-button { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }
.page { min-height: calc(100vh - 132px); padding: 48px 0 64px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.page-heading--detail { align-items: center; }
.page-heading h1 { margin: 5px 0 6px; font-size: clamp(30px, 4vw, 46px); line-height: 1; letter-spacing: -.04em; }
.page-heading p, .login-panel p { margin: 0; color: var(--muted); }
.eyebrow, .card-label { color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.card { background: var(--paper); border: 1px solid rgba(205,216,209,.85); border-radius: 18px; box-shadow: var(--shadow); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.stats article { padding: 22px 24px; border-radius: 16px; background: var(--green-dark); color: #fff; }
.stats article:nth-child(2) { background: #225d49; }
.stats article:nth-child(3) { background: #e6efe9; color: var(--ink); }
.stats span, .stats strong { display: block; }
.stats span { font-size: 12px; opacity: .72; text-transform: uppercase; letter-spacing: .1em; }
.stats strong { margin-top: 7px; font-size: 24px; }
.search { display: flex; gap: 8px; width: min(100%, 480px); }
input { width: 100%; border: 1px solid #cbd6cf; background: #fff; border-radius: 10px; padding: 12px 14px; font: inherit; color: inherit; outline: none; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,101,72,.12); }
.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid #cbd6cf; background: #fff; color: var(--ink); border-radius: 10px; padding: 11px 17px; font-weight: 750; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button--primary { border-color: var(--green); background: var(--green); color: #fff; }
.button--primary:hover { background: var(--green-dark); }
.button--danger { border-color: #9c2f2f; background: #9c2f2f; color: #fff; }
.button--danger:hover { background: #742323; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 14px 16px; color: var(--muted); background: #f8faf9; text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; }
th:first-child { border-radius: 17px 0 0; }
th:last-child { border-radius: 0 17px 0 0; }
td { padding: 16px; border-top: 1px solid #e9eeeb; vertical-align: top; }
tbody tr:hover { background: #fbfdfc; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 750; }
.document-link { font-weight: 800; text-decoration: none; }
.badge { display: inline-block; border-radius: 999px; padding: 6px 9px; font-size: 11px; font-weight: 800; }
.badge--imported { color: var(--green); background: var(--green-soft); }
.badge--verified { color: var(--green); background: var(--green-soft); white-space: nowrap; }
.badge--needs_review { color: var(--amber); background: #fff2d8; }
.danger-link { color: var(--red); font-weight: 750; text-decoration: none; }
.empty { text-align: center; color: var(--muted); padding: 48px; }
.pagination { display: flex; gap: 7px; margin-top: 20px; }
.pagination a { width: 36px; height: 36px; display: grid; place-items: center; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; }
.pagination a.is-active { color: white; background: var(--green); border-color: var(--green); }
.breadcrumbs { display: flex; gap: 9px; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.breadcrumbs a { text-decoration: none; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr 1.05fr; gap: 16px; margin-bottom: 22px; }
.info-card, .totals-card { padding: 24px; }
.info-card h2 { margin: 8px 0 22px; font-size: 20px; }
dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
dd { margin: 4px 0 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.totals-card { background: var(--green-dark); color: white; }
.totals-card div { display: flex; justify-content: space-between; gap: 20px; padding: 5px 0 13px; }
.totals-card span { opacity: .7; }
.totals-card .grand-total { border-top: 1px solid rgba(255,255,255,.2); margin-top: 7px; padding-top: 18px; font-size: 19px; }
.lines-card { overflow: hidden; }
.section-heading { display: flex; justify-content: space-between; align-items: end; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 5px 0 0; }
.section-heading > span { color: var(--muted); font-size: 13px; }
.lines-table { min-width: 1150px; }
.lines-table td:nth-child(3) { min-width: 300px; }
.lines-table td small { display: block; margin-top: 5px; color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.login-panel { width: min(100%, 440px); margin: 6vh auto 0; padding: 36px; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.login-panel h1 { margin: 7px 0 9px; font-size: 34px; letter-spacing: -.035em; }
.stack { display: grid; gap: 17px; margin-top: 28px; }
.stack label span { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.stack .button { margin-top: 4px; }
.alert { padding: 13px 15px; border-radius: 10px; margin-bottom: 18px; font-size: 14px; }
.alert--error { color: #782929; background: #fce9e9; border: 1px solid #f3cece; }
.alert--warning { color: #734b04; background: #fff4da; border: 1px solid #eedaa9; }
.alert--success { color: #15523d; background: var(--green-soft); border: 1px solid #c9e3d4; }
.upload-card { padding: 24px; }
.upload-card form { display: grid; gap: 16px; }
.drop-zone { min-height: 260px; border: 2px dashed #b9c9c0; border-radius: 15px; background: #f8fbf9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; text-align: center; cursor: pointer; transition: .18s ease; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--green); background: var(--green-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone__icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 14px; color: white; background: var(--green); font-size: 12px; font-weight: 900; letter-spacing: .06em; margin-bottom: 5px; }
.drop-zone > span:not(.drop-zone__icon), .drop-zone small, .upload-summary { color: var(--muted); }
.upload-summary { font-size: 13px; }
.upload-card .button { justify-self: start; }
.results-card { margin-top: 22px; overflow: hidden; }
.result-list { list-style: none; margin: 0; padding: 0; }
.result { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 16px 22px; border-top: 1px solid var(--line); }
.result:first-child { border-top: 0; }
.result__status { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); font-weight: 900; }
.result--error .result__status { background: #fce9e9; color: var(--red); }
.result--duplicate .result__status, .result--warning .result__status { background: #fff2d8; color: var(--amber); }
.result div strong, .result div span { display: block; overflow: hidden; text-overflow: ellipsis; }
.result div span { color: var(--muted); margin-top: 3px; font-size: 13px; }
.delete-confirmation { display: grid; grid-template-columns: 1fr minmax(340px, .8fr); gap: 30px; align-items: center; padding: 25px; margin-bottom: 22px; border-color: #e9c6c6; }
.delete-confirmation h2 { margin: 6px 0 8px; }
.delete-confirmation p { margin: 0; color: var(--muted); }
.delete-form label span { display: block; margin-bottom: 7px; font-size: 13px; }
.delete-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 12px; }
.footer { padding: 20px 0 26px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
@media (max-width: 900px) {
  .page-heading { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .delete-confirmation { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .shell { width: min(100% - 24px, 1420px); }
  .nav__user, .nav > a { display: none; }
  .page { padding-top: 30px; }
  .stats { grid-template-columns: 1fr; }
  .login-panel { margin-top: 2vh; padding: 25px; }
  .result { grid-template-columns: 32px 1fr; }
  .result > a { grid-column: 2; }
}
