/* ===========================
   Simple Budget - styles
   Base tone matches tokens.css (Terracotta & Cream);
   accent overridden to soft coral for this app.
   =========================== */

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  color-scheme: light;

  /* Base tone (from tokens.css) */
  --bg: #FAF4EC;
  --card: #FFFFFF;
  --border: #EDE2D4;
  --divider: #F4EBDF;
  --ink: #3D3229;
  --text-2: #6B5F51;
  --muted: #8C7F70;
  --faint: #B5A794;
  --error: #C0392B;

  /* Accent overridden to soft coral for this app */
  --accent: #E88C7D;
  --accent-hover: #D4715F;
  --accent-tint: #FBE7E2;
  --accent-line: #F0C3B8;

  --shadow-card: 0 2px 10px rgba(60, 40, 20, 0.06);
  --shadow-modal: 0 24px 60px rgba(60, 40, 20, 0.30);
  --modal-scrim: rgba(61, 50, 41, 0.40);
  --focus-ring: 0 0 0 3px rgba(232, 140, 125, 0.18);

  --radius-card: 20px;
  --radius-modal: 24px;
  --radius-pill: 999px;

  --font: "Nunito", sans-serif;

  /* Category colors (distinct from the accent, for day-to-day breakdown) */
  --cat-food-bg: #FDECC8;
  --cat-food-text: #A97710;
  --cat-daily-bg: #DCEFF4;
  --cat-daily-text: #2A7C8C;
  --cat-social-bg: #EFE1F7;
  --cat-social-text: #7B4FA0;
  --cat-other-bg: #ECE7DE;
  --cat-other-text: #6B5F51;
}

body {
  font-family: var(--font);
  margin: 0;
  padding: 40px 20px 64px;
  background: var(--bg);
  color: var(--ink);
}

header, main {
  max-width: 680px;
  margin: 0 auto;
}

header {
  margin-bottom: 24px;
}

header h1 {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

header h1 .title-accent {
  color: var(--accent-hover);
}

header p {
  color: var(--text-2);
  margin: 0;
  font-size: 14px;
}

/* Cards */
.add-card,
.month-card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}

/* Form */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-of-type {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
}

.form-group small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

#amountInput,
#editAmountInput {
  width: 100%;
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
}

#amountInput:focus,
#editAmountInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  cursor: pointer;
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--text-2);
}

.pill-btn:hover {
  background: var(--divider);
}

.pill-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.pill-btn.cat-food.selected { background: var(--cat-food-bg); color: var(--cat-food-text); border-color: transparent; }
.pill-btn.cat-daily.selected { background: var(--cat-daily-bg); color: var(--cat-daily-text); border-color: transparent; }
.pill-btn.cat-social.selected { background: var(--cat-social-bg); color: var(--cat-social-text); border-color: transparent; }
.pill-btn.cat-other.selected { background: var(--cat-other-bg); color: var(--cat-other-text); border-color: transparent; }

.primary-btn {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 800;
  border-radius: var(--radius-pill);
  padding: 14px 18px;
  cursor: pointer;
  border: none;
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.primary-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Month card */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.month-label {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  text-align: center;
  flex: 1;
}

.nav-btn {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  border: 1.5px solid var(--accent-line);
  background: var(--card);
  color: var(--accent-hover);
  border-radius: var(--radius-pill);
  width: 36px;
  height: 36px;
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--accent-tint);
}

.nav-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.month-total {
  text-align: center;
  margin: 16px 0 0;
  font-size: 14px;
  color: var(--text-2);
}

.month-total #monthTotal {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent-hover);
}

/* Calendar grid */
.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  margin: 16px 0 6px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day-cell {
  position: relative;
  font-family: var(--font);
  aspect-ratio: 1 / 1;
  width: 100%;
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px;
  overflow: hidden;
}

.day-num {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.day-amount {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-cell.day-muted {
  color: var(--faint);
  opacity: 0.5;
  cursor: default;
}

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

.day-cell.day-has-spending {
  background: var(--accent-tint);
  color: var(--accent-hover);
}

.day-cell.day-has-spending:hover {
  background: var(--accent-line);
}

.day-cell.day-today {
  border-color: var(--ink);
}

.day-cell:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Records list */
.empty-state {
  background: var(--accent-tint);
  color: var(--accent-hover);
  font-weight: 700;
  font-size: 14px;
  padding: 16px 20px;
  border-radius: var(--radius-card);
  text-align: center;
}

.day-group {
  margin-bottom: 20px;
}

.day-heading {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin: 0 0 8px 4px;
}

.day-heading:focus {
  outline: none;
}

.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  font-family: var(--font);
  text-align: left;
  background: var(--card);
  border: none;
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
}

.record-row:hover {
  background: var(--divider);
}

.record-row:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.record-amount {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}

.record-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.record-badge.cat-food { background: var(--cat-food-bg); color: var(--cat-food-text); }
.record-badge.cat-daily { background: var(--cat-daily-bg); color: var(--cat-daily-text); }
.record-badge.cat-social { background: var(--cat-social-bg); color: var(--cat-social-text); }
.record-badge.cat-other { background: var(--cat-other-bg); color: var(--cat-other-text); }

/* Modal */
.modal-scrim {
  position: fixed;
  inset: 0;
  background: var(--modal-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal-scrim[hidden] {
  display: none;
}

.modal-card {
  background: var(--card);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-modal);
  padding: 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.modal-date {
  font-size: 17px;
  font-weight: 800;
  margin: 0 0 16px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.danger-btn {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  cursor: pointer;
  background: var(--card);
  color: var(--error);
  border: 1.5px solid var(--border);
}

.danger-btn:hover {
  background: var(--divider);
}

.secondary-btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  cursor: pointer;
  background: var(--card);
  color: var(--text-2);
  border: 1.5px solid var(--border);
  width: 100%;
}

.secondary-btn:hover {
  background: var(--divider);
}

@media (max-width: 420px) {
  body {
    padding: 24px 12px 48px;
  }

  .add-card,
  .month-card {
    padding: 16px;
  }

  #amountInput,
  #editAmountInput {
    font-size: 18px;
  }

  .day-cell {
    border-radius: 10px;
  }

  .day-num {
    font-size: 12px;
  }

  .day-amount {
    font-size: 7.5px;
  }
}
