:root {
  /* Inspired by photos/download (1) - Copy.jpg: pastel-yellow base
     with a soft pink aura at the center. */
  /* The Tasks app "Cute" theme: soft pink canvas, gentle bright-pink
     accent, deep plum ink. The drawer carries a yellow/pink/blue ombre. */
  --bg: #ffe3ee;
  --card: #fffafc;
  --ink: #6e3350;
  --muted: #a76a89;
  --line: #d5aec0;
  --accent: #ff6fae;
  --accent-dark: #ff4f9a;
  --accent-text: #d63384;
  --header: #6e3350;
  --danger: #b91c1c;
  --track: #ffe0ee;
  /* Type roles (loaded from Google Fonts in index.html): headings in
     Petit Formal Script, subject text in Shadows Into Light Two,
     subheadings in Style Script. */
  --font-display: "Petit Formal Script", "Snell Roundhand", cursive;
  --font-sub: "Style Script", "Snell Roundhand", cursive;
  --font-btn: "Waterfall", "Snell Roundhand", cursive;
}
h1, h2, h3, .stat-val, .group-total { font-family: var(--font-display); }
.stat-label, .field > span, .view-head p { font-family: var(--font-sub); }
/* Subheadings: names that title a smaller unit — views, categories, repeat
   tags, picker options. Counts and data stay in the subject face. */
