/* The TezCut admin panel. Every colour is a token here, set once, and
   everything below reads them: TezCut's coral on its night ink (the brand
   kit's palette, brand/brand.ts), the states' amber, green and red, and the
   paper a receipt prints on. */

:root {
  color-scheme: dark;

  /* Surfaces, darkest first. */
  --ink: #0b0d12;
  --ink-raised: #0f121a;
  --surface: #141823;
  --surface-raised: #1a1f2c;
  --surface-hover: #212738;
  --line: #242a39;
  --line-strong: #343c52;
  --overlay: rgb(5 6 10 / 72%);
  --shadow: rgb(0 0 0 / 45%);
  --sheen: rgb(255 255 255 / 4%);

  /* Text. */
  --text: #f5f3f0;
  --text-muted: #a9b0bf;
  --text-faint: #737b8e;

  /* The brand's coral, and what sits on it. */
  --coral: #f7647c;
  --coral-bright: #ff8096;
  --coral-ink: #1c0a0f;
  --coral-wash: rgb(247 100 124 / 12%);
  --coral-line: rgb(247 100 124 / 38%);
  --coral-glow: rgb(247 100 124 / 22%);

  /* The states: pending and ending soon, approved and active, rejected and ended. */
  --amber: #f6b74a;
  --amber-wash: rgb(246 183 74 / 13%);
  --amber-line: rgb(246 183 74 / 36%);
  --green: #3ad69b;
  --green-wash: rgb(58 214 155 / 12%);
  --green-line: rgb(58 214 155 / 34%);
  --red: #ff5d5d;
  --red-wash: rgb(255 93 93 / 12%);
  --red-line: rgb(255 93 93 / 36%);
  --violet: #a68dfb;
  --violet-wash: rgb(166 141 251 / 13%);
  --violet-line: rgb(166 141 251 / 34%);
  --focus: #8fb0ff;

  /* The paper a receipt prints on. */
  --paper: #ffffff;
  --paper-ink: #16181d;
  --paper-muted: #5b6070;
  --paper-line: #d9dce3;
  --paper-accent: #c9344d;
  --paper-wash: #f4f5f8;

  --radius: 16px;
  --radius-small: 10px;
  --sidebar: 252px;
  --gap: 16px;
  font-family: "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

/* What the page hides stays hidden, whatever display a rule below gives it. */
[hidden] {
  /* biome-ignore lint/complexity/noImportantStyles: hidden must win over every display the page sets */
  display: none !important;
}

html {
  background: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.01em;
}

a {
  color: var(--coral);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The mark's drawing lives in an SVG that takes no room. */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.mark-body {
  fill: var(--text);
  stroke: var(--text);
  stroke-width: 64;
  stroke-linejoin: round;
}

.mark-tip {
  fill: var(--coral);
  stroke: var(--coral);
  stroke-width: 64;
  stroke-linejoin: round;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Controls ------------------------------------------------------------------------- */

button,
.button {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-small);
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s,
    box-shadow 0.15s;
}

button:hover,
.button:hover {
  background: var(--surface-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.primary,
.button.primary {
  background: var(--coral);
  border-color: var(--coral);
  color: var(--coral-ink);
  box-shadow: 0 6px 20px var(--coral-glow);
}

button.primary:hover,
.button.primary:hover {
  background: var(--coral-bright);
  border-color: var(--coral-bright);
}

button.danger {
  background: var(--red-wash);
  border-color: var(--red-line);
  color: var(--red);
}

button.danger:hover {
  background: var(--red);
  border-color: var(--red);
  color: var(--ink);
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

button.ghost:hover {
  background: var(--surface-raised);
  color: var(--text);
}

button.ghost-line,
.button.ghost-line {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text);
}

button.ghost-line:hover,
.button.ghost-line:hover {
  background: var(--surface-raised);
  border-color: var(--text-faint);
}

button.link {
  background: transparent;
  border-color: transparent;
  color: var(--coral);
  padding: 4px 0;
  min-height: 0;
  font-weight: 600;
  justify-content: flex-start;
}

button.link:hover {
  background: transparent;
  color: var(--coral-bright);
  text-decoration: underline;
}

button.small,
.button.small {
  font-size: 13px;
  padding: 5px 10px;
  min-height: 32px;
  gap: 6px;
}

.small > .icon {
  width: 15px;
  height: 15px;
}

.icon-only {
  padding: 8px;
}

.wide {
  width: 100%;
}

label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--ink-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  padding: 9px 12px;
  min-width: 0;
  min-height: 40px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--text-faint);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--coral-wash);
}

