@font-face {
  font-family: Inter;
  src: url("/fonts/inter-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: Inter, system-ui, sans-serif;
  color: #192420;
  background: #f7f8f6;
  --ink: #192420;
  --muted: #56655d;
  --border: #e0e6e1;
  --green: #1a4a36;
  --green-hover: #123c2b;
  --paper: #f3f6f3;
  --surface: #fff;
  --tint: #e8f2eb;
  --danger: #92362d;
  --radius: 12px;
  --shadow: 0 1px 2px #172d2410;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, label.button, select, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
:focus-visible { outline: 2px solid #43825f; outline-offset: 3px; }

.top {
  min-height: 66px;
  padding: 0 max(24px, calc((100vw - 1320px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}

.brand, .header-start, .top-nav { display: flex; align-items: center; }
.brand { gap: 4px; font-size: .99rem; font-weight: 750; letter-spacing: -.035em; }
.brand-accent { color: var(--green); }
.mark {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  margin-right: 7px;
  border-radius: 9px;
  background: var(--green);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
}
.header-start { gap: 14px; min-width: 0; }
.top-nav { gap: 8px; }
.top-nav button, .menu-toggle {
  padding: 6px 11px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
}
.top-nav button:hover, .menu-toggle:hover { background: var(--paper); color: var(--ink); }
.menu-toggle { display: none; align-items: center; gap: 6px; }
.menu-icon { font-size: 1rem; line-height: 1; }

main { max-width: 1168px; margin: auto; padding: 40px 24px; }
.workspace-shell {
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
  gap: 34px;
  max-width: 1368px;
  margin: auto;
  padding: 36px 24px 56px;
}
.workspace-shell main { width: 100%; min-width: 0; max-width: none; margin: 0; padding: 0; }
.workspace-sidebar { position: sticky; top: 24px; align-self: start; padding-right: 14px; border-right: 1px solid var(--border); }
.workspace-menu { display: grid; gap: 4px; }
.workspace-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
}
.workspace-menu a:hover { background: var(--paper); color: var(--ink); }
.workspace-menu a[aria-current] { background: var(--tint); color: var(--green); font-weight: 750; }
.navigation-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(310px, 88vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0 14px 14px 0;
}
.navigation-drawer[open] { animation: drawer-in .22s ease-out; }
.drawer-panel { display: flex; flex-direction: column; min-height: 100%; padding: 16px; }
.drawer-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.drawer-panel .workspace-menu { padding: 12px 0; }
body:has(.navigation-drawer[open]) { overflow: hidden; }
@keyframes drawer-in {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .navigation-drawer[open] { animation: none; }
}

.intro { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: .7rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3, p { margin: 0; }
h1 { margin-bottom: 7px; font-size: clamp(2rem, 4vw, 2.8rem); letter-spacing: -.055em; line-height: 1.12; font-weight: 750; overflow-wrap: anywhere; }
h2 { font-size: 1.18rem; line-height: 1.25; letter-spacing: -.03em; font-weight: 700; }
h3 { font-size: .98rem; line-height: 1.35; letter-spacing: -.015em; font-weight: 700; }
p, small, dt { color: var(--muted); }
small, dt { font-size: .77rem; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 650;
  white-space: nowrap;
}
.primary { background: var(--green); color: #fff; }
.primary:hover { background: var(--green-hover); }
.outline, .close { background: var(--surface); border-color: var(--border); color: var(--ink); }
.outline:hover, .close:hover { background: var(--paper); border-color: #cbd8ce; }
.close { min-width: 40px; padding: 6px; font-size: 1.21rem; line-height: 1; }
label.button { position: relative; }
label.button:focus-within { outline: 2px solid #43825f; outline-offset: 3px; }
label.button input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.danger-outline { background: var(--surface); border-color: #e4c1bc; color: var(--danger); }
.danger-outline:hover { background: #faeeec; }
.danger { background: var(--danger); color: white; }
.danger:hover { background: #76271f; }

select, input:not([type=file], [type=checkbox]), textarea {
  min-width: 0;
  min-height: 39px;
  padding: 7px 9px;
  border: 1px solid #d5ded7;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
textarea { width: 100%; resize: vertical; }
.stack { display: grid; gap: 12px; margin: 15px 0 0; }
.stack label, .store-picker, .queue-filters label, .inline-form label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: .79rem; font-weight: 650; }
.stack input:not([type=checkbox]), .stack select, .store-picker select, .queue-filters input { width: 100%; }
.stack fieldset { min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.stack legend { font-size: .83rem; font-weight: 700; }
.stack button { justify-self: start; }
.inline-form, .activity-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-bottom: 8px; }
.inline-form label { flex: 1; }
.activity-actions .inline-form { margin: 0; }
.feedback:not(:empty), #auth-error:not(:empty) { margin-bottom: 12px; }
#error, #auth-error, #clear-data-error, #confirmation-error, #merge-error { color: var(--danger); }
#error { margin-bottom: 15px; padding: 10px 12px; border: 1px solid #f2d4ce; border-radius: 8px; background: #faeeec; }

#controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 18px; color: var(--muted); font-size: .83rem; }
#controls input { margin-left: 6px; }
#import-status { flex: 1 1 170px; min-width: 0; overflow-wrap: anywhere; }
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.summary > div { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.summary span { color: var(--muted); font-size: .79rem; font-weight: 550; }
.summary strong { font-variant-numeric: tabular-nums; font-size: 1.65rem; font-weight: 700; letter-spacing: -.045em; line-height: 1.1; }
.summary > div:nth-child(2) strong { color: var(--danger); }
.workspace { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.workspace-head { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 10px 16px; min-height: 66px; padding: 16px 19px; }
.workspace-head h2 { align-self: center; }
.queue-filters { display: flex; align-items: end; flex-wrap: wrap; gap: 8px 10px; }
.queue-filters label:first-child { flex: 1 1 140px; }
.queue-filters select, .queue-filters input { min-height: 36px; }
.empty { padding: 54px 18px; text-align: center; }
.empty span { display: inline-grid; place-items: center; width: 42px; height: 42px; margin-bottom: 11px; border-radius: 10px; background: var(--tint); color: var(--green); font-size: 1.3rem; }
.empty p { margin-top: 5px; }
.account-list { margin: 0; padding: 0; list-style: none; }
.account {
  display: grid;
  grid-template-columns: minmax(115px, 1.65fr) minmax(84px, .85fr) minmax(92px, .85fr) minmax(115px, 1fr) minmax(72px, auto);
  align-items: center;
  gap: 12px;
  padding: 13px 19px;
}
.account-columns { padding-block: 8px; border-block: 1px solid var(--border); background: var(--paper); color: var(--muted); font-size: .74rem; font-weight: 650; }
.account + .account { border-top: 1px solid var(--border); }
.account strong { font-size: .875rem; font-weight: 650; overflow-wrap: anywhere; }
.account small { display: block; margin-top: 2px; }
.account > .button { justify-self: end; }
.queue-rows .account:hover { background: #fafcf9; }
.queue-rows .cell-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.status { display: inline-flex; align-items: center; justify-self: start; gap: 5px; border-radius: 20px; padding: 4px 8px; font-size: .73rem; font-weight: 700; white-space: nowrap; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.overdue { background: #f9eae7; color: #8e392f; }
.status.due { background: #faf0da; color: #785711; }
.status.upcoming { background: var(--tint); color: #2c633e; }
.status.review { background: #edf0ee; color: #46554e; }
.follow-up-state { font-weight: 650; }
#data-tools { margin-top: 17px; }
#data-tools summary { font-size: .86rem; font-weight: 650; }
#data-tools p { margin: 6px 0; }

.panel { padding: 20px; }
.auth-main { max-width: 448px; padding-top: clamp(42px, 11vh, 130px); }
.auth-card { padding: 28px; }
.auth-card h1 { margin-bottom: 14px; font-size: 2rem; }
.auth-card .stack { gap: 14px; }
.auth-card .stack button { width: 100%; margin-top: 4px; }

.access-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; align-items: start; }
.store-match { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 8px; padding: 5px 0; }
.store-match label { display: flex; align-items: center; overflow-wrap: anywhere; }
.store-match input:disabled { opacity: .55; }
.record-list { padding-left: 18px; overflow-wrap: anywhere; font-size: .85rem; }
.estimate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 12px; margin-top: 13px; }
.estimate-card { padding: 15px; border: 1px solid var(--border); border-radius: 10px; background: var(--paper); overflow-wrap: anywhere; }
.estimate-card p, .estimate-card strong, .estimate-card small { display: block; margin-top: 5px; }
.estimate-card strong { color: var(--green); }
.estimate-card ul, #purchases ul { padding-left: 18px; font-size: .85rem; }
.purchase-history { margin-top: 16px; }
#purchases { margin-top: 12px; }
#purchases details { padding: 10px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.invoice-summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; list-style: none; }
.invoice-summary::-webkit-details-marker { display: none; }
.invoice-summary::before { content: ""; width: 6px; height: 6px; margin-right: 3px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); }
details[open] .invoice-summary::before { transform: rotate(45deg); }
.invoice-description small { display: block; }
.invoice-total { font-variant-numeric: tabular-nums; white-space: nowrap; }
#more-purchases { margin-top: 10px; }

dialog { width: min(560px, calc(100% - 24px)); max-height: calc(100% - 26px); padding: 21px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 0 16px 48px #14271f26; }
dialog::backdrop { background: #19282077; }
#detail { width: min(650px, calc(100% - 24px)); }
.dialog-header, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dialog-header { position: sticky; top: -21px; z-index: 1; margin: -21px -21px 12px; padding: 15px 21px; border-bottom: 1px solid var(--border); background: var(--surface); }
.dialog-actions { margin-top: 9px; }
.detail-reason { margin-top: 6px; }
dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; margin: 12px 0; padding: 13px; border-radius: 8px; background: var(--paper); }
dd { margin: 3px 0 0; font-size: .88rem; overflow-wrap: anywhere; }
#facts h3 { margin-top: 13px; }
#facts details { margin: 10px 0; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; }
#facts summary { font-size: .86rem; font-weight: 650; }
#facts ul { padding-left: 20px; font-size: .86rem; }
#facts ul ul { margin: 4px 0 8px; }
.draft-label { display: block; margin: 12px 0 6px; font-weight: 650; }
#copy-status, #activity-feedback, #contact-feedback { color: var(--muted); font-size: .82rem; }
#account-tools, #retailer-contacts { margin: 15px 0; padding-top: 14px; border-top: 1px solid var(--border); }
#retailer-addresses dd { white-space: pre-line; }
.contact-list { margin: 8px 0; padding: 0; list-style: none; }
.contact-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.contact-row span, .contact-row small { display: block; margin-top: 2px; }
.contact-badge { color: var(--green); font-weight: 700; }
.contact-actions, .archive-actions, .reset-tools, .reset-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.archive-actions { margin: 9px 0; }
#archived-date { margin: 8px 0; font-size: .84rem; }
#contact-editor summary { font-weight: 650; }
#activity-title { margin: 13px 0 8px; }
#activity-log { margin: 8px 0; padding-left: 18px; font-size: .85rem; overflow-wrap: anywhere; }
#activity-log small { display: block; margin: 3px 0 7px; }
.reset-tools { margin-top: 16px; }
.reset-actions { justify-content: flex-end; }
#clear-data-description { margin: 10px 0 15px; }
#clear-data-error, #contact-feedback:not(:empty) { margin: 7px 0; }

.preview-controls, .preview-controls form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.preview-controls:has(> :not([hidden])) { margin-top: 9px; }
#preview-feedback:not(:empty) { margin-top: 8px; }
#results .account-list { margin-top: 12px; border-top: 1px solid var(--border); }
#results summary { color: var(--green); font-size: .83rem; }
#results details p { font-size: .79rem; }
.merge-help { margin: 6px 0 10px; }
.suggested-merge { display: grid; grid-template-columns: minmax(0, 2fr) minmax(100px, 1fr) auto; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.suggested-merge small { display: block; margin-top: 3px; }
.suggested-pair, .merge-fields, .merge-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.merge-fields .stack { margin: 0; }
.merge-card { padding: 10px; border: 1px solid var(--border); border-radius: 8px; overflow-wrap: anywhere; }
.merge-card h3, .merge-card p { margin: 3px 0; }

@media (max-width: 960px) {
  .workspace-shell { grid-template-columns: 155px minmax(0, 1fr); gap: 20px; }
  .workspace-sidebar { padding-right: 10px; }
  .account { gap: 8px; padding-inline: 13px; }
}
@media (max-width: 800px) {
  .workspace-shell { display: block; padding: 25px 16px 42px; }
  .workspace-sidebar { display: none; }
  .menu-toggle { display: inline-flex; }
}
@media (max-width: 680px) {
  .top { min-height: 60px; padding-inline: 14px; }
  .intro { align-items: start; flex-direction: column; gap: 13px; margin-bottom: 20px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .summary > div { padding: 12px 13px; }
  .workspace-head { align-items: start; flex-direction: column; padding: 13px; }
  .workspace-head h2 { align-self: start; }
  .queue-filters { width: 100%; }
  .queue-filters label { flex: 1 1 105px; }
  .queue-filters label:first-child { flex-basis: 100%; }
  .account-columns { display: none; }
  .account-list.queue-rows { border-top: 1px solid var(--border); }
  .account { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .account .status { align-self: start; justify-self: end; }
  .account > .button { grid-column: 1 / -1; justify-self: end; }
  .queue-rows .cell-label { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .access-grid { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 14px; }
  .auth-card { padding: 22px; }
}
@media (max-width: 520px) {
  .suggested-merge, .merge-fields { grid-template-columns: minmax(0, 1fr); }
  .suggested-merge .button { justify-self: start; }
}
@media (max-width: 380px) {
  .header-start { gap: 7px; }
  .header-start .brand { font-size: .82rem; }
  .header-start .mark { display: none; }
}

#purchase-import > summary, #purchase-import-history > summary { font-weight: 700; }
.purchase-help { margin: 7px 0; }
#purchase-import a { color: var(--green); font-size: .84rem; font-weight: 650; }
.purchase-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
#purchase-file { width: 100%; max-width: 100%; min-width: 0; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.purchase-summary { padding: 0 19px 12px; font-size: .82rem; }
.purchase-head { align-items: center; }
#purchase-error { color: var(--danger); }
#supplier-detail-content h3 { margin: 14px 0 8px; }
.supplier-invoice { padding: 8px 0; border-top: 1px solid var(--border); }
#supplier-copy-status { color: var(--muted); font-size: .83rem; }
@media (max-width: 680px) {
  .purchase-head { align-items: stretch; }
  .purchase-fields { grid-template-columns: minmax(0, 1fr); }
  .purchase-summary { padding-inline: 13px; }
}
