/* imp-base.css — type, surfaces, forms, buttons, tables, alerts and the balance stamp.
   Every colour, size and radius comes from brand.css. */

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--imp-bg);
  color: var(--imp-text);
  font-family: var(--imp-font);
  font-size: var(--fs-2);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd, fieldset { margin: 0; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---- focus: one ring everywhere, dark gold on light (gold on ink: imp-layout.css) ---- */
:focus-visible {
  outline: 2px solid var(--imp-primary-strong);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- page header: the title is set Expanded, the one line under it quiet ---- */
.page-header { margin-bottom: 28px; }
.page-title {
  font-size: var(--fs-5);
  font-weight: 700;
  font-stretch: var(--imp-wide);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--imp-ink);
}
.page-sub { margin-top: 6px; color: var(--imp-muted); max-width: 64ch; }

/* ---- cards: grouping only. Hairline, no shadow. ---- */
.section-card,
.imp-fieldset {
  background: var(--imp-surface);
  border: 1px solid var(--imp-rule);
  border-radius: var(--imp-radius);
  min-width: 0;
}
.section-card + .section-card,
.section-card + form,
form + .section-card { margin-top: 24px; }
.section-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--imp-rule);
}
.section-card-title { font-size: var(--fs-3); font-weight: 600; line-height: 1.3; }
.section-card-body { padding: 20px; }
.section-card-body > * + * { margin-top: 16px; }
.section-card-note { padding: 12px 20px 0; }
.section-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 16px 20px;
  border-top: 1px solid var(--imp-rule);
}
.section-card > .section-card-foot:first-child { border-top: 0; }

/* ---- fieldsets: the legend is a header INSIDE the card, never on its border ---- */
.imp-fieldset { padding: 0; margin: 0; }
.imp-fieldset > legend {
  float: left;             /* a floated legend leaves the border and becomes ordinary content */
  width: 100%;
  padding: 16px 20px;
  border-bottom: 1px solid var(--imp-rule);
  font-size: var(--fs-3);
  font-weight: 600;
  line-height: 1.3;
}
.imp-fieldset > legend + * { clear: both; }
.fieldset-body { padding: 20px; }
.fieldset-foot { padding: 0 20px 20px; }

form > .address-pair { margin-top: 24px; }

/* ---- fields ---- */
.form-grid { display: grid; gap: 16px 20px; grid: auto-flow / repeat(3, minmax(0, 1fr)); align-items: start; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: var(--fs-1); font-weight: 600; color: var(--imp-ink); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="date"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--imp-rule-strong);
  border-radius: var(--imp-radius-ctl);
  background-color: var(--imp-surface);
  font-size: var(--fs-2);
  line-height: 1.4;
  transition: border-color var(--imp-ease);
}
select {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--imp-ink) 50%), linear-gradient(135deg, var(--imp-ink) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
}
input:hover, select:hover { border-color: var(--imp-muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--imp-primary-strong);
  outline-offset: 2px;
  border-color: var(--imp-ink);
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--imp-red); border-width: 2px; padding: 9px 11px; }
select[aria-invalid="true"] { padding-right: 35px; }
/* a date input's native calendar UI carries its own intrinsic minimum width that width:100%
   does not always override (notably iOS Safari) — min-width:0 lets it actually shrink to fit
   a narrow filter-bar column instead of forcing the row wider than the viewport. */
input[type="date"] { min-width: 0; }

/* the file input: a real button for the picker, the chosen name beside it */
input[type="file"] {
  width: 100%;
  min-height: 44px;
  padding: 5px;
  border: 1px dashed var(--imp-rule-strong);
  border-radius: var(--imp-radius-ctl);
  background: var(--imp-bg);
  font-size: var(--fs-1);
  color: var(--imp-muted);
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--imp-ink);
  border-radius: 6px;
  background: var(--imp-surface);
  color: var(--imp-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--imp-ease), color var(--imp-ease);
}
input[type="file"]::file-selector-button:hover { background: var(--imp-ink); color: var(--imp-side-text); }
/* the drop zone is the file input itself, re-bordered while a file is dragged over it */
.dropzone { min-width: 0; }
.dropzone.is-over input[type="file"] { border-style: solid; border-color: var(--imp-ink); background: var(--imp-surface); }
.dropzone__hint { margin-top: 6px; font-size: var(--fs-1); color: var(--imp-muted); }
.map-table select { min-width: 0; max-width: 100%; }

