:root {
  --color-bg: #f4f7f3;
  --color-bg-alt: #ffffff;
  --color-surface: #ffffff;
  --color-border: #dce4dd;
  --color-accent: #1f6b4f;
  --color-accent-soft: #e5f1e9;
  --color-income: #19734f;
  --color-expense: #c05746;
  --color-text: #18211b;
  --color-muted: #647068;
  --shadow-lg: 0 20px 48px rgba(28, 52, 38, 0.09);
  --radius-lg: 8px;
  --radius-md: 8px;
  --radius-sm: 6px;
}

[hidden] {
  display: none !important;
}

body {
  overflow-x: hidden;
}

html {
  background: var(--color-bg);
}

.app-page,
.contact-page,
.profile-page,
.legal-page {
  background: var(--color-bg);
  color: var(--color-text);
}

.app-page::before,
.contact-page::before,
.profile-page::before,
.legal-page::before {
  display: none;
}

.app-wordmark {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--color-accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.app-shell,
.contact-wrap,
.profile-wrap {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.app-shell {
  max-width: 1240px;
}

.app-header,
.annual-header,
.contact-header,
.profile-header {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.app-header h1,
.annual-header h1,
.contact-intro h1,
.profile-intro h1,
.legal-content h1 {
  color: var(--color-text);
  letter-spacing: 0;
}

.tagline,
.user-greeting,
.profile-lead,
.contact-intro p,
.legal-updated,
.legal-content p {
  color: var(--color-muted);
}

.brand {
  color: var(--color-text);
  text-decoration: none;
}

.brand-logo {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: var(--color-accent);
  color: #ffffff;
  font-size: 1rem;
}

.nav-link,
button.nav-link {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #34433a;
}

.nav-link:hover,
.nav-link:focus-visible,
button.nav-link:hover,
button.nav-link:focus-visible,
.nav-link[aria-current="page"] {
  border: 0;
  background: #e5ebe6;
  color: var(--color-text);
  transform: none;
}

.nav-link-primary,
.nav-link-primary:hover,
.nav-link-primary:focus-visible {
  background: var(--color-accent);
  color: #ffffff;
  box-shadow: none;
}

.account-menu-panel {
  border-color: var(--color-border);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow-lg);
}

.account-menu-panel a,
.account-menu-panel button {
  min-height: 44px;
  color: var(--color-text);
}

.account-menu-panel a:hover,
.account-menu-panel button:hover,
.account-menu-panel a:focus-visible,
.account-menu-panel button:focus-visible {
  background: var(--color-accent-soft);
}

.btn {
  min-height: 44px;
  border-radius: 6px;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.btn.primary {
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: #ffffff;
  box-shadow: none;
}

.btn.primary:hover,
.btn.primary:focus-visible {
  background: #18573f;
  box-shadow: none;
}

.btn.secondary,
.link-chip {
  min-height: 44px;
  border: 1px solid #bfcfc4;
  border-radius: 6px;
  background: #ffffff;
  color: var(--color-accent);
  box-shadow: none;
}

.btn.ghost {
  color: var(--color-muted);
}

.btn:hover,
.link-chip:hover {
  transform: translateY(-1px);
  box-shadow: none;
}

.picker label {
  color: var(--color-muted);
  letter-spacing: 0.05em;
}

.period-controls select,
#month-select,
.annual-controls select {
  min-height: 46px;
  border: 1px solid #cbd7ce;
  border-radius: 6px;
  background: #ffffff;
  color: var(--color-text);
}

.period-controls select:focus,
#month-select:focus,
.annual-controls select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(31, 107, 79, 0.12);
  transform: none;
}

.summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-card {
  min-height: 118px;
  justify-content: center;
  padding: 20px;
  border-color: var(--color-border);
  border-radius: 8px;
  background: #ffffff;
}

.summary-card::after {
  display: none;
}

.summary-label {
  color: var(--color-muted);
  letter-spacing: 0.05em;
}

.summary-value,
#balance-summary .summary-value {
  color: var(--color-text);
}

#balance-summary {
  background: #edf7f1;
  border-color: #c8dfd0;
}

#balance-summary .summary-value {
  color: var(--color-income);
}

.panels {
  align-items: start;
}

.panel,
.annual-section,
.profile-card,
.contact-form-card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: none;
}

.category-card,
.chart-card,
.annual-card,
.profile-summary {
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: #f8faf8;
  box-shadow: none;
}

