@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* Same palette and type as samuelwiseman.com */
:root {
  --bg: #f2f3f5;
  --surface: #fff;
  --field: #f7f8f9;
  --line: #e3e5e9;
  --line-strong: #d2d5db;
  --text: #17181a;
  --muted: #62656c;
  --faint: #7b7e85;
  --dark: #141517;
  --critical: #c42b2b;

  --sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.mono, .fig {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }

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

.col { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 16px; padding-bottom: 64px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 48px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}

/* ---- pills and buttons ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .55);
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}
a.pill:hover { background: var(--surface); }
.pill.brand { font-weight: 500; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 16px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .5);
  color: var(--text);
  border-radius: 13px;
  cursor: pointer;
}
.btn:hover { background: var(--surface); }
.btn:disabled { opacity: 0.6; cursor: default; }

.btn-primary { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn-primary:hover { background: #000; }

.btn-danger { color: var(--critical); border-color: #ecc4c4; }
.btn-danger:hover { background: #fdf3f3; }

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

/* ---- page furniture ---- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 40px; }
.month-nav { gap: 4px; padding: 0 6px; }
.month-nav a { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; text-decoration: none; }
.month-nav a:hover { background: rgba(20, 21, 23, .05); }
.month-nav span { min-width: 128px; text-align: center; font-size: 14px; }
.chart { margin-top: 28px; padding: 22px 22px 18px; }
.page-actions { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px; }

.login { min-height: calc(100dvh - 90px); display: grid; place-content: center; justify-items: center; text-align: center; }
.login .hero { font-family: var(--sans); font-size: 36px; font-weight: 600; letter-spacing: -0.02em; }
.login .muted { margin: 10px 0 28px; }
.login .form-error { margin-bottom: 16px; }

.back { margin-bottom: 36px; }
.page-title { font-size: 22px; font-weight: 500; margin-bottom: 8px; }
.section-title { font-size: 17px; font-weight: 500; margin-bottom: 8px; }
.lead { margin-bottom: 24px; }
.block { margin-bottom: 40px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.text-input {
  height: 42px; font: inherit; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 12px;
}

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

/* ---- stacked bar ---- */
.bar { display: flex; gap: 3px; height: 44px; margin: 0 0 8px; }
.bar-seg { border: 0; padding: 0; cursor: pointer; position: relative; border-radius: 6px; transition: opacity 0.15s; }

.bar-empty {
  height: 44px; border: 1px dashed var(--line-strong); border-radius: 8px;
  display: grid; place-content: center; color: var(--faint); font-size: 13px;
}

.bar-axis {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 11px; color: var(--faint);
}

.tip {
  display: none;
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  box-shadow: 0 8px 24px -12px rgba(20, 21, 23, .3);
  border-radius: 10px; padding: 7px 10px; white-space: nowrap; font-size: 12px;
  pointer-events: none; z-index: 5;
}
.bar-seg:hover .tip, .bar-seg:focus .tip { display: block; }

.legend { display: grid; margin-top: 18px; border-top: 1px solid var(--line); }
.legend > div + div { border-top: 1px solid var(--line); }
.legend-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 0; padding: 12px 0; margin: 0;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.legend-caret { color: var(--faint); font-size: 11px; width: 12px; text-align: right; }
.legend-entries { list-style: none; margin: -4px 0 12px; padding: 0 0 0 20px; display: grid; gap: 6px; }
.legend-entries[hidden] { display: none; }
.legend-entry { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); }
.legend-entry-amt { color: var(--text); }
.legend-sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-name { flex: 1; }
.legend-pct { color: var(--muted); font-size: 13px; width: 42px; text-align: right; }

.table-toggle { margin-top: 10px; }
.table-toggle summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 8px 0; border-bottom: 1px solid var(--line); }
.data-table th { font-weight: 500; }
.data-table td.num, .data-table th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---- entries ---- */
.entries-head { display: flex; justify-content: space-between; align-items: flex-end; margin: 0 4px 24px; }
.entries-total { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 32px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.2; margin-top: 4px; }
.empty { color: var(--faint); padding: 48px 0; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }

