:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #202b24;
  background: #f5f6f1;
  --ink: #202b24;
  --muted: #59675d;
  --forest: #24523f;
  --forest-dark: #18392f;
  --line: #dce2d9;
  --surface: #fff;
  --tint: #f6f8f4;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid #507d61; outline-offset: 3px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  z-index: 3;
  left: 16px;
  top: 10px;
  transform: translateY(-160%);
  padding: 10px 14px;
  color: #fff;
  background: var(--forest-dark);
  border-radius: 8px;
}

.skip-link:focus { transform: none; }

.demo-workspace-notice {
  margin: 0;
  padding: 6px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #513b12;
  background: #fff0c4;
}
html[data-environment="demo"] :is(a[href="./backups.html"], a[href="./invoice123.html"],
  #claude-connection, #invoice123-panel, .op123-panel, .invoice123-notice) { display: none; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner, .workspace { width: min(100% - 64px, 1240px); margin-inline: auto; }

.header-inner {
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 38px;
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -.025em;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--forest-dark);
}

.brand-mark::before, .brand-mark::after {
  content: "";
  position: absolute;
  transform: rotate(45deg);
  background: #d6e8be;
  border-radius: 70% 0 70% 0;
}

.brand-mark::before { inset: 7px 11px 13px 13px; }
.brand-mark::after { inset: 13px 14px 7px 10px; }

.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.site-nav a {
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover { color: var(--forest-dark); background: var(--tint); }
.demo-label { margin-left: auto; color: var(--muted); font-size: 12px; text-align: right; }
.workspace { padding-block: 38px 64px; }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(28px, 4.25vw, 42px);
  line-height: 1.12;
  font-weight: 750;
  letter-spacing: -.046em;
}

.page-heading p { margin: 10px 0 0; font-size: 14px; color: var(--muted); line-height: 1.5; }
.page-actions, .selection-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.page-actions { flex: 0 0 auto; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 39px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--forest-dark);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
}

