:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #182d27;
  background: #f4f7f3;
  --accent: #17664e;
  --line: #dbe5de;
  --muted: #52645c;
  --surface: #fff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.6; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
a, button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #7f54a8; outline-offset: 3px; }
button, .button, .settings-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .55rem .9rem;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--surface);
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}
.primary { background: var(--accent); color: white; border-color: var(--accent); }
.delete { color: #9a2b2b; }
.site-header, .navigation { background: var(--surface); }
.site-header { border-bottom: 1px solid var(--line); }
.header-inner, .container { width: min(100% - 2rem, 60rem); margin-inline: auto; }
.header-inner, .row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.header-inner { min-height: 64px; padding-block: .65rem; }
.brand-block { display: grid; min-width: 0; line-height: 1.35; }
.subtitle { color: var(--muted); font-size: .85rem; }
.settings-link { flex-shrink: 0; }
.brand { font-size: 1.45rem; font-weight: 850; text-decoration: none; }
.navigation {
  position: fixed;
  z-index: 1;
  inset: auto 0 0;
  display: flex;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.navigation a {
  flex: 1;
  padding: .35rem .15rem;
  text-align: center;
  font-size: .8rem;
  font-weight: 650;
  text-decoration: none;
}
.navigation span { display: block; font-size: 1.2rem; line-height: 1.3; }
[aria-current="page"] { background: #e2f1e9; }
.container { padding: 1.25rem 0 calc(5rem + env(safe-area-inset-bottom)); }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.55rem, 5vw, 2.3rem); line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.stack { display: grid; gap: .85rem; }
.section { margin-top: 1.25rem; }
.panel, .tile {
  display: grid;
  gap: .45rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  padding: 1rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.tile { color: inherit; text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.hero { background: #123f32; color: #fff; padding: 1.25rem; }
.total { font-size: clamp(1.85rem, 7vw, 3.3rem); font-weight: 800; line-height: 1.2; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.metrics strong { font-size: 1.45rem; }
.muted { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.help-link {
  gap: .3rem;
  padding: 0 .35rem;
  border: 0;
  background: transparent;
  font-size: .85rem;
  white-space: nowrap;
}
.help-icon {
  display: inline-grid;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  line-height: 1;
}
.help-label { text-decoration: underline; text-underline-offset: .15em; }
.controls { display: grid; gap: .65rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.controls label:last-child { grid-column: 1 / -1; }
.expiry-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.label, .badge { font-size: .85rem; }
.badge { width: fit-content; border-radius: .4rem; padding: .12rem .45rem; font-weight: 650; }
.normal { background: #e5f2eb; color: #245640; }
.caution { background: #fff0b8; color: #634b00; }
.danger { background: #fbe4e1; color: #922c25; }
.expense-back {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  color: var(--muted);
  font-size: .875rem;
  text-underline-offset: .15em;
}
.confirmation-panel {
  display: grid;
  gap: .45rem;
  margin-top: .5rem;
  padding: .85rem;
  border-radius: .65rem;
  background: #fff8df;
  color: #634b00;
}
.confirmation-panel-title { display: flex; gap: .45rem; align-items: baseline; margin: 0; font-size: 1rem; }
.confirmation-panel .primary { justify-self: start; gap: .4rem; }
.confirmation-panel > .actions { gap: .35rem; font-size: .9rem; }
.method-confirmation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .5rem;
}
.method-confirmation-row .primary { padding-inline: .55rem; font-size: .9rem; }
.management-actions {
  margin-top: .4rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
}
.delete-outline { border-color: #c47777; }
.expense-totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}
.expense-totals .panel { padding: .65rem .75rem; gap: .2rem; align-content: start; }
.expense-totals h2 { font-size: .85rem; color: var(--muted); }
.expense-totals strong {
  color: var(--accent);
  font-size: clamp(1.15rem, 4vw, 1.65rem);
  font-variant-numeric: tabular-nums;
}
.expense-totals > p { grid-column: 1 / -1; font-size: .85rem; }
.expense-table {
  width: 100%;
  table-layout: fixed;
  border-spacing: 0;
  overflow-wrap: anywhere;
}
.expense-row { cursor: pointer; }
.expense-name-link { font-weight: 700; text-underline-offset: .15em; }
.expense-category, .expense-method { color: var(--muted); }
.expense-warnings { display: grid; gap: .25rem; }
.expense-warnings .badge { max-width: 100%; }
.expense-amount { font-variant-numeric: tabular-nums; }
.expense-amount .muted { font-size: .85em; }
@media (width < 700px) {
  .expense-table { display: block; }
  .expense-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .expense-table tbody { display: grid; gap: .5rem; }
  .expense-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "category category" "name amount" "method state";
    align-items: start;
    gap: .2rem .65rem;
    padding: .6rem .75rem;
    border: 1px solid var(--line);
    border-radius: .75rem;
    background: var(--surface);
    line-height: 1.4;
  }
  .expense-category { grid-area: category; font-size: .8rem; }
  .expense-name { grid-area: name; }
  .expense-amount { grid-area: amount; text-align: right; font-size: .9rem; }
  .expense-method { grid-area: method; font-size: .85rem; }
  .expense-state { grid-area: state; }
  .expense-warnings { justify-items: end; }
  .expense-state .badge { font-size: .75rem; }
}
label { display: grid; gap: .25rem; font-weight: 650; min-width: 0; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .45rem .55rem;
  border: 1px solid #a9bcb0;
  border-radius: .45rem;
  color: inherit;
  background: white;
}
textarea { resize: vertical; }
dialog {
  width: min(100% - 1.5rem, 33rem);
  max-height: calc(100dvh - 1.5rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem;
  color: inherit;
}
dialog::backdrop { background: #112820a0; }
.error { color: #9a2b2b; }
.memo { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (min-width: 700px) {
  .navigation { position: static; justify-content: center; border-top: 0; border-bottom: 1px solid var(--line); padding: 0; }
  .navigation a { flex: 0 1 10rem; padding: .75rem; font-size: .95rem; }
  .navigation span { display: inline; margin-right: .4rem; }
  .container { padding: 2rem 0 4rem; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .controls label:last-child { grid-column: auto; }
  .expense-table { border: 1px solid var(--line); border-radius: .75rem; background: var(--surface); }
  .expense-table th, .expense-table td { padding: .65rem .75rem; text-align: left; }
  .expense-table th { background: #e2f1e9; font-size: .85rem; }
  .expense-table th:first-child { width: 14%; border-top-left-radius: .7rem; }
  .expense-table th:nth-child(2) { width: 23%; }
  .expense-table th:nth-child(3) { width: 23%; }
  .expense-table th:nth-child(4) { width: 18%; }
  .expense-table th:last-child { border-top-right-radius: .7rem; }
  .expense-table td { border-top: 1px solid var(--line); vertical-align: middle; }
  .expense-row:hover td, .expense-row:focus-within td { background: #f4f7f3; }
  .expense-row:last-child td:first-child { border-bottom-left-radius: .7rem; }
  .expense-row:last-child td:last-child { border-bottom-right-radius: .7rem; }
}
