:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #69736e;
  --line: #dfe5e1;
  --surface: #ffffff;
  --canvas: #f4f6f4;
  --green: #175c45;
  --green-soft: #e4f0eb;
  --amber: #8a5a09;
  --amber-soft: #fff0cf;
  --red: #a23a34;
  --red-soft: #fbe7e5;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.topbar { height: 76px; padding: 0 max(24px, calc((100vw - 1320px) / 2)); display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }
.brand { border: 0; background: none; display: flex; align-items: center; gap: 12px; color: var(--ink); text-align: left; }
.brand span:last-child { display: grid; }
.brand small { color: var(--muted); margin-top: 2px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--green); color: white; font-weight: 750; }
main { max-width: 1320px; margin: 0 auto; padding: 48px 24px 96px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(30px, 4vw, 44px); letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 18px; }
.page-heading, .detail-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
.page-heading p:last-child, .detail-heading p:last-child, .panel-heading p { color: var(--muted); margin-bottom: 0; }
.eyebrow { margin-bottom: 8px; color: var(--green); font-size: 12px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.button { min-height: 40px; padding: 9px 15px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); font-weight: 650; }
.button:hover { border-color: #aab7b0; }
.button.primary { border-color: var(--green); background: var(--green); color: white; }
.button.subtle { background: transparent; }
.button:disabled { opacity: .52; cursor: not-allowed; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat small { display: block; color: var(--muted); margin-bottom: 9px; }
.stat strong { display: block; font-size: 23px; letter-spacing: -.02em; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.panel-heading { min-height: 64px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel-heading a { color: var(--green); font-size: 14px; font-weight: 650; }
.filter-controls { display: flex; align-items: end; gap: 10px; }
.filter-controls label { min-width: 150px; gap: 4px; font-size: 11px; }
.filter-controls select { padding-block: 8px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 18px; color: var(--muted); background: #fafbfa; font-size: 12px; text-align: left; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 16px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:first-child td { border-top: 0; }
.receipt-table tbody tr { cursor: pointer; }
.receipt-table tbody tr:hover { background: #f8faf8; }
.row-action { width: 58px; text-align: center; }
.delete-button { width: 32px; height: 32px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.delete-button:hover, .delete-button:focus-visible { border-color: #efc3bf; background: var(--red-soft); color: var(--red); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
td strong, td small { display: block; }
td small { color: var(--muted); margin-top: 4px; }
.number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.uploaded, .status.processing { color: #38638a; background: #e7f0fa; }
.status.review { color: var(--amber); background: var(--amber-soft); }
.status.approved { color: var(--green); background: var(--green-soft); }
.status.error { color: var(--red); background: var(--red-soft); }
.empty { padding: 64px 24px; display: grid; place-items: center; gap: 8px; color: var(--muted); }
.empty strong { color: var(--ink); }
.hidden { display: none !important; }
.back-link { margin-bottom: 24px; border: 0; padding: 0; background: none; color: var(--green); font-weight: 650; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr); gap: 18px; margin-bottom: 18px; }
.form-grid { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
label { display: grid; gap: 7px; color: #4f5a55; font-size: 13px; font-weight: 650; }
label.wide { grid-column: 1 / -1; }
input, select, textarea { width: 100%; border: 1px solid #cfd7d2; border-radius: 8px; background: white; color: var(--ink); padding: 10px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,92,69,.1); }
textarea { resize: vertical; }
.filename-preview { background: #f4f6f4; color: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
label small { color: var(--muted); font-weight: 400; }
.inline-field { display: flex; gap: 7px; }
.icon-button { width: 42px; border: 1px solid #cfd7d2; border-radius: 8px; background: white; color: var(--green); font-size: 20px; }
.document-panel { min-height: 420px; }
#document-frame { width: 100%; height: 510px; border: 0; background: #e9ecea; }
.positions-panel { margin-bottom: 18px; }
.positions-heading { padding-block: 18px; }
.selection-actions { display: flex; gap: 8px; }
.items-table .check { width: 46px; }
.items-table td { vertical-align: top; }
.items-table input[type="checkbox"] { width: 19px; height: 19px; accent-color: var(--green); }
.items-table input[type="number"], .items-table input[type="text"] { min-width: 125px; }
.item-description { min-width: 320px; line-height: 1.4; }
.irrelevant { opacity: .5; }
.positions-footer { padding: 18px 20px; display: flex; justify-content: space-between; align-items: flex-end; border-top: 1px solid var(--line); background: #fafbfa; color: var(--muted); }
.positions-footer div { text-align: right; }
.positions-footer small { display: block; margin-bottom: 4px; }
.positions-footer strong { color: var(--green); font-size: 25px; }
.actionbar { position: sticky; bottom: 16px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border: 1px solid #ccd6d0; border-radius: 12px; background: rgba(255,255,255,.94); box-shadow: 0 12px 36px rgba(22,38,31,.14); backdrop-filter: blur(12px); }
.actionbar > div:last-child { display: flex; gap: 8px; }
#action-hint { color: var(--muted); font-size: 13px; }
dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 24px 80px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(13,24,19,.52); backdrop-filter: blur(3px); }
#upload-form { padding: 26px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.dialog-heading h2 { font-size: 25px; }
.close-button { border: 0; background: none; color: var(--muted); font-size: 30px; line-height: 1; }
.dropzone { padding: 34px 20px; place-items: center; border: 1px dashed #9eada5; border-radius: 12px; background: #f7faf8; color: var(--green); text-align: center; }
.dropzone input { max-width: 290px; border: 0; box-shadow: none; }
.dropzone span { color: var(--muted); font-weight: 400; }
.dialog-note { margin: 16px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
#toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: 420px; padding: 13px 16px; border-radius: 10px; background: var(--ink); color: white; box-shadow: 0 8px 30px rgba(0,0,0,.2); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: var(--red); }
.login-page { min-height: 100vh; }
.login-shell { min-height: 100vh; max-width: none; padding: 24px; display: grid; place-items: center; }
.login-card { width: min(420px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 18px 60px rgba(22,38,31,.1); }
.login-card .brand-mark { margin-bottom: 28px; }
.login-card h1 { font-size: 34px; }
.login-intro { margin-bottom: 24px; color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 17px; }
.login-form .button { margin-top: 4px; }
.login-error { padding: 11px 13px; border-radius: 8px; background: var(--red-soft); color: var(--red); font-size: 13px; }
@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .document-panel { min-height: 0; }
  .actionbar { align-items: stretch; flex-direction: column; }
  .actionbar > div:last-child { flex-wrap: wrap; width: 100%; }
  .actionbar .button { flex: 1; }
  .overview-tools { align-items: flex-start; flex-direction: column; }
  .filter-controls { width: 100%; flex-wrap: wrap; }
  .filter-controls label { flex: 1; }
}
@media (max-width: 620px) {
  .topbar { padding-inline: 16px; }
  .brand small { display: none; }
  main { padding: 32px 14px 80px; }
  .stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  label.wide { grid-column: auto; }
  .positions-heading { align-items: flex-start; flex-direction: column; }
  .filter-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-controls .button { grid-column: 1 / -1; }
  .receipt-table th:nth-child(3), .receipt-table td:nth-child(3) { display: none; }
}