/* create label: the saved-address picker, the save tick box, swap; sign in: show password */
.picker__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.picker__row select { flex: 1 1 220px; min-width: 0; }
.field .check { display: flex; align-items: center; gap: 10px; font-size: var(--fs-2); font-weight: 500; }
form > .address-swap { margin-top: 24px; }
form > .address-swap + .address-pair { margin-top: 16px; }
/* a tap target stays >= 44px even though the toggle reads as a small text button */
.password-toggle.btn-text--sm { min-height: 44px; align-self: flex-start; }

.field-error { font-size: var(--fs-1); color: var(--imp-red); font-weight: 500; }
.field-error--form { font-size: var(--fs-2); }

.small-note { font-size: var(--fs-1); color: var(--imp-muted); }
.empty-note { color: var(--imp-muted); }

/* ---- actions: ONE gold button per page; everything else is a text button ---- */
.btn-imp-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--imp-radius-ctl);
  background: var(--imp-primary);
  color: var(--imp-primary-ink);
  font-size: var(--fs-2);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--imp-ease);
}
.btn-imp-primary:hover { background: var(--imp-primary-hover); }
.btn-imp-primary:active { background: var(--imp-primary-active); }
.btn-imp-full { width: 100%; }

.btn-text {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
  color: var(--imp-ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--imp-rule-strong);
  text-underline-offset: 4px;
  transition: text-decoration-color var(--imp-ease);
}
.btn-text:hover { text-decoration-color: var(--imp-ink); }
.btn-text[aria-current="page"] { text-decoration-color: var(--imp-ink); text-decoration-thickness: 2px; }
.btn-text--sm { min-height: 32px; font-size: var(--fs-1); }
button.btn-text { border: 0; background: none; font: inherit; font-weight: 600; cursor: pointer; }
button.btn-text--sm { font-size: var(--fs-1); }

/* the secondary action: an ink outline, quieter than the one gold button on the page */
.btn-imp-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--imp-ink);
  border-radius: var(--imp-radius-ctl);
  background: var(--imp-surface);
  color: var(--imp-ink);
  font-size: var(--fs-2);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--imp-ease), color var(--imp-ease);
}
.btn-imp-secondary:hover { background: var(--imp-ink); color: var(--imp-side-text); }

/* a destructive action (delete) is never the one gold button on a page: quiet, in the same
   red already used for debits and errors, until pressed. */
.btn-imp-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--imp-red);
  border-radius: var(--imp-radius-ctl);
  background: var(--imp-surface);
  color: var(--imp-red);
  font-size: var(--fs-2);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--imp-ease), color var(--imp-ease);
}
.btn-imp-danger:hover { background: var(--imp-red); color: var(--imp-side-text); }

.text-link { color: var(--imp-ink); font-weight: 600; text-underline-offset: 3px; }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 24px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }

/* ---- tables ---- */
.imp-table-wrap { position: relative; overflow-x: auto; }  /* relative: keeps the visually-hidden header inside the scroller */
.imp-table { width: 100%; border-collapse: collapse; font-size: var(--fs-2); }
.imp-table th {
  padding: 12px 20px;
  border-bottom: 1px solid var(--imp-rule);
  color: var(--imp-muted);
  font-size: var(--fs-1);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.imp-table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--imp-rule);
  vertical-align: top;
  overflow-wrap: anywhere;  /* a long unbroken order ref, name or file name never pushes the table wider */
}
.imp-table tbody tr:last-child td { border-bottom: 0; }
.imp-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.imp-table .when { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--imp-muted); }
.imp-table .action { text-align: right; white-space: nowrap; }
.imp-table td.action { padding-top: 6px; padding-bottom: 6px; }
.cell-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-sub { color: var(--imp-muted); font-size: var(--fs-1); }
.cell-file { max-width: 28ch; overflow-wrap: anywhere; }
.glance .cell-primary { white-space: nowrap; }

