/* Base: reset, typography, links, utilities (tokens in tokens.css, documented in docs/DESIGN_SYSTEM.md) */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  background: var(--color-bg);
}

/* Body: Roboto 400 16/24 on the light blue-grey ground. */
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  color: var(--color-text);
  background: var(--color-bg);
  font-feature-settings: var(--font-features-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: anywhere;
}

body.has-sheet,
body.has-dialog { overflow: hidden; }

h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd { margin: 0; }

/* Headings: Roboto 700. h1 = title 22/28, h2 = heading 17/24, h3 = 16/24, h4 = 14/20. */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  overflow-wrap: normal;
}

h1 { font-size: var(--text-title); line-height: var(--leading-title); }
h2 { font-size: var(--text-heading); }
h3 { font-size: var(--text-body); line-height: var(--leading-body); }
h4 { font-size: var(--text-label); line-height: var(--leading-label); }

/* Money and figures: Roboto 700 with tabular numerals, so columns line up and digits never shift. */
.num,
.money,
.stat__value,
.metric__value,
.kpi__value,
.hero__value,
.summary-card__value,
.figure__value,
.money-row__amount,
.amount-input--hero,
.amount-input .input,
td.num,
[data-amount] {
  font-family: var(--font-numeric);
  font-weight: var(--weight-display);
  font-variant-numeric: tabular-nums;
  font-feature-settings: var(--font-features-numeric);
  letter-spacing: var(--tracking-tight);
}

small { font-size: var(--text-caption); line-height: var(--leading-caption); }

strong,
b { font-weight: var(--weight-semibold); }

ul,
ol { margin: 0; padding: 0; }

ul[class],
ol[class] { list-style: none; }

a {
  color: var(--color-primary-text);
  text-decoration: none;
  text-underline-offset: 0.15em;
}

a:hover { text-decoration: underline; }

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

svg.icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
  width: 1.25em;
  height: 1.25em;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}

button:disabled,
[aria-disabled="true"] { cursor: not-allowed; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
table { border-collapse: collapse; border-spacing: 0; }

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

code,
kbd,
pre { font-family: var(--font-mono); font-size: 0.9em; }

kbd {
  padding: 0.1em 0.45em;
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  font-size: var(--text-caption);
}

summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }

[hidden] { display: none !important; }
::selection { background: var(--color-primary-soft); color: var(--color-text); }

/* Focus ring in primary (3px), offset so it reads on any surface. */
:focus { outline: none; }

:focus-visible {
  outline: 3px solid var(--color-border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Layout primitives --------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: max(var(--gutter), var(--safe-left)) max(var(--gutter), var(--safe-right));
}

.container--narrow { max-width: var(--content-narrow); }

/* Stacks of cards sit 12px apart (8 for --sm, 16 for --md, 24 for --lg). */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, var(--stack-gap-default, var(--space-3)));
}

.stack--sm { --stack-gap: var(--space-2); }
.stack--md { --stack-gap: var(--space-4); }
.stack--lg { --stack-gap: var(--space-6); }

.stack--xl { --stack-gap: var(--space-8); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-2));
}

.cluster--between { justify-content: space-between; }
.cluster--end { justify-content: flex-end; }

.cluster--nowrap { flex-wrap: nowrap; }

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

@media (min-width: 640px) {
  .grid--2,
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1200px) {
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.grid--auto { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.grid__span-2 { grid-column: 1 / -1; }

.divider {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-4) 0;
}

/* Utilities ----------------------------------------------------------- */

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

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  transform: translateY(-200%);
}

.skip-link:focus { transform: none; }
.text-muted { color: var(--color-text-muted); }

.text-subtle { color: var(--color-text-subtle); }
.text-primary { color: var(--color-primary-text); }
.text-teal { color: var(--color-teal); }

/* Type scale as utilities: label 14/20 500, caption 12/16 500. */
.text-xs,
.text-caption { font-size: var(--text-caption); line-height: var(--leading-caption); font-weight: var(--weight-medium); }
.text-sm,
.text-label { font-size: var(--text-label); line-height: var(--leading-label); }
.text-lg { font-size: var(--text-heading); line-height: var(--leading-heading); }
.text-title { font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-title); line-height: var(--leading-title); letter-spacing: var(--tracking-tight); }
.text-heading { font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-heading); line-height: var(--leading-heading); letter-spacing: var(--tracking-tight); }
.text-display { font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-display); line-height: var(--leading-display); letter-spacing: var(--tracking-tight); font-variant-numeric: tabular-nums; }

.text-center { text-align: center; }
.text-right { text-align: right; }

.text-medium { font-weight: var(--weight-medium); }
.text-semibold { font-weight: var(--weight-semibold); }
.text-success { color: var(--color-success); }

.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }

.numeric,
.tabular { font-variant-numeric: tabular-nums; }

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

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.flex-1 { flex: 1 1 0; min-width: 0; }
.w-full { width: 100%; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.hide-mobile { display: none !important; }

@media (min-width: 900px) {
  .hide-mobile { display: revert !important; }
  .hide-desktop { display: none !important; }
}

/* Print basics (print.css has the full set) --------------------------- */

@media print {
  body { background: var(--color-surface); color: var(--color-text); }
  a { color: inherit; }
}
