:root {
  --color-accent: #4f46e5;
  --color-accent-hover: #4338ca;
  --block-padding: 0.75rem;
  --block-gap: 0.625rem;
  --block-header-gap: 0.5rem;
  --block-row-bg: #f8fafc;
  --block-row-border: #dbeafe;
  --block-cell-bg: #ffffff;
  --block-cell-border: #e7e5e4;
  --block-notes-bg: #f5f3ff;
  --block-notes-border: #ddd6fe;

  /* Tag color picker — 6×6 grid */
  --tag-color-01: #f5f5f5;
  --tag-color-02: #ffffb3;
  --tag-color-03: #ffff80;
  --tag-color-04: #ffff4d;
  --tag-color-05: #ffff1a;
  --tag-color-06: #e6e601;
  --tag-color-07: #e0e0e0;
  --tag-color-08: #ffe6b3;
  --tag-color-09: #ffd580;
  --tag-color-10: #ffc44d;
  --tag-color-11: #ffb31a;
  --tag-color-12: #e69901;
  --tag-color-13: #cccccc;
  --tag-color-14: #ffb3b3;
  --tag-color-15: #ff8080;
  --tag-color-16: #fe4d4d;
  --tag-color-17: #fe1a1a;
  --tag-color-18: #e50000;
  --tag-color-19: #b8b8b8;
  --tag-color-20: #d5b5e6;
  --tag-color-21: #b984d5;
  --tag-color-22: #9c53c4;
  --tag-color-23: #8022b3;
  --tag-color-24: #67089a;
  --tag-color-25: #a3a3a3;
  --tag-color-26: #b8c6e6;
  --tag-color-27: #89a0d5;
  --tag-color-28: #597ac4;
  --tag-color-29: #2a54b3;
  --tag-color-30: #264ca1;
  --tag-color-31: #8a8a8a;
  --tag-color-32: #b3f0b3;
  --tag-color-33: #80e680;
  --tag-color-34: #4ddb4d;
  --tag-color-35: #1ad11a;
  --tag-color-36: #01b800;

  --tag-outline-width: 2.5px;

  /* Handwriting fonts — change these names to try others (all free on Google Fonts).
     Loaded in index.html: Patrick Hand, Caveat, Kalam, Architects Daughter, DM Sans */
  --font-body: "Architects Daughter", "DM Sans", system-ui, sans-serif;
  --font-heading: "Architects Daughter", "Patrick Hand", cursive;
  --font-data: "DM Sans", system-ui, sans-serif;
}

body {
  background-color: #fafaf9;
  font-family: var(--font-body);
}

.page-heading {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 600;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
}

header .site-title {
  font-family: var(--font-heading);
  font-weight: 600;
}

.tabular-nums,
.budget-overview-table,
.budget-table,
.budget-input,
input[type="number"],
input[type="date"],
select {
  font-family: var(--font-data);
}

.content-block {
  padding: var(--block-padding);
  border-color: #e7e5e4;
}

.content-block.block-type-subscription {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #eef2ff 0%, #ffffff 3rem);
  --layout-row-border: #93c5fd;
  --layout-row-bg: #eff6ff;
}

.content-block.block-type-subscription .content-block-header h2 {
  color: #4338ca;
}

.content-block.block-type-institution {
  border-color: #bbf7d0;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 3rem);
  --layout-row-border: #86efac;
  --layout-row-bg: #ecfdf5;
}

.content-block.block-type-institution .content-block-header h2 {
  color: #15803d;
}

.content-block.block-type-contact {
  border-color: #fed7aa;
  background: linear-gradient(180deg, #fff7ed 0%, #ffffff 3rem);
  --layout-row-border: #fdba74;
  --layout-row-bg: #ffedd5;
}

.content-block.block-type-contact .content-block-header h2 {
  color: #c2410c;
}

.content-block.block-type-subscription .block-form-layout .block-field-row,
.content-block.block-type-institution .block-form-layout .block-field-row,
.content-block.block-type-contact .block-form-layout .block-field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.625rem;
  border: 1px solid var(--layout-row-border);
  border-radius: 0.625rem;
  background: var(--layout-row-bg);
}

