:root {
  --paper:        #f5efe0;
  --paper-deep:   #efe7d4;
  --paper-soft:   #faf5e8;
  --paper-stripe: #f1ead9;
  --ink:          #1a1814;
  --ink-soft:     #3a362e;
  --muted:        #7e7668;
  --rule:         #c8bfa8;
  --rule-soft:    #dcd4bf;

  --accent:       #732629;
  --accent-dark:  #4d1214;
  --accent-soft:  #a13a40;
  --ochre:        #9c6b1a;
  --sage:         #2d4a30;
  --sage-soft:    #6a8870;
  --indigo:       #353a5e;

  --sans:         "Barlow Condensed", "Oswald", sans-serif;
  --sans-wide:    "Barlow", "Helvetica Neue", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-weight: 400;
  font-feature-settings: "lnum" 1;
  line-height: 1.35;
  background-image:
    radial-gradient(circle at 18% 10%, rgba(200, 191, 168, 0.16) 0, transparent 42%),
    radial-gradient(circle at 84% 82%, rgba(200, 191, 168, 0.12) 0, transparent 50%);
}

main { min-height: 100vh; }

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
  position: relative;
}

/* =============== NAV LINES =============== */

.month-nav,
.month-line {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto auto;
  align-items: baseline;
  gap: 1rem;
  padding: 0.4rem 0 0.55rem;
  border-bottom: 1px solid var(--ink);
}
.budget-nav {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 1rem;
  padding: 0.4rem 0 0.55rem;
  border-bottom: 1px solid var(--ink);
}

.nav-link,
.nav-month {
  font-family: var(--sans);
  font-weight: 400;
  font-style: italic;
  font-size: 1rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.12s;
  letter-spacing: 0.02em;
}
.nav-link:hover,
.nav-month:hover { color: var(--ink); }
.nav-month.prev { text-align: right; }
.nav-month .chev { font-style: normal; margin: 0 0.25em; }