.entry-group + .entry-group { margin-top: 28px; }
.group-title {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0 4px 10px; font-size: 15px; font-weight: 500;
}
.group-sum { font-family: var(--mono); font-size: 13px; font-weight: 400; color: var(--muted); }

.entries { list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 6px; }
.entries li + li { border-top: 1px solid var(--line); }

.entry {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.entry:hover { background: var(--field); }
.entry-tile {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 12px;
  font-weight: 600; font-size: 15px; color: rgba(20, 21, 23, .72);
  box-shadow: inset 0 0 0 1px rgba(20, 21, 23, .06);
}
.entry-text { display: grid; gap: 1px; min-width: 0; }
.entry-name { font-weight: 500; overflow-wrap: anywhere; }
.entry-meta { font-size: 13px; color: var(--muted); }
.entry-amt { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 15px; }
.entry-chev { color: var(--faint); font-size: 20px; line-height: 1; margin-left: -4px; }

@media (max-width: 480px) {
  .top { margin-bottom: 28px; }
  .pill { height: 42px; padding: 0 12px; border-radius: 14px; font-size: 14px; }
  .month-nav { padding: 0 4px; }
  .month-nav span { min-width: 0; padding: 0 2px; font-size: 13px; }
  .month-nav a { width: 30px; }
  .top { gap: 8px; }
  .entries { padding: 4px; }
  .entry { gap: 12px; padding: 12px 10px; }
  .entry-chev { display: none; }
  .entries-total { font-size: 28px; }
  .dialog-extra { flex-basis: 100%; justify-content: space-between; margin: 0 0 4px; }
  dialog .field-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dialog { padding: 20px; }
  .chart { padding: 18px 16px 14px; }
}

/* ---- dialog ---- */
dialog {
  margin: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 24px 60px -24px rgba(20, 21, 23, .35);
  padding: 24px; width: min(480px, 92vw);
}
dialog::backdrop { background: rgb(20 21 23 / 0.25); backdrop-filter: blur(2px); }
.dialog-title { font-size: 18px; font-weight: 500; margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.field-row label { min-width: 0; }
dialog label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
dialog input, dialog textarea {
  display: block; width: 100%; margin-top: 6px; font: inherit; color: var(--text);
  background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
/* iOS Safari draws date inputs natively (own width, height and centring) unless
   appearance is reset; after that it sizes like any other field. */
dialog input:not([type="checkbox"]) { line-height: 24px; min-width: 0; }
dialog input[type="date"] { -webkit-appearance: none; appearance: none; height: 46px; text-align: left; }
dialog input[type="date"]::-webkit-date-and-time-value { text-align: left; }
dialog input:focus, dialog textarea:focus { background: var(--surface); border-color: var(--line-strong); }
dialog label.check { display: flex; align-items: center; color: var(--text); }
dialog input[type="checkbox"] { width: 16px; height: 16px; margin: 0 8px 0 0; accent-color: var(--dark); }
.form-error { color: var(--critical); font-size: 14px; margin-bottom: 14px; }
.form-error[hidden], .dialog-note[hidden] { display: none; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.dialog-actions .btn-primary { order: 3; }
.dialog-actions [data-close] { order: 2; }
.dialog-extra { order: 1; display: flex; gap: 2px; margin-right: auto; }
.dialog-extra .btn { border-color: transparent; background: transparent; padding: 0 10px; font-weight: 400; color: var(--muted); }
.dialog-extra .btn:hover { background: var(--field); color: var(--text); }
.dialog-extra .btn-danger { color: var(--critical); }
.dialog-extra .btn-danger:hover { background: #fdf3f3; color: var(--critical); }
.dialog-extra[hidden], .dialog-extra [hidden] { display: none; }
.dialog-note { color: var(--faint); font-size: 13px; margin-bottom: 14px; }

/* ---- footer (matches samuelwiseman.com) ---- */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px;
  margin-top: 24px; padding-top: 22px; padding-bottom: 32px;
  border-top: 1px solid var(--line);
  color: var(--faint); font-size: 13px;
}
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