@media (min-width: 640px) {
  .content-block.block-type-subscription .block-form-layout .block-field-row,
  .content-block.block-type-institution .block-form-layout .block-field-row,
  .content-block.block-type-contact .block-form-layout .block-field-row {
    grid-template-columns: 1fr 1fr;
  }
}

.content-block.block-type-subscription .block-form-layout .block-field-cell,
.content-block.block-type-institution .block-form-layout .block-field-cell,
.content-block.block-type-contact .block-form-layout .block-field-cell {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--block-cell-border);
  border-radius: 0.5rem;
  background: var(--block-cell-bg);
}

@media (min-width: 640px) {
  .content-block.block-type-subscription .block-form-layout .block-field-cell-span,
  .content-block.block-type-institution .block-form-layout .block-field-cell-span,
  .content-block.block-type-contact .block-form-layout .block-field-cell-span {
    grid-column: 1 / -1;
  }
}

.content-block.block-type-subscription .block-form-layout .block-field-section,
.content-block.block-type-institution .block-form-layout .block-field-section,
.content-block.block-type-contact .block-form-layout .block-field-section {
  border-color: var(--layout-row-border);
  background: var(--layout-row-bg);
}

.content-block.block-type-subscription .block-layout-view .block-view-value,
.content-block.block-type-institution .block-layout-view .block-view-value,
.content-block.block-type-contact .block-layout-view .block-view-value {
  width: 100%;
  box-sizing: border-box;
  min-height: 2.125rem;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  border: 1px solid #e7e5e4;
  background: #fff;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.content-block.block-type-subscription .block-layout-view .block-field-section-notes .block-view-value,
.content-block.block-type-institution .block-layout-view .block-field-section-notes .block-view-value,
.content-block.block-type-contact .block-layout-view .block-field-section-notes .block-view-value {
  align-items: flex-start;
  min-height: 3.5rem;
}

.content-block.block-type-subscription .block-form-layout .block-field-cell .block-field,
.content-block.block-type-institution .block-form-layout .block-field-cell .block-field,
.content-block.block-type-contact .block-form-layout .block-field-cell .block-field {
  gap: 0.375rem;
}

.content-block.block-type-link {
  border-color: #bae6fd;
  background: linear-gradient(180deg, #f0f9ff 0%, #ffffff 3rem);
}

.content-block.block-type-link .content-block-header h2 {
  color: #0369a1;
}

.content-block.block-type-notes {
  border-color: #ddd6fe;
  background: linear-gradient(180deg, #f5f3ff 0%, #ffffff 3rem);
}

.content-block.block-type-notes .content-block-header h2 {
  color: #6d28d9;
}

.content-blocks {
  display: flex;
  flex-direction: column;
  gap: var(--block-gap);
}

.content-block-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: var(--block-header-gap);
  padding-bottom: 0.375rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.block-form-layout {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.block-field-row {
  display: grid;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--block-row-border);
  border-radius: 0.625rem;
  background: var(--block-row-bg);
}

@media (min-width: 640px) {
  .block-field-row {
    grid-template-columns: 1fr 1fr;
  }
}

.block-field-cell {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--block-cell-border);
  border-radius: 0.5rem;
  background: var(--block-cell-bg);
}

.block-field-cell .block-field {
  gap: 0.375rem;
}

.block-field-section {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--block-row-border);
  border-radius: 0.625rem;
  background: var(--block-row-bg);
}

.block-field-section-notes {
  background: var(--block-notes-bg);
  border-color: var(--block-notes-border);
}

.block-field-section-notes .block-field label,
.block-field-section-notes .block-view-label {
  color: #6d28d9;
}

.block-field {
  display: grid;
  gap: 0.25rem;
}

.block-field label,
.block-view-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #78716c;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.block-field input,
.block-field select,
.block-field textarea {
  width: 100%;
  border-radius: 0.375rem;
  border: 1px solid #e7e5e4;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  background: #fff;
}

.block-field input:focus,
.block-field select:focus,
.block-field textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.block-value-box {
  min-height: 1.75rem;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  background: #fff;
  border: 1px solid #e7e5e4;
}

.block-fields-grid {
  display: grid;
  gap: 0.75rem;
}

.block-fields-grid + .block-field,
.block-fields-grid + .mt-3 {
  margin-top: 0.75rem;
}

@media (min-width: 640px) {
  .block-fields-grid.two-col {
    grid-template-columns: 1fr 1fr;
  }
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.2;
}

.tag-chip.tag-chip-outline {
  color: #1c1917;
  border-style: solid;
  border-width: var(--tag-outline-width);
}

#toggle-tags-section:hover span {
  color: var(--color-accent);
}

