/* ========== Personal Finance App — Stylesheet Design =========== */

@font-face {
  font-family: "Public Sans";
  src: url("../assets/fonts/static/PublicSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("../assets/fonts/static/PublicSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --color-beige-100: #f8f4f0;
  --color-beige-500: #98908b;
  --color-grey-900: #201f24;
  --color-grey-500: #696868;
  --color-grey-300: #b3b3b3;
  --color-white: #ffffff;

  --color-green: #277c78;
  --color-cyan: #82c9d7;
  --color-yellow: #f2cdac;
  --color-navy: #626070;
  --color-red: #c94736;
  --color-purple: #826cb0;
  --color-turquoise: #597c7c;
  --color-brown: #93674f;
  --color-magenta: #934f6f;
  --color-blue: #3f82b2;
  --color-navy-grey: #97a0ac;
  --color-army-green: #7f9161;
  --color-pink: #af81ba;
  --color-gold: #cab361;
  --color-orange: #be6c49;

  --font-family:
    "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --text-preset-1-size: 32px;
  --text-preset-2-size: 20px;
  --text-preset-3-size: 16px;
  --text-preset-4-size: 14px;
  --text-preset-5-size: 12px;

  --space-50: 4px;
  --space-100: 8px;
  --space-150: 12px;
  --space-200: 16px;
  --space-250: 20px;
  --space-300: 24px;
  --space-400: 32px;
  --space-500: 40px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --sidebar-width: 300px;
  --sidebar-width-collapsed: 88px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-beige-100);
  color: var(--color-grey-900);
  font-family: var(--font-family), serif;
  font-weight: 400;
  line-height: 1.5;
}

h1,
h2,
h3,
p,
figure,
ul {
  margin: 0;
}
ul {
  list-style: none;
  padding: 0;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
img {
  display: block;
  max-width: 100%;
}
input,
select {
  font: inherit;
  color: inherit;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-white);
  color: var(--color-grey-900);
  padding: var(--space-150) var(--space-200);
  z-index: 100;
  border-radius: var(--radius-sm);
}
.skip-link:focus {
  left: var(--space-200);
  top: var(--space-200);
}

.text-preset-1 {
  font-size: var(--text-preset-1-size);
  font-weight: 700;
  line-height: 1.2;
}
.text-preset-2 {
  font-size: var(--text-preset-2-size);
  font-weight: 700;
  line-height: 1.2;
}
.text-preset-3 {
  font-size: var(--text-preset-3-size);
  font-weight: 700;
  line-height: 1.5;
}
.text-preset-4 {
  font-size: var(--text-preset-4-size);
  font-weight: 400;
  line-height: 1.5;
}
.text-preset-4-bold {
  font-size: var(--text-preset-4-size);
  font-weight: 700;
  line-height: 1.5;
}
.text-preset-5 {
  font-size: var(--text-preset-5-size);
  font-weight: 400;
  line-height: 1.5;
}
.text-preset-5-bold {
  font-size: var(--text-preset-5-size);
  font-weight: 700;
  line-height: 1.5;
}
.text-grey-500 {
  color: var(--color-grey-500);
}
.text-green {
  color: var(--color-green);
}
.text-red {
  color: var(--color-red);
}

