:root {
  --blue: #007aff;
  --blue-dark: #0062cc;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --yellow: #ffcc00;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --text-muted: #636366;
  --border: #d1d1d6;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --header-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header__brand { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; }

.header__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 11px;
  background: transparent;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.28);
}

.header__icon-image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 11px;
}

.header__icon:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.35);
}

.header__icon:active { transform: scale(0.96); }

.header__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header__subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav__btn {
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav__btn:hover { background: var(--bg); color: var(--text); }
.nav__btn--active { background: var(--blue); color: #fff; }

/* Main */
.main {
  flex: 1;
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 1.25rem;
}

.view { display: none; animation: fadeIn 0.25s ease; }
.view--active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.toolbar__group { display: flex; align-items: center; gap: 0.5rem; }
.toolbar__actions { gap: 0.25rem; }

.toolbar--month {
  flex-wrap: nowrap;
}

.toolbar__group--month {
  flex: 1;
  min-width: 0;
  gap: 0.35rem;
}

.toolbar__select {
  flex: 1;
  min-width: 0;
}

.toolbar__group--month .btn--icon {
  flex-shrink: 0;
  min-width: 2.25rem;
  min-height: 2.25rem;
  font-size: 1rem;
}

.toolbar__group--month #addMonth {
  font-size: 1.15rem;
  font-weight: 700;
}

/* Help box */
.help-box {
  background: #e8f4ff;
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: #333;
}

.help-box em { font-style: normal; font-weight: 600; color: var(--blue-dark); }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.stat-card__label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}

.stat-card__value {
  font-size: 1.15rem;
  font-weight: 700;
  word-break: break-word;
}

.stat-card__value--real { color: var(--green); }
.stat-card__value--balance { color: var(--red); }

.stat-card__value.positive { color: var(--green); }
.stat-card__value.negative { color: var(--red); }

/* Cards & charts */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card__title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.card__header .card__title { margin-bottom: 0; }
.card__text { margin: 0 0 1rem; color: var(--text-muted); font-size: 0.9rem; }

.stats-grid--overview {
  margin-bottom: 1rem;
}

.year-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.year-chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.year-chart-legend__swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
}

.year-chart-legend__swatch--budget { background: var(--blue); }
.year-chart-legend__swatch--real { background: var(--green); }

.year-chart {
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, #fafbfd 0%, #fff 100%);
  overflow-x: auto;
}

.year-chart__plot {
  min-width: 640px;
  padding: 1rem 0.75rem 0.5rem;
}

.year-chart__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(44px, 1fr));
  gap: 0.45rem;
  align-items: end;
  min-height: 220px;
}

.year-chart__month {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.year-chart__bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.25rem;
  width: 100%;
  height: 180px;
}

.year-chart__bar {
  flex: 1;
  max-width: 1.1rem;
  min-height: 0;
  align-self: flex-end;
  border-radius: 6px 6px 2px 2px;
  transition: height 0.25s ease;
}

.year-chart__empty {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.overview-period {
  display: block;
  margin-top: 0.35rem;
  font-weight: 600;
  color: var(--text);
}

.overview-details {
  margin-top: 0.25rem;
}

.overview-details__toggle {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 0.45rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--blue);
  user-select: none;
}

.overview-details__toggle::-webkit-details-marker {
  display: none;
}

.overview-details__toggle::before {
  content: '▸';
  font-size: 0.85rem;
  transition: transform 0.15s ease;
}

.overview-details[open] .overview-details__toggle::before {
  transform: rotate(90deg);
}

.overview-details .table-scroll {
  margin-top: 0.75rem;
}

.card__header--overview-category {
  align-items: flex-end;
}

.overview-category-picker {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: min(100%, 220px);
}

.overview-category-picker__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.line-chart {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, #fafbfd 0%, #fff 100%);
  overflow-x: auto;
  padding: 0.75rem;
}

.line-chart__svg {
  display: block;
  width: 100%;
  min-width: 640px;
  height: auto;
}

.line-chart__grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.line-chart__line {
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-chart__line--budget { stroke: var(--blue); }
.line-chart__line--real { stroke: var(--green); }

.line-chart__dot {
  stroke: #fff;
  stroke-width: 1.5;
}

.line-chart__dot--budget { fill: var(--blue); }
.line-chart__dot--real { fill: var(--green); }

.line-chart__label {
  fill: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
}

.year-chart__bar--budget { background: var(--blue); }
.year-chart__bar--real { background: var(--green); }

.year-chart__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.15;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}