.tag-remove {
  font-size: 0.875rem;
  line-height: 1;
  padding: 0;
  margin-left: 0.125rem;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.color-preview-square {
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 0.2rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.color-picker-popup {
  position: absolute;
  inset: 0;
  z-index: 50;
}

.color-picker-popup.hidden {
  display: none;
}

.color-picker-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
}

.color-picker-panel {
  position: absolute;
  z-index: 51;
  width: 13.5rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid #e7e5e4;
  background: white;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.color-picker-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #78716c;
  margin-bottom: 0.5rem;
}

.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.375rem;
}

.color-grid-swatch {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.2rem;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.color-grid-swatch.selected {
  border-color: #1c1917;
  box-shadow: 0 0 0 1px white, 0 0 0 3px #1c1917;
}

.color-grid-swatch:hover {
  transform: scale(1.1);
}

.tag-style-btn.selected,
.tag-mode-btn.selected {
  background-color: #1c1917;
  color: white;
}

.template-card {
  border: 2px solid #e7e5e4;
  border-radius: 0.75rem;
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.template-card:hover {
  border-color: #c7d2fe;
  background: #eef2ff;
}

.template-card.selected {
  border-color: var(--color-accent);
  background: #eef2ff;
}

textarea.note-autosize,
.block-field textarea.note-autosize {
  min-height: 3.5rem;
  overflow-y: hidden;
  resize: none;
}

.block-display-value {
  font-size: 0.875rem;
  color: #1c1917;
}

.block-display-value.empty {
  color: #a8a29e;
  font-style: italic;
}

.block-display-value a {
  color: var(--color-accent);
}

.block-display-value a:hover {
  text-decoration: underline;
}

.block-field-hint {
  margin: 0;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: #a8a29e;
}

.renewal-display {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.renewal-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: #e7e5e4;
  color: #57534e;
}

.renewal-badge-soon {
  background: #fef3c7;
  color: #92400e;
}

.renewals-panel-empty {
  border-style: dashed;
}

.renewals-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.renewals-list-item + .renewals-list-item {
  margin-top: 0;
}

.renewals-list-divider.rough-line-host,
.renewals-notify-divider.rough-line-host,
.budget-savings-divider.rough-line-host {
  height: 0.875rem;
  margin: 0.125rem 0 0.375rem;
}

.renewals-notify-divider.rough-line-host {
  margin-top: 0;
}

.budget-savings-withdrawal-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.renewals-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.625rem;
  border: 1px solid #fde68a;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.renewals-item:hover {
  border-color: #f59e0b;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.15);
}

.renewals-item-urgent {
  border-color: #fb923c;
  background: #fff7ed;
}

.renewals-item-main {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.renewals-item-name {
  font-weight: 600;
  color: #1c1917;
}

.renewals-item-cost {
  font-size: 0.8125rem;
  color: #78716c;
}

.renewals-item-when {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex-shrink: 0;
}

.renewals-item-date {
  font-size: 0.75rem;
  color: #78716c;
}

.renewals-notify-bar {
  color: #57534e;
}

.renewals-notify-banner {
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
  line-height: 1.45;
}

.renewals-notify-banner-ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.renewals-notify-banner-warn {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.renewals-notify-banner-blocked {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.renewals-notify-status-ok {
  color: #15803d;
}

.renewals-notify-status-blocked {
  color: #b91c1c;
}

.renewals-notify-btn {
  color: #4338ca;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.renewals-notify-btn:hover {
  color: #3730a3;
}

.renewals-notify-btn-primary {
  border-radius: 0.5rem;
  background: #4f46e5;
  color: #fff;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.renewals-notify-btn-primary:hover {
  background: #4338ca;
  color: #fff;
}

@media (max-width: 639px) {
  .renewals-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .renewals-item-when {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
}

.backup-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.backup-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.625rem;
  background: #fafaf9;
  border: 1px solid #e7e5e4;
}

.backup-list-info {
  flex: 1;
  min-width: 0;
}

.backup-restore-btn {
  flex-shrink: 0;
  border-radius: 0.5rem;
  border: 1px solid #c7d2fe;
  background: #fff;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #4338ca;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.backup-restore-btn:hover {
  background: #eef2ff;
  border-color: #818cf8;
}

.tag-manager-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tag-manager-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.625rem;
  background: #fafaf9;
  border: 1px solid #e7e5e4;
}

.tag-manager-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.tag-manager-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.tag-manager-btn {
  border-radius: 0.5rem;
  border: 1px solid #e7e5e4;
  background: #fff;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #57534e;
  cursor: pointer;
}

.tag-manager-btn:hover {
  background: #f5f5f4;
}

.tag-manager-btn-primary {
  border-color: #c7d2fe;
  color: #4338ca;
}

.tag-manager-btn-primary:hover {
  background: #eef2ff;
}

.tag-manager-btn-danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.tag-manager-btn-danger:hover {
  background: #fef2f2;
}

.tag-manager-input {
  min-width: 0;
}

@media (max-width: 639px) {
  .tag-manager-item {
    flex-direction: column;
    align-items: stretch;
  }

  .tag-manager-actions {
    justify-content: flex-end;
  }
}

/* Budget */
.budget-panel {
  background: white;
}

.budget-month-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid #e7e5e4;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.budget-month-card:hover {
  border-color: #a5b4fc;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.08);
}

.budget-total-card {
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid #e7e5e4;
  background: white;
}

.budget-total-in {
  border-color: #bbf7d0;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 70%);
}

.budget-total-out {
  border-color: #fed7aa;
  background: linear-gradient(180deg, #fff7ed 0%, #ffffff 70%);
}

.budget-total-net {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #eef2ff 0%, #ffffff 70%);
}

.budget-total-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #78716c;
}

.budget-total-value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.budget-table th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #78716c;
  padding: 0 0.5rem 0.5rem 0;
}

.budget-table td {
  padding: 0.5rem 0.5rem 0.5rem 0;
  vertical-align: middle;
}

.budget-input {
  width: 6.5rem;
  max-width: 100%;
  border-radius: 0.375rem;
  border: 1px solid #e7e5e4;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.budget-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.budget-cat-toggle-static {
  cursor: default;
  color: #1c1917;
}

.budget-cat-toggle-static:hover {
  color: #1c1917;
}

.budget-budget-cell {
  position: relative;
  z-index: 1;
}

.budget-chevron {
  display: inline-block;
  width: 1rem;
  color: #6366f1;
}

.budget-chevron.muted {
  color: #d6d3d1;
}

.budget-recipient-breakdown {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: #fafaf9;
  border: 1px solid #f5f5f4;
}

.budget-diff-under {
  color: #15803d;
}

.budget-diff-over {
  color: #dc2626;
}

.budget-diff-even {
  color: #78716c;
}

.budget-entry-type {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
}

.budget-entry-type-expense {
  background: #ffedd5;
  color: #c2410c;
}

.budget-entry-type-income {
  background: #dcfce7;
  color: #15803d;
}

.budget-entry-type-refund {
  background: #e0e7ff;
  color: #4338ca;
}

.budget-entry-type-transfer_to_savings {
  background: #cffafe;
  color: #0e7490;
}

.budget-entry-type-transfer_from_savings {
  background: #fce7f3;
  color: #be185d;
}

.budget-entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.budget-entry-divider {
  display: block;
}

.budget-entry-divider.rough-line-host {
  height: 0.875rem;
  margin: 0.125rem 0 0.375rem;
}

.budget-savings-panel .budget-total-card {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(6, 182, 212, 0.15);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
}

.budget-savings-form {
  border-color: rgba(6, 182, 212, 0.25) !important;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.budget-overview-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.budget-overview-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

.budget-overview-table th,
.budget-overview-table td {
  padding: 0.5rem 0.625rem;
  border-bottom: none;
  white-space: nowrap;
}

.budget-overview-divider-row td {
  padding: 0;
  border: none;
  background: transparent;
}

.budget-overview-divider-cell {
  padding: 0 0.625rem;
}

.budget-overview-divider.rough-line-host {
  height: 0.875rem;
  margin: 0.125rem 0;
}

.budget-overview-table th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #78716c;
}

.budget-overview-sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: white;
  min-width: 7rem;
  box-shadow: 1px 0 0 #f5f5f4;
}

