/* Console of the centre: a restrained monochrome look, the neutral tokens of the staff console of the platform.
   No web fonts, no images from elsewhere (CSP: style-src 'self'). */
:root {
  color-scheme: light dark;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --surface: #ffffff;
  --ground: #f4f5f7;
  --sunken: #eceef1;
  --line: #e1e4e8;
  --line-strong: #cdd1d6;
  --faint: #6b7178;
  --muted: #646a70;
  --ink: #16181b;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #c81e1e;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #16181b;
    --ground: #0c0d0f;
    --sunken: #1f2226;
    --line: #2a2e33;
    --line-strong: #3a3f45;
    --faint: #8d9298;
    --muted: #9ba1a7;
    --ink: #eceef1;
    --ok: #4cc27a;
    --warn: #f0b44c;
    --bad: #ff7b70;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 14px/1.5 var(--font-sans);
  overflow-wrap: anywhere;
}

a { color: inherit; text-underline-offset: 2px; }

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.mark {
  flex: none;
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 560px;
}

h1 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
}

p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }

.muted { color: var(--muted); }

.mono { font-family: var(--font-mono); }

[hidden] { display: none !important; }

.who {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 0 auto;
  min-width: 0;
}

.who .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button, .button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.link {
  flex: none;
  white-space: nowrap;
  padding: 0;
  border: 0;
  background: none;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.primary, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  font-weight: 500;
  text-decoration: none;
}

.primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.status {
  min-height: 21px;
  margin-top: 12px;
  color: var(--muted);
}

.status.bad { color: var(--bad); }

.nav {
  display: flex;
  gap: 4px;
  min-width: 0;
}

.nav a {
  flex: none;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}

.nav a[aria-current="page"] {
  background: var(--sunken);
  color: var(--ink);
  font-weight: 500;
}

.secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

/* Screens */

.screen-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 4px;
}