.category-total {
  border-radius: 5px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.entry-item {
  border: 1px solid #e4eae5;
  border-radius: 6px;
  background: #ffffff;
}

.input-group input,
.entry-form select,
.entry-amount-input,
.category-name-input {
  min-height: 44px;
  border-color: #cbd7ce;
  border-radius: 6px;
  background: #ffffff;
  color: var(--color-text);
}

.empty-state {
  border-radius: 7px;
  border-color: #cbd7ce;
  background: #f8faf8;
}

.chart-legend-label,
.chart-legend-value,
.annual-total,
.annual-card .month-value {
  color: var(--color-text);
}

.chart-legend-percent,
.annual-card .month-label,
.annual-note,
.empty-card {
  color: var(--color-muted);
}

.icon-btn {
  align-items: center;
  border-color: #cbd7ce;
  border-radius: 6px;
  background: #ffffff;
  color: var(--color-text);
  box-shadow: none;
}

.storage-warning {
  border-color: #e7bcb4;
  background: #fff4f1;
  color: #8b3e31;
}

.storage-warning strong {
  color: #8b3e31;
}

.annual-summary {
  gap: 18px;
}

.annual-section {
  padding: 22px;
}

.annual-card {
  min-height: 126px;
}

.badge {
  width: fit-content;
  padding: 7px 10px;
  border: 0;
  border-radius: 5px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  letter-spacing: 0.06em;
}

.contact-highlights {
  color: var(--color-muted);
}

.contact-highlights strong {
  color: var(--color-text);
}

.field,
.profile-fieldset {
  border-color: var(--color-border);
  border-radius: 7px;
  background: #f8faf8;
}

.field label,
.profile-fieldset legend {
  color: var(--color-text);
}

.field input,
.field textarea,
.field select,
.profile-card .field input,
.profile-card .field select {
  min-height: 46px;
  border-color: #cbd7ce;
  border-radius: 6px;
  background: #ffffff;
  color: var(--color-text);
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.profile-card .field input:focus,
.profile-card .field select:focus {
  border-color: var(--color-accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(31, 107, 79, 0.12);
}

.profile-avatar {
  border-color: #c8dfd0;
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.profile-email,
.profile-meta,
.fieldset-hint,
.profile-status,
.required-hint,
.form-status,
.field-feedback {
  color: var(--color-muted);
}

.legal-header,
.legal-content {
  width: min(840px, calc(100% - 40px));
}

.legal-content section {
  border-color: var(--color-border);
}

.legal-page .site-footer a {
  color: var(--color-muted);
}

.site-footer {
  color: var(--color-muted);
}

.site-footer .footer-brand,
.site-footer [aria-current="page"] {
  color: var(--color-text);
}

.site-footer .footer-copy {
  color: var(--color-muted);
}

.app-footer {
  border-color: var(--color-border);
}

/* Account and login */
.modal-overlay {
  padding: 20px;
  overflow-y: auto;
  background: rgba(19, 31, 23, 0.7);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  width: min(460px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 32px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--color-text);
  box-shadow: 0 28px 80px rgba(13, 31, 20, 0.22);
}

.modal-dialog::before,
.modal-dialog::after,
.modal-title::after {
  display: none;
}

.modal-close {
  z-index: 2;
  width: 40px;
  height: 40px;
  top: 12px;
  right: 12px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  color: #4d5a51;
}

.modal-close:hover,
.modal-close:focus-visible {
  background: #edf1ee;
  color: var(--color-text);
}

.signup-dialog {
  width: min(900px, calc(100vw - 40px));
  padding: 0;
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 0;
}

.signup-intro {
  min-width: 0;
  padding: 42px;
  background: #eaf2ec;
  border-right: 1px solid #d4dfd6;
}

.signup-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 52px;
  color: var(--color-text);
  font-weight: 700;
  text-decoration: none;
}

.signup-brand span {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: var(--color-accent);
  color: #ffffff;
}

.signup-eyebrow,
.signup-step {
  color: var(--color-accent);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.signup-intro .modal-title {
  margin: 10px 0 14px;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.modal-intro {
  color: var(--color-muted);
}

.signup-benefits {
  list-style: none;
  margin: 34px 0 0;
  padding: 0;
  display: grid;
  gap: 20px;
}

.signup-benefits li {
  display: grid;
  gap: 3px;
  padding-left: 20px;
  border-left: 2px solid #a9cbb6;
}

.signup-benefits strong {
  color: var(--color-text);
  font-size: 0.9rem;
}

.signup-benefits span {
  color: var(--color-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.signup-form-panel {
  min-width: 0;
  padding: 42px;
}

.signup-form-heading {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.signup-form-heading p {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.82rem;
}

.account-form {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.form-field:not(.form-actions) {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.form-field:not(.form-actions):hover,
.form-field:not(.form-actions):focus-within {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.form-field label {
  color: #34433a;
  font-size: 0.84rem;
  font-weight: 600;
}

.form-field input {
  min-width: 0;
  min-height: 48px;
  border: 1px solid #cbd7ce;
  border-radius: 6px;
  background: #ffffff;
  color: var(--color-text);
  font-size: 1rem;
}

.form-field-row > .form-field {
  min-width: 0;
}

.form-field input::placeholder {
  color: #8b968e;
}

.form-field input:focus {
  border-color: var(--color-accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(31, 107, 79, 0.12);
}

.password-hint,
.signup-legal {
  margin: 4px 0 0;
  color: var(--color-muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.signup-legal a,
.form-link {
  color: var(--color-accent);
}

.signup-consent {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 2px 0 0;
  color: var(--color-muted);
  font-size: 0.78rem;
  line-height: 1.55;
  cursor: pointer;
}

.signup-consent input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.signup-consent a {
  color: var(--color-accent);
  font-weight: 700;
  text-underline-offset: 2px;
}

.signup-consent.has-error {
  color: #8b3e31;
}

.signup-consent.has-error input {
  outline: 2px solid rgba(192, 87, 70, 0.28);
  outline-offset: 2px;
}

.signup-dialog .form-actions {
  margin-top: 0;
}

.signup-dialog .form-actions .btn {
  width: 100%;
  min-height: 50px;
}

.login-dialog .modal-title {
  padding-right: 36px;
  letter-spacing: 0;
}

.login-dialog .account-form {
  margin-top: 6px;
}

.form-feedback.is-success {
  border-color: #b7d8c2;
  background: #edf7f1;
  color: #17603f;
}

.form-feedback.is-error {
  border-color: #e7bcb4;
  background: #fff4f1;
  color: #8b3e31;
}

@media (max-width: 820px) {
  .signup-dialog {
    grid-template-columns: 1fr;
  }

  .signup-intro {
    padding: 28px 32px;
    border-right: 0;
    border-bottom: 1px solid #d4dfd6;
  }

  .signup-brand,
  .signup-benefits {
    display: none;
  }

  .signup-intro .modal-title {
    max-width: 520px;
    font-size: 1.55rem;
  }

  .signup-form-panel {
    padding: 30px 32px 34px;
  }
}

.signup-intro .modal-title,
.signup-intro .modal-intro,
.signup-legal {
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .app-page,
  body.annual-view,
  body.contact-page,
  .profile-page {
    padding: 16px 14px 0;
  }

  .app-shell,
  .contact-wrap,
  .profile-wrap {
    padding: 12px 0 28px;
    gap: 24px;
  }

  .app-header,
  .annual-header,
  .contact-header,
  .profile-header {
    gap: 16px;
    padding-bottom: 18px;
  }

  .app-header h1,
  .annual-header h1 {
    font-size: 1.75rem;
  }

  .tagline {
    font-size: 0.88rem;
  }

  .period-controls,
  .annual-controls {
    width: 100%;
    gap: 10px;
  }

  .picker-inline,
  .annual-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
  }

  .picker-inline select,
  .picker-inline .link-chip,
  .picker-inline .account-menu,
  .annual-actions .link-chip,
  .annual-actions .account-menu {
    width: 100%;
    min-width: 0;
  }

  .summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .summary-card {
    min-width: 0;
    min-height: 96px;
    padding: 12px 9px;
  }

  .summary-label {
    font-size: 0.62rem;
    line-height: 1.35;
  }

  .summary-value {
    font-size: 1rem;
    overflow-wrap: anywhere;
  }

  .panels {
    gap: 16px;
  }

  .panel,
  .annual-section,
  .contact-form-card,
  .profile-card {
    padding: 18px 14px;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .panel-actions .btn {
    width: 100%;
    padding-inline: 10px;
    font-size: 0.82rem;
  }

  .category-card {
    padding: 14px;
  }

  .category-header {
    flex-direction: column;
  }

  .category-actions {
    width: 100%;
  }

  .category-actions .btn {
    flex: 1;
  }

  .entry-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 12px;
  }

  .entry-info {
    grid-column: 1 / -1;
    width: 100%;
    flex: none;
  }

  .entry-meta,
  .entry-actions {
    width: auto;
  }

  .entry-actions .btn {
    width: auto;
    min-height: 36px;
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .entry-visibility-select {
    width: 100%;
  }

  .annual-summary {
    gap: 14px;
  }

  .annual-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .annual-card {
    min-height: 108px;
    padding: 12px;
  }

  .annual-card .month-value {
    font-size: 1.05rem;
  }

  .contact-nav,
  .profile-nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .contact-nav .nav-link,
  .profile-nav .nav-link {
    width: 100%;
    padding-inline: 8px;
    font-size: 0.82rem;
  }

  .profile-summary {
    align-items: center;
    flex-direction: row;
    padding: 16px;
  }

  .profile-fieldset,
  .field {
    padding: 14px;
  }

  .site-footer .footer-links {
    row-gap: 10px;
    font-size: 0.8rem;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-dialog,
  .signup-dialog {
    width: 100%;
    max-height: 94dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }

  .signup-intro {
    padding: 24px 20px 18px;
  }

  .signup-intro .modal-intro {
    padding-right: 28px;
    font-size: 0.86rem;
  }

  .signup-form-panel,
  .login-dialog {
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  }

  .signup-form-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .form-field-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .form-field input,
  .field input,
  .field textarea,
  .field select,
  .profile-card .field input,
  .profile-card .field select,
  .period-controls select,
  #month-select,
  .annual-controls select {
    font-size: 16px;
  }
}

@media (max-width: 390px) {
  .form-field-row,
  .picker-inline,
  .annual-actions {
    grid-template-columns: 1fr;
  }

  .summary-value {
    font-size: 0.9rem;
  }
}