/* ============================ App shell / layout =============================== */
.app {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.sidebar {
  background: var(--color-grey-900);
  color: var(--color-white);
  align-self: stretch;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
  padding-bottom: var(--space-300);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  width: var(--sidebar-width);
  transition: width 0.2s ease;
}
.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-100);
  padding: var(--space-500) var(--space-400) var(--space-100);
}
.sidebar__logo-mark {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--color-green);
}
.sidebar__logo-word {
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.5px;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar__nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-50);
  padding-right: var(--space-300);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  height: 56px;
  padding: var(--space-200) var(--space-400);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-left: 4px solid transparent;
  color: var(--color-grey-300);
  white-space: nowrap;
}
.nav-link svg,
.nav-link img {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.nav-link span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-link:hover {
  background: rgba(248, 244, 240, 0.1);
  color: var(--color-beige-100);
}
.nav-link.is-active {
  background: var(--color-beige-100);
  color: var(--color-grey-900);
  border-left-color: var(--color-green);
  font-weight: 700;
}

.sidebar__minimize {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  padding: var(--space-200) var(--space-400);
  color: var(--color-grey-300);
  white-space: nowrap;
}
.sidebar__minimize svg,
.sidebar__minimize img {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.sidebar__minimize:hover {
  color: var(--color-beige-100);
}

.sidebar.is-collapsed {
  width: var(--sidebar-width-collapsed);
}
.sidebar.is-collapsed .sidebar__logo-word,
.sidebar.is-collapsed .nav-link span,
.sidebar.is-collapsed .sidebar__minimize span {
  display: none;
}
.sidebar.is-collapsed .sidebar__logo {
  justify-content: center;
  padding-inline: var(--space-200);
}
.sidebar.is-collapsed .nav-link,
.sidebar.is-collapsed .sidebar__minimize {
  justify-content: center;
  padding-inline: var(--space-200);
}
.sidebar.is-collapsed .sidebar__nav {
  padding-right: 0;
}
.sidebar.is-collapsed .sidebar__minimize svg,
.sidebar.is-collapsed .sidebar__minimize img {
  transform: rotate(180deg);
}

.tabbar {
  display: none;
}
.tabbar__list li {
  flex: 1;
  min-width: 0;
}

.main {
  flex: 1;
  min-width: 0;
  padding: var(--space-400) var(--space-500);
  display: flex;
  flex-direction: column;
  gap: var(--space-400);
  align-items: center;
}
.main__title {
  width: 100%;
  max-width: 1440px;
}
.page-header {
  width: 100%;
  max-width: 1440px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-300);
  flex-wrap: wrap;
}
.page-body {
  width: 100%;
  max-width: 1440px;
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}

.main__title,
.page-header,
.page-body,
.summary,
.content,
.budgets-page-grid,
.pots-grid-page,
.filters-bar,
.tx-table-card,
.pagination,
.bills-grid {
  margin-inline: auto;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-150);
  border-radius: var(--radius-sm);
  padding: var(--space-200) var(--space-300);
  font-weight: 700;
  font-size: var(--text-preset-4-size);
  white-space: nowrap;
}
.btn-primary {
  background: var(--color-grey-900);
  color: var(--color-white);
}
.btn-primary:hover {
  background: #3a3942;
}
.btn-secondary {
  background: transparent;
  color: var(--color-grey-900);
  border: 1px solid var(--color-beige-500);
}
.btn-secondary:hover {
  background: var(--color-beige-100);
}
.btn-destroy {
  background: var(--color-red);
  color: var(--color-white);
  width: 100%;
}
.btn-destroy:hover {
  opacity: 0.85;
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: var(--space-150) var(--space-200);
  font-size: var(--text-preset-5-size);
}

.btn-tertiary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-150);
  color: var(--color-grey-500);
  font-size: var(--text-preset-4-size);
}
.btn-tertiary svg,
.btn-tertiary img {
  width: 12px;
  height: 12px;
  transform: rotate(-90deg);
}
.btn-tertiary:hover {
  color: var(--color-grey-900);
}
.btn-tertiary:hover svg path {
  stroke: var(--color-grey-900);
}

/* ---------- Summary row (overview) ---------- */
.summary {
  width: 100%;
  max-width: 1440px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-300);
}
.summary-card {
  border-radius: var(--radius-md);
  padding: var(--space-300);
  display: flex;
  flex-direction: column;
  gap: var(--space-150);
}
.summary-card--balance {
  background: var(--color-grey-900);
  color: var(--color-white);
}
.summary-card--income,
.summary-card--expenses {
  background: var(--color-white);
}
.summary-card__label {
  font-size: var(--text-preset-4-size);
}
.summary-card--balance .summary-card__label {
  color: var(--color-white);
}
.summary-card--income .summary-card__label,
.summary-card--expenses .summary-card__label {
  color: var(--color-grey-500);
}
.summary-card__value {
  font-size: var(--text-preset-1-size);
  font-weight: 700;
  line-height: 1.2;
}

