/* Crown's light palette derives from Photography's Botanical Lux; compact controls echo Lyra. */
@font-face {
  font-family: Mulish;
  src: url("fonts/Mulish-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: Lustria;
  src: url("fonts/lustria-latin-400-normal.woff2") format("woff2");
  font-display: swap;
}
:root {
  color-scheme: light;
  --ivory: #f7f4ee;
  --sage: #7f9d91;
  --ink: #252d26;
  --muted: #62695f;
  --border: #dce0d4;
  --accent: #14503e;
  --surface: #fffefa;
  --sunken: #bdc7b9;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font:
    16px/1.5 Mulish,
    system-ui,
    sans-serif;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button,
select {
  cursor: pointer;
}
button,
input,
select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  padding: 9px 12px;
  min-height: 42px;
}
button:hover {
  background: var(--sunken);
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #7f9d9188;
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
header {
  min-height: 88px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px max(24px, calc((100vw - 1280px) / 2));
  gap: 20px;
  background: #fffefa99;
}
.brand {
  text-decoration: none;
  color: var(--ink);
  font:
    28px Lustria,
    serif;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  font: 32px Georgia;
  color: var(--sage);
}
.brand-caption {
  font:
    11px Mulish,
    sans-serif;
  letter-spacing: 0.18em;
  margin-left: 12px;
  border-left: 1px solid var(--border);
  padding-left: 22px;
}
.header-actions {
  display: flex;
  gap: 10px;
  font-size: 14px;
}
main {
  max-width: 1280px;
  padding: 36px 24px 0;
  margin: auto;
}
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 32px;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin: 0 0 9px;
}
h1 {
  font:
    32px/1.3 Lustria,
    serif;
  margin: 0;
}
h2 {
  font:
    22px Lustria,
    serif;
  margin: 0;
}
h3 {
  font-size: 17px;
}
.month-control {
  display: flex;
  align-items: center;
  gap: 5px;
}
.month-control input {
  background: transparent;
  border: 0;
  width: 185px;
}
.month-control button {
  background: transparent;
  border: 0;
  font-size: 26px;
}
.totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 28px;
  background: #fffefa80;
  overflow: hidden;
}
.totals > div {
  padding: 22px 28px;
  border-right: 1px solid var(--border);
}
.totals > div:last-child {
  border: 0;
}
.totals span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}
.totals strong {
  font-size: 29px;
  font-weight: 600;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.totals .available-total {
  background: var(--sunken);
  color: var(--accent);
}
.workspace {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-heading p {
  font-size: 14px;
  color: var(--muted);
  margin: 6px 0 0;
}
.section-heading select,
.chart-controls select {
  font-size: 14px;
  padding: 7px;
}
.chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  gap: 8px;
}
.chart-controls span {
  font-size: 12px;
  color: var(--muted);
}
.bars {
  position: relative;
  height: 330px;
  margin: 28px 28px 20px 48px;
  display: flex;
  justify-content: space-around;
  gap: 48px;
}
.bar-column {
  height: 100%;
  width: 88px;
  text-align: center;
  z-index: 1;
}
.bar {
  height: 290px;
  background: #f0f1e9;
  border: 1px solid var(--border);
  border-radius: 9px;
  display: flex;
  flex-direction: column-reverse;
  position: relative;
  overflow: hidden;
}
.bar-column > span {
  font-size: 14px;
  display: block;
  margin-top: 12px;
}
.remaining-fill {
  background: var(--sage);
}
.segment {
  min-height: 0;
  flex-shrink: 0;
  position: relative;
  border-top: 1px solid #fff9;
  transition: height 0.2s;
}
.planned {
  background-image: repeating-linear-gradient(
    135deg,
    transparent 0,
    transparent 5px,
    #fff9 5px,
    #fff9 8px
  );
  border: 1px dashed #35452d88;
}
.ticks {
  position: absolute;
  left: -46px;
  right: -10px;
  top: 0;
  height: 290px;
  pointer-events: none;
}
.tick {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed #65745b36;
}
.tick span {
  position: absolute;
  left: 0;
  transform: translateY(-55%);
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  padding-right: 4px;
}
.chart-key {
  display: flex;
  justify-content: center;
  gap: 22px;
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0 20px;
}
.chart-key span {
  display: flex;
  align-items: center;
  gap: 7px;
}
.chart-key i {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--sage);
}
.chart-key .planned-key {
  background: repeating-linear-gradient(
    135deg,
    #7f9d91 0,
    #7f9d91 2px,
    #fff 2px,
    #fff 4px
  );
  border: 1px dashed var(--sage);
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  padding: 7px 0;
}
.legend-row i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}
.legend-row strong {
  margin-left: auto;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.chart-note {
  border-top: 1px solid var(--border);
  padding-top: 15px;
  font-size: 13px;
  color: var(--muted);
  margin: 18px 0 0;
}
.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 650;
}
.primary:hover {
  background: #103e31;
}
.ledger-panel {
  min-height: 596px;
  display: flex;
  flex-direction: column;
}
.empty {
  text-align: center;
  padding: 95px 10px 108px;
  color: var(--muted);
}
.empty h3 {
  font: 23px Lustria;
  color: var(--ink);
  margin: 20px 0 8px;
}
.empty p {
  font-size: 14px;
}
.empty-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--sunken);
  border-radius: 50%;
  font-size: 25px;
  color: var(--sage);
}
#expense-list {
  flex: 1;
}
.ledger-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 20px;
}
.ledger-footer button {
  font-size: 13px;
  border: 0;
  background: transparent;
  padding: 7px;
}
.ledger-footer > div {
  display: flex;
}
.expense-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 130px 110px 36px;
  gap: 8px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.expense-row input,