input[readonly],
textarea[readonly] {
  color: var(--text-muted);
  border-style: dashed;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-wash);
}

input[type="checkbox"] {
  min-height: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--coral);
}

input[type="date"],
input[type="month"] {
  color-scheme: dark;
}

select {
  cursor: pointer;
}

textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  font-size: 13px;
  line-height: 1.5;
}

button:focus-visible,
a:focus-visible,
.kpi-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.mono {
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 0.95em;
  overflow-wrap: anywhere;
}

.small-text {
  font-size: 12px;
}

.quiet {
  color: var(--text-muted);
  font-size: 14px;
}

.hint {
  font-size: 13px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* --- Chips ------------------------------------------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--text-muted);
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.chip[data-tone="pending"],
.chip[data-tone="soon"] {
  color: var(--amber);
  background: var(--amber-wash);
  border-color: var(--amber-line);
}

.chip[data-tone="approved"],
.chip[data-tone="active"],
.chip[data-tone="ok"] {
  color: var(--green);
  background: var(--green-wash);
  border-color: var(--green-line);
}

.chip[data-tone="rejected"],
.chip[data-tone="revoked"],
.chip[data-tone="expired-red"] {
  color: var(--red);
  background: var(--red-wash);
  border-color: var(--red-line);
}

.chip[data-tone="lifetime"],
.chip[data-tone="role-manager"] {
  color: var(--violet);
  background: var(--violet-wash);
  border-color: var(--violet-line);
}

.chip[data-tone="role-owner"] {
  color: var(--coral);
  background: var(--coral-wash);
  border-color: var(--coral-line);
}

