:root {
  --bg: #eff3ec;
  --ink: #151916;
  --muted: #657064;
  --line: rgba(21, 25, 22, 0.13);
  --paper: #fbfcf7;
  --panel: #ffffff;
  --green: #2f7d54;
  --red: #b54f45;
  --accent: #b9d77a;
  --shadow: 0 24px 70px rgba(41, 55, 43, 0.16);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, rgba(185, 215, 122, 0.32), transparent 24rem),
    radial-gradient(circle at 82% 10%, rgba(47, 125, 84, 0.18), transparent 26rem),
    linear-gradient(135deg, #f8f7ef 0%, var(--bg) 100%);
}

button,
input {
  font: inherit;
}

.auth-shell,
.shell {
  width: min(1120px, calc(100vw - 28px));
  margin: 0 auto;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-shell[hidden],
.shell[hidden] {
  display: none;
}

.auth-card,
.summary-card,
.entry-panel,
.calendar-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(251, 252, 247, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card {
  width: min(520px, 100%);
  padding: clamp(24px, 5vw, 42px);
}

.back-link {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  text-decoration: none;
}

.eyebrow {
  margin: 18px 0 8px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 10vw, 7rem);
  line-height: 0.85;
  letter-spacing: 0;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  margin: 30px 0 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
}

.auth-tab {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.auth-tab.is-active {
  color: #f9fff1;
  background: var(--ink);
}

.auth-form,
.entry-form {
  display: grid;
  gap: 14px;
}

.auth-form label,
.entry-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-form input,
.entry-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
  outline: none;
}

.auth-form input:focus,
.entry-form input:focus {
  border-color: rgba(47, 125, 84, 0.5);
  box-shadow: 0 0 0 4px rgba(47, 125, 84, 0.1);
}

.primary-button,
.ghost-button,
.nav-button {
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 12px 16px;
  color: #f9fff1;
  background: var(--ink);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.5);
}

.shell {
  min-height: 100vh;
  padding: 18px 0 28px;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.topbar .eyebrow,
.topbar h1 {
  text-align: center;
}

.topbar .eyebrow {
  margin-top: 0;
}

.user-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.summary-card {
  padding: 18px;
}

.summary-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  color: var(--green);
  font-size: clamp(1.7rem, 4vw, 2.7rem);
  line-height: 1;
}

.summary-card.expense strong {
  color: var(--red);
}

.summary-card.total-income strong {
  color: var(--green);
}

.summary-card.balance strong {
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 14px;
  align-items: start;
}

.entry-panel,
.calendar-panel {
  padding: 18px;
}

.month-toolbar {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.month-toolbar strong {
  text-align: center;
}

.nav-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  font-size: 1.8rem;
  line-height: 1;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekday-row {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  display: grid;
  grid-template-rows: auto minmax(20px, 1fr) auto;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.54);
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.calendar-day:hover {
  transform: translateY(-2px);
  border-color: rgba(47, 125, 84, 0.35);
  background: rgba(255, 255, 255, 0.76);
}

.calendar-day:disabled {
  cursor: default;
}

.calendar-day.is-outside {
  opacity: 0;
  pointer-events: none;
}

.calendar-day.is-today .day-number {
  color: var(--green);
}

.calendar-day.is-selected {
  border-color: rgba(47, 125, 84, 0.68);
  background: rgba(185, 215, 122, 0.28);
  box-shadow: 0 12px 28px rgba(47, 125, 84, 0.12);
}

.calendar-day.has-records {
  background: rgba(255, 255, 255, 0.78);
}

.day-number {
  font-weight: 900;
  line-height: 1;
}

.day-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-content: start;
  padding-top: 8px;
  min-width: 0;
}

.day-icons i {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0 5px;
  color: var(--muted);
  background: rgba(21, 25, 22, 0.06);
  font-style: normal;
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 56px;
}

.day-total {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 20px;
}

.day-chip {
  border-radius: 999px;
  padding: 3px 6px;
  color: var(--muted);
  background: rgba(21, 25, 22, 0.06);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.day-chip.income {
  color: var(--green);
}

.day-chip.expense {
  color: var(--red);
}

.selected-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
}

.selected-head span {
  font-size: 1.05rem;
  font-weight: 850;
  color: var(--ink);
}

.selected-head strong {
  color: var(--ink);
}

.selected-head strong.is-income {
  color: var(--green);
}

.selected-head strong.is-expense {
  color: var(--red);
}

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

.type-toggle label {
  cursor: pointer;
}

.type-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-toggle span {
  display: grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
}

.type-toggle input:checked + span {
  color: #f9fff1;
  background: var(--ink);
}

.ledger-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
  color: var(--muted);
}

.ledger-list {
  display: grid;
  gap: 9px;
}

.ledger-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.55);
}

.ledger-item div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ledger-item strong,
.ledger-item span {
  overflow-wrap: anywhere;
}

.ledger-item span {
  color: var(--muted);
  font-size: 0.82rem;
}

.ledger-item b {
  color: var(--red);
  white-space: nowrap;
}

.ledger-item.is-income b {
  color: var(--green);
}

.ledger-item button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(18px);
  border-radius: 999px;
  padding: 10px 16px;
  color: #f9fff1;
  background: rgba(21, 25, 22, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 760px) {
  .topbar,
  .workspace,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .topbar .eyebrow,
  .topbar h1 {
    text-align: left;
  }

  .user-box {
    justify-content: space-between;
  }

  .ledger-item {
    grid-template-columns: 1fr;
  }

  .weekday-row,
  .calendar-grid {
    gap: 5px;
  }

  .calendar-day {
    min-height: 78px;
    border-radius: 14px;
    padding: 7px;
  }

  .day-icons i {
    max-width: 34px;
  }

  .day-chip {
    font-size: 0.66rem;
    padding: 2px 4px;
  }
}