.content {
  width: 100%;
  max-width: 1440px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-300);
  align-items: start;
}
.content-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}

.card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--space-400);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card__title {
  font-size: var(--text-preset-2-size);
  font-weight: 700;
}

/* ---------- Pots preview (overview) ---------- */
.pots-preview {
  display: flex;
  align-items: center;
  gap: var(--space-250);
}
.pots-total-saved {
  background: var(--color-beige-100);
  border-radius: var(--radius-md);
  height: 110px;
  width: 247px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-200);
  padding: var(--space-200);
}
.pots-total-saved svg {
  width: 40px;
  height: 40px;
  color: var(--color-green);
  flex-shrink: 0;
}
.pots-total-saved__figures {
  display: flex;
  flex-direction: column;
  gap: var(--space-100);
}
.pots-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-200);
  min-width: 0;
}

.tag-item {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  min-width: 0;
}
.tag-item__bar {
  width: 4px;
  align-self: stretch;
  border-radius: var(--space-100);
  flex-shrink: 0;
  background: var(--color-green);
}
.tag-item__text {
  display: flex;
  flex-direction: column;
  gap: var(--space-50);
  min-width: 0;
}
.tag-item__text span:first-child {
  color: var(--color-grey-500);
}

/* ---------- Transactions list (overview widget) ---------- */
.tx-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-250);
}
.tx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-200);
  padding-bottom: var(--space-250);
  border-bottom: 1px solid #f2f2f2;
}
.tx-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.tx-row__who {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  min-width: 0;
}
.tx-row__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.tx-row__name {
  font-weight: 700;
}
.tx-row__name,
.tx-table .who-cell span,
.tx-card__who span,
.bills-table .who-cell span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-row__meta {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: var(--space-50);
  flex-shrink: 0;
}
.tx-row__amount {
  font-weight: 700;
}
.tx-row__amount.is-positive {
  color: var(--color-green);
}
.tx-row__date {
  color: var(--color-grey-500);
  font-size: var(--text-preset-5-size);
}

/* ---------- Budgets donut ---------- */
.budgets-body {
  display: flex;
  align-items: center;
  gap: var(--space-200);
}
.donut-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.donut {
  position: relative;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.donut::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--donut-stops, var(--color-green) 0 100%));
}
.donut__hole {
  position: relative;
  width: 165px;
  height: 165px;
  border-radius: 50%;
  background: var(--color-white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-100);
  text-align: center;
}
.donut__amount {
  font-size: var(--text-preset-1-size);
  font-weight: 700;
}
.donut__limit {
  color: var(--color-grey-500);
  font-size: var(--text-preset-5-size);
}
.budgets-legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-200);
  flex-shrink: 0;
}

/* ---------- Recurring bills summary (overview + bills card) ---------- */
.bill-summary-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-150);
}
.bill-summary-row {
  background: var(--color-beige-100);
  border-left: 4px solid var(--color-green);
  border-radius: var(--radius-sm);
  padding: var(--space-250) var(--space-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bill-summary-row__label {
  color: var(--color-grey-500);
}
.bill-summary-row__value {
  font-weight: 700;
}

/* ======================== Budgets page ========================== */
.budgets-page-grid {
  width: 100%;
  max-width: 1440px;
  display: grid;
  grid-template-columns: minmax(320px, 480px) 1fr;
  gap: var(--space-300);
  align-items: start;
}
.budget-categories {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}
.budget-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}
.budget-card__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.budget-card__name {
  display: flex;
  align-items: center;
  gap: var(--space-150);
  font-size: var(--text-preset-2-size);
  font-weight: 700;
}
.budget-card__dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-green);
  flex-shrink: 0;
}

