* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #071313;
  color: #f2faf5;
  font-family: Inter, system-ui, sans-serif;
  line-height: 1.5;
}

p {
  margin: 0;
}

main {
  max-width: 480px;
  margin: 0 auto;
}

.overview {
  padding: 20px;
  background: linear-gradient(45deg, #084f4d, #35652f);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.settings-button {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  font: inherit;
  font-size: 24px;
  display: grid;
  place-items: center;
  line-height: 1;
}

.settings-button svg {
  display: block;
}

.balance-label {
  font-size: 14px;
  color: #d4e8dd;
}

.balance-amount {
  margin-top: 4px;
  font-size: 38px;
  line-height: 1.15;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  min-height: 1.15em;
}

.loading-spinner {
  display: inline-block;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: currentColor;
  border-radius: 50%;
  vertical-align: middle;
  animation: spinner-rotation 0.8s linear infinite;
}

.loading-spinner[hidden] {
  display: none;
}

@keyframes spinner-rotation {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation: none;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.month-section {
  padding: 24px 20px;
}

.month-picker {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.month-picker input,
.expense-dialog input,
.expense-dialog select {
  width: 100%;
  min-width: 0;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid #34514a;
  border-radius: 10px;
  background: #102320;
  color: inherit;
  font: inherit;
}

.month-picker input {
  width: 190px;
  color-scheme: dark;
}

.month-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 0;
}

.month-summary dt {
  color: #a9c3b8;
  font-size: 13px;
}

.month-summary dd {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.categories-section {
  padding: 0 20px 24px;
}

.categories-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 500;
}

.category-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.category-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 0;
  border-bottom: 1px solid #203b35;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.empty-message {
  color: #a9c3b8;
  font-size: 14px;
}

.refresh-button,
.expense-button {
  padding: 8px 14px;
  border: 1px solid currentColor;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.refresh-button:disabled,
.expense-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.overview-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.overview-actions .expense-button {
  flex: 1;
}

.overview-actions .refresh-button {
  flex-shrink: 0;
}

.expense-dialog {
  width: min(400px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 20px;
  border: 1px solid #34514a;
  border-radius: 12px;
  background: #071313;
  color: #f2faf5;
}

.expense-dialog::backdrop {
  background: rgba(7, 19, 19, 0.75);
}

.expense-dialog h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 500;
}

.expense-dialog label {
  display: block;
  margin-bottom: 6px;
  color: #a9c3b8;
  font-size: 14px;
}

.expense-dialog-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.expense-categories {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.expense-categories button {
  min-width: 0;
  overflow-wrap: anywhere;
}

.expense-new-form {
  margin-top: 16px;
}

#expense-selected-amount {
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}


.expense-history-info {
  flex: 1;
  min-width: 0;
}

.expense-history-info time {
  display: block;
  color: #a9c3b8;
  font-size: 13px;
}

.expense-history-button {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.expense-history-button:focus-visible {
  outline: 2px solid #a9c3b8;
  outline-offset: 4px;
  border-radius: 4px;
}

.expense-history-amount {
  text-align: right;
}

.expense-details {
  margin: 0;
}

.expense-details > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  padding: 8px 0;
}

.expense-details dt {
  color: #a9c3b8;
}

.expense-details dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

#expense-details-title {
  text-align: center;
  overflow-wrap: anywhere;
}

.expense-dialog select {
  color-scheme: dark;
}

.stats-tabs {
  display: flex;
  gap: 12px;
  padding: 0 20px 16px;
}

.stats-tab {
  flex: 1;
  color: #a9c3b8;
  border-color: #34514a;
}

.stats-tab[aria-selected="true"] {
  background: #102320;
  color: #f2faf5;
  border-color: #a9c3b8;
}

.history-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

#balance-status:not(:empty),
#expense-dialog-status:not(:empty),
#history-status:not(:empty),
#expense-edit-status:not(:empty),
#settings-status:not(:empty) {
  margin-top: 12px;
}

#expense-new-category,
#expense-new-category-form button[type="submit"] {
  display: block;
  width: fit-content;
  margin: 0 auto;
}

.expense-dialog [hidden],
[role="tabpanel"][hidden],
.history-pagination[hidden] {
  display: none;
}

#expense-history > li {
  padding: 6px 0;
}

#expense-details-title:focus {
  outline: none;
}

.budget-value-button {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.budget-value-button:disabled {
  cursor: default;
}

.settings-options {
  display: grid;
  gap: 12px;
}

#settings-dialog-title {
  text-align: center;
  overflow-wrap: anywhere;
}

#settings-dialog-title:focus {
  outline: none;
}

.reminders-fields {
  width: 100%;
  min-width: 0;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.reminders-fields:disabled {
  opacity: 0.6;
}

.reminder-group + .reminder-group {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #203b35;
}

#reminders-form {
  width: 100%;
  min-width: 0;
  text-align: left;
}

.expense-dialog .reminder-toggle {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: inherit;
}

.expense-dialog .reminder-toggle input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: #d4e8dd;
}

.reminder-group .empty-message {
  margin-bottom: 12px;
}

.reminder-time-field {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid #34514a;
  border-radius: 10px;
  background: #102320;
}

.expense-dialog #reminders-form input[type="time"] {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  color-scheme: dark;
}

.reminders-loading {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.settings-category-list {
  margin: 16px 0;
  padding: 0;
  list-style: none;
}

.settings-category-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #203b35;
}

.settings-category-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.settings-category-list button {
  flex-shrink: 0;
}

#category-settings-empty:not([hidden]) {
  margin-bottom: 16px;
}

.category-settings-loading {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.category-remove-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ef7777;
  font-size: 28px;
  line-height: 1;
}

.refresh-icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
}

