:root {
  color-scheme: light dark;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1f2421;
  --muted: #68706b;
  --line: #dedcd4;
  --accent: #1f6f54;
  --accent-text: #ffffff;
  --positive: #1b7a56;
  --negative: #b4372f;
  --alert-bg: #fbeae8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181a;
    --surface: #1f2427;
    --text: #e9ece9;
    --muted: #9aa39e;
    --line: #343b3e;
    --accent: #4fbc92;
    --accent-text: #0e1a15;
    --positive: #5fcfa3;
    --negative: #f0897f;
    --alert-bg: #3a2220;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1,
h2,
h3,
p,
dl,
dd,
ol,
ul {
  margin: 0;
  padding: 0;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.2;
}

h2 {
  font-size: 0.95rem;
}

h3 {
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

ol {
  list-style: none;
}

.page {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 44rem;
  margin: 0 auto;
  padding: 1rem 1rem 0;
}

.brand {
  color: inherit;
  font-weight: 650;
  text-decoration: none;
}

.signout {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

.amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

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

.button {
  display: inline-block;
  padding: 0.55rem 1rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.link {
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.link.danger {
  color: var(--negative);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Totals */

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.summary > div {
  min-width: 0;
  padding: 0.9rem 1rem;
}

.summary > div + div {
  border-left: 1px solid var(--line);
}

.summary .amount {
  display: block;
  overflow: hidden;
  font-size: 1.3rem;
  text-overflow: ellipsis;
}

.label,
dt {
  color: var(--muted);
  font-size: 0.8rem;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.75rem 0 1rem;
}

.empty {
  padding: 2.5rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

/* Timeline */

.day {
  margin-top: 1.5rem;
}

.day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.items {
  position: relative;
  margin-left: 0.4rem;
  padding-left: 1.25rem;
  border-left: 2px solid var(--line);
}

.item {
  position: relative;
  padding-bottom: 0.75rem;
}

.item:last-child {
  padding-bottom: 0;
}

.item::before {
  position: absolute;
  top: 1.15rem;
  left: calc(-1.25rem - 7px);
  width: 12px;
  height: 12px;
  background: var(--positive);
  border: 2px solid var(--bg);
  border-radius: 50%;
  content: "";
}

.item[data-tone="negative"]::before {
  background: var(--negative);
}

.item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.item-header time {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.item-header .link {
  text-decoration: none;
}

.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  margin-top: 0.6rem;
}

.figures dd {
  font-weight: 600;
}

.notes {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Forms */

.login {
  max-width: 22rem;
  margin: 12vh auto 0;
  padding: 1.5rem;
}

.login h1 {
  margin-bottom: 1.25rem;
}

.form-card {
  padding: 1.5rem;
}

.form-card h1 {
  margin-bottom: 1.25rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 550;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
}

textarea {
  resize: vertical;
}

.two-columns {
  display: grid;
  align-items: end;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
}

.alert {
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--alert-bg);
  border-radius: 8px;
  color: var(--negative);
  font-size: 0.9rem;
  list-style-position: inside;
}

.danger-zone {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 30rem) {
  .summary .amount {
    font-size: 1.05rem;
  }

  .summary > div {
    padding: 0.75rem;
  }
}