.expense-row select {
  width: 100%;
  font-size: 14px;
  padding: 8px;
}
.expense-row .date {
  grid-column: 1;
  width: 145px;
  font-size: 12px;
  padding: 4px;
  min-height: 30px;
}
.expense-row .expected {
  grid-column: 2/4;
  align-self: center;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.expense-row .expected input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--sage);
}
.expense-row .delete {
  padding: 0;
  border: 0;
  color: var(--muted);
}
footer {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
  padding: 26px 0;
}
footer > span:last-child {
  margin-left: auto;
}
dialog {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  padding: 28px;
  width: min(620px, calc(100% - 28px));
  max-height: 90vh;
  overflow: auto;
}
dialog::backdrop {
  background: #202d255c;
  backdrop-filter: blur(4px);
}
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.settings-grid label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0;
  font-size: 14px;
}
.check-label input {
  min-height: 18px;
  accent-color: var(--sage);
}
.muted {
  font-size: 13px;
  color: var(--muted);
}
.category-edit {
  display: flex;
  gap: 7px;
  align-items: center;
  margin: 8px 0;
}
.category-edit input[type="color"] {
  width: 42px;
  padding: 4px;
  flex-shrink: 0;
}
.category-edit input[type="text"] {
  min-width: 0;
  width: 100%;
}
.category-edit button {
  padding: 5px 9px;
}
.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 26px;
}
.danger {
  color: #a33f30;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  background: #253b2b;
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 8px 30px #0002;
  z-index: 5;
}
#toast button {
  margin-left: 15px;
  padding: 4px 9px;
  min-height: 30px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.pie-wrap {
  padding: 32px 0 18px;
  display: flex;
  justify-content: center;
}
.pie-wrap svg {
  width: 260px;
  max-width: 100%;
}
.negative {
  color: #a33f30 !important;
}
@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: 340px minmax(0, 1fr);
  }
  .panel {
    padding: 18px;
  }
  .expense-row {
    grid-template-columns: minmax(100px, 1fr) 100px 80px 28px;
    gap: 5px;
  }
  .totals > div {
    padding: 20px;
  }
  .totals strong {
    font-size: 25px;
  }
}
@media (max-width: 800px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .chart-panel {
    max-width: none;
  }
  .bars {
    max-width: 310px;
    margin-left: auto;
    margin-right: auto;
  }
  .ledger-panel {
    min-height: 360px;
  }
  .empty {
    padding: 55px 5px;
  }
  .brand-caption {
    display: none;
  }
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }
  h1 {
    font-size: 28px;
  }
  .totals {
    grid-template-columns: 1fr 1fr;
  }
  .totals > div:nth-child(2) {
    border-right: 0;
  }
  .totals > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }
  footer {
    flex-wrap: wrap;
  }
  footer > span:last-child {
    margin-left: 0;
    width: 100%;
  }
}
@media (max-width: 440px) {
  main {
    padding: 26px 14px 0;
  }
  header {
    padding: 16px;
  }
  .header-actions button span {
    display: none;
  }
  .expense-row {
    grid-template-columns: minmax(110px, 1fr) 90px 30px;
  }
  .expense-row .amount {
    grid-column: 2;
    grid-row: 1;
  }
  .expense-row .category {
    grid-column: 1;
    grid-row: 2;
  }
  .expense-row .delete {
    grid-column: 3;
    grid-row: 1;
  }
  .expense-row .date {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
  }
  .expense-row .expected {
    grid-column: 2/4;
    grid-row: 3;
  }
  .ledger-footer {
    align-items: flex-start;
    flex-direction: column;
  }
  .section-heading {
    flex-wrap: wrap;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .category-edit {
    gap: 4px;
  }
  .category-edit button {
    padding: 4px 6px;
  }
  .totals strong {
    font-size: 23px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* The balance spans the workspace; totals frame only the expense ledger. */
.workspace {
  align-items: stretch;
}
.expense-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
.expense-column .totals {
  grid-template-columns: 1fr 1fr;
  margin: 0;
  flex-shrink: 0;
}
.expense-column .totals > div {
  border-bottom: 0;
}
.expense-column .totals > div:nth-child(2) {
  border: 0;
}
.expense-column .ledger-panel {
  flex: 1;
  min-height: 390px;
}
.chart-panel {
  display: flex;
  flex-direction: column;
}
.chart-panel #chart {
  flex: 1;
  min-height: 330px;
}
.bars {
  height: calc(100% - 48px);
  min-height: 330px;
}
.bar {
  height: calc(100% - 40px);
  min-height: 290px;
}
.ticks {
  height: calc(100% - 40px);
  min-height: 290px;
}
.empty {
  padding: 65px 10px;
}
.page-heading {
  margin-bottom: 28px;
}
.workspace {
  margin-bottom: 28px;
}

/* Frosted surfaces retain the bookings palette, with shallow raised and inset relief. */
:root {
  --surface: rgba(255, 254, 250, 0.68);
  --border: rgba(88, 116, 102, 0.3);
  --sunken: #bdc7b9;
}
body {
  background:
    radial-gradient(ellipse at 0% 15%, #c1d2c991, transparent 50%),
    radial-gradient(ellipse at 95% 85%, #c9d7ce7a, transparent 55%), #eeeee5;
  background-attachment: fixed;
}
header {
  background: rgba(250, 249, 244, 0.66);
  backdrop-filter: blur(24px) saturate(125%);
  border-bottom: 1px solid #96aa9a55;
  box-shadow: 0 5px 20px #5c736708;
  position: relative;
  z-index: 2;
}
header .month-control {
  margin-left: auto;
  margin-right: 22px;
}
main {
  padding-top: 28px;
}
.panel,
.totals {
  background: linear-gradient(135deg, #fffffff0, #fffefac7);
  backdrop-filter: blur(20px) saturate(115%);
  border: 1px solid #849d8d70;
  box-shadow:
    0 8px 24px #435b4d1c,
    0 2px 5px #435b4d0f,
    inset 0 1px 0 #ffffffeb;
  border-radius: 20px;
}
.totals .available-total {
  background: linear-gradient(130deg, #bdcfc3b8, #a8bdb099);
  box-shadow: inset 0 1px 0 #ffffff7a;
}
.bar {
  background: #d0dacf70;
  box-shadow:
    inset 3px 3px 8px #687c6c20,
    inset -3px -3px 7px #ffffffb3;
  border: 1px solid #8ba18f63;
}
.remaining-fill {
  background: linear-gradient(110deg, #93aca0, #7f9d91);
  box-shadow: inset 2px 0 4px #ffffff3b;
}
.bar,
.remaining-fill {
  border-radius: 12px;
}
.remaining-fill {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
button,
select,
input {
  background: #fbfcf8bb;
  border: 1px solid #8a9f9063;
  box-shadow:
    3px 3px 7px #62786d10,
    -2px -2px 6px #ffffff91;
  border-radius: 11px;
}
input {
  box-shadow:
    inset 2px 2px 5px #63776a12,
    inset -2px -2px 5px #ffffffb3;
}
.primary {
  background: linear-gradient(130deg, #326b57, #14503e);
  border-color: #436d5980;
  box-shadow:
    3px 5px 10px #14503e25,
    inset 0 1px #ffffff33;
}
.primary:hover {
  background: #14503e;
}
.tick span {
  background: #f6f8f1e8;
  border-radius: 4px;
}
.empty-symbol {
  background: #c5d3c799;
  box-shadow:
    inset 2px 2px 5px #6b847322,
    inset -2px -2px 6px #ffffff80;
}
.chart-note,
.ledger-footer {
  border-color: #8a9f904d;
}
@media (max-width: 800px) {
  header {
    flex-wrap: wrap;
    gap: 12px;
  }
  header .month-control {
    order: 3;
    justify-content: center;
    margin: 0;
    width: 100%;
    border-top: 1px solid #91a39226;
    padding-top: 6px;
  }
  .header-actions {
    margin-left: auto;
  }
  main {
    padding-top: 22px;
  }
  .panel,
  .totals {
    backdrop-filter: blur(12px);
  }
}

/* Compact ledger: preserve one line on narrow screens via a local horizontal scroll. */
#expense-list {
  overflow-x: auto;
  padding-top: 18px;
  padding-bottom: 8px;
}
.expense-row {
  display: grid;
  grid-template-columns: 36px minmax(120px, 1fr) 114px 90px 68px 48px 32px;
  align-items: center;
  gap: 8px;
  min-width: 660px;
  padding: 9px 10px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid
    color-mix(in srgb, var(--category-color) 30%, transparent);
  border-left: 4px solid var(--category-color);
  border-radius: 0;
  background: color-mix(in srgb, var(--category-color) 13%, #fffefa);
  white-space: nowrap;
}
.expense-row:first-child {
  border-radius: 9px 9px 0 0;
}
.expense-row:last-child {
  border-radius: 0 0 9px 9px;
}
.expense-row:only-child {
  border-radius: 9px;
}
.expense-row.finalized {
  min-width: 580px;
  grid-template-columns: 36px minmax(120px, 1fr) 80px 95px 28px 32px 32px;
  padding-block: 6px;
}
.expense-row > * {
  min-width: 0;
  grid-column: auto !important;
  grid-row: auto !important;
}
.expense-row input,
.expense-row button {
  font-size: 14px;
  min-height: 34px;
  height: 34px;
  padding: 5px 7px;
  border-radius: 6px;
  box-shadow: none;
}
.expense-row .date {
  width: 100%;
  font-size: 12px;
  min-height: 34px;
}
.expense-row .amount {
  text-align: right;
}
.expense-row .category-icon {
  font-size: 22px;
  padding: 0;
  background: color-mix(in srgb, var(--category-color) 23%, white);
  border: 1px solid color-mix(in srgb, var(--category-color) 50%, white);
  color: #202a26;
  width: 34px;
}
.expense-row .planned-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
.expense-row .planned-toggle input {
  width: 15px;
  height: 15px;
  min-height: 15px;
  accent-color: var(--category-color);
  padding: 0;
}
.expense-row .row-save {
  background: var(--accent);
  color: white;
  padding: 4px 6px;
  font-size: 12px;
}
.expense-row .row-edit,
.expense-row .delete {
  background: transparent;
  border: 0;
  font-size: 20px;
  padding: 0;
  color: #3f5146;
}
.row-description {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}
.row-date {
  font-size: 12px;
  color: #506054;
}
.row-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 700;
}
.expense-row input.complete-planned {
  appearance: none;
  display: block;
  border-radius: 50%;
  border: 2px solid var(--category-color);
  width: 21px;
  height: 21px;
  min-height: 21px;
  padding: 0;
  cursor: pointer;
  background: #fff8;
  margin: auto;
}
.expense-row input.complete-planned:hover {
  background: color-mix(in srgb, var(--category-color) 30%, white);
}
.actual-status {
  text-align: center;
  color: #546c5e;
}
#category-picker {
  width: min(430px, calc(100% - 28px));
  background: #f9faf4f5;
}
#category-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}
#category-options button {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-size: 14px;
  border-color: var(--category-color);
  background: color-mix(in srgb, var(--category-color) 15%, white);
  box-shadow: none;
}
#category-options button span {
  font-size: 24px;
}
#category-options button[aria-pressed="true"] {
  outline: 2px solid var(--category-color);
  outline-offset: 2px;
}

/* Only the ledger scrolls: the budget totals and subtotals remain in view. */
.ledger-panel {
  min-width: 0;
}
.ledger-scroll {
  height: clamp(280px, 48vh, 500px);
  overflow: auto;
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  isolation: isolate;
  scrollbar-gutter: stable;
}
#expense-list {
  overflow: visible;
  padding: 0;
  min-width: 660px;
}
.expense-row.finalized {
  grid-template-columns: 36px minmax(120px, 1fr) 114px 90px 68px 48px 32px;
  min-width: 660px;
}
.ledger-column-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 36px minmax(120px, 1fr) 114px 90px 68px 48px 32px;
  min-width: 660px;
  gap: 8px;
  padding: 10px 10px 10px 14px;
  background: #e3eae2;
  border-bottom: 1px solid #b5c4b7;
  font-size: 12px;
  color: #3a5041;
}
.ledger-column-head > span:nth-child(4) {
  text-align: right;
}
.add-expense-row {
  display: block;
  min-width: 660px;
  width: 100%;
  text-align: left;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: #edf2ea;
  box-shadow: none;
  color: var(--accent);
  padding: 12px 18px;
  font-size: 14px;
}
.expense-row:first-child,
.expense-row:last-child,
.expense-row:only-child {
  border-radius: 0;
}
.expense-column .ledger-panel {
  flex: 0 0 auto;
}
.ledger-footer {
  margin-top: 12px;
}
.ledger-scroll .empty {
  padding: 28px;
}
.ledger-scroll .empty h3 {
  font:
    14px Mulish,
    sans-serif;
}
.complete-planned {
  justify-self: center;
}
.category-breakdown {
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.category-breakdown summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  list-style: none;
}
.category-breakdown summary::-webkit-details-marker {
  display: none;
}
.category-breakdown summary::before {
  content: "›";
  font-size: 18px;
  width: 10px;
}
.category-breakdown[open] summary::before {
  transform: rotate(90deg);
}
.category-breakdown summary i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}
.category-breakdown summary strong {
  margin-left: auto;
  white-space: nowrap;
  font-weight: 600;
}
.category-breakdown summary span {
  min-width: 0;
}
.breakdown-totals {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  padding: 0 0 8px;
}
.category-breakdown ul {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.category-breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
}
.category-breakdown li span {
  overflow-wrap: anywhere;
}
.category-breakdown li strong {
  white-space: nowrap;
  font-weight: 500;
}
.category-breakdown small {
  display: block;
  color: var(--muted);
}
.category-breakdown p {
  color: var(--muted);
  margin: 0 0 12px;
}
.palette-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
#palette-preview {
  display: flex;
  gap: 5px;
  margin: 12px 0;
  flex-wrap: wrap;
}
#palette-preview i {
  width: 24px;
  height: 18px;
  border-radius: 3px;
}
.category-edit select {
  width: 62px;
  flex-shrink: 0;
  padding: 4px;
  font-size: 20px;
}
.category-edit input[type="text"] {
  font-size: 14px;
}
.category-edit input[type="color"] {
  width: 34px;
}
@media (max-width: 440px) {
  .category-edit {
    flex-wrap: wrap;
  }
  .category-edit input[type="text"] {
    width: calc(100% - 105px);
  }
  .palette-label {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Day and category precede the description in every ledger state. */
.expense-row,
.expense-row.finalized,
.ledger-column-head {
  grid-template-columns: 48px 36px minmax(120px, 1fr) 90px 68px 48px 32px;
  min-width: 580px;
}
#expense-list,
.add-expense-row {
  min-width: 580px;
}
.expense-row .day-select {
  font-size: 13px;
  padding: 4px;
  height: 34px;
  min-height: 34px;
  width: 48px;
  box-shadow: none;
}
.row-day {
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Ivory working surface, green reserved for actions and balance. */
body {
  background: #f7f4ee;
  background-attachment: initial;
}
header {
  background: #fffdf8e8;
  border-bottom: 1px solid #ddd9ce;
  box-shadow: 0 2px 12px #302f2408;
}
.panel,
.totals {
  background: #fffefaed;
  border-color: #d9d7cc;
  box-shadow:
    0 5px 16px #403f3010,
    inset 0 1px #fff;
}
.totals .available-total {
  background: #e7f2e7;
  color: #216442;
}
.remaining-fill {
  background: linear-gradient(110deg, #73be89, #3f9b63);
}
.bar {
  background: #f0f0e8;
  border-color: #d5dbd0;
}
.workspace {
  align-items: start;
  grid-template-columns: 340px minmax(0, 1fr);
}
.chart-panel {
  gap: 14px;
}
.chart-panel #chart {
  flex: none;
  min-height: 0;
}
.bars {
  height: 390px;
  min-height: 0;
  margin-top: 14px;
  margin-bottom: 6px;
}
.bar {
  height: 350px;
  min-height: 0;
}
.ticks {
  height: 350px;
  min-height: 0;
}
.major-tick {
  border-top: 1px dashed #738c705e;
}
.minor-tick {
  border-top: 1px dotted #80947730;
}
.chart-panel .pie-wrap {
  padding-block: 12px;
}
#category-breakdowns {
  border-top: 1px solid #deded2;
  font-size: 14px;
  margin-top: 6px;
  padding-top: 10px;
}
#category-breakdowns > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  padding: 8px 0;
}
#category-breakdowns > summary::after {
  content: "+";
  font-size: 20px;
  font-weight: 400;
}
#category-breakdowns[open] > summary::after {
  content: "−";
}
#category-breakdowns > summary::-webkit-details-marker {
  display: none;
}
.expense-column {
  gap: 12px;
}
.expense-column .totals > div {
  padding: 12px 20px;
}
.expense-column .totals span {
  font-size: 13px;
  margin-bottom: 3px;
}
.expense-column .totals strong {
  font-size: 23px;
}
.expense-column .ledger-panel {
  padding: 0;
  min-height: 0;
  overflow: hidden;
}
.ledger-panel > .section-heading {
  padding: 16px 20px 12px;
}
.ledger-panel h2 {
  font-size: 20px;
}
.ledger-scroll {
  border: 0;
  border-top: 1px solid #deded2;
  border-radius: 0;
  margin: 0;
  height: clamp(330px, calc(100vh - 310px), 720px);
  scrollbar-gutter: auto;
  background: #fffefa;
}
.ledger-column-head {
  background: #f0ede5;
  color: #4c574c;
  border-color: #d9d7cc;
}
.add-expense-row {
  background: #faf9f3;
  border-color: #deded2;
}
.expense-column .bottom-totals {
  position: sticky;
  bottom: 12px;
  z-index: 2;
  background: #fffefa;
  box-shadow: 0 3px 12px #403f3012;
}
.expense-row .category-icon,
#category-options button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}
.expense-row .category-icon {
  vertical-align: middle;
}
.category-edit select {
  text-align: center;
  text-align-last: center;
}
.row-day,
.day-select {
  display: flex;
  align-items: center;
  justify-content: center;
}
.expense-row .day-select {
  background: #fff9;
  border-color: #aaa8;
  font-variant-numeric: tabular-nums;
}
.category-icon:hover,
.day-select:hover {
  filter: brightness(0.97);
}
#settings {
  position: fixed;
  inset: 14px 14px 14px auto;
  margin: 0;
  width: min(550px, calc(100% - 28px));
  max-height: none;
  height: calc(100dvh - 28px);
  padding: 24px;
  background: #fffdf8f5;
  border: 1px solid #d9d7cc;
  box-shadow: -10px 0 45px #283b2620;
  border-radius: 18px;
  backdrop-filter: blur(18px);
}
.settings-section {
  border-top: 1px solid #deded2;
}
.settings-section > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  list-style: none;
  padding: 18px 0;
  font-weight: 650;
  font-size: 15px;
}
.settings-section > summary::after {
  content: "+";
  font-size: 20px;
  font-weight: 400;
}
.settings-section[open] > summary::after {
  content: "−";
}
.settings-section > summary::-webkit-details-marker {
  display: none;
}
.settings-section-body {
  padding: 0 0 20px;
  display: grid;
  gap: 14px;
}
.settings-section-body > label:not(.check-label) {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}
.settings-section-body > label > input:not([type="checkbox"]),
.settings-section-body > label > select {
  max-width: 240px;
  width: 58%;
}
.settings-section .check-label {
  margin: 0;
}
.settings-section p {
  margin: 0;
}
.file-actions {
  grid-template-columns: 1fr 1fr;
}
.file-actions #save-status {
  grid-column: 1/-1;
  color: var(--muted);
  font-size: 12px;
}
#settings .dialog-actions {
  position: sticky;
  bottom: -24px;
  padding: 16px 0;
  background: #fffdf8;
  justify-content: flex-end;
  margin-top: 0;
}
#settings .settings-section-body input,
#settings .settings-section-body select {
  background: #f8f7f0;
  border-color: #d9d7cc;
  box-shadow: none;
}
#day-picker {
  width: 310px;
  background: #fffefa;
  padding: 22px;
}
#day-picker h2 {
  font-size: 18px;
}
#day-options {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-top: 18px;
}
#day-options button {
  padding: 0;
  min-height: 32px;
  height: 32px;
  box-shadow: none;
  border: 0;
  background: transparent;
  font-size: 13px;
}
#day-options button[aria-pressed="true"] {
  background: #267849;
  color: white;
}
#day-options button:hover {
  background: #e0efdf;
  color: #17482b;
}
@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }
}
@media (max-width: 800px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .expense-column {
    grid-row: 1;
  }
  .bars {
    max-width: 310px;
  }
  .ledger-scroll {
    height: 420px;
  }
  .expense-column .bottom-totals {
    bottom: 0;
  }
  .settings-section-body > label:not(.check-label) {
    flex-wrap: wrap;
  }
}

