@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f3f6fb;
  --bg-soft: #eef3ff;
  --card: rgba(255, 255, 255, 0.92);
  --text: #13203a;
  --muted: #66758f;
  --primary: #2f6df6;
  --primary-2: #5e8cff;
  --success: #0fa67f;
  --danger: #e05454;
  --border: rgba(23, 48, 84, 0.12);
  --shadow: 0 10px 30px rgba(26, 51, 86, 0.09);
  --radius: 16px;
}

body.dark-mode {
  --bg: #0d1529;
  --bg-soft: #121d35;
  --card: rgba(19, 31, 54, 0.85);
  --text: #edf3ff;
  --muted: #9baed2;
  --primary: #5f8cff;
  --primary-2: #7ba0ff;
  --success: #2dc89e;
  --danger: #ff7b7b;
  --border: rgba(150, 170, 210, 0.18);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background: radial-gradient(circle at 20% 0%, #dfe8ff, transparent 36%), radial-gradient(circle at 90% 15%, #d7f2ff, transparent 30%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body.dark-mode {
  background: radial-gradient(circle at 20% 0%, #1b2c4d, transparent 36%), radial-gradient(circle at 90% 15%, #1f3b49, transparent 30%), var(--bg);
}

#appShell {
  display: block;
  width: min(1200px, 100% - 24px);
  margin: 10px auto 90px;
}

#sidebar,
#mainArea {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card,
.metric-card,
#summaryCards .metric-card,
#recentExpenses,
#inputSection,
#chartSection {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

#nameContainer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-weight: 800;
}

#nameContainer img {
  width: 30px;
  height: 30px;
}

#monthSelector,
#monthlyBudget,
#linksContainer {
  padding: 14px;
}

#monthSelector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#monthSelector label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

#monthPicker,
#budgetInput,
#amountInput,
#dateInput,
#categorySelect,
#description {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text);
  padding: 12px;
  font: inherit;
  outline: none;
}

#monthPicker:focus,
#budgetInput:focus,
#amountInput:focus,
#dateInput:focus,
#categorySelect:focus,
#description:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.15);
}

#monthlyBudget {
  display: flex;
  gap: 10px;
  flex-direction: column;
}

button,
#setBudget,
#addExpenses {
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

button:hover,
#setBudget:hover,
#addExpenses:hover {
  transform: scale(1.02);
  filter: brightness(1.05);
}

#linksContainer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#linksContainer a,
#linksContainer p {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

#linksContainer a {
  text-decoration: none;
}

#subHeading {
  padding: 16px 4px;
}

.lineOne {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2.5rem);
  font-weight: 800;
}

.secondLine {
  margin: 4px 0 0;
  color: var(--muted);
}

#summaryCards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.metric-card {
  padding: 18px;
}

.title {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.amount,
.bgtAmount,
.remainingAmount {
  margin: 8px 0 0;
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 800;
}

.remainingAmount {
  color: var(--success);
}

.over-budget .remainingAmount {
  color: var(--danger);
}

.progress-ring-wrap {
  margin: 14px 0 10px;
}

.progress-ring {
  width: 98px;
  height: 98px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--success) 0%, rgba(255, 255, 255, 0.25) 0%);
  position: relative;
}

.progress-ring::before {
  content: "";
  position: absolute;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
}

#progressPercent {
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #14b78a, #edb040, #e05454);
  transition: width 0.5s ease;
}

#dashboardGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

#inputSection,
#chartSection,
#recentExpenses {
  padding: 18px;
}

#inputSection span p,
#chartSection h3,
#recentExpenses h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

#inputFields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#warning {
  min-height: 16px;
  margin: 0;
  color: var(--danger);
}

.chart-wrapper {
  overflow-x: auto;
}

#barChart {
  min-height: 260px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 2px;
}

.parentDiv {
  flex: 1;
  min-width: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  max-width: 64px;
  min-height: 18px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: #fff;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 4px 2px 2px;
  gap: 2px;
  text-align: center;
  animation: barGrow 0.55s ease;
}

.cate {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: capitalize;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}

.bar-value {
  font-weight: 700;
  font-size: 0.68rem;
}

.bar-share {
  font-size: 0.63rem;
  opacity: 0.92;
}

.cate-name {
  font-weight: 700;
}

.cate-count {
  font-size: 0.62rem;
  opacity: 0.9;
}

.chart-empty {
  margin: auto;
  color: var(--muted);
  font-weight: 600;
  animation: fadeIn 0.45s ease;
}

#recentList {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.date-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  overflow: hidden;
  animation: slideUp 0.35s ease;
}

.date-group summary {
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.date-group summary::-webkit-details-marker {
  display: none;
}

.date-total {
  color: var(--muted);
  font-size: 0.84rem;
}

.date-items {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.recent-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}

.recent-category {
  text-transform: capitalize;
  font-weight: 600;
}

.recent-date {
  color: var(--muted);
  font-size: 0.8rem;
}

.recent-amount {
  font-weight: 700;
}

.load-more-btn {
  margin-top: 6px;
}

.section-enter {
  animation: slideUp 0.35s ease;
}

#mobileBottomNav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 1000;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

#mobileBottomNav button {
  padding: 10px 8px;
  font-size: 0.84rem;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(10, 20, 38, 0.3);
  z-index: 1100;
}

.modal-content {
  width: min(700px, 100%);
  max-height: 82vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  animation: fadeIn 0.22s ease;
}

.modal-content h2 {
  margin: 0 0 10px;
}

.closeBtn {
  float: right;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

#item {
  display: grid;
  gap: 10px;
}

#item .displayItem {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

#item .category {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--primary);
}

#item .note {
  font-size: 0.86rem;
  color: var(--muted);
}

#item .summary-date-heading {
  margin-top: 8px;
  font-weight: 700;
  color: var(--text);
}

#item .summary-line-item {
  margin-left: 8px;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes barGrow {
  from {
    transform: scaleY(0.05);
    transform-origin: bottom;
  }
  to {
    transform: scaleY(1);
    transform-origin: bottom;
  }
}

@media (min-width: 768px) {
  #appShell {
    margin-bottom: 24px;
  }

  #summaryCards {
    grid-template-columns: repeat(3, 1fr);
  }

  #dashboardGrid {
    grid-template-columns: 1fr 1.2fr;
  }

  #mobileBottomNav {
    display: none;
  }
}

@media (min-width: 1024px) {
  #appShell {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    align-items: start;
  }

  #sidebar {
    position: sticky;
    top: 12px;
  }

  #dashboardGrid {
    grid-template-columns: 320px 1fr;
  }

  #barChart {
    min-height: 320px;
  }
}