.card__menu {
  position: relative;
}
.card__ellipsis {
  padding: var(--space-100);
}
.card__ellipsis svg,
.card__ellipsis img {
  width: 14px;
  height: 4px;
}
.card__dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--color-white);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 140px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 5;
}
.card__dropdown.is-open {
  display: flex;
}
.card__dropdown button {
  text-align: left;
  padding: var(--space-150) var(--space-200);
  font-size: var(--text-preset-4-size);
}
.card__dropdown button:hover {
  background: var(--color-beige-100);
}
.card__dropdown button.is-destructive {
  color: var(--color-red);
}

.budget-card__maximum {
  color: var(--color-grey-500);
  font-size: var(--text-preset-4-size);
}
.progress-track {
  height: 32px;
  background: var(--color-beige-100);
  border-radius: 4px;
  padding: 4px;
}
.progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--color-green);
  width: 50%;
  max-width: 100%;
}
.progress-figures {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.progress-figures__spent {
  display: flex;
  align-items: center;
  gap: var(--space-150);
}
.progress-figures__spent .tag-item__bar {
  height: 32px;
}
.progress-figures__remaining {
  text-align: right;
}

.budget-latest {
  background: var(--color-beige-100);
  border-radius: var(--radius-sm);
  padding: var(--space-200);
  display: flex;
  flex-direction: column;
  gap: var(--space-150);
}
.budget-latest__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.budget-latest__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-150);
  border-bottom: 1px solid #e3ded9;
}
.budget-latest__row:last-of-type {
  border-bottom: none;
}
.budget-latest__who {
  display: flex;
  align-items: center;
  gap: var(--space-150);
  min-width: 0;
}
.budget-latest__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.budget-latest__meta {
  text-align: right;
}
.budget-latest__amount {
  font-weight: 700;
}
.budget-latest__date {
  color: var(--color-grey-500);
  font-size: var(--text-preset-5-size);
}

/* ======================== Pots page =============================== */
.pots-grid-page {
  width: 100%;
  max-width: 1440px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-300);
}
.pot-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}
.pot-card__saved {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pot-card__saved-value {
  font-size: var(--text-preset-1-size);
  font-weight: 700;
}
.pot-progress-track {
  height: 8px;
  background: var(--color-beige-100);
  border-radius: 4px;
}
.pot-progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--color-green);
  width: 0;
  max-width: 100%;
  transition: width 0.3s ease;
}
.pot-progress-figures {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pot-card__actions {
  display: flex;
  gap: var(--space-200);
}
.pot-card__actions .btn {
  flex: 1;
}

/* ====================== Transactions page ============================== */
.filters-bar {
  width: 100%;
  max-width: 1440px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-200);
  flex-wrap: wrap;
}
.search-field {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.search-field input {
  width: 100%;
  padding: var(--space-150) var(--space-200) var(--space-150) var(--space-400);
  border: 1px solid var(--color-beige-500);
  border-radius: var(--radius-sm);
  font-size: var(--text-preset-4-size);
}
.search-field svg {
  position: absolute;
  left: var(--space-150);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-grey-500);
}
.filters-controls {
  display: flex;
  align-items: center;
  gap: var(--space-300);
}
.select-field {
  display: flex;
  align-items: center;
  gap: var(--space-100);
}
.select-field label {
  color: var(--color-grey-500);
  font-size: var(--text-preset-4-size);
  white-space: nowrap;
}
.select-field select {
  border: 1px solid var(--color-beige-500);
  border-radius: var(--radius-sm);
  padding: var(--space-150) var(--space-200);
  font-size: var(--text-preset-4-size);
  background: var(--color-white);
}
.filter-mobile-btn {
  display: none;
  border: 1px solid var(--color-beige-500);
  border-radius: var(--radius-sm);
  padding: var(--space-150);
}