.budget-overview-month-col {
  min-width: 4.5rem;
}

.budget-overview-year-col {
  background: #fafaf9;
  min-width: 5.5rem;
}

.budget-overview-year-row td {
  border-top: none;
  border-bottom: none;
  background: #fafaf9;
}

.budget-rough-total-cell {
  padding: 0.75rem 0 0;
  border: none;
  background: transparent;
}

.budget-rough-total-band {
  position: relative;
  background: #fafaf9;
}

.budget-rough-total-band > * {
  position: relative;
  z-index: 1;
}

.budget-expense-summary-cols {
  display: grid;
  grid-template-columns: var(--expense-summary-cols);
  column-gap: var(--expense-summary-gap);
  padding-left: 0.625rem;
  padding-right: 0.5rem;
}

.budget-table-expense-summary {
  --expense-summary-cols: minmax(0, 1.4fr) 6.5rem minmax(4.5rem, 1fr) minmax(4.5rem, 1fr) minmax(6rem, 1.2fr);
  --expense-summary-gap: 0.5rem;
  display: grid;
  grid-template-columns: var(--expense-summary-cols);
  column-gap: var(--expense-summary-gap);
  width: 100%;
}

.budget-table-expense-summary thead,
.budget-table-expense-summary tbody,
.budget-table-expense-summary tr {
  display: contents;
}