.screen-title { min-width: 0; }
.screen-title h1 { margin: 0; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pick { min-width: 0; max-width: 100%; }
.pick .eyebrow { display: block; }
.pick-row { display: flex; gap: 8px; max-width: 100%; }

select {
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

input[type="text"], input[type="date"] {
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.search { margin: 0 0 16px; }
.search-field { flex: 0 1 420px; }
.search-field input { width: 100%; font-family: var(--font-mono); }
.facts .sub { display: block; margin-top: 2px; font-size: 12px; overflow-wrap: anywhere; }

.asof { margin: 0 0 16px; font-variant-numeric: tabular-nums; }

.note { margin-top: 12px; font-size: 13px; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sales {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.sales th, .sales td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.sales thead th {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sales tbody tr:last-child > * { border-bottom: 0; }

.sales .num { text-align: right; }

.sales .partner { font-weight: 400; white-space: normal; min-width: 160px; }
.sales .name { font-weight: 600; }

.sales .sub, .sales .amount {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.sales .units { display: block; }
.sales .units.blank::before { content: "\00a0"; }
.sales .invno { display: block; margin-top: 4px; font-size: 12px; }
.sales .total { font-weight: 600; }
.sales .bad, .bad { color: var(--bad); }

.sales tr.attention > :first-child { box-shadow: inset 3px 0 0 var(--warn); }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 18px;
  white-space: nowrap;
}

.badge.ok { border-color: var(--ok); color: var(--ok); }
.badge.warn { border-color: var(--warn); color: var(--warn); }
.badge.bad { border-color: var(--bad); color: var(--bad); }

.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* Invoices */

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.pick-field { min-width: 0; max-width: 100%; }
.pick-field .eyebrow { display: block; }
.pick-field select { width: 100%; }

.crumbs { margin: 0 0 8px; font-size: 13px; }
.crumbs a { color: var(--muted); }

.card {
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px 24px;
  margin: 0;
  padding: 16px 20px;
}

.facts dt {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.facts dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.facts .total { font-weight: 600; }

.before { padding: 16px 20px; border-top: 1px solid var(--line); }

.checks { margin: 0 0 12px; padding: 0; list-style: none; }

.check {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
}

.check .what { flex: 1 1 auto; min-width: 0; }
.check .code { flex: none; color: var(--muted); font-size: 12px; }

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.dot.hollow { background: none; border: 1.5px solid currentColor; }
.check.bad .dot { color: var(--bad); }
.check.warn .dot { color: var(--warn); }

.ready { font-weight: 600; }

.code { overflow-wrap: anywhere; }

.untrusted {
  display: inline-block;
  max-width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
  unicode-bidi: isolate;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sales .item { white-space: normal; min-width: 200px; }
.sales .lineid { font-weight: 400; }
.sales .warn { color: var(--warn); }
.sales tr:target > * { background: var(--sunken); }
.card-link { text-decoration: none; }

/* Queue */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 16px;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.tabs a[aria-current="page"] { border-color: var(--ink); color: var(--ink); font-weight: 500; }
.tabs .count { font-variant-numeric: tabular-nums; font-weight: 600; }

.sales .hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.sales .hint-line { display: block; }
.sales .hint-line + .hint-line { margin-top: 2px; }
.sales .sub.warn, .warn { color: var(--warn); }

.conflict { overflow: hidden; }
.conflict.attention { box-shadow: inset 3px 0 0 var(--warn); }
.conflict-head { padding: 16px 20px 12px; }
.conflict-head p { margin: 0 0 4px; }
.conflict-head .name { font-weight: 600; }
.conflict-decide { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 16px; }
.conflict-decide form { margin: 0; }

.diff-wrap { overflow-x: auto; border-top: 1px solid var(--line); }

.versions {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.versions th, .versions td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.versions thead th {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.versions th[scope="row"] { width: 30%; font-weight: 400; }
.versions tbody tr:last-child > * { border-bottom: 0; }
.versions tr.differs > * { background: var(--sunken); }
.versions tr.differs > :first-child { box-shadow: inset 3px 0 0 var(--warn); }

mark {
  padding: 0 1px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--warn) 38%, transparent);
  outline: 1px solid color-mix(in srgb, var(--warn) 60%, transparent);
  color: inherit;
  font-weight: 600;
}

.small { font-size: 11px; }
.sales.queue .item { min-width: 280px; }
.sales.history td { white-space: normal; }
.sales.history td.num, .sales.history .term .units, .sales.history .kind .mono { white-space: nowrap; }
.sales.history .notes > .val { display: block; min-width: 150px; }
.sales.history .notes .units { display: block; margin-top: 4px; }

/* Actions: form, review, result (design §4.7) */

.action { max-width: 640px; }
.action h1 { margin-bottom: 12px; }
.action-form { margin: 0; }

.field { margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.field > label:not(.choice), .field > legend {
  display: block;
  margin: 0 0 6px;
  padding: 0;
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.field input[type="text"] { width: 100%; }
.field input[type="date"] { width: 100%; max-width: 240px; font-variant-numeric: tabular-nums; }
#amount, #confirm { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
}
.choice + .choice { margin-top: 6px; }
.choice input { margin: 3px 0 0; accent-color: var(--ink); }
.choice:has(input:checked) { border-color: var(--ink); }
.choice .sub { display: block; font-size: 12px; }

.alert {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-left-width: 3px;
  border-radius: 8px;
  background: var(--sunken);
}
.alert.bad { border-left-color: var(--bad); }
.alert.warn { border-left-color: var(--warn); }
.code-line { margin: -6px 0 12px; font-size: 12px; }

.what { font-size: 16px; line-height: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.final { font-size: 13px; }
.facts.compact { padding: 12px 0; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.expires { font-variant-numeric: tabular-nums; }
.done { font-size: 16px; font-weight: 600; }
.done.ok { color: var(--ok); }

.decide { display: inline-flex; flex-wrap: nowrap; gap: 6px; justify-content: flex-end; }
.decide form { margin: 0; }
.decide .button { min-height: 32px; padding: 0 12px; font-size: 13px; }

/* Phone: every partner is a card, no table wider than the screen. */
@media (max-width: 760px) {
  .table-wrap { overflow: visible; background: none; border: 0; border-radius: 0; }
  .sales, .sales tbody, .sales tr, .sales th, .sales td { display: block; width: 100%; }
  .sales thead { display: none; }
  .sales tr {
    margin-bottom: 12px;
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .sales tr.attention { box-shadow: inset 3px 0 0 var(--warn); }
  .sales tr.attention > :first-child { box-shadow: none; }
  .sales th, .sales td {
    padding: 8px 0;
    white-space: normal;
  }
  .sales td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    text-align: right;
  }
  .sales td::before {
    content: attr(data-label);
    flex: none;
    color: var(--faint);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: left;
  }
  .sales td > * { min-width: 0; }
  .sales tr > :last-child { border-bottom: 0; }
  .sales .units.blank { display: none; }
  .sales .num { text-align: right; }
  .chips { justify-content: flex-end; }
  .sales .item { min-width: 0; }
  .sales td .untrusted { text-align: right; }
  .check { display: grid; grid-template-columns: 8px minmax(0, 1fr); column-gap: 10px; }
  .check .dot { margin-top: 6px; }
  .check .code { grid-column: 2; }
  .sales.queue td.item { display: block; text-align: left; }
  .sales.queue td.item::before { display: block; margin-bottom: 4px; }
  .sales.queue td.item .untrusted { text-align: left; }
  .sales.queue .item { min-width: 0; }
  .sales.history .notes > .val { display: inline; min-width: 0; }
  .conflict-head { padding: 14px 14px 10px; }
  .conflict-decide { padding: 0 14px 14px; }
  .versions th, .versions td { padding: 8px 10px; }
  .versions th[scope="row"] { width: 28%; }
}

@media (max-width: 480px) {
  .actions, .conflict-decide { justify-content: stretch; }
  .conflict-decide form { display: flex; flex: 1 1 0; }
  .primary, .button { flex: 1 1 auto; }
  .pick, .pick-row { width: 100%; }
  .pick-row select { flex: 1 1 auto; }
  .pick-row .button { flex: none; }
  .filters, .pick-field { width: 100%; }
  .pick-go .button { width: 100%; }
  .who > .muted { display: none; }
  .bar { flex-wrap: wrap; gap: 4px 8px; padding: 8px 12px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .nav a { padding: 6px 7px; }
}

/* Payment of an invoice (GEOS-908) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.head-actions form { margin: 0; }
.check .what .sub { display: block; margin-top: 2px; font-size: 12px; overflow-wrap: anywhere; }
.sales td.pay { text-align: right; }
@media (max-width: 480px) {
  .head-actions { width: 100%; }
  .head-actions form, .head-actions .button { flex: 1 1 0; }
  .head-actions form .button { width: 100%; }
}

/* Overview (GEOS-1104) */
.cycle-meta { margin: 4px 0 0; font-variant-numeric: tabular-nums; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.toggle .switch {
  position: relative;
  flex: none;
  width: 26px;
  height: 16px;
  border-radius: 999px;
  background: var(--line-strong);
}
.toggle .switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
}
.toggle.on { border-color: var(--ink); color: var(--ink); font-weight: 500; }
.toggle.on .switch { background: var(--ink); }
.toggle.on .switch::after { left: 12px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}
.tile {
  min-width: 0;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
}
.tile .big { margin: 2px 0 2px; font-size: 24px; line-height: 32px; font-weight: 600; }
.tile-amounts { margin: 0 0 8px; font-weight: 500; }
.tile-amounts .line, .kinds .line { display: block; }
.tile-sub { margin: 0 0 8px; font-size: 12px; }
.tile-cmp { margin: 0; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; }
.tile-cmp .muted { display: block; font-size: 12px; }

.chart-card { padding: 16px 18px; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin: 0 0 12px; }
.card-head p { margin: 0; font-size: 12px; }
h2 { margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; }
.section-title { margin: 24px 0 10px; }

.chart { display: block; width: 100%; height: 140px; }
.chart rect { fill: var(--line-strong); }
.chart rect.past { fill: var(--muted); }
.chart rect.today { fill: var(--ink); }
.chart rect.future { fill: var(--line); }
.chart-axis { display: flex; justify-content: space-between; margin: 6px 0 16px; font-size: 12px; font-variant-numeric: tabular-nums; }

.kinds-wrap { border-radius: 8px; }
.sales.kinds th[scope="row"] { font-weight: 500; }
.sales.partners td.go { text-align: right; }

/* Needs attention and the base (GEOS-1105) */
.attention-card { padding: 16px 18px; margin: 0 0 16px; }
.attention-card .card-head { margin-bottom: 4px; }
.all-clear { margin: 0 0 4px; font-weight: 500; }
.checks.attention { margin: 0; }
.checks.attention .check { padding: 8px 0; border-top: 1px solid var(--line); color: var(--ink); }
.checks.attention .check:first-child { border-top: 0; }
.check.ok .dot { color: var(--ok); }
.checks.attention .name { font-weight: 600; }
.checks.attention .sub { display: block; margin-top: 2px; font-size: 12px; overflow-wrap: anywhere; }
.checks.attention .sub .code { color: var(--muted); }
.checks.attention .blocked { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; }
.checks.attention .bp { white-space: nowrap; }
.checks.attention .bp .code { margin-left: 4px; }
.tiles.stats .tile-sub { margin: 0 0 2px; }

/* Term of payment and overdue (GEOS-1106) */
.tile-sub.overdue a { font-weight: 500; }
.sales .overdue { display: block; margin-top: 4px; }
.sales td.due { white-space: nowrap; }
.sales td.due .badge { margin-left: 6px; }

/* GP used from the daily snapshot (GEOS-1108) */
.tile .big { overflow-wrap: anywhere; }
.tile-sub.gp-alert { margin: 0 0 2px; color: var(--warn); font-weight: 500; }
.sales .gap { display: block; margin-top: 4px; }
.sales td.gp .sub { white-space: normal; }

@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .chart-card { padding: 14px; }
  .kinds-wrap { overflow: visible; }
  .sales.kinds tr { padding: 4px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; margin: 0; }
  .sales.kinds tr:last-child { border-bottom: 0; }
  .sales.kinds td { padding: 4px 0; }
  .sales.kinds .val { text-align: right; }
  .sales.partners td.go { justify-content: flex-end; }
  .sales.partners td.go::before { content: none; }
}

@media (max-width: 760px) {
  .attention-card { padding: 14px; }
  .checks.attention .bp { white-space: normal; }
}

@media (max-width: 480px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .tiles.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles.stats .tile.wide { grid-column: span 2; }
  .toggle { width: 100%; justify-content: center; }
}
