/* FairOffer components — logical properties throughout so RTL (fa-IR) and LTR (en-CA) share one stylesheet.
 * 0.21.0: calmer and lighter — borderless cards on a tinted page, larger touch targets, quieter provenance marks,
 * fewer lines. Every colour comes from tokens.css, so the three themes restyle everything here. */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
body {
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  font: 400 var(--fs-md) / var(--lh-body) var(--font-ui);
}
:lang(fa) body,
body:lang(fa) {
  font-family: var(--font-fa);
}
h1,
h2,
h3 {
  font-family: var(--font-head);
  line-height: var(--lh-tight);
  margin: 0 0 var(--s3);
  font-weight: 700;
  letter-spacing: -0.01em;
}
/* Persian has no capitals to carry weight and joins letters: no negative tracking, a little more leading */
:lang(fa) :is(h1, h2, h3) {
  letter-spacing: 0;
  line-height: 1.4;
}
h1 {
  font-size: var(--fs-2xl);
  font-weight: 800;
}
h2 {
  font-size: var(--fs-xl);
}
h3 {
  font-size: var(--fs-lg);
}
:lang(fa) h1,
:lang(fa) h2,
:lang(fa) h3 {
  letter-spacing: 0;
}
p {
  margin: 0 0 var(--s3);
  max-width: var(--measure);
}
a {
  color: var(--primary);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}
.visually-hidden {
  position: absolute !important;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.muted {
  color: var(--on-surface-variant);
}
.small {
  font-size: var(--fs-sm);
}

/* ---------- figures & provenance marks (signature, quieter in 0.21.0) ---------- */
.figure {
  font-family: var(--font-figure);
  font-variant-numeric: var(--nums);
  font-weight: 650;
  unicode-bidi: isolate;
  direction: ltr;
  display: inline-block;
  white-space: nowrap;
}
.figure.big {
  font-size: var(--fs-3xl);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.figure.mid {
  font-size: var(--fs-xl);
  font-weight: 750;
}
.prov {
  text-decoration-line: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.28em;
}
.figure.big.prov {
  text-decoration-thickness: 2px;
}
.prov-document {
  text-decoration-style: solid;
  text-decoration-color: color-mix(in srgb, var(--verified) 55%, transparent);
}
.prov-stated {
  text-decoration-style: dashed;
  text-decoration-color: color-mix(in srgb, var(--stated) 60%, transparent);
}
.prov-unknown {
  text-decoration-style: dotted;
  text-decoration-color: var(--unknown);
}
.prov-calculated {
  text-decoration-style: double;
  text-decoration-color: color-mix(in srgb, var(--ink-3) 55%, transparent);
}
.prov-synthetic {
  text-decoration-style: wavy;
  text-decoration-color: color-mix(in srgb, var(--estimate) 70%, transparent);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
  font-size: var(--fs-sm);
  color: var(--on-surface-variant);
  padding: 0;
  margin: 0;
  list-style: none;
}

/* ---------- controls ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  padding: 12px 24px;
  min-block-size: 48px;
  font: 700 var(--fs-md) / 1.2 var(--font-ui);
  cursor: pointer;
  background: var(--primary);
  color: var(--on-primary);
  transition: filter var(--dur-short) var(--ease-standard), background var(--dur-short) var(--ease-standard);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  text-decoration: none;
  text-align: center;
}
:lang(fa) .btn {
  font-family: var(--font-fa);
}
.btn:hover {
  filter: brightness(1.06);
}
.btn:active {
  filter: brightness(0.96);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.tonal {
  background: var(--primary-soft);
  color: var(--primary);
}
.btn.outline {
  background: var(--surface-container);
  color: var(--on-surface);
  border-color: var(--outline-strong);
}
.btn.text {
  background: transparent;
  color: var(--primary);
  padding-inline: 12px;
  min-block-size: 44px;
  font-weight: 650;
  font-size: var(--fs-sm);
}
.btn.text:hover {
  background: var(--surface-container-high);
  filter: none;
}
.btn.danger {
  background: var(--negative);
  color: var(--surface-container);
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: center;
}
.field {
  display: grid;
  gap: 8px;
  margin-block-end: var(--s4);
}
.field > label,
.field > .label {
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--on-surface);
}
.field .hint {
  font-size: var(--fs-xs);
  line-height: 1.55;
  color: var(--ink-3);
}
input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='month'],
input[type='time'],
input[type='url'],
input[type='search'],
input[type='tel'],
input[type='datetime-local'],
select,
textarea {
  font: inherit;
  color: var(--on-surface);
  background: var(--surface-container);
  border: 1px solid var(--outline-strong);
  border-radius: var(--r-control);
  padding: 12px 16px;
  min-block-size: 48px;
  inline-size: 100%;
  transition: border-color var(--dur-short) var(--ease-standard), box-shadow var(--dur-short) var(--ease-standard);
}
select {
  padding-inline-end: 36px;
}
textarea {
  min-block-size: 160px;
  resize: vertical;
  line-height: 1.6;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
  outline: none;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
input[type='file'] {
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--on-surface-variant);
  inline-size: 100%;
  max-inline-size: 100%;
}
input[type='file']::file-selector-button {
  font: 650 var(--fs-sm) / 1 var(--font-ui);
  border: 0;
  border-radius: var(--r-btn);
  background: var(--primary-soft);
  color: var(--primary);
  padding: 12px 16px;
  min-block-size: 44px;
  margin-inline-end: var(--s3);
  cursor: pointer;
}
:lang(fa) input[type='file']::file-selector-button {
  font-family: var(--font-fa);
}
.input-money {
  direction: ltr;
  text-align: start;
}
:dir(rtl) .input-money {
  text-align: end;
}
.check {
  display: flex;
  gap: var(--s2);
  align-items: flex-start;
  margin-block: var(--s2);
}
.check input,
input[type='checkbox'],
input[type='radio'] {
  inline-size: 20px;
  block-size: 20px;
  accent-color: var(--primary);
}
.check input {
  margin-block-start: 4px;
  flex: none;
}
.grid-2 {
  display: grid;
  gap: 0 var(--s4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

/* segmented tri-state (Yes / No / Not sure yet) */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-container-high);
  border-radius: var(--r-btn);
}
.segmented label {
  position: relative;
  padding: 8px 16px;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  min-block-size: 40px;
  display: flex;
  align-items: center;
  border-radius: calc(var(--r-btn) - 4px);
  color: var(--on-surface-variant);
}
.segmented input {
  position: absolute;
  opacity: 0;
}
.segmented label:has(input:checked) {
  background: var(--surface-container);
  color: var(--on-surface);
  box-shadow: var(--shadow-card);
  font-weight: 700;
}
.segmented label:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