.tx-table-card {
  width: 100%;
  max-width: 1440px;
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--space-300) var(--space-400);
}
.tx-table-card {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tx-table {
  width: 100%;
  border-collapse: collapse;
}
.tx-table {
  min-width: 680px;
  margin-inline: auto;
}
.tx-table thead th {
  text-align: left;
  color: var(--color-grey-500);
  font-size: var(--text-preset-5-size);
  font-weight: 400;
  padding-bottom: var(--space-200);
  border-bottom: 1px solid #f2f2f2;
}
.tx-table thead th:last-child,
.tx-table tbody td:last-child {
  text-align: right;
}
.tx-table tbody td {
  padding-block: var(--space-200);
  border-bottom: 1px solid #f2f2f2;
  vertical-align: middle;
}
.tx-table tbody tr:last-child td {
  border-bottom: none;
}
.tx-table .who-cell {
  display: flex;
  align-items: center;
  gap: var(--space-200);
}
.tx-table .who-cell img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.tx-table .category-cell {
  color: var(--color-grey-500);
}
.tx-table .date-cell {
  color: var(--color-grey-500);
}
.tx-table .amount-cell {
  font-weight: 700;
}
.tx-table .amount-cell.is-positive {
  color: var(--color-green);
}

.pagination {
  width: 100%;
  max-width: 1440px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pagination__pages {
  display: flex;
  align-items: center;
  gap: var(--space-100);
}
.pagination__page {
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-beige-500);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-preset-4-size);
}
.pagination__page.is-active {
  background: var(--color-grey-900);
  color: var(--color-white);
  border-color: var(--color-grey-900);
}
.pagination__page:hover:not(.is-active) {
  background: var(--color-beige-100);
}
.pagination__nav {
  display: flex;
  align-items: center;
  gap: var(--space-100);
  border: 1px solid var(--color-beige-500);
  border-radius: var(--radius-sm);
  padding: var(--space-150) var(--space-200);
  font-size: var(--text-preset-4-size);
}
.pagination__nav:hover:not(:disabled) {
  background: var(--color-beige-100);
}
.pagination__nav:disabled {
  opacity: 0.4;
  cursor: default;
}
.pagination__nav svg,
.pagination__nav img {
  width: 6px;
  height: 11px;
}

/* Mobile transaction cards (shown instead of table under 640px) */
.tx-cards {
  display: none;
  flex-direction: column;
}
.tx-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-200);
  border-bottom: 1px solid #f2f2f2;
  gap: var(--space-200);
}
.tx-card:last-child {
  border-bottom: none;
}
.tx-card__who {
  display: flex;
  align-items: center;
  gap: var(--space-150);
  min-width: 0;
}
.tx-card__who img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.tx-card__meta-left {
  min-width: 0;
}
.tx-card__category {
  color: var(--color-grey-500);
  font-size: var(--text-preset-5-size);
}
.tx-card__meta-right {
  text-align: right;
  flex-shrink: 0;
}
.tx-card__date {
  color: var(--color-grey-500);
  font-size: var(--text-preset-5-size);
}

/* ===================== Recurring bills page ========================== */
.bills-grid {
  width: 100%;
  max-width: 1440px;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: var(--space-300);
  align-items: start;
}
.bills-total-card {
  background: var(--color-grey-900);
  color: var(--color-white);
}
.bills-total-card svg {
  width: 40px;
  height: 40px;
  color: var(--color-cyan);
}
.bills-total-card__value {
  font-size: var(--text-preset-1-size);
  font-weight: 700;
  margin-top: var(--space-200);
}
.bills-summary-card .bill-summary-row.is-due-soon {
  border-color: var(--color-red);
}
.bills-summary-card .bill-summary-row.is-due-soon .bill-summary-row__value {
  color: var(--color-red);
}