.budget-table-expense-summary td {
  padding: 0.5rem 0;
  vertical-align: middle;
}

.budget-table-expense-summary th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #78716c;
  padding: 0 0 0.5rem;
  white-space: nowrap;
}

.budget-expense-summary-span {
  grid-column: 1 / -1;
}

.budget-expense-summary-divider-cell {
  padding: 0;
}

.budget-expense-summary-divider.rough-line-host {
  height: 0.75rem;
  margin: 0.125rem 0;
}

.budget-expense-summary-footer-totals td {
  padding-top: 0.25rem;
}

.budget-overview-table-wrap {
  position: relative;
  width: max-content;
  min-width: 100%;
  overflow: visible;
}

.budget-rough-total-row--overview td {
  padding-top: 1.25rem;
  background: transparent;
  border: none;
  position: relative;
  z-index: 2;
}

.budget-rough-total-row--overview .budget-overview-sticky-col {
  background: transparent;
  box-shadow: none;
}

.budget-rough-total-row--overview .budget-overview-sticky-col.is-scrolled {
  background: #fafaf9;
  box-shadow: 1px 0 0 #f5f5f4;
}

.budget-rough-total-band-overview--overlay {
  position: absolute;
  pointer-events: none;
  z-index: 1;
  background: #fafaf9;
  box-sizing: border-box;
  overflow: visible;
}

.budget-row-status {
  margin-right: 0.375rem;
}

/* legacy — year/expense totals now use .budget-rough-total-band */
.budget-summary-total-row td {
  border-top: none;
  padding-top: 0.625rem;
  background: transparent;
}

/* Rough.js sketch borders (budget pages) */
.rough-border-host {
  position: relative;
  border: none !important;
  box-shadow: none !important;
  overflow: visible;
}

.budget-sketch-root input.rough-border-host:not([type="checkbox"]),
.budget-sketch-root select.rough-border-host,
.budget-sketch-root textarea.rough-border-host,
.budget-sketch-root button.rough-border-host,
.budget-sketch-root a.rough-border-host {
  border-color: transparent !important;
  box-shadow: none !important;
}

.budget-sketch-root input.rough-border-host:not([type="checkbox"]):focus,
.budget-sketch-root select.rough-border-host:focus,
.budget-sketch-root textarea.rough-border-host:focus,
.budget-sketch-root button.rough-border-host:focus {
  outline: 2px solid rgba(99, 102, 241, 0.3);
  outline-offset: 1px;
}

.budget-sketch-root button.rough-filled-btn {
  position: relative;
  z-index: 0;
  background: transparent !important;
  color: #ffffff !important;
}

.budget-sketch-root button.rough-filled-btn .rough-border-svg {
  z-index: -1;
}

.budget-sketch-root button.rough-filled-btn:hover {
  filter: brightness(0.92);
}

.budget-sketch-root .tag-chip.rough-border-host {
  position: relative;
  border-color: transparent !important;
}

