@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/fonts/bricolage-grotesque-latin-wght-normal.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans';
  src: url('/fonts/instrument-sans-latin-wght-normal.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --ink: #1c1917;
  --graphite: #44403c;
  --steel: #6b6460;
  --rule: #e7e5e4;
  --edge: #d6d3d1;
  --receipt: #fff4ec;
  --orange: #ea580c;
  --orange-text: #c2410c;
  --orange-light: #fb923c;
  --grid: rgba(28, 25, 23, 0.055);
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-text: 'Instrument Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --gutter: clamp(16px, 4vw, 40px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--edge) var(--paper);
}
body {
  margin: 0;
  background: #fbfaf9;
  color: var(--ink);
  font: 400 1rem/1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
}
::selection {
  background: #fed7aa;
  color: var(--ink);
}
a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover {
  color: var(--orange-text);
}
:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
  border-radius: 2px;
}
.mono {
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--steel);
}
.small {
  font-size: 0.8125rem;
}
.sheet {
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
.h2 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.h3 {
  font-family: var(--font-display);
  font-weight: 560;
  font-size: 1.125rem;
  margin: 0;
}

/* Logo */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.logo__mark {
  flex: none;
  width: 28px;
  height: 28px;
}
.logo__word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.03em;
  line-height: 1;
}
.logo__wise {
  color: var(--orange-text);
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.03);
}
.topbar__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.topbar__home {
  text-decoration: none;
}
.topbar__nav {
  display: flex;
  gap: 4px;
  margin-right: auto;
  font-size: 0.9375rem;
  font-weight: 500;
}
.topbar__nav a {
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 4px;
}
.topbar__nav a[aria-current='page'] {
  background: var(--ink);
  color: var(--paper);
}
.topbar__user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--graphite);
}

/* Layout */
.page {
  padding: clamp(24px, 4vw, 40px) 0 72px;
}
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  gap: 20px;
}
.wrap--narrow {
  max-width: 760px;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head .muted {
  margin: 0;
}
.toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 20px;
  align-items: start;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}
.stack {
  display: grid;
  gap: 16px;
}

/* Cards and summary */
.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 20px;
  display: grid;
  gap: 14px;
}
.card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
}
.summary__item {
  padding: 16px 20px;
  display: grid;
  gap: 4px;
  border-left: 1px solid var(--rule);
}
.summary__item:first-child {
  border-left: 0;
}
.summary__label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--steel);
}
.summary__value {
  font-size: 1.5rem;
}

/* Tables */
.table-scroll {
  overflow-x: auto;
}
.report {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.report th,
.report td {
  text-align: left;
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
  vertical-align: middle;
}
.report thead th {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--steel);
  border-bottom: 2px solid var(--ink);
}
.report tbody th {
  font-weight: 600;
}
.report tbody tr:last-child > * {
  border-bottom: 0;
}
.report td.mono {
  font-size: 0.875rem;
}
.report .is-flagged > * {
  background: var(--receipt);
}
.report .is-flagged th a {
  color: var(--orange-text);
}
.report__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}
.report__bar .mono {
  width: 4ch;
  text-align: right;
}
.note-cell {
  white-space: normal !important;
  min-width: 180px;
  color: var(--graphite);
  font-size: 0.875rem;
}
.report .bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--rule);
  position: relative;
}
.bar__fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
  background: var(--ink);
}
.is-flagged .bar__fill {
  background: var(--orange);
}
.bar__target {
  position: absolute;
  left: 83.333%;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--steel);
}

/* Alerts and focus */
.alerts {
  list-style: none;
  margin: 0;
  padding: 0;
}
.alerts li {
  display: grid;
  gap: 2px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.alerts li:last-child {
  border-bottom: 0;
}
.alerts span {
  color: var(--orange-text);
  font-size: 0.9375rem;
}
.focus-list {
  display: grid;
  gap: 12px;
}
.focus-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}
.focus-note {
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  padding: 16px 20px;
}
.focus-note__label {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--orange-light);
}
.focus-note__text {
  margin: 0;
  font-size: 1.0625rem;
}

/* Forms */
.field {
  display: grid;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
}
.field small {
  font-weight: 400;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--edge);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: 500 1rem/1.4 var(--font-text);
  caret-color: var(--orange);
}
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 0;
  border-color: var(--orange);
}
.field input[type='number'] {
  font-family: var(--font-mono);
  font-size: 1.125rem;
}
.field--inline input,
.field--inline select {
  min-height: 38px;
  padding: 6px 10px;
}
.close-form .field input[type='number'] {
  min-height: 52px;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  padding-top: 14px;
  border-top: 1px dashed var(--edge);
}
.row-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-form input {
  width: 110px;
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--edge);
  font: 500 0.9375rem var(--font-mono);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  border-radius: 2px;
  border: 1px solid transparent;
  font: 600 0.9375rem/1.2 var(--font-text);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.btn--dark {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.btn--dark:hover {
  background: #000;
  color: var(--paper);
}
.btn--orange {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--ink);
}
.btn--orange:hover {
  background: var(--orange-light);
  color: var(--ink);
}
.btn--outline {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.btn--outline:hover {
  background: var(--ink);
  color: var(--paper);
}
.btn--small {
  min-height: 34px;
  padding: 4px 10px;
  font-size: 0.8125rem;
}
.btn--quiet {
  min-height: 34px;
  padding: 4px 8px;
  background: none;
  color: var(--graphite);
  text-decoration: underline;
}

/* Flash and invite */
.flash {
  margin: 0;
  padding: 12px 16px;
  border-radius: 4px;
  font-weight: 600;
}
.flash--ok {
  background: #ecfdf3;
  color: #166534;
}
.flash--error {
  background: var(--receipt);
  color: var(--orange-text);
}
.invite-box {
  background: var(--receipt);
  border-radius: 8px;
  padding: 16px 20px;
  display: grid;
  gap: 10px;
}
.invite-box p {
  margin: 0;
}
.invite-box__url {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--edge);
  background: var(--paper);
  font-size: 0.875rem;
}

/* Chart */
.chart {
  width: 100%;
  height: auto;
}
.chart__grid {
  stroke: var(--rule);
}
.chart__axis {
  font: 500 11px var(--font-mono);
  fill: var(--steel);
}
.chart__bar {
  fill: var(--ink);
}
.chart__bar--low {
  fill: var(--orange);
}
.chart__target {
  stroke: var(--steel);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

/* Auth */
.auth {
  min-height: calc(100vh - 160px);
  display: grid;
  place-items: center;
  padding: 24px var(--gutter);
}
.auth__card {
  width: min(100%, 420px);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 14px;
  box-shadow: 0 24px 40px -28px rgba(28, 25, 23, 0.3);
}
.auth__card p {
  margin: 0;
}

@media (max-width: 900px) {
  .split {
    grid-template-columns: 1fr;
  }
  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .summary__item:nth-child(3) {
    border-left: 0;
  }
  .summary__item:nth-child(n + 3) {
    border-top: 1px solid var(--rule);
  }
}

@media (max-width: 640px) {
  .topbar__inner {
    flex-wrap: wrap;
    gap: 8px 16px;
    padding-block: 8px;
  }
  .topbar__nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }
  .topbar__user span {
    display: none;
  }
  .topbar__user {
    margin-left: auto;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .focus-row {
    grid-template-columns: 1fr;
  }
}

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