:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
}

[x-cloak] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f5f4;
  color: #1c1917;
  line-height: 1.5;
}

a {
  color: #1d4ed8;
}

:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: #1c1917;
  color: #fafaf9;
  text-decoration: none;
  transform: translateY(-200%);
}

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

.app-shell {
  display: grid;
  min-height: 100vh;
}

.nav-rail {
  display: none;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem 1rem;
  background: #292524;
  color: #fafaf9;
}

.nav-rail__links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-rail__logout {
  margin-top: auto;
}

.nav-rail__brand {
  font-size: 1.25rem;
  font-weight: 700;
}

.nav-rail__link {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: #fafaf9;
  font: inherit;
  font-size: 1rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav-rail__link--active,
.nav-rail__link:hover {
  background: #44403c;
}

.nav-rail__link:focus-visible,
.mobile-header__menu:focus-visible {
  outline-color: #bfdbfe;
}

.mobile-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #292524;
  color: #fafaf9;
}

.mobile-header__menu,
.menu-modal__close {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
}

.mobile-header__title {
  font-weight: 700;
}

.menu-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.menu-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(28 25 23 / 50%);
}

.menu-modal__panel {
  position: absolute;
  top: 0;
  left: 0;
  width: min(18rem, 85vw);
  height: 100%;
  padding: 1rem;
  background: #fafaf9;
  box-shadow: 0 10px 30px rgb(28 25 23 / 20%);
}

.menu-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-weight: 700;
}

