* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

body {
  max-width: 1100px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1b1b1b;
  font-size: 14px;
}

.ai-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-summary-header h2 {
  margin: 0;
}

.ai-summary-btn {
  background: #6b2c81;
  color: #fff;
  border: none;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
}

.ai-summary-btn:hover {
  background: #582269;
}

.ai-summary-btn:disabled {
  background: #b9a4c2;
  cursor: default;
}

.ai-instructions-toggle {
  display: block;
  margin-top: 8px;
  padding: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #aaa;
  background: none;
  border: none;
  cursor: pointer;
  user-select: none;
}

.ai-instructions-toggle:hover {
  color: #888;
}

.ai-instructions-toggle:focus-visible {
  outline: 2px solid #2d9cdb;
  outline-offset: 1px;
}

.ai-instructions-input {
  width: 100%;
  margin-top: 8px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.4;
  color: #555;
  background: #fafafa;
  border: 1px solid #e2e2e2;
  border-radius: 5px;
  resize: vertical;
}

.ai-instructions-input:focus {
  color: #1b1b1b;
  background: #fff;
  outline: none;
  border-color: #b9a4c2;
}

.ai-instructions-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.ai-instructions-actions .ai-instructions-template {
  margin-top: 0;
}

.ai-instructions-template {
  display: block;
  margin-top: 4px;
  padding: 3px 4px;
  font-size: 11px;
  color: #6b2c81;
  background: none;
  border: 1px solid #e2e2e2;
  border-radius: 4px;
  cursor: pointer;
}

.ai-template-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.ai-template-name-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 6px;
  font-size: 11px;
  font-family: inherit;
  border: 1px solid #e2e2e2;
  border-radius: 4px;
}

.ai-template-name-row button {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.ai-summary-output {
  margin-top: 10px;
  padding: 10px 12px;
  background: #f7f2f9;
  border: 1px solid #e6d9ec;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.account-visibility-details {
  padding-top: 8px;
}

.account-visibility-details summary {
  font-size: 11px;
  font-weight: 600;
  color: #6b2c81;
  cursor: pointer;
  user-select: none;
}

.account-columns {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
  margin-top: 10px;
}

.account-column {
  flex: 1 1 200px;
  min-width: 0;
}

.account-column h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  margin: 0 0 6px;
}

.option-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #aaa;
  padding: 8px 0 2px;
}

.option-group-heading:first-of-type {
  padding-top: 0;
}

.option-group-actions {
  display: flex;
  gap: 4px;
  text-transform: none;
  letter-spacing: normal;
}

.option-group-actions button {
  background: none;
  border: none;
  padding: 0;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b2c81;
  cursor: pointer;
}

.option-group-actions button:hover {
  text-decoration: underline;
}

.option-group-actions-separator {
  color: #ccc;
}

.option-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 400;
  padding: 3px 0;
  cursor: pointer;
}

.account-columns .muted {
  font-size: 12px;
  color: #888;
}

.status-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 10px;
  padding: 8px 16px;
  font-size: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.status-banner-message {
  font-weight: 700;
}

.status-banner-ok {
  background: #e6f4ea;
  color: #1e7b34;
}

.status-banner-ok .status-banner-meta {
  color: rgba(30, 123, 52, 0.75);
}

.status-banner-warning {
  background: #fdf0dc;
  color: #8a5a00;
}

.status-banner-warning .status-banner-meta {
  color: rgba(138, 90, 0, 0.75);
}

.status-banner-danger {
  background: #fbe0df;
  color: #a12a22;
}

.status-banner-danger .status-banner-meta {
  color: rgba(161, 42, 34, 0.75);
}

.status-banner-chip {
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.status-banner-chip-next {
  background: #c9ecd4;
  color: #1e7b34;
}

.status-banner-chip-second {
  background: #fbe3b8;
  color: #8a5a00;
}

.columns {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
}

.columns > .column {
  flex: 1 1 340px;
  min-width: 0;
}

.columns > .column + .column {
  border-left: 1px solid #eee;
}

.column > section + section {
  border-top: 1px solid #eee;
}

@media (max-width: 1020px) {
  .columns > .column {
    flex: 1 1 100%;
    border-left: none !important;
    border-top: 1px solid #eee;
  }

  .columns > .column:first-child {
    border-top: none;
  }
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #6b2c81;
  color: #fff;
}

header h1 {
  font-size: 16px;
  margin: 0;
  line-height: 0;
}

.header-icon {
  display: block;
  height: 26px;
  width: 26px;
  border-radius: 6px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px 10px;
}

.profile-switcher {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 600;
  max-width: 140px;
}

.profile-switcher option {
  color: #1b1b1b;
}

#refresh-btn,
#collapse-all-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

#collapse-all-btn:hover {
  color: rgba(255, 255, 255, 0.8);
}

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

