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

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-body);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: 1.45;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-md);
  padding: 0 16px;
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.btn:focus-visible {
  box-shadow: var(--focus-ring);
}

.btn-sm {
  gap: 6px;
  height: var(--control-sm);
  padding: 0 12px;
  font-size: var(--text-sm);
}

.btn-lg {
  height: var(--control-lg);
  padding: 0 22px;
  font-size: var(--text-lg);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-pill {
  height: 34px;
  padding: 0 18px;
  border-radius: 17px;
}

.btn-pill .plus {
  font-size: 16px;
  line-height: 1;
  margin-top: -1px;
}

.btn-pill-lg {
  height: 38px;
  padding: 0 22px;
  border-radius: 19px;
}

.btn-ghost.btn-pill-lg {
  padding: 0 18px;
}

.btn-primary {
  background: var(--action-primary-bg);
  color: var(--action-primary-fg);
}

.btn-primary:hover {
  background: var(--action-primary-hover);
}

.btn-secondary {
  background: var(--surface-card);
  color: var(--text-body);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--teal-tint);
}

.btn-ghost {
  background: transparent;
  color: var(--booksly-teal);
}

.btn-ghost:hover {
  background: var(--teal-tint);
}

.btn-gold {
  background: var(--booksly-gold);
  color: var(--booksly-teal);
}

.btn-gold:hover {
  background: var(--gold-hover);
}

.btn-destructive {
  background: var(--action-destructive-bg);
  color: #ffffff;
}

.btn-destructive:hover {
  background: var(--wine-hover);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--booksly-steel);
  opacity: 0.8;
  cursor: not-allowed;
}

a.btn[aria-disabled="true"] {
  pointer-events: none;
}

.app-header {
  background: var(--booksly-teal);
  border-bottom: 3px solid var(--booksly-gold);
  padding: 0 48px;
}

.app-header__row {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  gap: 32px;
  height: 56px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-md);
  background: var(--booksly-gold);
  color: var(--booksly-teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  align-self: center;
}

.nav-tabs {
  display: flex;
  gap: 6px;
}

.nav-tab {
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--on-teal-muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}

.nav-tab:hover {
  color: var(--on-teal);
}

.nav-tab--active {
  font-weight: var(--weight-semibold);
  color: var(--on-teal);
  border-bottom-color: var(--booksly-gold);
}

/* The year select and the sign-out belong together as one right-hand cluster, so the 32px
   row gap must not fall between them. */
.app-header__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Switching year is navigation, so the years are links rather than a form: each one is a real URL
   that opens in a second tab to compare two years. */
.fy-menu {
  position: relative;
}

.fy-select {
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 26px 0 10px;
  font-family: var(--font-numeric);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--on-teal);
  background-color: rgba(255, 255, 255, 0.08);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='6'%3E%3Cpath d='M1 1l3.5 3.5L8 1' fill='none' stroke='%23C8AD55' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 9px 6px;
  border: 1px solid var(--on-teal-border);
  border-radius: var(--radius-md);
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  list-style: none;
}

.fy-select::-webkit-details-marker {
  display: none;
}

.fy-select:hover {
  border-color: var(--booksly-gold);
}

.fy-select:focus-visible {
  box-shadow: var(--focus-ring);
}

.fy-menu__list {
  top: calc(100% + 4px);
  right: 0;
  display: flex;
  flex-direction: column;
  min-width: 100%;
  padding: 5px;
}

.fy-menu__item {
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-family: var(--font-numeric);
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.fy-menu__item:hover {
  background: var(--teal-tint);
}

.fy-menu__item--active {
  color: var(--gold-text);
  font-weight: var(--weight-semibold);
}

.sign-out {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sign-out__person {
  font-size: var(--text-sm);
  color: var(--on-teal-muted);
}

/* A .btn-secondary on the teal bar would shout, so the variant keeps its shape and takes its
   colours from the header instead. */
.sign-out__button {
  height: 30px;
  padding: 0 14px;
  color: var(--on-teal);
  background: transparent;
  border-color: var(--on-teal-border);
  border-radius: 15px;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.sign-out__button:hover {
  background: var(--on-teal-hover);
  border-color: var(--booksly-gold);
}

select {
  appearance: none;
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 9px 6px;
}

select.on-light {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='6'%3E%3Cpath d='M1 1l3.5 3.5L8 1' fill='none' stroke='%234C6169' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}

select:hover {
  border-color: var(--booksly-gold);
}

@supports selector(::picker(select)) {
  select,
  select::picker-icon {
    appearance: base-select;
  }

  select:not([hidden]) {
    white-space: nowrap;
    display: flex;
    align-items: center;
  }

  select.on-light {
    background-image: none;
    padding-right: 12px !important;
  }

  select.on-light::picker-icon {
    color: var(--text-muted);
  }

  ::picker(select) {
    appearance: base-select;
    margin-top: 4px;
    padding: 5px;
    background: #FFFFFF;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(14, 59, 67, 0.14);
  }

  select option {
    padding: 7px 10px;
    border-radius: var(--radius-md);
    font-family: var(--font-numeric);
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
  }

  select option:hover {
    background: var(--teal-tint);
  }

  select option:checked {
    color: var(--gold-text);
    font-weight: var(--weight-semibold);
  }

  select option::checkmark {
    color: var(--booksly-gold);
  }
}

main {
  padding: 24px 48px 40px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  margin: 0 0 24px -10px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--booksly-teal);
  text-decoration: none;
  border-radius: var(--radius-md);
}

.back-link:hover {
  background: var(--teal-tint);
}

.page-title {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--booksly-teal);
}

.page-help {
  margin: 0 0 40px;
  font-size: 14px;
  color: var(--text-muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field__error {
  font-size: var(--text-sm);
  color: var(--wine-text);
}

.input-underline {
  padding: 4px 0 8px;
  font-family: var(--font-ui);
  font-size: 17px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--line-soft);
  outline: none;
  transition: border-color 0.12s ease;
}

.input-underline::placeholder {
  color: var(--text-faint);
}

.input-underline.is-error {
  border-bottom-color: var(--wine-text);
}

.input-underline:focus {
  border-bottom-color: var(--booksly-gold);
}

.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}

.btn-ghost--muted {
  color: var(--text-muted);
}

.content {
  max-width: 1040px;
  margin: 0 auto;
  border-left: 2px solid rgba(72, 22, 32, 0.3);
  padding-left: 28px;
}

.summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-strong);
}