/* tracking numbers: tabular Archivo (not monospace), ink links, underline on hover only */
.tracking {
  color: var(--imp-ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.tracking:hover { text-decoration: underline; text-underline-offset: 3px; }

.text-red { color: var(--imp-red); }
.text-green { color: var(--imp-green); }
.num-inline { font-variant-numeric: tabular-nums; }

/* ---- definition lists (label detail, profile) ---- */
.facts { display: grid; gap: 20px 32px; grid: auto-flow / repeat(auto-fit, minmax(180px, 1fr)); }
.facts__item { min-width: 0; }
.facts__item--wide { grid-column: 1 / -1; }
.facts dt { font-size: var(--fs-1); color: var(--imp-muted); font-weight: 600; margin-bottom: 4px; }
.facts dd { overflow-wrap: anywhere; }
.facts dd + dd { margin-top: 4px; }
.tracking-lg {
  font-size: var(--fs-4);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  color: var(--imp-ink);
}
.address-block { font-style: normal; }
.address-block span { display: block; }
input[type="checkbox"] { width: 20px; height: 20px; margin: 0; accent-color: var(--imp-ink); }
.imp-table .select { width: 1%; }

/* ---- alerts: a white strip with a coloured left rule ---- */
.imp-alert {
  margin-bottom: 20px;
  padding: 12px 16px;
  border: 1px solid var(--imp-rule);
  border-left-width: 4px;
  border-radius: var(--imp-radius-ctl);
  background: var(--imp-surface);
}
.imp-alert > * + * { margin-top: 6px; }
.imp-alert-danger  { border-left-color: var(--imp-red); }
.imp-alert-success { border-left-color: var(--imp-green); }
.imp-alert-warning { border-left-color: var(--imp-primary-strong); }
.imp-alert-info    { border-left-color: var(--imp-ink); }

/* ---- progress (batch page) ---- */
.imp-progress-wrap { display: flex; flex-direction: column; gap: 10px; }
progress {
  width: 100%;
  height: 12px;
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: var(--imp-bg);
  overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--imp-bg); border-radius: 6px; }
progress::-webkit-progress-value { background: var(--imp-ink); border-radius: 6px; }
progress::-moz-progress-bar { background: var(--imp-ink); border-radius: 6px; }
.progress-counts { font-variant-numeric: tabular-nums; color: var(--imp-muted); }
.imp-progress-wrap + .field-error { margin-top: 16px; }

/* ---- pager ---- */
.pager { justify-content: flex-end; }
.pager__export { margin-right: auto; }

/* ---- filter bar (labels, wallet): fields in a row that wraps, the action at the end ---- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-bottom: 20px; }
.filter-bar .field { flex: 0 1 180px; }
.filter-bar .filter-bar__search { flex: 1 1 260px; }
.filter-bar__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-height: 44px; }
.filter-bar__note { flex: 1 1 100%; }

/* ---- the balance stamp: the one bold element (dashboard + wallet) ----
   A gold postage stamp. The perforations are real holes: a mask of radial-gradient
   dots centred on the edge line, unioned with a solid inner rectangle. */
.stamp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 32px; margin-bottom: 32px; }
.stamp {
  --perf: 5px;                 /* hole radius */
  --pitch: 16px;               /* hole spacing */
  position: relative;
  min-width: 260px;
  padding: 30px 34px 26px;
  background: var(--imp-primary);
  color: var(--imp-primary-ink);
  -webkit-mask:
    radial-gradient(circle var(--perf), #0000 96%, #000) round calc(var(--pitch) / -2) calc(var(--pitch) / -2) / var(--pitch) var(--pitch),
    linear-gradient(#000 0 0) no-repeat 50% 50% / calc(100% - var(--pitch)) calc(100% - var(--pitch));
          mask:
    radial-gradient(circle var(--perf), #0000 96%, #000) round calc(var(--pitch) / -2) calc(var(--pitch) / -2) / var(--pitch) var(--pitch),
    linear-gradient(#000 0 0) no-repeat 50% 50% / calc(100% - var(--pitch)) calc(100% - var(--pitch));
}
/* the printed frame inside the perforations */
.stamp::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px solid var(--imp-ink-frame);
  pointer-events: none;
}
.stamp__amount {
  font-size: var(--fs-6);
  font-weight: 700;
  font-stretch: var(--imp-wide);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--imp-ink);
}
.stamp__label { margin-top: 6px; font-size: var(--fs-2); font-weight: 500; color: var(--imp-primary-ink); }
.stamp-row__actions { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.stamp-row__note { color: var(--imp-muted); max-width: 36ch; }

/* ---- error page ---- */
.imp-error { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.imp-error-card {
  width: 100%;
  max-width: 480px;
  padding: 32px;
  background: var(--imp-surface);
  border: 1px solid var(--imp-rule);
  border-radius: var(--imp-radius);
}
.imp-error-seal { display: block; width: 40px; height: 40px; margin-bottom: 20px; }
.imp-error-title { font-size: var(--fs-4); font-weight: 700; font-stretch: var(--imp-wide); margin-bottom: 8px; }
.imp-error-card .ref { margin-top: 16px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.imp-error-actions { margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* plan P9: the price-changes list inside a table cell */
.price-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