.button--primary { background: var(--forest); color: #fff; }
.button--primary:hover:not(:disabled) { background: var(--forest-dark); }
.button--secondary { background: var(--surface); border-color: #cdd7cc; }
.button--secondary:hover:not(:disabled), .button--quiet:hover:not(:disabled) { background: #eaf0e8; }
.button-icon { font-size: 19px; line-height: .8; font-weight: 400; }

.trade-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 32px;
  padding: 23px 26px;
  border-radius: var(--radius);
  background: var(--forest-dark);
  color: #fff;
}

.trade-summary > * { min-width: 0; }
.trade-route, .trade-contracts { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 24px; }
.trade-route { flex: 1 1 auto; }
.trade-contracts { flex: 0 1 auto; }
.trade-party, .trade-contract { display: grid; gap: 4px; }
.trade-party-label, .trade-contract-label, .trade-summary .muted { color: #c6dace; font-size: 12px; }
.trade-party-name { font-size: 21px; font-weight: 700; line-height: 1.2; letter-spacing: -.025em; }
.trade-arrow { color: #acd0bd; font-size: 21px; }
.trade-contract { padding-left: 20px; border-left: 1px solid #426256; }
.trade-contract-value { font-weight: 650; font-size: 15px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 176px), 1fr));
  gap: 12px;
  margin-top: 14px;
}

.metric {
  display: grid;
  align-content: start;
  min-width: 0;
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.metric-label { color: var(--muted); font-size: 12px; font-weight: 650; line-height: 1.35; }
.metric-value {
  margin-top: 5px;
  color: var(--forest-dark);
  font-size: clamp(19px, 2.7vw, 25px);
  line-height: 1.2;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}

.metric-note { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.panel {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  scroll-margin-top: 14px;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 21px;
}

.panel-heading h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.023em; }
.panel-meta { color: var(--muted); font-size: 13px; }
.table-scroll { position: relative; overflow-x: auto; }
.table-scroll:focus-visible { outline-offset: -3px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-scroll table { min-width: 420px; }
.table-scroll .load-table { min-width: 770px; }
th, td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; text-align: left; }
th { color: var(--muted); background: var(--tint); font-size: 11px; font-weight: 700; letter-spacing: .015em; white-space: nowrap; }
.table-scroll tr > :first-child { width: 44px; padding-inline: 20px 4px; }
.table-scroll tr > :last-child { padding-right: 20px; text-align: right; }
.table-scroll tbody tr:hover { background: #f8faf7; }
.table-scroll tbody tr:has(input:checked) { background: #eef5ed; }
td input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--forest); vertical-align: middle; }
.numeric { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-title { display: block; font-weight: 650; }
.cell-detail { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.cell-detail--warning { color: #912f22; font-weight: 650; }
.document-ref { display: block; padding: 2px 6px; border: 1px solid var(--line); border-radius: 4px; background: #f5f7f4; color: var(--forest-dark); font-size: 12px; white-space: nowrap; }
.document-ref:hover { background: #eaf0e8; }
.document-ref + .document-ref { margin-top: 4px; }
.row-action {
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--forest-dark);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.row-action:hover { background: #eaf0e8; }
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 5px;
  background: #edf0eb;
  color: #455449;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.badge--success { background: #e6f1e6; color: #2d5c3c; }
.badge--warn { background: #f7edd4; color: #74531b; }
.badge--neutral { background: #edf0eb; color: #455449; }

.selection-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: #eef5ed;
}

.selection-count { color: var(--forest-dark); font-size: 13px; font-weight: 650; }
.selection-buttons { justify-content: flex-end; }
.draft-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.document { display: grid; gap: 7px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; text-align: left; }
.document:hover { background: #f4f7f3; }
.document-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.document-header h3 { margin: 0; font-size: 15px; }
.document-meta { margin: 5px 0 0; color: var(--muted); }
.document-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.empty-state { margin: 0; padding: 7px 9px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.muted { color: var(--muted); }

dialog {
  width: min(640px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 80px #142c2255;
}

dialog::backdrop { background: #12251dd0; }
.dialog-header { position: sticky; z-index: 1; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--surface); }
.dialog-header h2 { margin: 0; font-size: 21px; letter-spacing: -.025em; }
.dialog-header p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.dialog-body { padding: 20px 22px; }
.dialog-body > :first-child { margin-top: 0; }
.dialog-footer { position: sticky; z-index: 1; bottom: 0; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--line); background: var(--surface); }
.stack { display: grid; gap: 14px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; align-content: start; color: var(--ink); font-size: 13px; font-weight: 600; }
.field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%;
  min-width: 0;
  min-height: 41px;
  padding: 8px 10px;
  border: 1px solid #cdd7cc;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 400;
}

.field textarea { min-height: 84px; resize: vertical; }
.field small { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.4; }
.notice, .error { padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.45; }
.notice { background: #edf4eb; color: #31513c; }
.error { background: #fbefeb; color: #912f22; }
.error:empty { display: none; }

.toast {
  position: fixed;
  z-index: 2;
  right: 20px;
  bottom: 20px;
  max-width: min(380px, calc(100% - 40px));
  padding: 12px 16px;
  border-radius: 9px;
  background: var(--forest-dark);
  color: #fff;
  box-shadow: 0 12px 32px #142c2244;
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 820px) {
  .header-inner, .workspace { width: min(100% - 36px, 1240px); }
  .header-inner { gap: 16px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .workspace { padding-top: 28px; }
}

@media (max-width: 590px) {
  .header-inner, .workspace { width: calc(100% - 28px); }
  .header-inner { flex-wrap: wrap; gap: 0 12px; min-height: 0; padding-block: 10px 5px; }
  .site-nav { order: 2; flex: 1 1 100%; margin-top: 7px; margin-left: -7px; }
  .site-nav a { padding-inline: 7px; }
  .demo-label { max-width: 130px; }
  .page-heading { margin-bottom: 18px; }
  .trade-summary { padding: 17px; }
  .trade-route, .trade-contracts { gap: 10px 13px; }
  .trade-party-name { font-size: 17px; }
  .trade-contract { padding-left: 12px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 9px; }
  .metric { padding: 12px; }
  .panel-heading { padding: 14px; }
  .document, .empty-state { padding-inline: 14px; }
  .selection-actions { align-items: flex-start; flex-direction: column; padding-inline: 14px; }
  .selection-buttons { justify-content: flex-start; }
  .table-scroll .load-table { min-width: 675px; }
  .load-table th, .load-table td { padding-inline: 9px; }
  .table-scroll .load-table tr > :first-child { padding-inline: 12px 4px; }
  .table-scroll .load-table tr > :last-child { position: sticky; right: 0; padding-inline: 6px; border-left: 1px solid var(--line); }
  .load-table td:last-child { background: var(--surface); }
  .load-table tr:has(input:checked) td:last-child { background: #eef5ed; }
}

@media (max-width: 420px) {
  .field-grid { grid-template-columns: 1fr; }
  .dialog-header, .dialog-body, .dialog-footer { padding-inline: 15px; }
}