.bills-table-card {
  width: 100%;
}
.bills-table {
  width: 100%;
  border-collapse: collapse;
}
.bills-table {
  min-width: 520px;
  margin-inline: auto;
}
.bills-table thead th {
  text-align: left;
  color: var(--color-grey-500);
  font-size: var(--text-preset-5-size);
  font-weight: 400;
  padding-bottom: var(--space-200);
  border-bottom: 1px solid #f2f2f2;
}
.bills-table thead th:last-child,
.bills-table tbody td:last-child {
  text-align: right;
}
.bills-table tbody td {
  padding-block: var(--space-200);
  border-bottom: 1px solid #f2f2f2;
}
.bills-table tbody tr:last-child td {
  border-bottom: none;
}
.bills-table .who-cell {
  display: flex;
  align-items: center;
  gap: var(--space-200);
}
.bills-table .who-cell img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.bills-table .amount-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-100);
  font-weight: 700;
}
.bills-table .amount-cell svg {
  width: 14px;
  height: 14px;
}
.bills-table .amount-cell.is-due {
  color: var(--color-red);
}

/* ========================= Modals ============================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 31, 36, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-200);
  z-index: 50;
}
.modal-overlay.is-open {
  display: flex;
}
.modal {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--space-300);
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
  max-height: 90vh;
  overflow-y: auto;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-200);
}
.modal__title {
  font-size: var(--text-preset-2-size);
  font-weight: 700;
}
.modal__close svg,
.modal__close img {
  width: 26px;
  height: 26px;
}
.modal__close:hover svg path {
  fill: var(--color-grey-900);
}
.modal__description {
  color: var(--color-grey-500);
  font-size: var(--text-preset-4-size);
}
.modal--danger .modal__title {
  color: var(--color-red);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-100);
}

.field__label {
  font-size: var(--text-preset-5-size);
  font-weight: 700;
  color: var(--color-grey-500);
}
.field__label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field__control {
  border: 1px solid var(--color-beige-500);
  border-radius: var(--radius-sm);
  padding: var(--space-150) var(--space-200);
  font-size: var(--text-preset-4-size);
  color: var(--color-grey-900);
  background: var(--color-white);
  width: 100%;
}
.field__control:focus {
  border-color: var(--color-grey-900);
}
.field__control--prefix-wrap {
  position: relative;
}
.field__control--prefix-wrap .field__control {
  padding-left: 28px;
}
.field__prefix {
  position: absolute;
  left: var(--space-200);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-grey-500);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-100) var(--space-200);
  max-height: 280px;
  overflow-y: auto;
}
.theme-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-100) var(--space-150);
  border-radius: var(--radius-sm);
}
.theme-option:hover {
  background: var(--color-beige-100);
}
.theme-option__left {
  display: flex;
  align-items: center;
  gap: var(--space-150);
}
.theme-option__swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}
.theme-option input {
  accent-color: var(--color-grey-900);
  width: 16px;
  height: 16px;
}
.theme-option.is-taken {
  opacity: 0.4;
}
.theme-option.is-taken .theme-option__left::after {
  content: "Already used";
  font-size: 11px;
  color: var(--color-grey-500);
  margin-left: var(--space-100);
}

.modal__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-200);
}

.new-amount-box {
  background: var(--color-beige-100);
  border-radius: var(--radius-md);
  padding: var(--space-300);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-100);
  text-align: center;
}
.new-amount-box__label {
  color: var(--color-grey-500);
  font-size: var(--text-preset-4-size);
}
.new-amount-box__value {
  font-size: var(--text-preset-1-size);
  font-weight: 700;
}
.new-amount-box__target {
  color: var(--color-grey-500);
  font-size: var(--text-preset-5-size);
}
.modal-progress-track {
  height: 8px;
  background: #e3ded9;
  border-radius: 4px;
  width: 100%;
  margin-top: var(--space-150);
}
.modal-progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--color-grey-900);
  transition: width 0.2s ease;
}
.modal-progress-bar.is-over {
  background: var(--color-red);
}
.modal-progress-figures {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: var(--space-100);
  font-size: var(--text-preset-5-size);
}

/* ================= Auth pages (Sign Up/Login) ====================== */
.auth-shell { display: flex; align-items: stretch; min-height: 100vh; }