.budget-sketch-root .tag-chip:not(.tag-chip-outline).rough-border-host {
  isolation: isolate;
  background: transparent !important;
}

.budget-sketch-root .tag-chip:not(.tag-chip-outline).rough-border-host .rough-border-svg {
  z-index: -1;
}

.budget-sketch-root .tag-chip.rough-border-host .tag-chip-label,
.budget-sketch-root .tag-chip.rough-border-host .tag-remove {
  position: relative;
  z-index: 1;
}

.budget-sketch-root button.rough-text-btn {
  padding: 0.2rem 0.45rem;
  margin: -0.2rem -0.1rem;
  line-height: 1.35;
}

.budget-month-card.rough-border-host:hover,
.template-card.rough-border-host:hover,
.renewals-item.rough-border-host:hover {
  border: none !important;
  box-shadow: none !important;
}

.rough-border-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}

.rough-border-host > :not(.rough-border-svg) {
  position: relative;
  z-index: 1;
}

.rough-line-host {
  position: relative;
  display: block;
  height: 0.625rem;
  margin-top: 0.375rem;
  overflow: visible;
}

.rough-line-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.budget-sketch-demo {
  border: 1px dashed #c7d2fe;
  border-radius: 0.75rem;
  background: linear-gradient(180deg, #faf5ff 0%, #ffffff 100%);
  padding: 0.875rem 1rem;
  font-size: 0.8125rem;
  color: #57534e;
  line-height: 1.45;
}

.budget-sketch-demo strong {
  color: #4338ca;
  font-weight: 600;
}

.calendar-entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.calendar-item + .calendar-item,
.calendar-month-header + .calendar-item,
.calendar-item + .calendar-month-header {
  margin-top: 0.75rem;
}

.calendar-month-header {
  list-style: none;
  padding: 0.5rem 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #78716c;
}

.calendar-month-header:first-child {
  padding-top: 0;
}

.calendar-recurrence-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0e7490;
  background: rgba(165, 229, 250, 0.55);
  padding: 0.1rem 0.45rem;
  border-radius: 0.25rem;
  flex-shrink: 0;
}

.calendar-item-card {
  border-radius: 0.5rem;
}

.calendar-item-head {
  position: relative;
}

.calendar-toggle {
  gap: 0.5rem;
  padding: 0.75rem 1rem;
}

.calendar-toggle .budget-chevron {
  flex-shrink: 0;
}

.calendar-item-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.calendar-item-body {
  padding: 0 1rem 1rem;
}

.calendar-item.expanded .calendar-item-body {
  padding-top: 0.75rem;
}

.calendar-datetime-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .calendar-datetime-grid {
    grid-template-columns: repeat(2, max-content);
  }
}

@media (min-width: 1024px) {
  .calendar-datetime-grid {
    grid-template-columns: repeat(4, max-content);
  }
}

.calendar-datetime-input {
  width: 10.5rem;
  max-width: 100%;
}

.calendar-time-input {
  width: 8.25rem;
}

.calendar-item-soon::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 0.25rem;
  background: #a5e5fa;
  z-index: 0;
  pointer-events: none;
}

.calendar-item-urgent .calendar-toggle .font-medium {
  color: #4338ca;
}

/* To-do */
.todo-subject-list,
.todo-list-links,
.todo-task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.todo-subject-list > li + li,
.todo-list-links > li + li,
.todo-task-list > li + li {
  margin-top: 0.75rem;
}

.todo-subject-card,
.todo-list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 0.5rem;
  text-decoration: none;
  color: inherit;
}

.todo-subject-card:hover,
.todo-list-card:hover {
  color: inherit;
}

.todo-task-card {
  border-radius: 0.5rem;
  padding: 0.75rem;
}