.month-label,
.month-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.45rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0;
  white-space: nowrap;
}
.month-title .year {
  font-weight: 300;
  font-style: italic;
  margin-left: 0.35em;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.state-badge {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.state-badge::before { content: "· "; opacity: 0.5; letter-spacing: 0; }
.state-badge::after  { content: " ·"; opacity: 0.5; letter-spacing: 0; }
.state-badge.state-planning { color: var(--indigo); }
.state-badge.state-active   { color: var(--sage); }
.state-badge.state-closed   { color: var(--muted); text-transform: none; letter-spacing: 0.04em; font-style: italic; }
.state-badge.state-closed::before,
.state-badge.state-closed::after { content: ""; }

.lifecycle-form { margin: 0; }

.lifecycle-form button,
.btn-close {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--paper-soft);
  border: 1px solid var(--ink);
  padding: 0.25rem 0.9rem 0.3rem;
  cursor: pointer;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.lifecycle-form button:hover,
.btn-close:hover { background: var(--ink); color: var(--paper); }
.lifecycle-form button.secondary { background: transparent; }
.lifecycle-form button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
  color: var(--muted);
  border-color: var(--muted);
}
.lifecycle-form button[disabled]:hover {
  background: var(--paper-soft);
  color: var(--muted);
}

.back-link-row {
  display: flex;
  justify-content: flex-end;
  padding: 0.3rem 0 0;
}
.back-link {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.back-link:hover { color: var(--ink); }

.spacer { flex: 1; }

.month-picker {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.88rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--rule);
  background: var(--paper-soft);
  color: var(--ink);
  letter-spacing: 0.04em;
}

/* =============== ZERO HERO =============== */

.zero-widget {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  align-items: center;
  gap: 1.8rem;
  padding: 1rem 0.25rem 1rem;
  border-bottom: 3px double var(--ink);
}
.zero-widget.single {
  grid-template-columns: auto 1fr;
}

.zero-brand { justify-self: start; }
.zero-brand img {
  height: 132px;
  width: auto;
  display: block;
  mix-blend-mode: multiply;
}

.zero-side {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.zero-side.left  { text-align: right;  padding-right: 0.3rem; }
.zero-side.right { text-align: left;   padding-left:  0.3rem; }

.zero-sublabel {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}
.zero-subvalue {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1.45rem;
  color: var(--ink);
  font-feature-settings: "lnum" 1, "tnum" 1;
}
.zero-subvalue .cent { font-size: 0.7em; vertical-align: 0.4em; color: var(--muted); margin-left: 0.08em; }

.zero-center { text-align: center; padding: 0 0.4rem; }
.zero-label {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.15rem;
}
.zero-value {
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(2.8rem, 7vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--sage);
  font-feature-settings: "lnum" 1, "tnum" 1;
}
.zero-value .dollar { font-size: 0.5em; vertical-align: 0.4em; color: var(--muted); margin-right: 0.04em; font-weight: 400; }
.zero-value .cent   { font-size: 0.38em; vertical-align: 1em;  color: var(--muted); margin-left: 0.05em; font-weight: 400; }
.zero-value.tone-zero     { color: var(--sage); }
.zero-value.tone-positive { color: var(--ochre); }
.zero-value.tone-negative { color: var(--accent); }

.zero-caption {
  font-family: var(--sans);
  font-style: italic;
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0.2rem 0 0;
  letter-spacing: 0.02em;
}

/* =============== GROUPS =============== */

details.group {
  border-bottom: 1px solid var(--ink);
  margin: 0;
}
details.group[open] { padding-bottom: 0.6rem; }

details.group > summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.6rem 0 0.4rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-bottom: 1px solid var(--rule);
}
details.group > summary::-webkit-details-marker { display: none; }
details.group[open] > summary { border-bottom: none; }

details.group .chevron {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  position: relative;
  transform: rotate(-90deg);
  transition: transform 0.15s ease;
}
details.group .chevron::before {
  content: "";
  position: absolute; top: 50%; left: 0;
  width: 0.7rem; height: 1px;
  background: var(--ink); transform: translateY(-0.5px);
}
details.group .chevron::after {
  content: "";
  position: absolute; top: 50%; left: 50%;
  width: 1px; height: 0.7rem;
  background: var(--ink); transform: translate(-50%, -50%);
  transition: opacity 0.15s ease;
}
details.group[open] > summary .chevron { transform: rotate(0); }
details.group[open] > summary .chevron::after { opacity: 0; }

.group-name {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.group-total {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1rem;
  font-feature-settings: "lnum" 1, "tnum" 1;
}
.group-total .divider { color: var(--rule); margin: 0 0.15em; font-weight: 300; }
.group-total .planned { color: var(--muted); font-size: 0.92em; font-weight: 400; }
.group-total .applied { color: var(--ink); }

/* =============== SECTIONS =============== */

.section {
  padding: 0.4rem 0 0.4rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.section + .section { border-top: 1px dashed var(--rule); }

.section-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.15rem 0.25rem 0.2rem;
}

.section-header h2 {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

.total {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-feature-settings: "lnum" 1, "tnum" 1;
}
.total .divider { color: var(--rule); margin: 0 0.2em; font-weight: 300; }
.total .planned { color: var(--muted); font-weight: 400; }
.total .applied { color: var(--ink-soft); }
.total.empty { color: var(--muted); }

/* =============== ENTRY LIST (BUDGET TEMPLATE) =============== */

.budget-entries { display: flex; flex-direction: column; }

.entry-row.reading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem auto;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.26rem 0.25rem 0.28rem;
  border-bottom: 1px dotted var(--rule);
  position: relative;
}
.entry-row.reading:hover { background: var(--paper-stripe); }

.entry-row.reading .entry-name {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1.02rem;
  color: var(--ink);
  letter-spacing: 0.01em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-row.reading .note-badge {
  font-family: var(--sans);
  font-style: italic;
  font-size: 0.82rem;
  color: var(--muted);
  margin-left: 0.5rem;
  letter-spacing: 0.02em;
  opacity: 0.85;
}
.entry-row.reading .note-badge::before {
  content: "·  ";
  color: var(--rule);
  font-style: normal;
}
.entry-row.reading .entry-amount {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1rem;
  color: var(--ink);
  font-feature-settings: "lnum" 1, "tnum" 1;
  text-align: right;
  min-width: 0;
}

.entry-row.reading .entry-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}
.entry-row.reading .entry-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  color: var(--rule);
  opacity: 0;
  transition: color 0.12s ease, opacity 0.12s ease;
}
.entry-row.reading:hover .entry-actions button { opacity: 1; }
.entry-row.reading .entry-actions button.edit {
  font-size: 0.95rem;
  color: var(--rule);
}
.entry-row.reading .entry-actions button.edit:hover { color: var(--ink); }
.entry-row.reading .entry-actions button.delete {
  font-size: 1.2rem;
  font-weight: 400;
}
.entry-row.reading .entry-actions button.delete:hover { color: var(--accent); }

.entry-row.editing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem minmax(0, 1.4fr) auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.26rem 0.25rem 0.28rem;
  border-bottom: 1px dotted var(--rule);
  background: var(--paper-soft);
  margin: 0;
}
.entry-row.editing input {
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 0.12s;
  min-width: 0;
}
.entry-row.editing input:focus { border-color: var(--ink); }
.entry-row.editing input[type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.entry-row.editing .notes-input {
  font-style: italic;
  font-size: 0.88rem;
  color: var(--muted);
}
.entry-row.editing .entry-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.entry-row.editing .save-btn,
.entry-row.editing .cancel-btn {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.entry-row.editing .save-btn {
  border: 1px solid var(--ink);
  background: var(--paper-soft);
  color: var(--ink);
}
.entry-row.editing .save-btn:hover {
  background: var(--sage);
  color: var(--paper);
  border-color: var(--sage);
}
.entry-row.editing .cancel-btn {
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
}
.entry-row.editing .cancel-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.empty-row {
  padding: 0.4rem 0.5rem;
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
}

.add-row {
  padding: 0.4rem 0.25rem 0.2rem;
  grid-column: 1 / -1;
}

/* Add-entry disclosure: collapsed trigger, expanded form */
details.add-entry { margin: 0; }
details.add-entry > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: inline-block;
  padding: 0.1rem 0.25rem;
}
details.add-entry > summary::-webkit-details-marker { display: none; }
details.add-entry .add-trigger {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-bottom: 1px dashed transparent;
  padding-bottom: 1px;
  transition: color 0.12s ease, border-color 0.12s ease;
}
details.add-entry > summary:hover .add-trigger {
  color: var(--ink);
  border-bottom-color: var(--rule);
}
details.add-entry[open] > summary .add-trigger {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
details.add-entry > .add-form,
details.add-entry > .month-add-form {
  margin-top: 0.45rem;
}

@media (max-width: 520px) {
  .entry-row.reading {
    grid-template-columns: minmax(0, 1fr) 4.6rem auto;
    gap: 0.4rem;
  }
  .entry-row.editing {
    grid-template-columns: minmax(0, 1fr) 4.6rem;
    gap: 0.4rem;
  }
  .entry-row.editing .notes-input,
  .entry-row.editing .entry-actions { grid-column: 1 / -1; }
}

.tag {
  font-family: var(--sans);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  padding: 0.03rem 0.4rem 0.05rem;
  margin-left: 0.45rem;
  vertical-align: 0.15em;
  border: 1px solid currentColor;
  color: var(--ochre);
  display: inline-block;
}
.tag-edited { color: var(--ochre); }
.tag-new    { color: var(--indigo); }

/* Target card keeps the table-based layout from before Task 2 rewrite. */
.target-section table.entries { width: 100%; border-collapse: collapse; font-family: var(--sans); }
.target-section table.entries thead { display: none; }
.target-section table.entries tbody tr.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem 5.5rem 1.2rem;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.26rem 0.25rem 0.28rem;
  position: relative;
  border-bottom: 1px dotted var(--rule);
}
.target-section table.entries tbody tr.entry td {
  padding: 0;
  border: none;
  vertical-align: baseline;
  min-width: 0;
}
.target-section table.entries tr.add-row td {
  padding: 0.4rem 0.25rem 0.2rem !important;
  border-bottom: none !important;
  grid-column: 1 / -1;
  display: block;
}

/* =============== PRIMARY DEBT TARGET =============== */

.section.target-section {
  padding: 0.4rem 0 0.4rem 0.75rem;
  border-left: 3px solid var(--accent);
  background: linear-gradient(90deg, rgba(115, 38, 41, 0.05), transparent 40%);
  position: relative;
}
.section.target-section::before {
  content: "↳";
  position: absolute;
  left: -1.1rem;
  top: 0.45rem;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 400;
}
.section.target-section .section-header h2 {
  color: var(--accent);
}
.section.target-section .total .applied,
.section.target-section .total .planned {
  color: var(--ink);
}

.target-section .entries td.entry-name {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.02rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.target-section .entries td.entry-name .muted {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-style: italic;
}

.target-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}
.target-form label {
  grid-column: 1 / -1;
  font-size: 0.66rem;
  color: var(--muted);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
}
.target-form select {
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--rule);
  background: var(--paper-soft);
  color: var(--ink);
}
.target-form button[type="submit"] {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.25rem 0.8rem;
  border: 1px solid var(--ink);
  background: var(--paper-soft);
  color: var(--ink);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.target-form button[type="submit"]:hover { background: var(--ink); color: var(--paper); }

/* =============== ADD FORM =============== */

.add-form,
.month-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem auto;
  gap: 0.5rem;
  align-items: center;
  padding-top: 0.5rem;
}
.add-form input[type="text"],
.add-form input[type="number"],
.month-add-form input[type="text"],
.month-add-form input[type="number"] {
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--rule);
  background: var(--paper-soft);
  color: var(--ink);
  outline: none;
  transition: border-color 0.12s;
}
.add-form input[type="number"],
.month-add-form input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
.add-form input:focus,
.month-add-form input:focus { border-color: var(--ink); }
.add-form button[type="submit"],
.month-add-form button[type="submit"] {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.25rem 0.9rem;
  border: 1px solid var(--ink);
  background: var(--paper-soft);
  color: var(--ink);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.add-form button[type="submit"]:hover,
.month-add-form button[type="submit"]:hover { background: var(--ink); color: var(--paper); }

.add-form input.add-notes,
.month-add-form input.add-notes {
  grid-column: 1 / -1;
  font-style: italic;
  font-size: 0.88rem;
  padding: 0.15rem 0.4rem;
}

/* =============== MONTH ENTRIES — details-based layout =============== */

.month-entries {
  display: flex;
  flex-direction: column;
}

.entry-block {
  border-bottom: 1px dotted var(--rule);
  margin: 0;
}

.entry-block > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: grid;
  grid-template-columns: 0.9rem minmax(0, 1fr) 5.5rem 9rem 1.2rem;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.32rem 0.25rem 0.36rem;
  position: relative;
}
.entry-block > summary::-webkit-details-marker { display: none; }
.entry-block > summary:hover { background: var(--paper-stripe); }