.btn--active {
  background: var(--blue);
  color: #fff;
}

.modal__intro {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.modal-empty {
  margin: 0;
}

.category-picker {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: min(50vh, 360px);
  overflow-y: auto;
}

.category-picker__item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.category-picker__item:hover {
  border-color: var(--blue);
  background: #f0f7ff;
}

.category-picker__name {
  flex: 1;
}

#summaryTable:not(.table--edit) .col-actions {
  display: none;
}

#summaryTable.table--edit tfoot .col-actions {
  vertical-align: middle;
}

#openAddCategoryModal {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

#openAddCategoryModal[hidden] {
  display: none;
}

/* Tables */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 480px;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table thead th {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.data-table tbody tr:nth-child(even) { background: #fafafa; }
.data-table tbody tr:hover { background: #f0f7ff; }

.data-table tbody tr.row-paid {
  background: #e8f4ff !important;
}

.data-table tbody tr.row-paid:hover {
  background: #d9ecff !important;
}

.data-table tbody tr.row-over {
  background: #e8f8ec !important;
}

.data-table tbody tr.row-over:hover {
  background: #d4f0da !important;
}

.data-table tbody tr.row-over .col-money:last-child,
.data-table tbody tr.row-over .real-cell {
  color: #1b7a2e;
  font-weight: 600;
}

.data-table tbody tr.row-over .real-cell:hover {
  color: #156024;
}

.data-table tbody tr.row-partial {
  background: #b8daff !important;
}

.data-table tbody tr.row-partial:hover {
  background: #a3ceff !important;
}

.data-table tbody tr.row-overdue {
  background: #ffe5e3 !important;
}

.data-table tbody tr.row-overdue:hover {
  background: #ffd4d1 !important;
}

.data-table tbody tr.row-pending {
  background: #f7f7f9 !important;
}

.data-table tbody tr.row-pending:hover {
  background: #ececf0 !important;
}

.data-table tbody tr.row-overdue .col-money:last-child {
  color: #c62828;
  font-weight: 600;
}

.data-table tbody tr.row-overdue .real-cell {
  color: #c62828;
  font-weight: 600;
}

.real-cell {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  text-align: right;
  color: inherit;
  cursor: pointer;
}

.real-cell--stacked {
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
}

.real-cell-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

.real-cell-main {
  font-variant-numeric: tabular-nums;
}

.real-cell:hover {
  text-decoration: underline;
  color: var(--blue);
}

.data-table tbody tr.row-overdue .real-cell:hover {
  color: #a31f1f;
}

.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-top: 0.35rem;
}

.status-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border: none;
  border-radius: 6px;
  padding: 0.15rem 0.35rem;
  background: transparent;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, outline-color 0.15s;
}

.status-legend__item:hover {
  background: var(--bg);
  color: var(--text);
}

.status-legend__item--active {
  background: #eef5ff;
  color: var(--blue);
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.status-legend__item::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.status-legend__item--pending::before { background: #f7f7f9; }
.status-legend__item--paid::before { background: #e8f4ff; }
.status-legend__item--over::before { background: #e8f8ec; }
.status-legend__item--partial::before { background: #b8daff; }
.status-legend__item--overdue::before { background: #ffe5e3; }

.summary-filter-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem 1rem !important;
}

.status-filter-select-wrap {
  display: none;
  width: 100%;
}

.status-filter-select {
  width: 100%;
}

.card__header--summary .status-filter-wrap {
  width: 100%;
}

.pull-refresh {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding-top: calc(var(--header-h) + 0.25rem);
  transform: translate(-50%, calc(-100% + var(--pull-offset, 0px)));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.pull-refresh--visible { opacity: 1; }

.pull-refresh--ready .pull-refresh__label {
  color: var(--blue);
  font-weight: 600;
}

.pull-refresh__spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
}

.pull-refresh--loading .pull-refresh__spinner {
  animation: pull-spin 0.7s linear infinite;
}

.pull-refresh__label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.data-table tfoot .row-total {
  background: #eef5ff;
  font-weight: 700;
}

.col-money { text-align: right !important; white-space: nowrap; }
.col-date { white-space: nowrap; min-width: 140px; }
.col-actions { width: 48px; text-align: center !important; }

#categoriesTable .col-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  width: auto;
  min-width: 5.25rem;
  white-space: nowrap;
}

#categoriesTable .col-actions .btn--icon {
  flex: 0 0 auto;
}

.input-budget,
.input-due {
  width: 100%;
  min-width: 110px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
}

.input-budget {
  text-align: right;
}

.input-due {
  min-width: 130px;
}

.input-budget:focus,
.input-due:focus {
  outline: 2px solid var(--blue);
  border-color: var(--blue);
}

.diff-positive { color: var(--green); font-weight: 600; }
.diff-negative { color: var(--red); font-weight: 600; }
.diff-zero { color: var(--text-muted); }

.color-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.1);
}

/* Forms & inputs */
.select, .input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
  min-height: 40px;
}

.select:focus, .input:focus {
  outline: 2px solid var(--blue);
  border-color: var(--blue);
}

.input--search { min-width: 200px; }
.input--color { padding: 0.25rem; height: 40px; cursor: pointer; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field span { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.field--full { grid-column: 1 / -1; }

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

.recurrence-fields {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.recurrence-fields legend {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 0.35rem;
}

.field-hint {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.recurrence-cell {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.due-date--fixed {
  display: inline-block;
  padding: 0.35rem 0;
  font-variant-numeric: tabular-nums;
}

.col-category {
  text-align: left !important;
  vertical-align: middle;
  min-width: 8.5rem;
  padding-left: 0.85rem;
  padding-right: 0.5rem;
}

.summary-row--sub .col-category {
  padding-left: 0.85rem;
}

.row-category {
  display: block;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

.row-occurrence {
  display: inline;
  margin-left: 0.2rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.row-amount {
  display: block;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.row-amount--hint {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.row-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.row-budget-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: var(--blue-dark); }
.btn--ghost { background: var(--bg); color: var(--text); }
.btn--ghost:hover { background: var(--border); }
.btn--danger { background: #ffebea; color: var(--red); }
.btn--danger:hover { background: #ffd6d4; }
.btn--small { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn--icon {
  padding: 0.35rem 0.5rem;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
}
.btn--icon:hover { background: var(--bg); color: var(--red); }
.btn--file { cursor: pointer; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  display: none;
}

.empty-state.visible { display: block; }

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

.settings-help {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.settings-help summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
}

.settings-help ol {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
}

.settings-help li + li {
  margin-top: 0.45rem;
}

.settings-help code {
  font-size: 0.8rem;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

body.app-locked .app,
body.app-locked .toast {
  visibility: hidden;
}

body.app-locked {
  overflow: hidden;
  background: var(--bg);
}

.field-error {
  min-height: 1.25rem;
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--red);
}

.icloud-status,
.server-sync-status {
  font-size: 0.85rem;
}

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(480px, calc(100vw - 2rem));
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.modal::backdrop { background: rgba(0,0,0,0.45); }

.modal__content { padding: 1.25rem; }

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

.modal__header h2 { margin: 0; font-size: 1.1rem; }

.modal__close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.confirm-message {
  margin: 0;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-line;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0.5rem);
  background: #1c1c1e;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
  .header { flex-wrap: wrap; }

  .nav-toggle { display: flex; }

  .nav {
    display: none;
    width: 100%;
    order: 3;
    flex-direction: column;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }

  .nav.open { display: flex; }

  .nav__btn { width: 100%; text-align: left; border-radius: 8px; }

  .main { padding: 1rem; }

  .form-grid { grid-template-columns: 1fr; }

  .header__title { font-size: 0.95rem; }

  #prevMonth,
  #nextMonth,
  .toolbar__nav {
    display: none;
  }

  .toolbar--month {
    flex-direction: row;
    align-items: center;
  }

  .toolbar--month .btn {
    width: auto;
  }

  .card__header--summary {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title actions"
      "filter filter";
    align-items: center;
    gap: 0.65rem;
  }

  .card__header--summary .card__title {
    grid-area: title;
    margin: 0;
    font-size: 1rem;
  }

  .card__header--summary .card__actions {
    grid-area: actions;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .card__header--summary .status-filter-wrap {
    grid-area: filter;
  }

  .card__header--summary .status-legend {
    display: none;
  }

  .status-filter-select-wrap {
    display: block;
  }

  #categoriesTable .col-recurrence {
    display: none;
  }
}

@media (max-width: 480px) {
  .toolbar:not(.toolbar--month) { flex-direction: column; align-items: stretch; }
  .toolbar:not(.toolbar--month) .btn { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