/* ---------- surfaces ---------- */
.panel {
  background: var(--surface-container);
  border: 0;
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-card);
  padding: var(--card-pad);
}
.panel + .panel {
  margin-block-start: var(--gutter);
}
.panel > h2:first-child,
.panel > h3:first-child {
  margin-block-start: 0;
}
.panel h2 {
  font-size: var(--fs-lg);
}
.panel h3 {
  font-size: var(--fs-md);
}
.sheet {
  background: var(--surface-container);
  border-radius: var(--r-sheet);
  padding: var(--s6);
  box-shadow: var(--shadow-card);
}
.divider {
  border: 0;
  border-block-start: 1px solid var(--outline);
  margin-block: var(--s5);
}

/* chips (state = text + shape, colour secondary) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--r-chip);
  padding: 4px 12px;
  font-size: var(--fs-xs);
  font-weight: 650;
  line-height: 1.4;
  border: 0;
  white-space: nowrap;
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
}
.chip::before {
  content: '';
  inline-size: 7px;
  block-size: 7px;
  border-radius: 2px;
  background: currentColor;
  flex: none;
}
.chip.ok {
  color: var(--verified);
  background: var(--verified-soft);
}
.chip.unknown {
  color: var(--unknown);
  background: var(--unknown-soft);
}
.chip.unknown::before {
  border-radius: 50%;
  background: transparent;
  border: 2px dotted currentColor;
  inline-size: 9px;
  block-size: 9px;
}
.chip.bad {
  color: var(--negative);
  background: var(--negative-soft);
}
.chip.bad::before {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  border-radius: 0;
  inline-size: 9px;
  block-size: 8px;
}
.chip.info {
  color: var(--stated);
  background: var(--stated-soft);
}
.chip.warn {
  color: var(--estimate);
  background: var(--estimate-soft);
}
.chip.warn::before {
  border-radius: 50%;
}

/* banners: a soft tint and a leading mark, no heavy edge */
.banner {
  position: relative;
  border-radius: var(--r-control);
  padding: var(--s3) var(--s4);
  padding-inline-start: var(--s6);
  background: var(--surface-container-high);
  margin-block: var(--s3);
  color: var(--on-surface-variant);
}
.banner::before {
  content: '';
  position: absolute;
  inset-inline-start: var(--s4);
  inset-block-start: calc(var(--s3) + 0.55em);
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  background: currentColor;
}
.banner p {
  color: var(--on-surface);
  margin: 0;
}
.banner p + p {
  margin-block-start: var(--s1);
}
.banner strong {
  display: block;
  margin-block-end: 2px;
  color: var(--on-surface);
}
.banner .btn {
  margin-block-start: var(--s2);
}
.banner.unknown {
  color: var(--unknown);
  background: var(--unknown-soft);
}
.banner.bad {
  color: var(--negative);
  background: var(--negative-soft);
}
.banner.ok {
  color: var(--verified);
  background: var(--verified-soft);
}
.banner.warn {
  color: var(--estimate);
  background: var(--estimate-soft);
}
.banner.info {
  color: var(--stated);
  background: var(--stated-soft);
}