/* Progress bar on the summary row */
.entry-block > summary::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--sage-soft);
  width: min(100%, calc(var(--ratio, 1) * 100%));
  transition: width 0.25s ease;
  opacity: 0.7;
}
.entry-block > summary.state-edited::after { background: var(--accent); opacity: 0.85; }
.entry-block > summary.state-new_in_month::after { background: var(--indigo); opacity: 0.55; }

/* Caret: rotates on [open] */
.entry-block .caret {
  display: inline-block;
  width: 0.7rem;
  position: relative;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
  align-self: center;
}
.entry-block .caret::before {
  content: "▸";
  font-size: 0.7rem;
  color: var(--muted);
  display: inline-block;
  line-height: 1;
}
.entry-block[open] > summary .caret { transform: rotate(90deg); }

/* Entry row cells */
.entry-block .entry-name {
  font-weight: 500;
  font-size: 1rem;
  min-width: 0;
  overflow: hidden;
}
.entry-block .entry-name input,
.entry-block .entry-amount input {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0;
  width: 100%;
  outline: none;
  transition: border-color 0.12s;
}
.entry-block .entry-name input:hover,
.entry-block .entry-amount input:hover { border-bottom-color: var(--rule); }
.entry-block .entry-name input:focus,
.entry-block .entry-amount input:focus { border-bottom-color: var(--ink); }