.allocation-section {
  background: var(--allocation-color);
  flex-shrink: 0;
  border-top: 1px solid #ffffffb3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.allocation-section span {
  font-size: 11px;
  background: #fffefaed;
  color: #203426;
  max-width: 94%;
  padding: 2px 4px;
  border-radius: 4px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.allocation-section.outlined {
  background: #dbf0df;
  border: 1px dashed #4a8d60;
}
.category-allocation {
  font-size: 12px;
  color: #4f6454;
}
.category-edit {
  display: grid;
  grid-template-columns: 50px 32px minmax(90px, 1fr) 90px 28px 28px 28px;
  gap: 5px;
}
.category-edit select {
  width: 50px;
  min-width: 0;
}
.category-edit input[type="text"] {
  width: 100%;
}
.category-edit input.category-budget {
  width: 90px;
  padding: 7px;
  font-size: 13px;
  text-align: right;
}
.category-edit button {
  padding: 3px;
}
.category-edit input[type="color"] {
  width: 32px;
}
.settings-section .category-edit {
  margin: 0 0 8px;
}
@media (max-width: 520px) {
  .category-edit {
    grid-template-columns: 42px 30px minmax(80px, 1fr) 85px;
  }
  .category-edit select {
    width: 42px;
  }
  .category-edit input.category-budget {
    width: 85px;
  }
  .category-edit button {
    grid-row: 2;
    width: 32px;
  }
  .category-edit button[data-remove-category] {
    grid-column: 4;
    justify-self: end;
  }
  .category-edit input[type="text"] {
    width: 100%;
  }
}

/* A fixed-height balance surface gives space back to details as they expand. */
.chart-panel {
  height: max(560px, calc(100dvh - 145px));
  position: sticky;
  top: 112px;
}
.balance-heading {
  margin: 0;
  flex-shrink: 0;
}
.balance-heading button {
  padding: 6px 9px;
  font-size: 12px;
  min-height: 32px;
}
.chart-panel #chart {
  flex: 1 1 auto;
  min-height: 160px;
}
.chart-panel .bars {
  height: calc(100% - 20px);
  min-height: 140px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.chart-panel .bar,
.chart-panel .ticks {
  height: calc(100% - 36px);
  min-height: 100px;
}
#category-breakdowns {
  flex: 0 1 auto;
  max-height: 50%;
  overflow: auto;
}
#budget-edit {
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}
#budget-edit > span {
  font-size: 15px;
  opacity: 0.6;
  margin: 0;
}
.month-control select {
  padding: 8px;
  min-height: 38px;
  font-size: 13px;
}
.file-format {
  grid-column: 1/-1;
}
@media (max-width: 800px) {
  .chart-panel {
    position: static;
    height: 650px;
  }
  .month-control {
    flex-wrap: wrap;
  }
}