.todo-task-layout {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.todo-task-move {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-top: 0.35rem;
}

.todo-move-btn {
  font-size: 0.65rem;
  line-height: 1;
  color: #78716c;
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
}

.todo-move-btn:hover {
  color: #4338ca;
  background: rgba(99, 102, 241, 0.08);
}

.todo-task-fields {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.todo-task-top-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.todo-task-title {
  flex: 1 1 8rem;
  min-width: 0;
}

.todo-task-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.todo-task-status {
  width: auto;
  min-width: 7.5rem;
}

.todo-task-comments {
  min-height: 2.75rem;
  line-height: 1.4;
  box-sizing: border-box;
}

.todo-status-started .todo-task-status {
  border-color: rgba(79, 70, 229, 0.35);
}

.todo-status-blocked .todo-task-status {
  border-color: rgba(220, 38, 38, 0.35);
}

.todo-status-postponed .todo-task-status {
  border-color: rgba(217, 119, 6, 0.35);
}

.todo-status-finished .todo-task-title,
.todo-status-finished .todo-task-comments {
  color: #78716c;
}

.crossword-layout {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 960px) {
  .crossword-layout {
    grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
    align-items: start;
  }
}

.crossword-lang-toggle {
  display: inline-flex;
  border: 1px solid #e7e5e4;
  border-radius: 0.5rem;
  overflow: hidden;
}

.crossword-lang-btn {
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  color: #78716c;
  background: #fff;
}

.crossword-lang-btn.is-active {
  color: #312e81;
  background: #eef2ff;
}

.crossword-grid {
  display: grid;
  gap: 2px;
  width: min(100%, 22rem);
  margin: 0 auto;
}

.crossword-row {
  display: grid;
  grid-template-columns: repeat(var(--crossword-size), 1fr);
  gap: 2px;
}

.crossword-cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid #d6d3d1;
  background: #fff;
}

.crossword-cell-block {
  background: #1c1917;
  border-color: #1c1917;
}

.crossword-cell-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.crossword-cell-letter.is-word {
  background: #fafaf9;
}

.crossword-cell-letter.is-selected {
  background: #eef2ff;
  border-color: #6366f1;
  box-shadow: inset 0 0 0 1px #6366f1;
}

.crossword-cell-letter.is-wrong {
  background: #fef2f2;
  border-color: #f87171;
}

.crossword-cell-letter.is-revealed {
  color: #4f46e5;
}

.crossword-cell-number {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 0.55rem;
  line-height: 1;
  color: #78716c;
  pointer-events: none;
}

.crossword-cell-letter-text {
  font-size: clamp(0.85rem, 2.8vw, 1.1rem);
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1;
}

.crossword-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.crossword-board-panel {
  position: relative;
}

.crossword-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: center;
}

.crossword-tool-btn {
  border: 1px solid #e7e5e4;
  border-radius: 0.5rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  color: #44403c;
  background: #fff;
}

.crossword-tool-btn:hover {
  border-color: #c7d2fe;
  color: #312e81;
}

.crossword-clue-heading {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #78716c;
  margin-bottom: 0.5rem;
}

.crossword-clue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.crossword-clue-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  padding: 0.45rem 0.55rem;
  display: flex;
  gap: 0.45rem;
  color: #44403c;
  background: transparent;
}

.crossword-clue-btn:hover,
.crossword-clue-btn.is-active {
  border-color: #c7d2fe;
  background: #eef2ff;
}

.crossword-clue-number {
  flex-shrink: 0;
  font-weight: 600;
  color: #57534e;
}

.crossword-clue-item {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
}

.crossword-clue-edit {
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: 0.4rem;
  padding: 0.35rem 0.45rem;
  font-size: 0.85rem;
  color: #78716c;
  background: transparent;
}

.crossword-clue-edit:hover {
  border-color: #e7e5e4;
  color: #4f46e5;
}

.crossword-clue-source {
  flex-shrink: 0;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #a8a29e;
  align-self: center;
}

.crossword-clue-edit-row {
  border: 1px solid #c7d2fe;
  border-radius: 0.5rem;
  padding: 0.55rem;
  background: #eef2ff;
  display: grid;
  gap: 0.45rem;
}

.crossword-clue-edit-meta {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
}

.crossword-clue-word {
  font-size: 0.8rem;
  color: #57534e;
}

.crossword-clue-edit-input {
  width: 100%;
  border: 1px solid #e7e5e4;
  border-radius: 0.5rem;
  padding: 0.45rem 0.55rem;
  font-size: 0.9rem;
}

.crossword-clue-edit-actions {
  display: flex;
  gap: 0.5rem;
}

.crossword-clue-text {
  min-width: 0;
  flex: 1;
}

.auth-screen {
  display: flex;
  justify-content: center;
  padding-top: 2rem;
}

.auth-card {
  width: min(100%, 24rem);
}
