:root {
  color-scheme: light;
  font-family: "Segoe UI", Arial, sans-serif;
  color: #1d2b24;
  background: #f5f7f2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --green: #23694d;
  --green-light: #e5f3e9;
  --red: #a33d37;
  --red-light: #fae9e6;
  --border: #dce4dc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select {
  min-height: 48px;
}

button {
  cursor: pointer;
}

.app {
  width: min(100% - 32px, 680px);
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 6vw, 2rem);
}

h2 {
  margin-bottom: 14px;
  font-size: 1.2rem;
}

.button {
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 700;
}

.button-light {
  color: var(--green);
  background: #e8eee8;
}

.button-primary {
  color: #fff;
  background: var(--green);
}

.button:focus-visible,
.type-button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #91c5a5;
  outline-offset: 2px;
}

.summary,
.entry-panel,
.history {
  margin-bottom: 24px;
}

.summary .section-heading {
  margin-bottom: 12px;
}

.summary .section-heading h2,
.history .section-heading h2 {
  margin-bottom: 0;
}

.month-picker,
.calendar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.month-picker {
  flex: 0 0 auto;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 6px;
  background: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}

.month-label-button {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-radius: 8px;
  padding: 0 4px;
  color: inherit;
  background: transparent;
  font-weight: 800;
}

.month-label-button:focus-visible {
  outline: 3px solid #91c5a5;
  outline-offset: 1px;
}

.calendar-nav {
  display: inline-grid;
  width: 40px;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--green);
  background: #fff;
  font-size: 1.4rem;
  line-height: 1;
}

.month-picker .calendar-nav {
  width: 30px;
  min-height: 30px;
  border: 0;
  font-size: 1.2rem;
}

.month-picker #month-label {
  min-width: 110px;
  text-align: center;
}

.summary-month-chooser {
  display: grid;
  grid-template-columns: auto minmax(100px, 140px);
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}

.summary-month-chooser[hidden] {
  display: none;
}

.summary-month-chooser > label {
  font-weight: 700;
}

.summary-month-chooser select {
  min-height: 48px;
  border: 1px solid #cbd6cc;
  border-radius: 10px;
  padding: 0 10px;
  background: #fff;
}

.summary-month-grid {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.summary-month-option {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  color: #344239;
  background: #fff;
  text-transform: capitalize;
}

.summary-month-option.selected {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-card {
  min-width: 0;
  border-radius: 14px;
  padding: 14px 12px;
  background: #fff;
}

.summary-card span {
  display: block;
  margin-bottom: 8px;
  color: #56645b;
  font-size: 0.85rem;
}

.summary-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(0.95rem, 4vw, 1.25rem);
}

.income-card strong {
  color: var(--green);
}

.expense-card strong {
  color: var(--red);
}

.entry-panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  background: #fff;
}

.type-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.type-button {
  border: 1px solid var(--border);
  border-radius: 12px;
  color: #344239;
  background: #fff;
  font-weight: 700;
}

.type-button[data-type="income"].selected {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-light);
}

.type-button[data-type="expense"].selected {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-light);
}

form {
  display: grid;
  gap: 9px;
}

form label {
  margin-top: 5px;
  font-size: 0.95rem;
  font-weight: 700;
}

.optional {
  color: #68756d;
  font-size: 0.82rem;
  font-weight: 400;
}

form input,
form select {
  width: 100%;
  border: 1px solid #cbd6cc;
  border-radius: 10px;
  padding: 0 12px;
  color: inherit;
  background: #fff;
}

.date-picker-button {
  width: 100%;
  border: 1px solid #cbd6cc;
  border-radius: 10px;
  padding: 0 12px;
  color: inherit;
  background: #fff;
  text-align: left;
}

.calendar-panel {
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px;
  background: #fbfcfa;
}

.calendar-panel[hidden] {
  display: none;
}

.calendar-heading {
  margin-bottom: 10px;
}

.calendar-heading strong {
  text-align: center;
  text-transform: capitalize;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-weekday,
.calendar-empty,
.calendar-day {
  display: grid;
  min-width: 0;
  min-height: 42px;
  place-items: center;
}

.calendar-weekday {
  color: #647168;
  font-size: 0.8rem;
  font-weight: 700;
}

.calendar-day {
  border: 1px solid transparent;
  border-radius: 9px;
  color: inherit;
  background: #fff;
}

.calendar-day:hover {
  border-color: #91c5a5;
}

.calendar-day.selected {
  color: #fff;
  background: var(--green);
}

.amount-field {
  display: flex;
  min-height: 54px;
  align-items: center;
  border: 1px solid #cbd6cc;
  border-radius: 10px;
  padding-left: 14px;
  color: #536158;
  font-weight: 700;
}

.amount-field input {
  min-height: 52px;
  border: 0;
  outline-offset: -3px;
}

.save-button {
  min-height: 54px;
  margin-top: 10px;
  font-size: 1rem;
}

.form-message {
  min-height: 1.2em;
  margin: 0;
  color: var(--green);
  font-size: 0.9rem;
}

.transaction-count {
  color: #66736a;
  font-size: 0.9rem;
}

.transaction-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.transaction {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 13px 14px;
  background: #fff;
}

.transaction-info {
  min-width: 0;
}

.transaction-title {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.transaction-meta {
  margin: 0;
  color: #68756d;
  font-size: 0.85rem;
}

.transaction-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.transaction-amount {
  white-space: nowrap;
  font-weight: 800;
}

.transaction-amount.income {
  color: var(--green);
}

.transaction-amount.expense {
  color: var(--red);
}

.delete-button {
  min-width: 42px;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #526057;
  background: #fff;
}

.empty-state {
  border: 1px dashed #cbd6cc;
  border-radius: 13px;
  padding: 20px;
  color: #637067;
  text-align: center;
}

.privacy-note {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  color: #647168;
  font-size: 0.85rem;
  line-height: 1.5;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (max-width: 420px) {
  .app {
    width: min(100% - 24px, 680px);
    padding-top: 20px;
  }

  .entry-panel {
    padding: 16px;
  }

  .summary-grid {
    gap: 7px;
  }

  .summary-card {
    padding: 12px 9px;
  }

  .summary-card span {
    font-size: 0.78rem;
  }

  .transaction {
    gap: 8px;
    padding: 11px;
  }

  .transaction-side {
    gap: 6px;
  }
}


/* Cloud Sync Status Bar */
.cloud-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 24px;
  font-size: 0.85rem;
}

.status-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
  transition: background-color 0.3s;
}

.status-dot.synced {
  background: #23694d;
}

.status-dot.syncing {
  background: #d97706;
  animation: pulse-sync 1.2s infinite ease-in-out;
}

.status-dot.offline {
  background: #9ca3af;
}

.status-dot.error {
  background: #b91c1c;
}

@keyframes pulse-sync {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.status-sync-btn {
  background: var(--green-light);
  border: 1px solid #b8ddc6;
  border-radius: 8px;
  padding: 0 12px;
  min-height: 34px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--green);
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
}

.status-sync-btn:hover {
  background: #d1ebd8;
}

.status-sync-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