.summary__stats {
  display: flex;
  gap: 44px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat__value {
  font-family: var(--font-numeric);
  font-size: 24px;
  font-weight: var(--weight-medium);
  line-height: 1;
  min-height: 24px;
  font-variant-numeric: tabular-nums;
  color: var(--booksly-teal);
}

.stat__value--neg {
  color: var(--amount-negative);
}

.mark {
  background: linear-gradient(transparent 58%, var(--gold-tint) 58%);
  padding: 0 5px;
  margin: 0 -5px;
}

.ledger-head,
.ledger-row,
.ledger-total {
  display: grid;
  column-gap: 16px;
}

.ledger-head {
  padding: 10px 12px 7px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

a.ledger-row {
  text-decoration: none;
  color: inherit;
}

.ledger-row {
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.ledger-row:hover {
  background: var(--teal-tint);
  box-shadow: inset 3px 0 0 var(--booksly-gold);
}

.cell-no {
  font-family: var(--font-numeric);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  color: var(--gold-text);
}

.cell-title {
  font-size: 14px;
  font-weight: var(--weight-medium);
  color: var(--ink);
}

.cell-verifs {
  text-align: right;
  font-family: var(--font-numeric);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.cell-balance {
  text-align: right;
  font-family: var(--font-numeric);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.cell-balance--neg {
  color: var(--amount-negative);
}

.num-right {
  text-align: right;
}

.ledger-total {
  padding: 10px 12px;
  margin-top: 2px;
  border-top: 2px solid var(--booksly-gold);
  border-bottom: 7px double var(--booksly-gold);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.ledger-total .label {
  color: var(--text-muted);
}

.ledger-total .num {
  text-align: right;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.ledger-total .net {
  text-align: right;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.popover {
  position: absolute;
  z-index: 20;
  background: var(--surface-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
}

.combobox {
  position: relative;
}

.combobox__input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  font-family: var(--font-numeric);
  font-size: 13px;
  color: var(--ink);
  background-color: transparent;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  outline: none;
}

.combobox__input::placeholder {
  color: var(--ink-faint);
}

.combobox__input:focus {
  border-color: var(--booksly-gold);
}

.combobox__list {
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
}

.combobox__option {
  padding: 6px 10px;
  font-family: var(--font-numeric);
  font-size: 13px;
  color: var(--ink);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combobox__option.is-active {
  background: var(--gold-tint);
}

.combobox__option--muted {
  color: var(--text-faint);
}

.combobox__more {
  padding: 6px 10px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-faint);
  white-space: nowrap;
}

.datepicker {
  position: relative;
}

.calendar {
  top: calc(100% + 4px);
  left: 0;
  width: 260px;
  padding: 10px;
}

.calendar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.calendar__title {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--ink);
}

.calendar__nav {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--ink-secondary);
  background: transparent;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.calendar__nav:hover {
  background: var(--teal-tint);
}

.calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar__weekday {
  padding: 4px 0;
  text-align: center;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--ink-faint);
}

.calendar__day {
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-numeric);
  font-size: 12.5px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.calendar__day.is-empty {
  cursor: default;
}

.calendar__day:hover:not(.is-empty) {
  background: var(--teal-tint);
}

.calendar__day.is-today {
  border-color: var(--line);
}

.calendar__day.is-cursor {
  border-color: var(--booksly-gold);
}

.calendar__day.is-selected {
  background: var(--booksly-teal);
  color: var(--action-primary-fg);
}
