:root {
  color-scheme: light;
  --ink: #202722;
  --muted: #536158;
  --paper: #f4f0e6;
  --panel: #fffdf8;
  --line: #cec6b7;
  --green: #3f7047;
  --green-deep: #264d30;
  --danger: #9c3c27;
  --focus: #0b5427;
  --shadow: 0 18px 54px rgb(32 39 34 / 11%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgb(32 39 34 / 4%) 1px, transparent 1px),
    linear-gradient(180deg, rgb(32 39 34 / 4%) 1px, transparent 1px), var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}

button,
input {
  min-height: 44px;
  font: inherit;
}

button {
  border: 1px solid var(--ink);
  border-radius: 7px;
  padding: 0 15px;
  background: var(--ink);
  color: var(--panel);
  cursor: pointer;
  font-weight: 750;
  transition:
    transform 130ms ease,
    background 130ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.secondary {
  background: transparent;
  color: var(--ink);
}

.compact {
  min-height: 36px;
  padding-inline: 12px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffefa;
  color: var(--ink);
  padding: 9px 11px;
}

button:focus-visible,
input:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 34%, transparent);
  outline-offset: 2px;
  border-color: var(--focus);
}

label,
legend {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

label {
  display: block;
  margin-bottom: 6px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--ink);
  color: white;
}

.skip-link:focus {
  transform: translateY(0);
}

main {
  width: min(1160px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0 24px;
}

.topbar-actions {
  display: grid;
  grid-template-columns: auto 160px auto auto;
  align-items: end;
  gap: 9px;
}

.month-picker {
  margin-bottom: 12px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: Georgia, Cambria, 'Times New Roman', serif;
  font-size: clamp(2.7rem, 7vw, 5.7rem);
  line-height: 0.86;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--green-deep);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.supporting,
.hint {
  color: var(--muted);
}

.session-badge,
.person-lock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eee8dc;
  padding: 4px 5px 4px 12px;
}

.passcode-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.7fr);
  gap: 28px;
  align-items: center;
  width: min(760px, 100%);
  margin: 9vh auto 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: clamp(22px, 5vw, 42px);
  box-shadow: var(--shadow);
}

.passcode-form,
form {
  display: grid;
  gap: 11px;
}

.passcode-form .status {
  min-height: 20px;
}

.locked .authenticated,
.unlocked .passcode-panel {
  display: none;
}

.summary {
  display: grid;
  grid-template-columns: 1.35fr repeat(3, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgb(255 253 248 / 94%);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 126px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 16px;
}

.metric.available {
  border-color: var(--green-deep);
  background: var(--green-deep);
  color: var(--panel);
}

.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.available .metric-label,
.available .metric-note {
  color: #e2eadf;
}

.metric-value,
.amount {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.metric-value {
  overflow-wrap: anywhere;
  font-size: clamp(1.25rem, 2.7vw, 1.95rem);
}

.metric-note {
  color: var(--muted);
  font-size: 0.86rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(360px, 1.18fr);
  gap: 12px;
  align-items: start;
}

.panel {
  padding: 17px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.section-heading .eyebrow {
  margin-bottom: 4px;
}

.hint {
  font-size: 0.78rem;
}

.fixed-list,
.expense-list {
  display: grid;
  gap: 8px;
}

.fixed-row {
  display: grid;
  grid-template-columns: 1fr 140px 44px;
  gap: 8px;
  align-items: end;
}

.fixed-row label {
  margin: 0;
}

.button-row,
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.icon-button {
  width: 44px;
  min-height: 44px;
  padding: 0;
  background: transparent;
  font-size: 1.45rem;
}

.danger {
  border-color: #bb8f84;
  color: var(--danger);
}

.expense-list {
  margin-top: 14px;
}

.expense {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 44px;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.expense:first-child {
  border-top: 0;
  padding-top: 0;
}

.expense strong,
.expense span {
  display: block;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex !important;
  min-height: 23px;
  align-items: center;
  margin-right: 7px;
  border-radius: 999px;
  padding: 0 8px;
  background: #ded3c1;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.amount {
  white-space: nowrap;
}

.expense-spacer {
  width: 44px;
  height: 44px;
}

.empty,
.status {
  color: var(--muted);
  font-size: 0.9rem;
}

.status {
  min-height: 20px;
}

.status.error {
  color: var(--danger);
}

.status.ok {
  color: var(--green-deep);
}

.undo-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: #e7eee4;
  padding: 8px 9px 8px 12px;
}

.load-older {
  width: 100%;
  margin-top: 12px;
}

.reload-setup {
  justify-self: start;
}

noscript {
  display: block;
  padding: 20px;
  text-align: center;
}

@media (max-width: 860px) {
  main {
    width: min(640px, calc(100vw - 20px));
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    grid-template-columns: auto minmax(130px, 1fr) auto auto;
  }

  .summary,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .passcode-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  main {
    width: calc(100vw - 16px);
    padding-top: 13px;
  }

  .topbar-actions,
  .fixed-row,
  .button-row,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .month-picker {
    margin-bottom: -4px;
  }

  .notification-button,
  .session-badge {
    width: 100%;
  }

  .metric,
  .panel {
    padding: 13px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .fixed-row .icon-button {
    width: 100%;
  }

  .expense {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .expense .amount {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