.entry-block .entry-amount {
  font-weight: 500;
  font-size: 1rem;
  text-align: right;
  font-feature-settings: "lnum" 1, "tnum" 1;
  min-width: 0;
}
.entry-block .entry-amount input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.entry-block .entry-amount.planned input { color: var(--muted); font-weight: 400; }

.entry-block .applied-cell {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.35rem;
  white-space: nowrap;
  flex-wrap: nowrap;
}
.entry-block .applied-cell .value {
  font-weight: 500;
  white-space: nowrap;
}
.entry-block .applied-cell .count {
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--muted);
  white-space: nowrap;
}

.entry-block .entry-actions button.delete {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--rule);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: color 0.12s ease, opacity 0.12s ease;
  align-self: center;
}
.entry-block > summary:hover .entry-actions button.delete { opacity: 1; }
.entry-block .entry-actions button.delete:hover { color: var(--accent); }

/* Expanded body */
.entry-block .entry-body {
  padding: 0.5rem 1.6rem 0.75rem;
  background: var(--paper-soft);
  border-top: 1px solid var(--rule-soft);
}

.entry-block .entry-notes {
  margin-bottom: 0.5rem;
}
.entry-block .entry-notes input {
  font-family: var(--sans);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink);
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--rule);
  padding: 0.15rem 0;
  outline: none;
}
.entry-block .entry-notes input:focus { border-bottom-color: var(--ink); }
.entry-block .entry-notes.readonly {
  font-family: var(--sans);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Transactions table */
table.transactions {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
}
table.transactions thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.2rem 0.3rem 0.25rem;
  border-bottom: 1px solid var(--rule);
}
table.transactions th.col-amount,
table.transactions td.col-amount { text-align: right; width: 5.5rem; }
table.transactions th.col-date,
table.transactions td.col-date { width: 7.5rem; }
table.transactions th.col-actions,
table.transactions td.col-actions { width: 1.2rem; }

