/* Assouline reconciliation — stylesheet (Step 16, D38). System fonts only, no external asset, no inline style
   (CSP style-src 'self'). Identity after assouline.com: ink on paper, hairlines instead of boxes, a Didot-style
   serif for display and numerals, a geometric sans for uppercase labels, deep red used sparingly. Every status
   colour travels with a text label (chips, badges, KPI captions); nothing is conveyed by colour alone. */

:root {
  --paper: #ffffff;
  --surface: #f7f5f1;
  --ink: #1c1c1c;
  --muted: #666e75;            /* 4.8:1 on --surface and 5.2:1 on --paper; the brief's #6c757d is 4.3:1 on --surface */
  --hairline: #e6e2dc;
  --red: #b3261e;

  --c-matched: #1f7a4d;   --t-matched: #eef7f2;   --b-matched: #c3dfcf;
  --c-missing: #b3261e;   --t-missing: #fbeeed;   --b-missing: #ead0cd;
  --c-mismatch: #b7791f;  --c-mismatch-ink: #8a5a12; --t-mismatch: #fbf3e6; --b-mismatch: #e9d4ad;
  --c-pending: #2b5fa3;   --t-pending: #eef3fa;   --b-pending: #c7d6ea;
  --c-returns: #6b4ea0;   --t-returns: #f3eff9;   --b-returns: #d6cbe8;
  --c-unknown: #666e75;   --t-unknown: #f3f2ef;   --b-unknown: #dcd8d1;

  --font-display: "Didot", "Bodoni 72", "Bodoni MT", "Playfair Display", Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 3px;
  --gutter: 24px;
  --max: 1400px;
}