.menu-modal__nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.menu-modal__link {
  display: block;
  width: 100%;
  padding: 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: #1c1917;
  font: inherit;
  font-size: 1rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-modal__link--button {
  margin-top: 0.5rem;
}

.menu-modal__link:hover {
  background: #e7e5e4;
}

.app-main {
  min-width: 0;
  padding: 1rem;
  scroll-margin-top: 1rem;
}

.page-title {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}

.page-header {
  margin-bottom: 1rem;
}

.page-header h1 {
  margin: 0;
}

.page-header__subtitle {
  margin: 0.25rem 0 0;
  color: #57534e;
}

.card {
  box-sizing: border-box;
  margin-bottom: 1rem;
  padding: 1rem;
  background: white;
  border: 1px solid #d6d3d1;
  border-radius: 0.75rem;
}

.card h2 {
  margin-top: 0;
}

.card__lede {
  margin: -0.25rem 0 1rem;
  color: #57534e;
}

.messages {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.messages__item {
  margin-bottom: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: #dbeafe;
}

.messages__item--success {
  background: #dcfce7;
  color: #14532d;
}

.messages__item--error {
  background: #fee2e2;
  color: #7f1d1d;
}

.form-field {
  margin: 0 0 1rem;
}

.form-field--invalid input,
.form-field--invalid select,
.form-field--invalid textarea {
  border: 1px solid #b91c1c;
}

.field-error,
.form-errors {
  margin: 0.35rem 0 0;
  color: #b91c1c;
}

.stacked-form p {
  margin: 0 0 1rem;
}

label,
input,
select,
textarea,
button {
  box-sizing: border-box;
}

label {
  display: block;
  font-weight: 600;
}

input,
select,
textarea,
button {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem;
  font-size: 1rem;
}

button,
.button-secondary {
  display: inline-block;
  width: auto;
  min-width: 6rem;
  margin-top: 0.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid #a8a29e;
  border-radius: 0.5rem;
  background: #1c1917;
  color: white;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button-secondary {
  background: white;
  color: #1c1917;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.ledger-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ledger-row {
  padding: 0.85rem 0;
  border-bottom: 1px solid #e7e5e4;
}

.ledger-row__main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.ledger-row__note {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-row__amount {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.ledger-row__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
  min-width: 0;
}

.ledger-row__facts {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #57534e;
  font-size: 0.875rem;
}

.table-wrap {
  display: none;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid #e7e5e4;
  text-align: left;
  vertical-align: top;
}

.data-table__amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table__actions {
  white-space: nowrap;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.inline-form {
  display: contents;
}

.action-link {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #1d4ed8;
  font: inherit;
  font-size: inherit;
  line-height: inherit;
  text-decoration: underline;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.rollup-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rollup-list__item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e7e5e4;
}

.rollup-grand-total {
  margin: 1rem 0 0;
}

.category-list {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.category-list__item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e7e5e4;
}

.empty-state {
  color: #57534e;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.receipt-scan {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px dashed #93c5fd;
  border-radius: 0.75rem;
  background: #dbeafe;
}

.receipt-scan__heading {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.receipt-scan__lede {
  margin: 0 0 1rem;
  color: #57534e;
}

.receipt-scan__panel {
  min-height: 5.5rem;
}

.receipt-scan__state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.receipt-scan__status {
  margin: 0;
}

.receipt-scan__status--success {
  color: #14532d;
}

.receipt-scan__status--error {
  color: #7f1d1d;
}

.receipt-scan__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.receipt-scan__file-label {
  display: inline-block;
  margin: 0;
  cursor: pointer;
}

.receipt-scan__file-label:has(.receipt-scan__file-input:focus-visible)
  .receipt-scan__choose {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.receipt-scan__choose,
.receipt-scan__retry {
  margin-top: 0;
}

.receipt-scan__progress {
  width: 100%;
  height: 0.5rem;
  overflow: hidden;
  border-radius: 999px;
  background: #bfdbfe;
}

.receipt-scan__progress-bar {
  height: 100%;
  border-radius: inherit;
  background: #1d4ed8;
  transition: width 150ms ease;
}

.receipt-scan__spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid #93c5fd;
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: receipt-scan-spin 0.8s linear infinite;
}

@keyframes receipt-scan-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .receipt-scan__spinner {
    animation: none;
    border-top-color: #1d4ed8;
  }

  .receipt-scan__progress-bar {
    transition: none;
  }
}

.form-field--from-receipt label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
}

.form-field__receipt-tag {
  font-size: 0.75rem;
  font-weight: 500;
  color: #1d4ed8;
}

.expense-total {
  margin: -0.5rem 0 1rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.expense-total__value {
  font-variant-numeric: tabular-nums;
}

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

.auth-card {
  box-sizing: border-box;
  width: min(100% - 2rem, 28rem);
  margin: 4rem auto;
  padding: 1.5rem;
  background: white;
  border: 1px solid #d6d3d1;
  border-radius: 0.75rem;
  scroll-margin-top: 1rem;
}

.auth-card h1 {
  margin-top: 0;
}

.auth-card__lede {
  margin: 0 0 1rem;
  color: #57534e;
}

.auth-card__footer {
  margin: 1rem 0 0;
}

@media (width < 768px) {
  .card {
    padding: 1.25rem;
  }

  .receipt-scan {
    margin-bottom: 1.25rem;
    padding: 1.25rem;
  }

  .receipt-scan__lede {
    margin-bottom: 1.25rem;
  }

  .receipt-scan__file-label {
    display: block;
    width: 100%;
  }

  .receipt-scan__choose,
  .receipt-scan__retry {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.75rem;
  }

  .stacked-form .form-field {
    margin-bottom: 1.15rem;
  }

  .row-actions .action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
  }

  .category-list__item {
    align-items: center;
    padding: 0.65rem 0;
  }
}

@media (width >= 768px) {
  .ledger-list {
    display: none;
  }

  .table-wrap {
    display: block;
  }

  .app-shell {
    grid-template-columns: 12rem 1fr;
  }

  .nav-rail {
    display: flex;
  }

  .mobile-header,
  .menu-modal {
    display: none;
  }

  .app-main {
    padding: 1.5rem 2rem;
  }
}

@media (width >= 1024px) {
  .app-main {
    max-width: 60rem;
  }
}