/* Keep actions outside the scroll region, with no sticky overlap or negative offsets. */
#settings {
  overflow: hidden;
  padding: 0;
}
#settings-form {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#settings-form > .section-heading {
  padding: 22px 24px 0;
  margin: 0;
  flex-shrink: 0;
}
#settings-form > p {
  padding: 0 24px;
  margin: 10px 0 18px;
  font-size: 13px;
}
.settings-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 24px 20px;
  scrollbar-gutter: stable;
}
.settings-footer {
  display: block;
  flex-shrink: 0;
  border-top: 1px solid #dedbd1;
  background: #f8f6ef;
  padding: 16px 20px;
}
.settings-file-actions {
  display: grid;
  grid-template-columns: 76px 1fr 1fr 1.5fr;
  gap: 8px;
  align-items: center;
}
.settings-file-actions button,
.settings-file-actions select {
  margin: 0;
  min-width: 0;
  padding: 10px 8px;
  min-height: 42px;
  font-size: 13px;
  white-space: nowrap;
}
.settings-footer #save-status {
  display: block;
  margin-left: 0;
  text-align: right;
  color: var(--muted);
  margin-top: 10px;
  font-size: 11px;
}
.settings-section .reset-month {
  justify-self: start;
  font-size: 12px;
  padding: 7px 10px;
  box-shadow: none;
}
@media (max-width: 520px) {
  .settings-file-actions {
    grid-template-columns: 70px 1fr 1fr;
  }
  .settings-file-actions .primary {
    grid-column: 1/-1;
  }
  .settings-footer {
    padding: 12px 16px;
  }
}