/* tables: lines only between rows */
.table-wrap {
  overflow-x: auto;
  border: 0;
  border-radius: var(--r-panel);
  background: var(--surface-container);
  box-shadow: var(--shadow-card);
}
.panel .table-wrap {
  box-shadow: none;
  border-radius: var(--r-control);
  margin-inline: calc(var(--s2) * -1);
}
table {
  border-collapse: collapse;
  inline-size: 100%;
  font-size: var(--fs-sm);
}
th,
td {
  text-align: start;
  padding: 12px 16px;
  border-block-end: 1px solid var(--outline);
  vertical-align: top;
}
th {
  color: var(--ink-3);
  font-weight: 650;
  font-size: var(--fs-xs);
  background: transparent;
}
tr:last-child td {
  border-block-end: 0;
}
td.num,
th.num {
  text-align: end;
}

/* evidence highlighting in source text */
.source-text {
  white-space: pre-wrap;
  font-size: var(--fs-sm);
  line-height: 1.8;
  background: var(--surface-container-high);
  border: 0;
  border-radius: var(--r-control);
  padding: var(--s4);
  max-block-size: 360px;
  overflow: auto;
  direction: ltr;
  text-align: left;
}
mark.ev {
  background: var(--verified-soft);
  color: inherit;
  border-block-end: 2px solid var(--verified);
  padding-inline: 1px;
  border-radius: 2px;
}
mark.ev.conflict {
  background: var(--negative-soft);
  border-color: var(--negative);
}

/* stepper (a real sequence) */
.stepper {
  list-style: none;
  display: flex;
  gap: var(--s2);
  padding: 0;
  margin: 0 0 var(--s5);
  counter-reset: step;
  flex-wrap: wrap;
}
.stepper li {
  counter-increment: step;
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.stepper li::before {
  content: counter(step);
  inline-size: 26px;
  block-size: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-container-high);
  font-weight: 700;
  font-size: var(--fs-xs);
}
.stepper li[aria-current='step'] {
  color: var(--on-surface);
  font-weight: 700;
}
.stepper li[aria-current='step']::before {
  background: var(--primary);
  color: var(--on-primary);
}
.stepper li.done {
  color: var(--verified);
}
.stepper li + li::after {
  order: -1;
  content: '';
  inline-size: 16px;
  block-size: 2px;
  border-radius: 2px;
  background: var(--outline);
}

/* toast */
.toast {
  position: fixed;
  inset-block-end: 96px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--slate-0);
  padding: 12px 16px;
  border-radius: var(--r-btn);
  box-shadow: var(--shadow-float);
  z-index: 50;
  font-size: var(--fs-sm);
  font-weight: 600;
  max-inline-size: min(92vw, 520px);
}
:dir(rtl) .toast {
  transform: translateX(50%);
}

details.faq {
  border-block-end: 1px solid var(--outline);
  padding-block: var(--s3);
}
details.faq summary {
  cursor: pointer;
  font-weight: 650;
  min-block-size: 32px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

fieldset {
  border: 0;
  border-radius: var(--r-control);
  background: var(--surface-container-high);
  padding: var(--s3) var(--s4) var(--s4);
  margin: 0 0 var(--s3);
}
legend {
  padding: 0;
  font-weight: 650;
  font-size: var(--fs-sm);
  float: inline-start;
  inline-size: 100%;
  margin-block-end: var(--s2);
}
fieldset > legend + * {
  clear: both;
}

/* F231 Context Help (packages/context-help) in FairOffer's tokens — used by the app, the site and the console */
:root {
  --ch-bg: var(--surface-container);
  --ch-ink: var(--on-surface);
  --ch-muted: var(--on-surface-variant);
  --ch-accent: var(--primary);
  --ch-on-accent: var(--on-primary);
  --ch-line: var(--outline);
  --ch-soft: var(--surface-container-high);
  --ch-radius: var(--r-sheet, 16px);
  --ch-font: var(--font-ui);
  --ch-official: var(--verified);
}
:root[lang^='fa'] {
  --ch-font: var(--font-fa, var(--font-ui));
}