table.transactions td {
  padding: 0.2rem 0.3rem;
  border-bottom: 1px dotted var(--rule-soft);
}
table.transactions tr.posting:hover { background: var(--paper); }
table.transactions input {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0;
  width: 100%;
  outline: none;
  transition: border-color 0.12s;
}
table.transactions input:hover { border-bottom-color: var(--rule); }
table.transactions input:focus { border-bottom-color: var(--ink); }
table.transactions input[type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
table.transactions input[type="date"] {
  font-family: var(--sans);
  color: var(--muted);
}
table.transactions tr.empty td {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 0.5rem;
}

table.transactions td .readonly {
  color: var(--ink);
}

table.transactions button.delete {
  font-size: 1rem;
  color: var(--rule);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: color 0.12s ease, opacity 0.12s ease;
}
table.transactions tr:hover button.delete { opacity: 1; }
table.transactions button.delete:hover { color: var(--accent); }

/* Add-posting form */
form.add-posting-form {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr) minmax(0, 1fr) 5.5rem auto;
  gap: 0.4rem;
  align-items: center;
  padding: 0.35rem 0.3rem 0.2rem;
  border-top: 1px dashed var(--rule);
}
form.add-posting-form input {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 0.12s;
}
form.add-posting-form input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
form.add-posting-form input:focus { border-color: var(--ink); }
form.add-posting-form button[type="submit"] {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--ink);
  background: var(--paper-soft);
  color: var(--ink);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
form.add-posting-form button[type="submit"]:hover { background: var(--ink); color: var(--paper); }

@media (max-width: 640px) {
  .entry-block > summary {
    grid-template-columns: 0.9rem minmax(0, 1fr) 4.2rem 7rem 1rem;
    gap: 0.4rem;
  }
  .entry-block .entry-body { padding: 0.5rem 0.75rem 0.6rem; }
  .entry-block .applied-cell .count { font-size: 0.58rem; letter-spacing: 0.1em; }
  form.add-posting-form {
    grid-template-columns: 1fr 1fr;
  }
  form.add-posting-form input[type="date"],
  form.add-posting-form input[type="number"],
  form.add-posting-form button[type="submit"] { grid-column: 1 / -1; }
}

/* Disabled inputs (closed month) */
input[disabled],
select[disabled],
button[disabled] {
  cursor: not-allowed;
  color: var(--muted);
  background: transparent;
  opacity: 0.8;
}

/* =============== MONTH CREATE FLOW =============== */

.month-missing {
  padding: 2rem 1rem;
  text-align: center;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin: 1rem 0;
}
.month-missing h2 {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 0.75rem;
  color: var(--muted);
}
.month-missing-body {
  max-width: 520px;
  margin: 0 auto 1.2rem;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.4;
}
.month-create-form button {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.5rem 1.5rem;
  border: 2px solid var(--ink);
  background: var(--paper-soft);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.month-create-form button:hover { background: var(--ink); color: var(--paper); }

/* =============== COLOPHON =============== */

.colophon {
  text-align: center;
  margin: 2rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-style: italic;
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.colophon .signoff {
  font-family: var(--sans);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* =============== RESPONSIVE =============== */

@media (max-width: 640px) {
  .zero-widget,
  .zero-widget.single {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    text-align: center;
    padding: 0.75rem 0.25rem;
  }
  .zero-brand { justify-self: center; }
  .zero-brand img { height: 100px; }
  .zero-side.left,
  .zero-side.right { text-align: center; padding: 0; }
  .zero-center { padding: 0.25rem 0; }
}

@media (max-width: 520px) {
  .page { padding: 1rem 0.85rem 2rem; }
  .month-nav,
  .month-line,
  .budget-nav {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .month-title,
  .month-label {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 1.1rem;
  }
  .state-badge,
  .lifecycle-form,
  .back-link,
  .month-picker,
  .nav-link {
    grid-column: 1 / -1;
    text-align: center;
    justify-self: center;
  }
}