.auth-sidebar-wrap { flex: 1 0 0; max-width: 600px; display: flex; align-items: center; padding: var(--space-250); }
.auth-sidebar {
  position: sticky; top: 0; flex: 1 0 0; height: calc(100vh - var(--space-250) * 2); min-height: 480px;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: var(--space-500); border-radius: 12px; overflow: hidden;
  background: var(--color-grey-900); color: var(--color-white);
}
.auth-sidebar__bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; opacity: 0.9; }
.auth-sidebar__scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(32,31,36,0.15), rgba(32,31,36,0.55)); z-index: 0; }
.auth-sidebar > *:not(.auth-sidebar__bg):not(.auth-sidebar__scrim) { position: relative; z-index: 1; }
.auth-logo { display: inline-flex; align-items: center; gap: var(--space-100); color: var(--color-white); }
.auth-logo svg { width: 24px; height: 24px; color: var(--color-green); flex-shrink: 0; }
.auth-logo span { font-weight: 700; font-size: 24px; letter-spacing: -0.5px; }
.auth-sidebar__copy { display: flex; flex-direction: column; gap: var(--space-300); max-width: 420px; }
.auth-sidebar__copy h1 { font-size: var(--text-preset-1-size); font-weight: 700; line-height: 1.2; }
.auth-sidebar__copy p { font-size: var(--text-preset-4-size); line-height: 1.5; }

.auth-header { display: none; }

.auth-main { flex: 1 0 0; display: flex; align-items: center; justify-content: center; padding: var(--space-400) var(--space-500); }
.auth-modal { width: 100%; max-width: 560px; background: var(--color-white); border-radius: var(--radius-md); padding: var(--space-400); display: flex; flex-direction: column; gap: var(--space-400); }
.auth-modal__title { font-size: var(--text-preset-1-size); font-weight: 700; }
.auth-modal__fields { display: flex; flex-direction: column; gap: var(--space-200); }
.auth-modal__hint { font-size: var(--text-preset-5-size); color: var(--color-grey-500); text-align: right; margin-top: var(--space-50); }
.auth-modal__footer { display: flex; align-items: center; justify-content: center; gap: var(--space-100); font-size: var(--text-preset-4-size); color: var(--color-grey-500); }
.auth-modal__footer a { font-weight: 700; color: var(--color-grey-900); text-decoration: underline; }

.field__control--suffix-wrap { position: relative; }
.field__control--suffix-wrap .field__control { padding-right: 44px; }
.field__suffix-btn { position: absolute; right: var(--space-200); top: 50%; transform: translateY(-50%); padding: var(--space-50); line-height: 0; }
.field__suffix-btn svg, .field__suffix-btn img { width: 16px; height: 16px; display: block; }


/* ====================== Responsive: Tablet ====================== */
@media (max-width: 1024px) {
  .sidebar {
    display: none;
  }
  .app {
    flex-direction: column;
    align-items: stretch;
  }

  .tabbar {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-grey-900);
    padding: var(--space-100) var(--space-300) 0;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .tabbar__list {
    flex: 1;
    max-width: 800px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-100);
  }
  .tabbar .nav-link {
    flex-direction: column;
    gap: var(--space-50);
    height: auto;
    width: 100%;
    min-width: 0;
    padding: var(--space-100) var(--space-100) var(--space-150);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-left: none;
    border-bottom: 4px solid transparent;
    justify-content: center;
    text-align: center;
  }
  .tabbar .nav-link span {
    font-size: var(--text-preset-5-size);
    font-weight: 700;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tabbar .nav-link.is-active {
    border-left: none;
    border-bottom-color: var(--color-green);
  }

  .main {
    padding: var(--space-400);
  }
  .content,
  .summary,
  .main__title,
  .page-header,
  .page-body,
  .budgets-page-grid,
  .pots-grid-page,
  .filters-bar,
  .tx-table-card,
  .pagination,
  .bills-grid {
    max-width: 800px;
  }
  .content {
    grid-template-columns: 1fr;
  }
  .budgets-page-grid {
    grid-template-columns: 1fr;
  }
  .pots-grid-page {
    grid-template-columns: 1fr 1fr;
  }
  .bills-grid {
    grid-template-columns: 1fr;
  }

  .filters-controls {
    gap: var(--space-200);
  }
  .select-field label {
    display: none;
  }
  /*New style entries over here*/
  .auth-sidebar-wrap { display: none; }
  .auth-shell { flex-direction: column; }
  .auth-header { display: flex; align-items: center; justify-content: center; background: var(--color-grey-900); padding: var(--space-300) var(--space-500); border-radius: 0 0 8px 8px; }
}