.chip[data-tone="expired"] {
  color: var(--text-muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* --- Signing in ------------------------------------------------------------------------------ */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(60rem 30rem at 85% -10%, var(--coral-wash), transparent 70%),
    radial-gradient(40rem 26rem at -10% 110%, var(--violet-wash), transparent 70%), var(--ink);
}

.auth-card {
  width: min(100%, 460px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow:
    0 1px 0 var(--sheen) inset,
    0 30px 80px var(--shadow),
    0 0 0 1px var(--coral-wash);
}

.auth-card h1 {
  font-size: 24px;
  margin-bottom: 2px;
}

.auth-lead {
  color: var(--text-muted);
  margin-bottom: 6px;
}

.auth-checking {
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-form label {
  margin-top: 6px;
}

.auth-form > button {
  margin-top: 8px;
}

.auth-form > button.primary {
  min-height: 44px;
}

.auth-note {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-faint);
}

.code-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.code-field input {
  font-size: 20px;
  letter-spacing: 0.3em;
  text-align: center;
}

.forgot-ways {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.forgot-way {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--ink-raised);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.forgot-way h2 {
  font-size: 15px;
  color: var(--text);
}

.form-error {
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
}

.form-error:empty {
  display: none;
}

/* --- Brand ---------------------------------------------------------------------------------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mark {
  width: 26px;
  height: 29px;
  flex: none;
  filter: drop-shadow(0 4px 12px var(--coral-glow));
}

.brand-name {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-tag {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--coral);
  background: var(--coral-wash);
  border: 1px solid var(--coral-line);
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: 2px;
}

.brand-large .mark {
  width: 34px;
  height: 38px;
}

.brand-large .brand-name {
  font-size: 22px;
}

/* --- The shell: a sidebar on a desk, a top bar and a menu on a phone ---------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
  /* The sidebar's colour and edge run the whole page down, past its sticky panel. */
  background: linear-gradient(
    to right,
    var(--ink-raised) calc(var(--sidebar) - 1px),
    var(--line) calc(var(--sidebar) - 1px) var(--sidebar),
    var(--ink) var(--sidebar)
  );
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 14px 16px;
  background: var(--ink-raised);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.top-only {
  display: none;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
}

.nav-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  padding: 9px 12px;
  min-height: 40px;
  font-size: 14.5px;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item[aria-current="page"] {
  background: var(--coral-wash);
  border-color: var(--coral-line);
  color: var(--text);
}

.badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: var(--amber);
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 0;
  min-width: 0;
}

.who-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.who-name {
  font-weight: 650;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who-role {
  font-size: 12px;
  color: var(--text-faint);
}

.main {
  min-width: 0;
  padding: 28px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1400px;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 28px;
  font-weight: 800;
}

.view-note {
  color: var(--text-muted);
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.updated {
  font-size: 13px;
  color: var(--text-faint);
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 6px;
}

.section-sub {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  margin-left: 6px;
}

/* A heading and its cards, kept apart as the view's own sections are. */
.section-block {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* --- Toolbars, filters and segmented controls --------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.toolbar-note {
  color: var(--text-muted);
  font-size: 14px;
  flex: 1 1 380px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.filters.grow {
  flex: 1 1 520px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  max-width: 420px;
  min-width: 0;
}

.search .icon {
  position: absolute;
  left: 12px;
  color: var(--text-faint);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding-left: 38px;
}

.select select {
  min-width: 150px;
}

.date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.date span {
  font-size: 13px;
  color: var(--text-faint);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  min-width: 0;
  padding: 4px;
  border-radius: 12px;
  background: var(--ink-raised);
  border: 1px solid var(--line);
}

.segment {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  min-height: 34px;
  padding: 6px 12px;
}

.segment:hover {
  background: var(--surface);
}

.segment[aria-pressed="true"] {
  background: var(--surface-raised);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: 0 4px 14px var(--shadow);
}

.segment-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  font-weight: 600;
  font-size: 14px;
}

.segment-input input {
  min-height: 32px;
  padding: 4px 8px;
}

/* --- Cards and figures ------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  box-shadow: 0 1px 0 var(--sheen) inset;
}

.table-card {
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 12px;
}

.table-card > .card-head {
  padding: 18px 20px 12px;
}

.card-head button {
  white-space: nowrap;
}

.card-head h2 {
  font-size: 17px;
}

.card-note {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 3px;
}

.kpis {
  display: grid;
  gap: 14px;
}

.kpis-money {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpis-counts {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.kpis-funnel {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.kpi {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  min-width: 0;
  text-align: left;
  box-shadow: 0 1px 0 var(--sheen) inset;
}

.kpi::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--line-strong);
}

.kpi h3,
.kpi .kpi-label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-muted);
}

.kpi-value {
  font-size: clamp(20px, 2.1vw, 28px);
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-note {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-faint);
}

.kpi-hero {
  border-color: var(--coral-line);
  background:
    radial-gradient(28rem 10rem at 100% 0%, var(--coral-glow), transparent 70%), var(--surface);
  box-shadow:
    0 1px 0 var(--sheen) inset,
    0 12px 40px var(--coral-wash);
}

.kpi-hero::after,
.kpi[data-tone="licence"]::after {
  background: var(--coral);
}

.kpi[data-tone="pending"]::after {
  background: var(--amber);
}

.kpi[data-tone="approved"]::after {
  background: var(--green);
}

.kpi[data-tone="rejected"]::after,
.kpi[data-tone="revoked"]::after {
  background: var(--red);
}

.kpi[data-tone="pending"] .kpi-value {
  color: var(--amber);
}

.kpi-link {
  cursor: pointer;
  min-height: 0;
  font-weight: inherit;
}

.kpi-link:hover {
  background: var(--surface-raised);
  border-color: var(--line-strong);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: var(--gap);
}

.grid-even {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* A row of two whose first is hidden (staff see no takings chart): the other takes the row. */
.grid-2:has(> [hidden]) {
  grid-template-columns: minmax(0, 1fr);
}

/* The charts: drawn by the page as SVG to their box's size, coloured here. */
.chart {
  position: relative;
  flex: 1 1 auto;
  min-height: 250px;
  width: 100%;
}

.chart svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart .grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.chart .axis-line {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.chart .tick {
  fill: var(--text-faint);
  font-size: 11px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.chart .bar {
  fill: var(--coral);
  opacity: 0.78;
  transition: opacity 0.15s;
}

.chart .bar:hover,
.chart .bar-today {
  opacity: 1;
}

.chart .bar-empty {
  fill: var(--line-strong);
  opacity: 1;
}

.chart .hit {
  fill: transparent;
}

.chart .hit:hover + .bar {
  opacity: 1;
}

.chart .chart-empty {
  fill: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
}

/* Orders by payment method. */
.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--line-strong);
}

.swatch[data-tone="approved"],
.method-bar .seg-approved {
  background: var(--green);
  fill: var(--green);
}

.swatch[data-tone="pending"],
.method-bar .seg-pending {
  background: var(--amber);
  fill: var(--amber);
}

.swatch[data-tone="rejected"],
.method-bar .seg-rejected {
  background: var(--red);
  fill: var(--red);
}

.methods {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.method {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.method-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.method-name {
  font-weight: 600;
}

.method-sum {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.method-bar {
  display: block;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--ink-raised);
  overflow: hidden;
}

.method-bar .track {
  fill: var(--ink-raised);
}

/* --- Tables: a sticky header, scrolling inside their card on a phone --------------------------------- */

.table-slot {
  min-width: 0;
}

.table-wrap {
  overflow: auto;
  max-height: min(70vh, 760px);
  min-width: 0;
}

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-raised);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data tr.clickable {
  cursor: pointer;
}

table.data tbody tr:hover td {
  background: var(--sheen);
}

table.data .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table.data th.num {
  text-align: right;
}

table.data .nowrap {
  white-space: nowrap;
}

table.data .wide-cell {
  min-width: 260px;
}

/* A short table read whole (a report), with no scrolling box of its own. */
.table-tall .table-wrap {
  max-height: none;
}

table.data tbody tr.total-row td {
  font-weight: 800;
  background: var(--ink-raised);
  border-top: 1px solid var(--line-strong);
}

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
}

.cell-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 0;
  min-height: 0;
  background: transparent;
  border: 0;
  font-weight: inherit;
  text-align: left;
  color: inherit;
}

.cell-button:hover {
  background: transparent;
}

.cell-title {
  font-weight: 650;
  color: var(--text);
  overflow-wrap: break-word;
}

.cell-button .cell-title {
  color: var(--text);
}

.cell-button:hover .cell-title {
  color: var(--coral-bright);
}

.cell-sub {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  overflow-wrap: break-word;
}

.person {
  display: flex;
  align-items: center;
  gap: 10px;
}

.person-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.row-actions select {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 13px;
}

/* --- Paging, loading and empty states ------------------------------------------------------------------ */

.pager-slot:empty {
  display: none;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-muted);
}

.orders-pane .pager {
  border-top: 0;
  padding: 4px 0;
}

.pager-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager-page {
  font-variant-numeric: tabular-nums;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 16px;
  color: var(--text-muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--coral);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 44px 16px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state .icon {
  width: 34px;
  height: 34px;
  color: var(--text-faint);
  stroke-width: 1.5;
}

/* --- Rows: orders in a list ------------------------------------------------------------------------ */

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row-button {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  text-align: left;
  font-weight: 400;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 64px;
}

.row-button:hover {
  background: var(--surface-raised);
  border-color: var(--line-strong);
}

.order-row[aria-current="true"] .row-button {
  border-color: var(--coral-line);
  background: var(--surface-raised);
  box-shadow:
    0 0 0 1px var(--coral-line),
    0 10px 30px var(--coral-wash);
}

.avatar {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  color: var(--coral);
  background: var(--coral-wash);
  border: 1px solid var(--coral-line);
  text-transform: uppercase;
}

.order-row[data-state="approved"] .avatar {
  color: var(--green);
  background: var(--green-wash);
  border-color: var(--green-line);
}

.order-row[data-state="rejected"] .avatar {
  color: var(--red);
  background: var(--red-wash);
  border-color: var(--red-line);
}

.row-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-title {
  font-weight: 650;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.row-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

.row-meta .icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.empty {
  color: var(--text-muted);
  padding: 28px 16px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
}

/* --- The orders view ---------------------------------------------------------------------------- */

.orders-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  min-width: 0;
  padding: 4px;
  border-radius: 12px;
  background: var(--ink-raised);
  border: 1px solid var(--line);
}

.tab {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  min-height: 34px;
  padding: 6px 12px;
}

.tab:hover {
  background: var(--surface);
}

.tab[aria-pressed="true"] {
  background: var(--surface-raised);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: 0 4px 14px var(--shadow);
}

.tab-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.tab[data-state="pending"] .tab-count:not(:empty) {
  color: var(--amber);
}

.fresh {
  align-self: flex-start;
  background: var(--amber-wash);
  border-color: var(--amber-line);
  color: var(--amber);
}

.fresh:hover {
  background: var(--amber);
  color: var(--ink);
}

.orders-layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.orders-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.list-note {
  font-size: 13px;
  color: var(--text-faint);
}

.list-note:empty {
  display: none;
}

.detail {
  position: sticky;
  top: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  box-shadow: 0 1px 0 var(--sheen) inset;
}

.detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

.detail-empty .icon {
  width: 40px;
  height: 40px;
  color: var(--text-faint);
  stroke-width: 1.5;
}

.back {
  display: none;
  align-self: flex-start;
}

.detail-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-head h2 {
  font-size: 22px;
  font-weight: 800;
}

.detail-amount {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.detail-when {
  color: var(--text-muted);
  font-size: 14px;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.detail-section > button {
  align-self: flex-start;
}

.detail-section h3,
.drawer-section h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(110px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 8px 16px;
  font-size: 14px;
}

.facts dt {
  color: var(--text-muted);
}

.facts dd {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  overflow-wrap: anywhere;
}

/* A long reference breaks rather than runs out of its box. */
.facts dd > span {
  min-width: 0;
  max-width: 100%;
}

.proof {
  display: block;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--ink-raised);
  border: 1px solid var(--line-strong);
  max-width: 320px;
  min-height: 80px;
}

.proof img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.proof:hover {
  border-color: var(--coral-line);
}

.decide {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.decide fieldset {
  margin: 0;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--ink-raised);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.decide fieldset.approve {
  border-color: var(--green-line);
}

.decide fieldset.reject {
  border-color: var(--red-line);
}

.decide legend {
  font-weight: 800;
  font-size: 15px;
  padding: 0 6px;
}

.decide .approve legend {
  color: var(--green);
}

.decide .reject legend {
  color: var(--red);
}

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

.chips button {
  font-weight: 500;
  font-size: 12.5px;
  padding: 4px 10px;
  min-height: 30px;
  border-radius: 10px;
  text-align: left;
}

.issued {
  border: 1px solid var(--green-line);
  background: var(--green-wash);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.issued-title {
  color: var(--green);
  font-weight: 700;
}

.key {
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
  padding: 12px 14px;
  background: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.decided-note {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  border: 1px solid var(--line);
  background: var(--ink-raised);
  color: var(--text-muted);
}

.decided-note[data-tone="approved"] {
  border-color: var(--green-line);
}

.decided-note[data-tone="rejected"] {
  border-color: var(--red-line);
}

/* --- Alerts: what the owner must hear about, above every view --------------------------------------- */

.alerts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: var(--gap);
}

.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid var(--red-line);
  background: var(--red-wash);
}

.alert-text {
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.alert-title {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.alert-detail {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

/* --- Forms ------------------------------------------------------------------------------------------ */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  align-items: start;
}

.form-grid.nested {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--ink-raised);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  /* What is typed reads as text, not as the label around it. */
  font-weight: 400;
  font-size: 14.5px;
}

.field-wide {
  grid-column: 1 / -1;
}

.form-grid > .form-error {
  grid-column: 1 / -1;
}

.form-grid > .chips {
  grid-column: 1 / -1;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.inline-form .field {
  flex: 0 1 260px;
}

.field-problem {
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  margin-top: -6px;
}

.field-problem:empty {
  display: none;
}

/* --- Settings: the messages and their preview ----------------------------------------------------------- */

.templates {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.templates-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.preview {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--ink-raised);
  min-width: 0;
}

.preview h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.preview-subject {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.preview-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  max-height: 420px;
  overflow: auto;
}

.placeholders {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.placeholders li {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.placeholder {
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 12.5px;
  font-weight: 600;
  padding: 2px 8px;
  min-height: 26px;
  border-radius: 8px;
  color: var(--coral);
  background: var(--coral-wash);
  border-color: var(--coral-line);
  flex: none;
}

/* --- Your account: two-step sign-in -------------------------------------------------------------------- */

.two-step {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.two-step-setup {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: flex-start;
}

.qr {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  flex: none;
}

.qr-light {
  fill: var(--paper);
}

.qr-dark {
  fill: var(--paper-ink);
}

.two-step-on {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Toasts, dialogs, the drawer ------------------------------------------------------------------------ */

.toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: 0 18px 50px var(--shadow);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.toast[data-tone="success"] {
  border-color: var(--green-line);
  box-shadow:
    0 18px 50px var(--shadow),
    inset 3px 0 0 var(--green);
}

.toast[data-tone="danger"] {
  border-color: var(--red-line);
  box-shadow:
    0 18px 50px var(--shadow),
    inset 3px 0 0 var(--red);
}

.toast-close {
  min-height: 0;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 18px;
  line-height: 1.2;
}

dialog.sheet {
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  padding: 22px;
  max-width: min(92vw, 900px);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 30px 90px var(--shadow);
}

dialog.sheet::backdrop,
dialog.drawer::backdrop {
  background: var(--overlay);
}

dialog.sheet img {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  margin: 0 auto 14px;
  border-radius: 10px;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

dialog.confirm {
  width: min(92vw, 440px);
}

dialog.confirm h2 {
  font-size: 19px;
  margin-bottom: 8px;
}

dialog.confirm p {
  color: var(--text-muted);
  margin-bottom: 18px;
  overflow-wrap: anywhere;
}

dialog.form-sheet {
  width: min(92vw, 620px);
}

dialog.form-sheet h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

#form-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* A long form keeps its buttons in sight at the sheet's foot. */
dialog.form-sheet .sheet-actions {
  position: sticky;
  bottom: -22px;
  margin: 0 -22px -22px;
  padding: 14px 22px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

dialog.drawer {
  margin: 0 0 0 auto;
  height: 100vh;
  max-height: 100vh;
  width: min(100vw, 640px);
  max-width: 100vw;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: -30px 0 90px var(--shadow);
}

dialog.drawer[open] {
  display: flex;
  flex-direction: column;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

dialog.drawer .drawer-head h2 {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  overflow-y: auto;
  min-height: 0;
}

.drawer-hero {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-kicker {
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 600;
}

.drawer-big {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.drawer-section .table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 340px;
}

.drawer-section > button {
  align-self: flex-start;
}

.danger-zone {
  border: 1px solid var(--red-line);
  background: var(--red-wash);
  border-radius: 14px;
  padding: 16px;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 16px;
  border-left: 2px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timeline li {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 3px var(--surface);
}

.timeline-when {
  font-size: 12px;
  color: var(--text-faint);
}

.timeline-what {
  font-weight: 650;
}

.timeline-who {
  font-size: 13px;
  color: var(--text-muted);
}

.timeline-detail {
  font-size: 13px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* --- The receipt: a sheet on the screen, one clean A4 page in print ------------------------------------------ */

.receipt-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: auto;
  padding: 24px 16px 48px;
  background: var(--overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.receipt-bar {
  display: flex;
  gap: 8px;
  width: min(100%, 794px);
  justify-content: flex-end;
}

.receipt {
  width: min(100%, 794px);
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 6px;
  padding: 48px 52px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  box-shadow: 0 30px 90px var(--shadow);
  font-size: 14px;
}

.receipt-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--paper-ink);
}

.receipt-from {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--paper-muted);
}

.receipt-business {
  font-size: 18px;
  font-weight: 800;
  color: var(--paper-ink);
}

.receipt-title {
  text-align: right;
}

.receipt-title h1 {
  font-size: 30px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.receipt-paid {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 12px;
  border: 2px solid var(--paper-accent);
  border-radius: 6px;
  color: var(--paper-accent);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.receipt .facts {
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 8px 20px;
}

.receipt .facts dt {
  color: var(--paper-muted);
}

.receipt-lines {
  width: 100%;
  border-collapse: collapse;
}

/* The receipt's cells have classes of their own, so no rule of the panel's tables reaches them. */
.r-cell {
  text-align: left;
  padding: 12px 0;
  border-bottom: 1px solid var(--paper-line);
}

.r-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--paper-muted);
}

.r-total {
  font-size: 16px;
  border-bottom: 0;
  border-top: 2px solid var(--paper-ink);
}

.r-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.receipt-foot {
  color: var(--paper-muted);
  font-size: 13px;
}

/* The most specific of the icon and button rules come last, after the general ones. */

.nav-item[aria-current="page"] .icon {
  color: var(--coral);
}

.decide fieldset > button {
  align-self: flex-start;
}

/* --- Narrower screens --------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .kpis-counts,
  .kpis-funnel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid-2,
  .templates {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview {
    position: static;
  }

  /* One column: the list, or the order open over it. */
  .orders-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .orders-layout .detail {
    display: none;
    position: static;
  }

  .orders-layout.show-detail .detail {
    display: flex;
  }

  .orders-layout.show-detail .orders-pane {
    display: none;
  }

  .back {
    display: inline-flex;
  }
}

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

  .kpi-value {
    font-size: 24px;
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    background: var(--ink);
  }

  .sidebar {
    position: sticky;
    z-index: 20;
    height: auto;
    max-height: 100vh;
    gap: 0;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .top-only {
    display: inline-flex;
  }

  .sidebar-top {
    padding: 0;
  }

  .nav {
    display: none;
    padding-top: 10px;
  }

  .sidebar.open .nav {
    display: flex;
  }

  .main {
    padding: 18px 16px 72px;
    gap: 16px;
  }

  .topbar {
    flex-wrap: nowrap;
    align-items: flex-start;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .topbar-actions button {
    padding: 8px 10px;
  }

  .toasts {
    left: 16px;
    right: 16px;
    bottom: 16px;
    width: auto;
  }

  .detail {
    scroll-margin-top: 80px;
  }

  .grid-even {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  /* A table keeps readable columns and scrolls sideways inside its card, never the page. */
  table.data {
    min-width: 680px;
  }

  .drawer-section table.data {
    min-width: 520px;
  }

  .kpis-counts,
  .kpis-funnel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpis-counts .kpi:last-child {
    grid-column: 1 / -1;
  }

  .kpis {
    gap: 10px;
  }

  .kpi {
    padding: 14px;
  }

  .kpi-value {
    font-size: 21px;
  }

  .card,
  .detail {
    padding: 16px;
  }

  .table-card {
    padding: 0;
  }

  .chart {
    min-height: 210px;
  }

  .decide,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .filters,
  .filters.grow {
    flex-basis: 100%;
  }

  .search {
    max-width: none;
    flex-basis: 100%;
  }

  .select,
  .select select,
  .date {
    flex: 1 1 140px;
  }

  .date input,
  .select select {
    width: 100%;
  }

  .toolbar-actions {
    margin-left: 0;
    width: 100%;
  }

  .toolbar-actions > button {
    flex: 1 1 auto;
  }

  .tabs,
  .segmented {
    width: 100%;
  }

  .tab,
  .segment {
    flex: 1 1 0;
    padding: 6px 4px;
    font-size: 13px;
  }

  .topbar-actions .updated {
    display: none;
  }

  .topbar-actions span:not(.updated) {
    display: none;
  }

  .facts {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .facts dd {
    margin-bottom: 8px;
  }

  .auth-card {
    padding: 26px 20px;
  }

  dialog.sheet {
    max-width: calc(100vw - 24px);
  }

  .receipt {
    padding: 28px 22px;
  }

  .receipt-head {
    flex-direction: column;
  }

  .receipt-title {
    text-align: left;
  }

  .receipt .facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .qr {
    width: 160px;
    height: 160px;
  }
}

/* --- Print: the receipt alone, one A4 page ------------------------------------------------------------------- */

@media print {
  @page {
    size: A4;
    margin: 14mm;
  }

  html,
  body {
    background: var(--paper);
    color: var(--paper-ink);
  }

  body:has(.receipt-view:not([hidden])) > :not(.receipt-view) {
    display: none;
  }

  .receipt-view {
    position: static;
    padding: 0;
    background: var(--paper);
    display: block;
    overflow: visible;
  }

  .receipt-bar {
    display: none;
  }

  .receipt {
    width: 100%;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
    break-inside: avoid;
  }
}

/* The partners' page (T101): the admin page's stylesheet comes first, with
   its tokens and colours; these rules add only the layout of a page with no
   sidebar, made for a phone first (360 px). No colour is set here: only the
   admin page's tokens, by var(). */

.partner-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.partner-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 12px var(--gap);
  border-bottom: 1px solid var(--line);
  background: var(--ink-raised);
}

.partner-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.partner-main {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.partner-main .view {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.partner-link {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.partner-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.partner-total {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
}

.partner-total-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.partner-total-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.partner-months {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* T116: the reseller agreement's text, drawn from the build's blocks. Layout only. */
.agreement-text {
  max-height: 60vh;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
  overflow-wrap: anywhere;
}

.agreement-text p {
  margin: 0 0 8px;
}

.agreement-item {
  display: flex;
  gap: 8px;
}

.agreement-marker {
  flex: none;
  min-width: 1.5em;
}

.agreement-depth-1 {
  margin-left: 1.5rem;
}

.agreement-depth-2 {
  margin-left: 3rem;
}

@media (max-width: 480px) {
  .partner-main {
    padding: 10px;
  }

  .partner-top {
    padding: 10px;
  }
}