.refresh-icon-button svg {
  display: block;
}

.expense-retry-button {
  display: block;
  width: fit-content;
  margin: 12px auto 0;
}

.expense-date-field {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid #34514a;
  border-radius: 10px;
  background: #102320;
}

.expense-dialog #expense-edit-date {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 1.5em;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.5;
  text-align: left;
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
}

#expense-edit-date::-webkit-date-and-time-value {
  text-align: left;
}

#expense-edit-date::-webkit-datetime-edit {
  padding: 0;
}

.category-history-button {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.category-history-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
}

.category-history-name {
  min-width: 0;
}

.category-history-amount {
  font-variant-numeric: tabular-nums;
}

.category-share-track {
  display: block;
  height: 4px;
  margin-top: 8px;
  border-radius: 999px;
  background: #102320;
  overflow: hidden;
}

.category-share-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #a9c3b8;
}

.category-history-button:focus-visible {
  outline: 2px solid #a9c3b8;
  outline-offset: 4px;
  border-radius: 4px;
}

.history-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.history-filter[hidden] {
  display: none;
}

.history-filter-label {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #a9c3b8;
}

.history-summary {
  margin: 0 0 12px;
  font-variant-numeric: tabular-nums;
}

.statistics-dialog {
  overflow-y: auto;
}

#statistics-title {
  text-align: center;
}

#statistics-title:focus {
  outline: none;
}

.statistics-fields {
  width: 100%;
  min-width: 0;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.statistics-date-field {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid #34514a;
  border-radius: 10px;
  background: #102320;
}

.expense-dialog .statistics-date-field input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 1.5em;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.5;
  text-align: left;
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
}

.statistics-date-field input::-webkit-date-and-time-value {
  text-align: left;
}

.statistics-date-field input::-webkit-datetime-edit {
  padding: 0;
}

.statistics-loading {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

#statistics-results {
  margin-top: 20px;
}

.statistics-total {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.statistics-chart {
  width: 100%;
  margin: 20px 0;
}

.statistics-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.statistics-legend {
  margin: 0;
  padding: 0;
  list-style: none;
}

.statistics-legend li {
  padding: 0;
  border-bottom: 1px solid #203b35;
}

.statistics-legend-button {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 4px 10px;
  width: 100%;
  min-width: 0;
  padding: 10px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.statistics-legend-button[aria-pressed="true"] {
  background: #102320;
}

.statistics-legend-button:focus-visible {
  outline: 2px solid #a9c3b8;
  outline-offset: 2px;
}

.statistics-swatch {
  width: 12px;
  height: 12px;
  margin-top: 6px;
  border-radius: 3px;
}

.statistics-category-value {
  grid-column: 2;
  color: #a9c3b8;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

#statistics-status:not(:empty),
#statistics-empty {
  margin-top: 12px;
}

.statistics-view-switch {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.statistics-view-button {
  flex: 1;
  min-width: 0;
  padding: 8px;
  color: #a9c3b8;
  border-color: #34514a;
}

.statistics-view-button[aria-pressed="true"] {
  background: #102320;
  color: #f2faf5;
  border-color: #a9c3b8;
}

#statistics-timeline-view,
#statistics-timeline {
  min-width: 0;
  max-width: 100%;
}

.timeline-range {
  margin: 4px 0 12px;
}

.timeline-frame {
  min-width: 0;
}

.timeline-scroll {
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.timeline-scroll:focus-visible {
  outline: 2px solid #a9c3b8;
  outline-offset: 2px;
}

.timeline-columns {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: max-content;
  min-width: 100%;
  padding: 4px;
}

.timeline-column {
  flex: 0 0 48px;
  width: 48px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.timeline-months .timeline-column {
  flex-basis: 64px;
  width: 64px;
}

.timeline-track {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 180px;
  border-bottom: 1px solid #34514a;
}

.timeline-bar {
  display: block;
  width: 26px;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: #a9c3b8;
}

.timeline-bar-zero {
  background: #34514a;
}

.timeline-label {
  display: block;
  margin-top: 8px;
  color: #a9c3b8;
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.timeline-column[aria-pressed="true"] .timeline-track {
  background: rgba(255, 255, 255, 0.06);
}

.timeline-column[aria-pressed="true"] .timeline-bar {
  background: #d4e8dd;
}

.timeline-column[aria-pressed="true"] .timeline-label {
  color: #f2faf5;
  font-weight: 600;
}

.timeline-column:focus-visible {
  outline: 2px solid #a9c3b8;
  outline-offset: 2px;
}

.timeline-details {
  margin-top: 12px;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.timeline-pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.currency-fields {
  width: 100%;
  min-width: 0;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.currency-loading {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

#currency-custom {
  text-transform: uppercase;
}

#budget-period {
  margin-top: 12px;
}

.balance-details-button {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-variant-numeric: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.balance-details-button:disabled {
  opacity: 1;
  cursor: default;
}

.balance-details-button:focus-visible {
  outline: 2px solid #a9c3b8;
  outline-offset: 4px;
  border-radius: 4px;
}

#balance-details-title {
  text-align: center;
}

#balance-details-title:focus {
  outline: none;
}

.balance-details-available {
  margin-bottom: 12px;
  font-size: 28px;
  font-weight: 500;
  text-align: center;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.balance-details-list {
  margin: 16px 0;
}

.balance-details-list > div {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.balance-details-list dt {
  overflow-wrap: anywhere;
}

#refresh-data {
  position: relative;
}

#refresh-data[aria-busy="true"] svg {
  visibility: hidden;
}

#refresh-data[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  margin: auto;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spinner-rotation 0.8s linear infinite;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  #refresh-data[aria-busy="true"]::after {
    animation: none;
  }
}