/* ================== Responsive: Mobile ====================== */
@media (max-width: 640px) {
  .main {
    padding: var(--space-300) var(--space-200);
    gap: var(--space-300);
  }
  .main__title {
    text-align: center;
  }
  .summary {
    grid-template-columns: 1fr;
  }
  .summary-card {
    padding: var(--space-250);
  }
  .card {
    padding: var(--space-300) var(--space-250);
  }

  .pots-preview {
    flex-direction: column;
    align-items: stretch;
  }
  .pots-total-saved {
    width: 100%;
  }
  .pots-grid {
    grid-template-columns: 1fr;
  }
  .pots-grid-page {
    grid-template-columns: 1fr;
  }

  .budgets-body {
    flex-direction: column;
  }
  .budgets-legend {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-200);
  }

  .tabbar {
    padding: var(--space-100) var(--space-200) 0;
  }
  .tabbar .nav-link {
    width: auto;
    flex: 1;
    padding-inline: var(--space-100);
  }
  .tabbar .nav-link span {
    display: none;
  }
  .tabbar .nav-link svg,
  .tabbar .nav-link img {
    width: 24px;
    height: 24px;
  }

  .modal {
    padding: var(--space-250);
    border-radius: var(--radius-md);
  }

  .filters-bar {
    gap: var(--space-150);
  }
  .search-field {
    max-width: none;
    width: 100%;
  }
  .filters-controls .select-field:first-child label {
    display: none;
  }
  .filters-controls .select-field:nth-child(2) {
    display: none;
  }
  .filter-mobile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .filter-mobile-btn svg,
  .filter-mobile-btn img {
    width: 18px;
    height: 16px;
  }
  .filters-controls {
    width: 100%;
    justify-content: space-between;
  }

  .tx-table {
    display: none;
  }
  .tx-cards {
    display: flex;
  }
  .tx-table-card {
    padding: var(--space-250);
  }

  .pagination {
    flex-wrap: wrap;
    gap: var(--space-150);
    justify-content: center;
  }
  .pagination__nav {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }
  .pagination__pages {
    order: 2;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .pot-card__actions {
    flex-direction: column;
  }

  .page-header {
    align-items: stretch;
    justify-content: center;
    text-align: center;
  }
  .page-header > :first-child {
    width: 100%;
  }
  .page-header .btn {
    width: 100%;
  }

  .donut {
    width: 200px;
    height: 200px;
  }
  .donut__hole {
    width: 136px;
    height: 136px;
  }

  .bills-table thead {
    display: none;
  }
  .bills-table,
  .bills-table tbody,
  .bills-table tr,
  .bills-table td {
    display: block;
    width: 100%;
  }
  .bills-table tr {
    padding-block: var(--space-200);
    border-bottom: 1px solid #f2f2f2;
  }
  .bills-table td {
    border-bottom: none;
    padding: 2px 0;
  }
  .bills-table .who-cell {
    margin-bottom: var(--space-100);
  }
  .bills-table .amount-cell {
    justify-content: space-between;
  }
  .bills-table .amount-cell::before {
    content: "Due Date";
    color: var(--color-grey-500);
    font-weight: 400;
  }
}

@media (max-width: 420px) {
  .main {
    padding-inline: var(--space-150);
  }
  .card {
    padding: var(--space-250) var(--space-200);
  }
  .theme-grid {
    grid-template-columns: 1fr;
  }
  .modal {
    padding: var(--space-200);
  }
}