/* ---------------------------------------------------------------- base ---------------------------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

a { color: inherit; }
code { font-family: var(--font-mono); font-size: 0.92em; }
time { font-variant-numeric: tabular-nums; }

.num, td.num, th.num, .kpi-value, .table-count, .page-indicator { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Keyboard focus is always visible; mouse focus stays quiet. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }

/* Uppercase small labels: the geometric-sans voice of the identity */
.eyebrow, .f-label, .kpi-label, .detail-heading, thead th, .facts caption, .chip, .badge {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.section-title { font-family: var(--font-display); font-weight: 400; font-size: 24px; line-height: 1.1; margin: 0; letter-spacing: 0.005em; }
.wordmark { display: block; height: 22px; width: auto; }
.wordmark-link { display: inline-flex; text-decoration: none; }
.logo-centre { display: inline-block; height: auto; vertical-align: middle; }
.inline-form { display: inline; margin: 0; }

/* ---------------------------------------------------------------- forms --------------------------------- */

.field { display: block; margin-bottom: 18px; }
.field-label { display: block; margin-bottom: 8px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.field-hint { text-transform: none; letter-spacing: 0; font-size: 11px; }
.field-input, .input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}
.field-input:hover, .input:hover { border-color: #c9c3ba; }
.field-input:focus-visible, .input:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
select.input { appearance: auto; }
select.input option:disabled { color: #a9a39b; }

.button {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  min-height: 44px; padding: 0 20px;
  border-radius: var(--radius); border: 1px solid var(--ink);
  background: var(--paper); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.button-primary { width: 100%; background: var(--ink); color: var(--paper); }
.button-primary:hover { background: #000; }
.button-ghost { border-color: var(--hairline); color: var(--ink); }
.button-ghost:hover { border-color: var(--ink); }
.button-link { font: inherit; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; background: none; border: none; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.alert { margin: 0 0 16px; padding: 10px 12px; border-left: 2px solid var(--red); color: var(--red); background: #fbeeed; font-size: 14px; }
.notice { margin: 0 0 16px; padding: 10px 12px; border-left: 2px solid var(--muted); background: var(--surface); font-size: 14px; }

/* ---------------------------------------------------------------- login / password ---------------------- */

.page-auth { background: var(--paper); }

.wall { position: fixed; inset: 0; z-index: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: var(--wall-gap);
  --wall-gap: 14px;
  --cover-h: calc((100vh - 2 * var(--wall-gap)) / 3);
  --cover-w: calc(var(--cover-h) * 0.8);
}
.wall-row { display: flex; width: max-content; will-change: transform; animation: drift 100s linear infinite; }
.wall-row-2 { animation-direction: reverse; animation-duration: 130s; }
.wall-row-3 { animation-duration: 85s; }
.wall-track { display: flex; }
.wall-cover { display: block; width: var(--cover-w); height: var(--cover-h); object-fit: cover; margin-right: var(--wall-gap); background: var(--paper); }
.wall-scrim { position: absolute; inset: 0; background: radial-gradient(ellipse 60% 70% at 50% 50%, rgba(255,255,255,0.62) 0%, rgba(255,255,255,0.34) 60%, rgba(255,255,255,0.22) 100%); }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .wall-row { animation-play-state: paused; }
}

.auth { position: relative; z-index: 1; flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--hairline); border-radius: 4px; padding: 36px 36px 28px; box-shadow: 0 18px 50px rgba(28,28,28,0.10), 0 1px 0 rgba(28,28,28,0.06); }
.auth-head { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 28px; }
.auth-head .wordmark { height: 26px; }
.auth-head .eyebrow { margin: 0; }
.auth-title { font-family: var(--font-display); font-weight: 400; font-size: 28px; line-height: 1.1; margin: 0 0 22px; text-align: center; }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--hairline); color: var(--muted); font-size: 12px; }
.auth-foot .logo-centre { height: 26px; width: auto; }
.auth-foot-split { justify-content: space-between; }

/* ---------------------------------------------------------------- dashboard shell ----------------------- */

/* Loading state while a filter, a KPI card or a page link reloads the dashboard in place (D42):
   a thin bar sweeps under the top bar and the content dims; the fresh content fades in. */
body.is-loading .dashboard { opacity: 0.45; pointer-events: none; transition: opacity 160ms ease; }
body.is-loading::after { content: ""; position: fixed; top: 0; left: 0; height: 3px; width: 28%; background: var(--ink); z-index: 20; animation: sweep 900ms ease-in-out infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(360%); } }
.dashboard.is-fresh { animation: fadein 220ms ease-out; }
@keyframes fadein { from { opacity: 0.45; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  body.is-loading::after { animation: none; width: 100%; opacity: 0.5; }
  .dashboard.is-fresh { animation: none; }
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px var(--gutter); border-bottom: 1px solid var(--hairline); background: var(--paper); }
.topbar-brand { display: flex; align-items: center; gap: 22px; min-width: 0; }
.topbar-title { white-space: nowrap; }
.topbar-nav { display: flex; align-items: center; gap: 16px; }
.topbar-user { color: var(--muted); font-size: 12px; }

.dashboard { flex: 1; width: 100%; max-width: var(--max); margin: 0 auto; padding: 22px var(--gutter) 40px; display: flex; flex-direction: column; gap: 26px; }
.dashboard > .page-head + .banner { margin-top: -6px; }

.foot { border-top: 1px solid var(--hairline); padding: 14px var(--gutter); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.foot p { margin: 0; }
.foot-credit { display: inline-flex; align-items: center; gap: 8px; }
.foot .logo-centre { height: 20px; width: auto; }

/* ---------------------------------------------------------------- banner -------------------------------- */

.banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; background: var(--surface); border-left: 2px solid var(--ink); }
.banner-text { margin: 0; font-size: 15px; line-height: 1.5; }
.banner-text time { font-weight: 600; }

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-weight: 400; font-size: 32px; line-height: 1.1; margin: 0; letter-spacing: 0.005em; }

/* Chips and badges: colour + text, always */
.chip, .badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--b-unknown); border-radius: 999px; background: var(--t-unknown); color: var(--c-unknown); white-space: nowrap; line-height: 1.4; }
.chip::before, .badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip-type::before { display: none; }
.chip-matched, .badge-live { color: var(--c-matched); background: var(--t-matched); border-color: var(--b-matched); }
.chip-missing_in_netsuite { color: var(--c-missing); background: var(--t-missing); border-color: var(--b-missing); }
.chip-amount_mismatch, .badge-warn { color: var(--c-mismatch-ink); background: var(--t-mismatch); border-color: var(--b-mismatch); }
.chip-pending_integration { color: var(--c-pending); background: var(--t-pending); border-color: var(--b-pending); }
.chip-returns_attention { color: var(--c-returns); background: var(--t-returns); border-color: var(--b-returns); }
.chip-unknown, .badge-muted, .chip-type { color: var(--c-unknown); }
.chip-shipping_tax { color: var(--c-unknown); background: var(--t-unknown); border-color: #b8b1a7; }  /* D52: the shipping-tax pattern rows read grey, like their tile */
.badge { font-weight: 600; }

/* ---------------------------------------------------------------- KPI row ------------------------------- */

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 28px; }  /* six tiles, three per row: no truncated label */
.kpi { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 16px 0 14px; border-top: 3px solid var(--ink); text-decoration: none; color: inherit; }
.kpi:hover .kpi-label, .kpi[aria-current="true"] .kpi-label { color: var(--ink); }
.kpi[aria-current="true"] .kpi-label { text-decoration: underline; text-underline-offset: 4px; }
.kpi-label { white-space: normal; }
.kpi-value { font-family: var(--font-display); font-size: 52px; line-height: 1; letter-spacing: -0.01em; }
.kpi-caption { color: var(--muted); font-size: 12px; }
.kpi-matched { border-top-color: var(--c-matched); }               .kpi-matched .kpi-value { color: var(--c-matched); }
.kpi-missing_in_netsuite { border-top-color: var(--c-missing); }   .kpi-missing_in_netsuite .kpi-value { color: var(--c-missing); }
.kpi-amount_mismatch { border-top-color: var(--c-mismatch); }      .kpi-amount_mismatch .kpi-value { color: var(--c-mismatch); }
.kpi-returns_attention { border-top-color: var(--c-returns); }     .kpi-returns_attention .kpi-value { color: var(--c-returns); }
.kpi-shipping_tax { border-top-color: #b8b1a7; }                 .kpi-shipping_tax .kpi-value { color: var(--muted); }  /* D49: noted, not alarming */

.empty-state { padding: 18px 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.empty-state p { margin: 8px 0 0; }

/* ---------------------------------------------------------------- filters ------------------------------- */

.filters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.6fr) auto; gap: 14px 12px; align-items: end; padding: 18px 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; }
.f-hint { text-transform: none; letter-spacing: 0; color: #a9a39b; font-size: 10px; }
.f-actions { display: flex; gap: 8px; }
.f-actions .button-primary { width: auto; }

/* ---------------------------------------------------------------- exception table ----------------------- */

.table-head { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.table-count { margin: 0; color: var(--muted); font-size: 13px; }
.export-link { margin-left: auto; min-height: 36px; font-size: 11px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; vertical-align: top; border-bottom: 1px solid var(--hairline); }
thead th { font-weight: 500; padding-top: 6px; padding-bottom: 8px; border-bottom-color: var(--ink); }
th.num, td.num { text-align: right; white-space: nowrap; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--surface); }
tr.row.is-open td { background: var(--surface); border-bottom-color: transparent; }
td.diff { color: var(--red); font-weight: 600; }
td.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.cell-date { color: var(--muted); font-size: 13px; }
.cell-reason { white-space: nowrap; color: var(--ink); font-size: 13px; }
.cell-store { white-space: nowrap; }
.cell-order { min-width: 130px; }
.row-toggle { font: inherit; font-weight: 600; background: none; border: none; padding: 0; color: var(--ink); cursor: pointer; text-align: left; }
.row-toggle-name { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #b8b1a7; }
.row-toggle-name:hover, tr.row:hover .row-toggle-name { text-decoration-color: var(--ink); }
.table-hint { margin: 0; color: var(--muted); font-size: 12px; }
.order-id { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sub { display: block; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cell-expand { width: 1%; text-align: right; white-space: nowrap; }
.row-toggle-details { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 10px; border: 1px solid var(--hairline); border-radius: 999px; font-weight: 500; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); background: var(--paper); }
.row-toggle-details:hover, tr.row:hover .row-toggle-details { border-color: var(--ink); }
.chevron { display: inline-block; width: 7px; height: 7px; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: rotate(45deg) translateY(-2px); transition: transform 120ms ease; }
.row-toggle[aria-expanded="true"] .chevron { transform: rotate(-135deg) translateY(-1px); }
tr.detail-row > td { padding: 0 0 24px; background: var(--surface); max-width: 0; }  /* the detail never widens the table */
.detail-slot { overflow-x: auto; }
.detail-slot.is-loading { color: var(--muted); padding: 14px 12px; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; }
.page-indicator { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- detail fragment ----------------------- */

.detail { background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 24px; }
.detail-head { display: flex; flex-direction: column; gap: 10px; }
.detail-explanation { margin: 0; font-family: var(--font-display); font-size: 19px; line-height: 1.3; }
.detail-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.label-warning { margin: 4px 0 0; padding: 8px 12px; border-left: 2px solid var(--c-mismatch); background: var(--t-mismatch); color: var(--c-mismatch-ink); font-size: 13px; }
.label-note { margin: 0; padding: 8px 12px; border-left: 2px solid var(--c-pending); background: var(--t-pending); color: var(--c-pending); font-size: 13px; }
.detail-block { min-width: 0; }
.detail-heading { margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--ink); color: var(--ink); }
.detail-heading .muted { text-transform: none; letter-spacing: 0; }
.facts-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 28px; }
.facts-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 0 28px; }
.facts { font-size: 13px; }
.facts caption { text-align: left; padding: 8px 0 6px; }
.facts th, .facts td { padding: 5px 0; border-bottom: 1px dotted var(--hairline); vertical-align: baseline; }
.facts th { font-weight: 400; color: var(--muted); width: 44%; padding-right: 10px; }
.facts td { word-break: break-word; }
.facts td.num { text-align: right; }
.ident-value { word-break: break-all; }
.copy { font: inherit; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 7px; margin-left: 6px; border: 1px solid var(--hairline); border-radius: 999px; background: var(--paper); color: var(--muted); cursor: pointer; vertical-align: middle; }
.copy:hover { border-color: var(--ink); color: var(--ink); }
.copy.is-done { color: var(--c-matched); border-color: var(--b-matched); }
.cell-id { white-space: nowrap; }
.amounts, .lines, .related { font-size: 13px; }
.amounts th, .amounts td, .lines th, .lines td, .related th, .related td { padding: 7px 10px; }
.amounts tbody th { font-weight: 400; }
.amounts tr.diff td, .amounts tr.diff th { color: var(--red); font-weight: 600; }
.amounts tr.basis-not_compared td, .amounts tr.basis-not_compared th { color: var(--muted); }
.amounts tr.basis-allocation td, .amounts tr.basis-allocation th { color: #8a5a12; }
.basis-note { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 400; margin-left: 6px; color: inherit; opacity: 0.85; }
.lines th.group { text-align: center; border-left: 1px solid var(--hairline); border-bottom-color: var(--hairline); }
.lines td:nth-child(7), .lines th:nth-child(7) { border-left: 1px solid var(--hairline); }
.unmatched-line { font-style: italic; }

/* ---------------------------------------------------------------- responsive ---------------------------- */

@media (max-width: 1280px) {
  .row-toggle-details .toggle-text { display: none; }
  .row-toggle-details { width: 32px; height: 32px; padding: 0; justify-content: center; }
}

@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .f-search { grid-column: span 2; }
  .facts-3 { grid-template-columns: 1fr; gap: 10px 0; }
  .facts-2 { grid-template-columns: 1fr; gap: 12px 0; }
  .kpi-value { font-size: 44px; }
}

@media (max-width: 720px) {
  :root { --gutter: 16px; }
  .topbar { padding: 14px var(--gutter); }
  .topbar-title { display: none; }
  .dashboard { gap: 24px; padding-top: 16px; }
  .page-title { font-size: 26px; }
  .banner { padding: 12px 14px; }

  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
  .kpi-shopify_orders { grid-column: 1 / -1; }
  .kpi-value { font-size: 40px; }

  .filters { grid-template-columns: 1fr 1fr; }
  .f-search, .f-actions { grid-column: 1 / -1; }
  .f-actions .button { flex: 1; }

  .table-head .export-link { margin-left: 0; }
  /* Rows become cards: each cell shows its column label */
  .exceptions thead { display: none; }
  .exceptions, .exceptions tbody, .exceptions tr, .exceptions td { display: block; }
  .exceptions tr.row { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px 48px 14px 0; border-bottom: 1px solid var(--hairline); }
  .exceptions tr.row:hover td { background: transparent; }
  .exceptions tr.row td { border: 0; padding: 0; min-width: 0; }
  .exceptions td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
  .exceptions td.num { text-align: left; }
  .exceptions .cell-order { grid-column: 1 / -1; }
  .exceptions .cell-reason { white-space: normal; }
  .exceptions .cell-expand { position: absolute; top: 12px; right: 0; width: auto; }
  .exceptions .row-toggle-details .toggle-text { display: none; }
  .exceptions .row-toggle-details { width: 32px; height: 32px; padding: 0; justify-content: center; }
  .exceptions tr.detail-row > td { padding: 0 0 18px; }
  .exceptions tr.detail-row[hidden] { display: none; }
  .exceptions tr.empty-row td.empty { display: block; }
  .detail { padding: 16px; }
  .detail-explanation { font-size: 17px; }

  .foot { flex-direction: column; align-items: flex-start; gap: 6px; }
}

@media (max-width: 480px) {
  .wall { --wall-gap: 10px; --cover-w: calc((100vw - 2 * var(--wall-gap)) / 3); --cover-h: calc(var(--cover-w) * 1.25); justify-content: space-evenly; }
  .auth { padding: 24px 16px; align-items: center; }
  .auth-card { padding: 28px 20px 22px; max-width: none; }
  .auth-head .wordmark { height: 22px; }
  .auth-title { font-size: 26px; }
  .kpi-value { font-size: 36px; }
  .banner-text { font-size: 14px; }
}

/* ---------------------------------------------------------------- print --------------------------------- */

@media print {
  .wall, .topbar-nav, .filters, .copy, .pagination, .cell-expand, .foot-credit { display: none !important; }
  body { background: #fff; color: #000; }
  .dashboard { padding: 0; }
  .detail { border-color: #999; }
  table { font-size: 11px; }
  th, td { border-bottom: 1px solid #999; }
  tr.detail-row[hidden] { display: none; }
  a { color: inherit; text-decoration: none; }
}