/* Both workspace columns share the viewport; only the ledger body scrolls. */
.expense-column {
  height: max(560px, calc(100dvh - 145px));
}
.expense-column .ledger-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0;
}
.ledger-panel > .section-heading {
  flex-shrink: 0;
}
.expense-column .ledger-scroll {
  flex: 1 1 0;
  height: auto;
  min-height: 0;
}
.expense-column .bottom-totals {
  position: static;
}
.category-glyph {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  vertical-align: middle;
  object-fit: contain;
}
.settings-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  min-height: 40px;
}
.category-breakdown summary > span {
  display: flex;
  align-items: center;
  gap: 7px;
}
#icon-library {
  width: min(520px, calc(100% - 32px));
  background: #fffdf8;
}
#icon-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}
#icon-options button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 5px;
  font-size: 11px;
  min-height: 72px;
  box-shadow: none;
}
#icon-options button[aria-pressed="true"] {
  border-color: #267849;
  background: #e4efdf;
}
@media (max-width: 800px) {
  .expense-column {
    height: max(560px, calc(100dvh - 180px));
  }
}
@media (max-width: 520px) {
  .settings-icon {
    width: 42px;
  }
  #icon-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .category-edit .settings-icon {
    grid-row: 1;
  }
}
.row-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.row-status button,
.future-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 29px;
  height: 32px;
  min-height: 32px;
  padding: 4px;
  border: 0;
  box-shadow: none;
  background: transparent;
}
.future-toggle {
  position: relative;
  cursor: pointer;
  border-radius: 7px;
}
.future-toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.future-toggle:has(input:checked),
.row-status .active,
.future-status {
  background: #d4e7de;
  border-radius: 7px;
}
.future-toggle:has(input:focus-visible) {
  outline: 2px solid #267849;
}
.row-status .recurring-toggle:not(.active) {
  opacity: 0.45;
}
#recurring-dialog {
  width: min(420px, calc(100% - 32px));
}
#recurring-form > label {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}
#recurring-form > label[hidden] {
  display: none;
}
.add-expense-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 580px;
  border-top: 1px solid #deded2;
  background: #faf9f3;
}
.add-expense-actions .add-expense-row {
  min-width: 0;
  width: 100%;
  border-top: 0;
  text-align: center;
  padding: 13px 7px;
  font-weight: 600;
}
.add-expense-actions .add-expense-row + .add-expense-row {
  border-left: 1px solid #deded2;
}
.add-expense-actions .add-expense-row:hover {
  background: #e8f0e7;
}
.scheduled-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.scheduled-setting span {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.scheduled-setting small {
  color: var(--muted);
}
.scheduled-setting button {
  flex: 0 0 auto;
}
.schedule-override {
  color: #a56c1b;
}
.chart-panel .bars.has-allocations {
  gap: 10px;
  justify-content: space-between;
  margin-right: 5px;
}
.bars.has-allocations .bar-column {
  flex: 1 1 0;
  width: min(62px, 31%);
  min-width: 0;
}
.bars.has-allocations .bar-column > span {
  font-size: 11px;
  white-space: nowrap;
}
.allocation-segment {
  border-top: 1px solid #fff9;
}

/* Header navigation: one date control, with clear labels and deliberate touch targets. */
header {
  display: grid;
  grid-template-columns: minmax(145px, 1fr) auto minmax(145px, 1fr);
  gap: 22px;
  padding: 14px max(24px, calc((100vw - 1280px) / 2));
  min-height: 84px;
}
header .brand {
  justify-self: start;
  white-space: nowrap;
}
header .month-control {
  margin: 0;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f8f7f1;
  border: 1px solid #d8ded4;
  border-radius: 17px;
  padding: 5px;
  box-shadow:
    inset 0 1px 3px #4155430e,
    0 2px 8px #3247350a;
}
.month-control button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: transparent;
  box-shadow: none;
}
.month-control button:hover {
  background: #e4efe5;
}
.date-fields {
  display: flex;
  align-items: center;
  gap: 0;
  border-inline: 1px solid #dce3d9;
}
.date-field {
  display: grid;
  align-content: center;
  min-width: 62px;
  padding: 3px 8px 3px 12px;
  border-right: 1px solid #dce3d9;
}
.date-field:last-child {
  border-right: 0;
  padding-right: 12px;
}
.date-field span {
  color: #687d6f;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.month-control .date-field select {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  min-height: 25px;
  height: 25px;
  padding: 1px 20px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: #293b2e;
}
#year {
  width: 67px;
}
#month {
  width: 121px;
}
#selected-day {
  width: 58px;
}
.header-actions {
  justify-self: end;
  align-items: center;
  gap: 8px;
}
.profile-control {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d8ded4;
  border-radius: 12px;
  background: #fffefa;
  padding: 0 7px 0 12px;
  height: 46px;
}
.profile-control img {
  opacity: 0.72;
}
.header-actions #profile {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0 3px;
  min-height: 42px;
  max-width: 120px;
  font-weight: 700;
}
.header-actions #settings-open {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 46px;
  min-height: 46px;
  border-radius: 12px;
  background: #e4efe5;
  color: #245c3c;
  border-color: #cadece;
  font-weight: 700;
  white-space: nowrap;
  padding: 8px 13px;
}
.header-actions #settings-open:hover {
  background: #d4e8d7;
}
@media (max-width: 1000px) {
  header {
    grid-template-columns: auto 1fr auto;
    gap: 10px;
  }
  .date-field {
    padding-left: 7px;
    padding-right: 5px;
  }
  #month {
    width: 104px;
  }
}
@media (max-width: 800px) {
  header {
    grid-template-columns: 1fr auto;
    padding: 12px 18px;
  }
  header .month-control {
    grid-column: 1/-1;
    grid-row: 2;
    justify-self: stretch;
    width: 100%;
    justify-content: center;
    border-top: 1px solid #d8ded4;
    padding: 5px;
    flex-wrap: nowrap;
  }
  .header-actions {
    grid-column: 2;
    grid-row: 1;
  }
}
@media (max-width: 440px) {
  header {
    padding: 10px 12px;
  }
  .brand {
    font-size: 23px;
  }
  .brand-mark {
    font-size: 25px;
  }
  .header-actions #settings-open {
    width: 44px;
    padding: 0;
    justify-content: center;
  }
  .header-actions #settings-open span {
    display: none;
  }
  .profile-control {
    padding-left: 7px;
  }
  .header-actions #profile {
    max-width: 80px;
  }
  .date-field {
    padding-left: 5px;
    padding-right: 3px;
  }
  #month {
    width: 96px;
  }
  #year {
    width: 61px;
  }
  #selected-day {
    width: 55px;
  }
}
/* Row calendar uses the same weekday grid as a conventional month view. */
#day-picker .calendar-weekdays {
  margin-top: 18px;
}
#day-picker #day-options {
  margin-top: 0;
}
#day-picker {
  width: min(350px, calc(100% - 32px));
  padding: 22px;
  background: #fffdf8;
}
#day-picker h2 {
  font-size: 20px;
}
.calendar-weekdays,
#day-options {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
  gap: 4px;
}
.calendar-weekdays {
  margin-top: 20px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #637468;
}
#day-options button {
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  height: 38px;
  min-height: 38px;
  font-size: 13px;
}
#day-options button:hover {
  background: #e7f3e9;
}
#day-options button[aria-pressed="true"] {
  background: #287c50;
  color: #fff;
}
/* Native select arrows need enough width for the full four-digit year. */
#year {
  width: 82px;
}
@media (max-width: 440px) {
  #year {
    width: 77px;
  }
}