.nav-item, .cat-item, .mp-cell, .wp-row, .badge { font-family: var(--font-sub); }
.nav-item .count, .cat-item .count, .mp-cell .count, .wp-row .count {
  font-family: "Shadows Into Light Two", "Segoe Print", cursive;
}
.sub { font-family: var(--font-sub); }

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: "Shadows Into Light Two", "Segoe Print", cursive;
  font-size: 16px;
  line-height: 1.45;
  background-color: var(--bg);
  /* Cute canvas: dual dot grid, darker ombre up top, then pastel
     pink + blue + yellow washes. */
  background-image:
    radial-gradient(#ffffff8c 0.5px, transparent 0.7px),
    radial-gradient(#7b2e501c 0.5px, transparent 0.7px),
    linear-gradient(180deg, rgba(255, 183, 205, 0.55) 0%, rgba(255, 227, 238, 0) 34%),
    radial-gradient(135% 115% at 8% 0%, #ffc6def2, #ffc6de00 52%),
    radial-gradient(120% 115% at 96% 6%, #c9e3ffe6, #c9e3ff00 48%),
    radial-gradient(130% 130% at 50% 108%, #ffedb2e6, #ffedb200 55%);
  background-position: 0 0, 3px 3px, 0 0, 0 0, 0 0, 0 0;
  background-repeat: repeat, repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  background-size: 6px 6px, 6px 6px, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  background-attachment: fixed;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }

/* Slim top bar: menu button + brand + month total. */
.topbar-mini {
  display: flex; align-items: center; gap: 12px;
  /* Ombre: deeper pink at the very top melting into the canvas — no edge. */
  background: linear-gradient(180deg, rgba(255, 200, 218, 0.95) 0%, rgba(255, 227, 238, 0) 100%);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--header);
  padding: 10px 18px 16px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.menu-btn {
  font-family: var(--font-btn);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--header);
  width: 36px; height: 36px;
  cursor: pointer;
  flex: none;
}
.menu-btn:hover { border-color: var(--header); }
.topbar-brand { font-family: "Petit Formal Script", "Snell Roundhand", cursive; font-size: 24px; }
.topbar-month {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
}

/* Drawer: sidebar hides off-canvas until the menu button opens it. */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(74, 47, 58, 0.35);
  z-index: 45;
}
.backdrop[hidden] { display: none; }
.side {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: min(300px, 86vw);
  overflow-y: auto;
  /* Prominent pastel yellow → pink → blue ombre. */
  background: linear-gradient(165deg, #fff3c2 0%, #ffd9e8 48%, #cfe4ff 100%);
  background-attachment: fixed;
  padding: 16px 14px 24px;
  z-index: 50;
  transform: translateX(-105%);
  transition: transform 0.22s ease-out;
  border-right: 1px solid var(--line);
}
body.nav-open .side { transform: none; }
.nav-add { background: var(--accent); color: #fff; }
.nav-add:hover { background: var(--accent-dark); }
[hidden] { display: none !important; }
/* (Currency is INR-only; no picker.) */

/* Layout: single centered column; the sidebar is an off-canvas drawer. */
.layout { display: grid; grid-template-columns: 1fr; gap: 18px; padding-top: 32px; padding-bottom: 88px; padding-bottom: calc(88px + env(safe-area-inset-bottom)); align-items: start; }
.side { display: grid; gap: 14px; align-content: start; }
.content { display: grid; gap: 18px; min-width: 0; max-width: 720px; width: 100%; margin: 0 auto; }

/* Sidebar search */
.side-search input {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  width: 100%;
}
.side-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Sidebar view nav: icon + label + count, active is deep plum. */
.views { display: grid; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  font: inherit;
  font-family: var(--font-sub);
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: #ffe0ee; }
.nav-item.active { background: var(--header); color: #fff; }
.nav-item svg { flex: none; }
.nav-item .count {
  margin-left: auto;
  font-size: 12px;
  background: #ffe0ee;
  color: var(--accent-text);
  border-radius: 999px;
  padding: 1px 9px;
}
.nav-item.active .count { background: rgba(255, 255, 255, 0.24); color: #fff; }

/* Sidebar categories */
.side-h {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.6px;
  color: var(--header);
  background: #c9e3ff;
  border-radius: 8px;
  padding: 6px 12px;
  margin: 6px 0 0;
}
.cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cat-item {
  display: flex; align-items: center; gap: 10px;
  font: inherit;
  font-family: var(--font-sub);
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.cat-item:hover { background: #ffe0ee; }
.cat-item.active { background: var(--header); color: #fff; }
.cat-item .count {
  margin-left: auto;
  font-size: 12px;
  background: #ffe0ee;
  color: var(--accent-text);
  border-radius: 999px;
  padding: 1px 9px;
}
.cat-item.active .count { background: rgba(255, 255, 255, 0.24); color: #fff; }
.cats li[draggable="true"] { cursor: grab; }
.cats li.dragging { opacity: 0.45; }
.cats li.drag-over { box-shadow: 0 -3px 0 var(--accent); }

/* Sidebar footer card */
.side-foot {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.field.compact { margin-bottom: 0; }
.month-total {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.month-total strong { font-family: var(--font-display); font-weight: 400; font-size: 19px; color: var(--ink); }
.side-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.period-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.period-pick .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Main view header: big title + date subline, like the Tasks Today view. */
.view-head h2 { margin: 0; font-size: 35px; }
.view-head p { margin: 4px 0 0; }

/* Month picker: year stepper + calendar-like month grid with counts. */
.mp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mp-head strong { font-family: var(--font-display); font-weight: 400; font-size: 19px; }
.icon-btn.mp-nav { font-size: 24px; line-height: 1; padding: 2px 14px 6px; background: var(--accent); color: #fff; border-radius: 10px; }
.icon-btn.mp-nav:hover { background: var(--accent-dark); color: #fff; }
.mp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 500px) { .mp-grid { grid-template-columns: repeat(3, 1fr); } }
.mp-cell {
  display: grid; gap: 2px; justify-items: center;
  font: inherit;
  font-family: var(--font-sub);
  color: var(--ink);
  background: #ffe0ee;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 4px;
  cursor: pointer;
}
.mp-cell:hover { border-color: var(--accent); }
.mp-cell.active { background: var(--header); border-color: var(--header); color: #fff; }
.mp-cell.active .count { background: rgba(255, 255, 255, 0.24); color: #fff; }
.mp-cell .count {
  font-size: 12px;
  background: #ffd9e8;
  color: var(--accent-text);
  border-radius: 999px;
  padding: 0 9px;
}

/* Date picker: calendar input + today shortcut + recent dates. */
.dp-input {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  max-width: 170px;
}
.dp-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.dp-today { margin-bottom: 10px; }

/* Week picker: stepper head plus week rows with counts. */
.wp-list { display: grid; gap: 8px; }
.wp-row {
  display: flex; align-items: center; gap: 10px;
  font: inherit;
  font-family: var(--font-sub);
  color: var(--ink);
  background: #ffe0ee;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.wp-row:hover { border-color: var(--accent); }
.wp-row.active { background: var(--header); border-color: var(--header); color: #fff; }
.wp-row.active .count { background: rgba(255, 255, 255, 0.24); color: #fff; }
.wp-row .count {
  margin-left: auto;
  font-size: 12px;
  background: #ffd9e8;
  color: var(--accent-text);
  border-radius: 999px;
  padding: 0 9px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  scroll-margin-top: 76px;
}
.card h2 { margin: 0 0 12px; font-size: 20px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 600px) { .stats { grid-template-columns: 1fr; } }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-val { display: block; font-size: 30px; margin-top: 4px; }

/* Form */
.field { display: grid; gap: 5px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.field input, .field select {
  font: inherit;
  min-width: 0;
  font-size: 16px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  width: 100%;
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: #fff;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-err { color: var(--danger); font-size: 13px; margin: 0 0 10px; }
.form-btns { display: flex; gap: 8px; }
.update-pill {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60;
  font-family: var(--font-btn); font-size: 19px;
  background: var(--accent); color: #fff; border: none; border-radius: 999px;
  padding: 10px 22px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(214, 51, 132, 0.35);
}
.update-pill:hover { background: var(--accent-dark); }
.update-pill:disabled { opacity: 0.75; cursor: default; }

/* Buttons */
.btn {
  font: inherit;
  font-family: var(--font-btn);
  font-size: 17px;
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.subtle { background: #ffe0ee; color: var(--ink); border-color: var(--line); }
.btn.ghost-light { background: var(--card); color: var(--header); border-color: var(--line); font-size: 16px; padding: 7px 12px; }
.btn.ghost-light:hover { border-color: var(--header); }
.btn.small { font-size: 17px; padding: 6px 12px; }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: #e8a8b4; }
/* Front page: larger subheadings and buttons on the add-expense card. */
#addCard .field > span { font-size: 16px; }
#addCard .btn { font-size: 20px; padding: 11px 18px; }
.icon-btn { font-family: var(--font-btn); font-size: 18px; background: none; border: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; }
.icon-btn:hover { color: var(--ink); background: #ffe0ee; }
.icon-btn svg { display: block; }

/* (Views and repeats filters live in the sidebar now.) */

/* Summary bars */
.sum-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sum-head h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.bars { display: grid; gap: 10px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 76px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-sub); }
.bar-track { background: var(--track); border-radius: 6px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.bar-amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 400; }
.empty-note { color: var(--muted); font-size: 14px; margin: 4px 0; }

/* Grouped list */
.group { margin-bottom: 16px; }
.group-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  background: var(--header); color: #fff8e7;
  border-radius: 10px 10px 0 0;
  padding: 10px 14px;
}
.group-head h3 { margin: 0; font-size: 18px; }
.group-total { font-variant-numeric: tabular-nums; font-weight: 700; }
.items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-top: none; border-radius: 0 0 10px 10px; background: var(--card); }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: none; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.item-main { flex: 1; min-width: 0; }
.item-desc { font-weight: 400; }
.item-meta { color: var(--muted); font-size: 12.5px; }
.item-amt { font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-ops { display: flex; gap: 2px; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 400;
  border-radius: 999px; padding: 1px 8px; margin-left: 8px; vertical-align: 1px;
  background: var(--accent); color: #fff;
}
.badge.daily { background: var(--accent); color: #fff; }
.badge.weekly { background: var(--accent); color: #fff; }
.badge.monthly { background: var(--accent); color: #fff; }

/* Templates */
.templates { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.template { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--card); }
.template-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.template-top strong { font-weight: 400; }
.template-next { color: var(--muted); font-size: 12.5px; margin: 4px 0 8px; }

/* Footer */
.foot { margin: 0; }

/* Small phones: single-column form, tighter rhythm, no overflow. */
@media (max-width: 520px) {
  .wrap { padding: 0 12px; }
  .topbar-mini { padding: 10px 12px 16px; }
  .topbar-month { font-size: 14px; }
  .card { padding: 14px; }
  .row2 { grid-template-columns: 1fr; }
  .row2 > * { min-width: 0; }
  .view-head h2 { font-size: 28px; }
  .bar-row { grid-template-columns: 96px 1fr 64px; gap: 8px; font-size: 12.5px; }
  .stats { gap: 12px; }
  .group-head { flex-wrap: wrap; row-gap: 2px; }
  .form-btns { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