#refresh-btn.refreshing {
  animation: refresh-spin 0.8s linear infinite;
}

#refresh-btn:disabled {
  cursor: default;
}

#add-cash-btn,
#currency-toggle-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
}

#add-cash-btn:hover,
#currency-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

#add-cash-btn:disabled {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.5);
  cursor: not-allowed;
}

.auto-refresh {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
}

.auto-refresh label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  user-select: none;
}

.auto-refresh input[type="checkbox"] {
  cursor: pointer;
}

.auto-refresh input[type="number"] {
  width: 46px;
  padding: 3px 5px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.auto-refresh input[type="number"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auto-refresh-countdown {
  min-width: 2.5em;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.weather-widget {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

/* Narrow phones: the full header-actions row (currency toggle, add
   transaction, auto-refresh controls, refresh button) doesn't fit even with
   the icon-only title - the auto-refresh number input, "min" label, and
   countdown were the biggest offenders, so those shrink the most. */
@media (max-width: 600px) {
  .header-actions {
    gap: 6px;
  }

  #add-cash-btn,
  #currency-toggle-btn {
    padding: 5px 7px;
    font-size: 11px;
  }

  .auto-refresh {
    gap: 3px;
    font-size: 11px;
  }

  .auto-refresh input[type="number"] {
    width: 26px;
    padding: 2px 3px;
    font-size: 11px;
  }

  .auto-refresh-countdown {
    display: none;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 16px;
}

.modal {
  background: #fff;
  border-radius: 8px;
  padding: 18px 20px;
  width: 320px;
  max-width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.modal h2 {
  font-size: 15px;
  text-transform: none;
  letter-spacing: normal;
  color: #1b1b1b;
  margin: 0 0 10px;
}

#add-cash-form {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#add-cash-form label {
  font-size: 11px;
  font-weight: 600;
  color: #666;
  margin-top: 6px;
}

#add-cash-form input,
#add-cash-form select {
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 5px;
  width: 100%;
}

.amount-row {
  display: flex;
  gap: 6px;
}

.amount-row select {
  flex: 0 0 100px;
}

.amount-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.cash-error {
  color: #c0392b;
  font-size: 12px;
  margin-top: 6px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.modal-actions button {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}

#cash-save-btn {
  background: #6b2c81;
  color: #fff;
  border: none;
}

#cash-save-btn:hover {
  background: #582269;
}

#cash-save-btn:disabled {
  background: #b9a4c2;
  cursor: default;
}

.secondary-btn {
  background: none;
  border: 1px solid #ccc;
  color: #555;
}

.secondary-btn:hover {
  border-color: #999;
}

.undo-toast {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1b1b1b;
  color: #fff;
  padding: 8px 10px 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  z-index: 20;
}

.undo-toast.hidden {
  display: none;
}

#undo-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
}

#undo-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

#undo-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.state {
  padding: 32px 16px;
  text-align: center;
  color: #666;
}

.hidden {
  display: none !important;
}

section {
  padding: 12px 16px;
}

h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  margin: 6px 0;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid #f0f0f0;
}

li:last-child {
  border-bottom: none;
}

.item-name {
  color: #333;
  display: inline-flex;
  align-items: center;
}

/* Budget category and account names link through to their transactions.
   Styled to stay a name rather than become link-coloured: a dashboard of
   twenty purple underlined rows reads as navigation, not as a balance sheet.
   The affordance shows on hover/focus instead. */
.budget-category-link,
.account-link {
  color: inherit;
  text-decoration: none;
  text-underline-offset: 2px;
}
.budget-category-link:hover,
.budget-category-link:focus-visible,
.account-link:hover,
.account-link:focus-visible {
  color: #6b2c81;
  text-decoration: underline;
}

#accounts-list li,
#debts-list li {
  padding: 4px 0;
  gap: 8px;
}

#accounts-list .item-name,
#debts-list .item-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#accounts-list .item-amount,
#debts-list .item-amount {
  flex-shrink: 0;
}

.group-heading {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #aaa;
  padding: 6px 0 1px;
  border-bottom: none;
}

.group-heading:first-child {
  padding-top: 0;
}

.group-heading-toggle {
  cursor: pointer;
  user-select: none;
}

.group-heading-toggle:hover {
  color: #888;
}

.group-heading-toggle:focus-visible {
  outline: 2px solid #2d9cdb;
  outline-offset: 1px;
}

.group-heading-arrow {
  display: inline-block;
  width: 12px;
  margin-left: 4px;
  font-size: 9px;
}

.currency-heading:first-child {
  padding-top: 0;
}

.currency-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ccc;
  padding: 4px 0 2px 8px;
  border-bottom: none;
}

.subtotal-row {
  border-bottom: none;
  border-top: 1px solid #f0f0f0;
  color: #888;
  font-size: 11px;
}

.subtotal-row .item-amount {
  font-weight: 500;
}

.grand-total-row {
  border-top: 2px solid #ddd;
  margin-top: 2px;
  padding-top: 6px;
  font-weight: 700;
}

.grand-total-row-extra {
  border-top: 1px solid #eee;
  margin-top: 0;
  font-weight: 600;
}

.property-value-row {
  border-bottom: none;
  color: #6b2c81;
  font-size: 11px;
  font-style: italic;
  padding: 0 0 6px 8px;
}

.property-value-row .item-amount {
  font-weight: 500;
}

.property-value-source {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #6b2c81;
  background: #f3e8f7;
  border-radius: 4px;
  text-decoration: none;
}

.property-value-source:hover {
  background: #e8d4ef;
  text-decoration: underline;
}

.due-date-row {
  border-bottom: none;
  color: #888;
  font-size: 11px;
  font-style: italic;
  padding: 0 0 6px 8px;
}

.due-date-row .item-amount {
  font-weight: 500;
}

.due-date-row.due-tomorrow {
  color: #f2994a;
}

.due-date-row.due-tomorrow .item-amount {
  font-weight: 700;
}

.due-date-row.due-today {
  color: #eb5757;
}

.due-date-row.due-today .item-amount {
  font-weight: 700;
}

@keyframes due-today-blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.due-date-row.due-today {
  animation: due-today-blink 1.2s ease-in-out infinite;
}

/* Same green as the status banner's "Next:" chip, so the "closest to
   payment" account reads consistently wherever it's shown. */
.account-due-next {
  background-color: #e6f4ea;
  box-shadow: inset 3px 0 0 0 #1e7b34;
  border-radius: 4px;
  padding: 4px 6px !important;
  margin: -4px -6px !important;
}

.due-next-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #1e7b34;
  background: #c9ecd4;
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}

.item-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.amount-negative {
  color: #c0392b;
}

.amount-positive {
  color: #22875a;
}

.budget-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.budget-header h2 {
  margin: 0;
  min-width: 120px;
  text-align: center;
}

.month-nav {
  background: none;
  border: none;
  color: #888;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
}

.month-nav:hover {
  color: #6b2c81;
}

.budget-month-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.budget-month-progress .budget-bar-track {
  flex: 1;
}

.budget-month-progress-label {
  font-size: 10px;
  color: #999;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.budget-mode-note {
  font-size: 10px;
  color: #999;
  text-align: center;
  min-height: 13px;
  margin-bottom: 2px;
}

.budget-total {
  margin-bottom: 10px;
}

.budget-total:empty {
  margin-bottom: 0;
}

.budget-total-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
  gap: 1px;
}

.budget-total .budget-bar-track {
  height: 9px;
}

.budget-row {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.budget-row .budget-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.budget-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
}

.budget-amount-line {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.budget-diff-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.budget-diff {
  font-variant-numeric: tabular-nums;
}

.pace-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #999;
}

.budget-subtotal-row {
  border-top: 1px solid #ddd;
  border-bottom: none;
  margin-top: 2px;
  padding-top: 8px;
}

.budget-subtotal-row .item-name {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #888;
}

.budget-subtotal-row .budget-amount-line {
  font-weight: 700;
}

.budget-net-row {
  border-top: 2px solid #1b1b1b;
  border-bottom: none;
  margin-top: 6px;
  padding-top: 8px;
}

.budget-net-row .item-name {
  font-weight: 700;
}

.budget-net-row .budget-amount-line {
  font-weight: 700;
}

.budget-bar-track {
  height: 6px;
  border-radius: 3px;
  background: #eee;
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  background: #22875a;
}

.budget-bar-fill.over {
  background: #c0392b;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px 16px;
  font-size: 11px;
  color: #999;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

#uncategorized-status {
  font-weight: 600;
}

.uncategorized-status-warning {
  color: #c0392b;
}

.uncategorized-status-ok {
  color: #22875a;
}

#updated-at {
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

footer a {
  color: #6b2c81;
  text-decoration: none;
}

.app-version {
  color: #bbb;
  cursor: default;
}

#error {
  padding: 32px 16px;
}

#error a {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  border: 1px solid #6b2c81;
  color: #6b2c81;
  text-decoration: none;
  border-radius: 6px;
  cursor: pointer;
}

@keyframes value-blink {
  0%, 100% {
    background-color: transparent;
    box-shadow: inset 3px 0 0 0 transparent;
  }
  4%, 24%, 44% {
    background-color: #ffcc33;
    box-shadow: inset 3px 0 0 0 #f2994a;
  }
  14%, 34%, 54% {
    background-color: #fff3b0;
    box-shadow: inset 3px 0 0 0 #f2994a;
  }
}

.value-changed {
  animation: value-blink 10s ease-out;
}

.item-amount-changed {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.value-was {
  font-size: 10px;
  font-weight: 500;
  color: #999;
  font-variant-numeric: tabular-nums;
}
