html,
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
a,
button,
label,
input,
textarea {
  font-family: inherit !important;
}



:root {
  /* Light theme colors */
  --bg-primary: #f8fafc;
  --bg-secondary: #f8f8f8;
  --bg-tertiary: #f1f5f9;
  --bg-quaternary: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-quaternary: #94a3b8;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --accent-blue: #3b82f6;
  --accent-blue-hover: #5981d7;
  --accent-green: #10b981;
  --accent-red: #e86767;
  --accent-orange: #ce9d49;
  --accent-purple: #957eca;
}

.dark-theme {
  /* Enhanced dark theme colors for better readability */
  --bg-primary: #000000;
  --bg-secondary: #292929;
  --bg-tertiary: #334155;
  --bg-quaternary: #475569;
  --text-primary: #f8fafc;
  --text-secondary: #e2e8f0;
  --text-tertiary: #cbd5e1;
  --text-quaternary: #94a3b8;
  --border-color: #475569;
  --border-light: #64748b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  --accent-blue: #60a5fa;
  --accent-blue-hover: #3b82f6;
  --accent-green: #34d399;
  --accent-red: #f87171;
  --accent-orange: #fbbf24;
  --accent-purple: #a78bfa;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  width: 100vw;
  min-height: 100vh;
  margin: 0;
  /* Ensures background fills the viewport even if not much content */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #121212;
  /* Fallback for browsers that don't support gradients */
  background: linear-gradient(135deg,
      #121212 25%,
      #1a1a1a 25%,
      #1a1a1a 50%,
      #121212 50%,
      #121212 75%,
      #1a1a1a 75%,
      #1a1a1a);
  background-size: 40px 40px;
  animation: move 4s linear infinite;
}

body.light-theme {
  background: #ffffff;
  /* fallback if gradients unsupported */
  background: linear-gradient(135deg,
      #ffffff 25%,
      #f8f8f8 25%,
      #f8f8f8 50%,
      #ffffff 50%,
      #ffffff 75%,
      #f8f8f8 75%,
      #f8f8f8);
  background-size: 40px 40px;
  animation: move 4s linear infinite;
}


/* Keyframes for the animated movement effect */
@keyframes move {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 40px 40px;
  }
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  animation: fadeInUp 0.8s ease-out;
}

/* Enhanced Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleInBounce {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }

  50% {
    transform: scale(1.05);
  }

  70% {
    transform: scale(0.9);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulseGlow {

  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }

  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }

  100% {
    background-position: calc(200px + 100%) 0;
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes wiggle {

  0%,
  7% {
    transform: rotateZ(0);
  }

  15% {
    transform: rotateZ(-15deg);
  }

  20% {
    transform: rotateZ(10deg);
  }

  25% {
    transform: rotateZ(-10deg);
  }

  30% {
    transform: rotateZ(6deg);
  }

  35% {
    transform: rotateZ(-4deg);
  }

  40%,
  100% {
    transform: rotateZ(0);
  }
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 30px;
  animation: slideInLeft 0.8s ease-out;
}

.logo {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-blue);
  margin-bottom: 5px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  display: inline-block;
}

.logo:hover {
  transform: scale(1.1);
  text-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
  animation: float 2s ease-in-out infinite;
}

.tagline {
  color: var(--text-secondary);
  font-size: 1.1rem;
  animation: fadeInUp 1s ease-out 0.3s both;
}

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 55px;
  height: 55px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
  z-index: 1000;
  overflow: hidden;
}

.theme-toggle::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.theme-toggle:hover::before {
  transform: translateX(100%);
}

.theme-toggle:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-blue);
  animation: pulseGlow 2s infinite;
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-icon {
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
}

.dark-theme .theme-icon {
  transform: rotate(360deg);
}

/* Summary Cards */
.summary {
  display: flex;
  flex-direction: row;
  gap: 15px;
  justify-content: center;
  flex-wrap: nowrap;
  margin-bottom: 30px;
}

.summary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 300px;
  width: 300px;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), filter 0.4s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.10);
  padding: 20px 10px;
  background: #3498db;
  border: none;
  position: relative;
  overflow: visible;
}

.summary-card.owe {
  background: #e74c3c;
}

.summary-card.owed {
  background: #2ecc71;
}

.summary-card.friends {
  background: #9b59b6;
}

.summary-card h3 {
  font-size: 0.9em;
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
  color: #fff;
}

.summary-card .amount,
.summary-card .count {
  font-size: 1.3em;
  font-weight: bold;
  margin-bottom: 4px;
  color: #fff;
  transition: transform 0.3s, text-shadow 0.3s;
}

.summary-card .period,
.summary-card .label {
  font-size: 0.75em;
  color: rgba(255, 255, 255, 0.85);
}

/* Card Scale on Hover */
.summary-card:hover {
  transform: scale(1.15);
  z-index: 2;
}

/* Sibling Blur -- ONLY active when a card is hovered */
.summary:hover>.summary-card:not(:hover) {
  filter: blur(4px);
  transform: scale(0.93);
}

/* Responsive for mobile: stack cards vertically */
@media (max-width: 600px) {
  .summary {
    flex-direction: column;
    align-items: center;
    gap: 15px;
  }
}


/* Action Buttons */
.actions {
  display: flex;
  gap: 15px;
  margin-bottom: 40px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 14px 28px;
  border: none;
  border-radius: 15px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  display: inline-block;
  position: relative;
  overflow: hidden;
  transform: translateY(0);
}

.btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(-1px);
  transition: transform 0.1s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-blue-hover), #7c3aed);
  box-shadow: 0 15px 35px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-quaternary);
  border-color: var(--accent-blue);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.btn-tertiary {
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-red));
  color: white;
  box-shadow: var(--shadow);
}

.btn-tertiary:hover {
  background: linear-gradient(135deg, #f59e0b, #dc2626);
  box-shadow: 0 15px 35px rgba(245, 158, 11, 0.4);
}

.btn-quaternary {
  background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
  color: white;
  box-shadow: var(--shadow);
}

.btn-quaternary:hover {
  background: linear-gradient(135deg, #a78bfa, #6d28d9);
  box-shadow: 0 15px 35px rgba(139, 92, 246, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-red), #dc2626);
  color: white;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #f87171, #b91c1c);
  box-shadow: 0 15px 35px rgba(239, 68, 68, 0.4);
}

/* Sections */
.balances,
.recent-expenses {
  background: var(--bg-secondary);
  padding: 25px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
  transition: all 0.3s ease;
  animation: slideInRight 0.8s ease-out;
  position: relative;
  overflow: hidden;
}

.balances:hover,
.recent-expenses:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.balances h2,
.recent-expenses h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
  position: relative;
}

.balances h2::after,
.recent-expenses h2::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  border-radius: 2px;
  animation: slideInLeft 0.8s ease-out 0.5s both;
}

.balances-list,
.expenses-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.balance-item,
.expense-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  background: var(--bg-tertiary);
  border-radius: 15px;
  border-left: 4px solid transparent;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.balance-item::before,
.expense-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.balance-item:hover::before,
.expense-item:hover::before {
  transform: translateX(100%);
}

.balance-item:hover,
.expense-item:hover {
  transform: translateX(8px) scale(1.02);
  box-shadow: var(--shadow-md);
}

.balance-item:active,
.expense-item:active {
  transform: translateX(4px) scale(0.98);
}

.balance-item.positive {
  border-left-color: var(--accent-green);
  background: linear-gradient(135deg, var(--bg-tertiary), rgba(16, 185, 129, 0.1));
}

.balance-item.negative {
  border-left-color: var(--accent-red);
  background: linear-gradient(135deg, var(--bg-tertiary), rgba(239, 68, 68, 0.1));
}

.expense-item {
  border-left-color: var(--accent-blue);
}

.balance-name,
.expense-details h4 {
  font-weight: 600;
  color: var(--text-primary);
}

.balance-amount,
.expense-amount {
  font-weight: 700;
  font-size: 1.1rem;
  transition: all 0.3s ease;
}

.balance-item:hover .balance-amount,
.expense-item:hover .expense-amount {
  transform: scale(1.05);
}

.balance-item.positive .balance-amount {
  color: var(--accent-green);
}

.balance-item.negative .balance-amount {
  color: var(--accent-red);
}

.expense-amount {
  color: var(--text-primary);
}

.expense-details h4 {
  margin-bottom: 4px;
}

.expense-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.expense-meta .separator {
  color: var(--text-tertiary);
}

.no-data {
  text-align: center;
  color: var(--text-quaternary);
  font-style: italic;
  padding: 40px 20px;
  animation: fadeInUp 1s ease-out;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  animation: fadeInUp 0.3s ease-out;
}

.modal-content {
  background: var(--bg-secondary);
  margin: 5% auto;
  padding: 0;
  border-radius: 25px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s ease;
  animation: scaleInBounce 0.4s ease-out;
  border: 1px solid var(--border-color);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
  border-radius: 25px 25px 0 0;
}

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.close {
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  position: relative;
  /* Fix: Prevent position change on hover */
  transform-origin: center;
}

.close:hover {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
  /* Fix: Use rotate instead of transform to maintain position */
  transform: rotate(90deg) scale(1.1);
}

.close:active {
  transform: rotate(90deg) scale(0.9);
}

.modal-form {
  padding: 25px;
}

.modal-body {
  padding: 25px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
  padding: 20px 25px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  border-radius: 0 0 25px 25px;
}

.form-group {
  margin-bottom: 20px;
  animation: slideInLeft 0.4s ease-out;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
  transform: translateY(-2px);
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 150px;
  overflow-y: auto;
  padding: 15px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 12px;
  border-radius: 10px;
  transition: all 0.3s ease;
}

.checkbox-item:hover {
  background: var(--bg-tertiary);
  transform: translateX(8px);
}

.checkbox-item input[type="checkbox"] {
  width: auto;
  margin: 0;
  transform: scale(1.3);
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* Large Modal for History */
.large-modal {
  max-width: 800px;
  width: 95%;
}

/* Settlement Modal Styles */
.settlement-summary {
  margin-bottom: 20px;
  padding: 18px;
  background: var(--bg-tertiary);
  border-radius: 15px;
  border-left: 4px solid var(--accent-blue);
  animation: slideInLeft 0.5s ease-out;
}

.settlement-summary h3 {
  color: var(--text-primary);
  margin-bottom: 8px;
}

.settlement-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.settlement-expenses-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.settlement-expense-item {
  display: flex;
  align-items: center;
  padding: 18px;
  background: var(--bg-tertiary);
  border-radius: 15px;
  margin-bottom: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid transparent;
  cursor: pointer;
}

.settlement-expense-item:hover {
  transform: translateX(8px) scale(1.02);
  box-shadow: var(--shadow);
}

.settlement-expense-item.selected {
  border-left-color: var(--accent-green);
  background: linear-gradient(135deg, var(--bg-tertiary), rgba(16, 185, 129, 0.1));
  transform: translateX(8px);
}

.settlement-checkbox {
  margin-right: 15px;
  transform: scale(1.3);
  cursor: pointer;
}

.settlement-expense-details {
  flex: 1;
}

.settlement-expense-details h4 {
  color: var(--text-primary);
  margin-bottom: 4px;
  font-weight: 600;
}

.settlement-expense-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
  align-items: center;
}

.settlement-expense-amount {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.settlement-expense-item:hover .settlement-expense-amount {
  transform: scale(1.05);
}

.settlement-expense-amount.positive {
  color: var(--accent-green);
}

.settlement-expense-amount.negative {
  color: var(--accent-red);
}

.settlement-totals {
  border-top: 2px solid var(--border-color);
  padding-top: 15px;
  margin-top: 15px;
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-quaternary));
  border-radius: 15px;
  padding: 20px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 1rem;
}

.total-row.final-total {
  border-top: 1px solid var(--border-color);
  margin-top: 10px;
  padding-top: 15px;
  font-weight: 700;
  font-size: 1.1rem;
}

.total-row .amount {
  font-weight: 600;
  transition: all 0.3s ease;
}

.final-total .amount {
  font-size: 1.3rem;
  animation: pulseGlow 2s infinite;
}

/* History Modal Styles */
.history-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
  padding: 20px;
  background: var(--bg-tertiary);
  border-radius: 15px;
  animation: slideInLeft 0.5s ease-out;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-group label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.filter-group select {
  padding: 10px 14px;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.filter-group select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.expense-history-list {
  max-height: 500px;
  overflow-y: auto;
}

.history-item {
  padding: 18px;
  background: var(--bg-tertiary);
  border-radius: 15px;
  margin-bottom: 12px;
  border-left: 4px solid var(--accent-blue);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.history-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  transition: left 0.6s;
}

.history-item:hover::before {
  left: 100%;
}

.history-item:hover {
  transform: translateX(8px) scale(1.02);
  box-shadow: var(--shadow);
}

.history-item.settlement {
  border-left-color: var(--accent-green);
  background: linear-gradient(135deg, var(--bg-tertiary), rgba(16, 185, 129, 0.05));
}

.history-item.edit {
  border-left-color: var(--accent-orange);
  background: linear-gradient(135deg, var(--bg-tertiary), rgba(245, 158, 11, 0.05));
}

.history-item.expense {
  border-left-color: var(--accent-blue);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.history-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.history-type {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 15px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  transition: all 0.3s ease;
}

.history-type:hover {
  transform: scale(1.05);
}

.history-type.expense {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-blue);
}

.history-type.settlement {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
}

.history-type.edit {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-orange);
}

.history-details {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.4;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.history-amount {
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.history-item:hover .history-amount {
  transform: scale(1.05);
}

.history-amount.positive {
  color: var(--accent-green);
}

.history-amount.negative {
  color: var(--accent-red);
}

.history-amount.neutral {
  color: var(--text-primary);
}

/* Edit History Styles */
.edit-history {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.edit-history h4 {
  color: var(--text-primary);
  margin-bottom: 15px;
  font-size: 1.1rem;
}

.edit-history-list {
  max-height: 200px;
  overflow-y: auto;
}

.edit-history-item {
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border-left: 3px solid var(--accent-blue);
  transition: all 0.3s ease;
}

.edit-history-item:hover {
  transform: translateX(5px);
  background: var(--bg-quaternary);
}

.edit-timestamp {
  font-weight: 600;
  color: var(--accent-blue);
}

/* Friends Management Styles */
.friends-management-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.friend-management-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  background: var(--bg-tertiary);
  border-radius: 15px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.friend-management-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  transition: left 0.6s;
}

.friend-management-item:hover::before {
  left: 100%;
}

.friend-management-item:hover {
  transform: translateX(8px) scale(1.02);
  box-shadow: var(--shadow);
}

.friend-info {
  display: flex;
  flex-direction: column;
}

.friend-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.friend-balance {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.friend-actions {
  display: flex;
  gap: 10px;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 10px;
  transition: all 0.3s ease;
}

.btn-small:hover {
  transform: translateY(-2px);
}

/* Balance Details Enhancements */
.balance-details {
  margin-bottom: 20px;
}

.balance-detail-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px;
  margin-bottom: 12px;
  background: var(--bg-tertiary);
  border-radius: 15px;
  border-left: 4px solid var(--accent-blue);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.balance-detail-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  transition: left 0.6s;
}

.balance-detail-item:hover::before {
  left: 100%;
}

.balance-detail-item:hover {
  transform: translateX(8px) scale(1.02);
  box-shadow: var(--shadow);
}

.balance-detail-info h4 {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.balance-detail-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.balance-detail-amount {
  font-weight: 700;
  font-size: 1.1rem;
  text-align: right;
  transition: all 0.3s ease;
}

.balance-detail-item:hover .balance-detail-amount {
  transform: scale(1.05);
}

.balance-detail-amount.positive {
  color: var(--accent-green);
}

.balance-detail-amount.negative {
  color: var(--accent-red);
}

.balance-summary {
  border-top: 2px solid var(--border-color);
  padding-top: 20px;
  margin-top: 20px;
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-quaternary));
  border-radius: 15px;
  padding: 20px;
  animation: scaleInBounce 0.5s ease-out;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

.summary-label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.summary-amount {
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.summary-amount:hover {
  transform: scale(1.05);
}

.summary-amount.positive {
  color: var(--accent-green);
}

.summary-amount.negative {
  color: var(--accent-red);
}

/* Category badge styling */
.expense-category {
  display: inline-block;
  background: var(--bg-quaternary);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 8px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.expense-category:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Enhanced category colors for dark mode compatibility */
.category-food {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
}

.category-groceries {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #065f46;
}

.category-travel {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1e40af;
}

.category-transportation {
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  color: #3730a3;
}

.category-shopping {
  background: linear-gradient(135deg, #fce7f3, #fbcfe8);
  color: #be185d;
}

.category-entertainment {
  background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
  color: #7c2d12;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .logo {
    font-size: 2rem;
  }

  .summary {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
    align-items: center;
  }

  .btn {
    width: 100%;
    max-width: 300px;
  }

  .modal-content {
    margin: 10% auto;
    width: 95%;
    border-radius: 20px;
  }

  .form-actions,
  .modal-footer {
    flex-direction: column;
  }

  .expense-item,
  .balance-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .balance-detail-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .balance-detail-amount {
    text-align: left;
  }

  .friend-management-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .friend-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .large-modal {
    width: 98%;
    margin: 2% auto;
  }

  .history-filters {
    grid-template-columns: 1fr;
  }

  .settlement-expense-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .settlement-checkbox {
    margin-right: 0;
    margin-bottom: 10px;
  }

  .history-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .history-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
}

@media (max-width: 480px) {

  .modal-header,
  .modal-form,
  .modal-body {
    padding: 20px;
  }

  .summary-card,
  .balances,
  .recent-expenses {
    padding: 20px;
  }

  .expense-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .expense-category {
    margin-left: 0;
    margin-top: 4px;
  }

  .theme-toggle {
    top: 15px;
    right: 15px;
    width: 50px;
    height: 50px;
  }
}

/* Loading and transition states */
.loading {
  opacity: 0.7;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Notification enhancements */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: linear-gradient(135deg, var(--accent-green), #059669);
  color: white;
  padding: 15px 20px;
  border-radius: 15px;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  font-weight: 600;
  animation: slideInRight 0.4s ease-out;
  border-left: 4px solid rgba(255, 255, 255, 0.3);
  transform: translateX(0);
}

.notification.error {
  background: linear-gradient(135deg, var(--accent-red), #dc2626);
}

.notification.warning {
  background: linear-gradient(135deg, var(--accent-orange), #d97706);
}

/* Settlement status indicators */
.settlement-status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-left: 8px;
  transition: all 0.3s ease;
}

.settlement-status:hover {
  transform: scale(1.05);
}

.settlement-status.settled {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
}

.settlement-status.partial {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-orange);
}

.settlement-status.pending {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
}

/* Interactive elements */
.interactive-glow {
  position: relative;
  overflow: hidden;
}

.interactive-glow::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s;
}

.interactive-glow:hover::after {
  left: 100%;
}

/* Smooth scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--accent-blue);
  border-radius: 10px;
  transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue-hover);
}

/* Animated Footer with Apple Fonts and Theme Support */

@keyframes fadeInUpFooter {
  from {
    opacity: 0;
    transform: translateY(32px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.footer {
  padding: 36px 0 16px;
  text-align: center;
  animation: fadeInUpFooter 0.9s ease-out;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.05);
  transition: background 0.4s ease, color 0.3s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* CONTACT heading */
.footer-contact-title {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 2px;
  margin-bottom: 16px;
  text-transform: uppercase;
  transition: color 0.3s, text-shadow 0.3s;
}

.footer-contact-title:hover {
  transform: scale(1.1);
  text-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
  animation: float 2s ease-in-out infinite;
}

/* Icons container */
.footer-icons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

/* Individual icon styling */
.footer-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
}

/* Copyright text */
.footer-copy,
.footer-copyright {
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  transition: color 0.3s;
  opacity: 0;
  animation: fadeInUpFooter 0.6s 0.3s forwards;
}

/* Dark Theme */
body.dark-theme .footer {
  background-color: #1e1f24;
  color: #f1f1f1;
}

body.dark-theme .footer-contact-title {
  color: #5ef2c8;
}

body.dark-theme .footer-icon {
  filter: grayscale(5%) brightness(0.92) contrast(1.1);
}

/* Light Theme */
body.light-theme .footer {
  background-color: #000000;
  color: #222;
}

body.light-theme .footer-contact-title {
  color: #00b894;
}

body.light-theme .footer-icon {
  filter: grayscale(30%) brightness(0.9) contrast(1.2);
}

body.light-theme .footer-copyright {
  color: white;
}

/* Responsive for mobile */
@media (max-width: 600px) {
  .footer-icons {
    gap: 12px;
  }

  .footer-contact-title {
    font-size: 1.05rem;
  }
}


@media (max-width: 650px) {
  .form-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    /* space between stacked buttons */
    width: 100%;
  }

  .form-actions button,
  .form-actions .btn {
    width: 100%;
    max-width: 300px;
    /* keeps buttons from stretching too wide on tablets */
    margin: 0 auto;
    box-sizing: border-box;
  }
}

/* From Uiverse.io by cssbuttons-io */
.button {
  display: inline-block;
  padding: 12px 24px;
  border: 1px solid #4f4f4f;
  border-radius: 4px;
  transition: all 0.2s ease-in;
  position: relative;
  overflow: hidden;
  font-size: 19px;
  cursor: pointer;
  color: black;
  z-index: 1;
}

.button:before {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%) scaleY(1) scaleX(1.25);
  top: 100%;
  width: 140%;
  height: 180%;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  display: block;
  transition: all 0.5s 0.1s cubic-bezier(0.55, 0, 0.1, 1);
  z-index: -1;
}

.button:after {
  content: "";
  position: absolute;
  left: 55%;
  transform: translateX(-50%) scaleY(1) scaleX(1.45);
  top: 180%;
  width: 160%;
  height: 190%;
  background-color: #000000;
  border-radius: 50%;
  display: block;
  transition: all 0.5s 0.1s cubic-bezier(0.55, 0, 0.1, 1);
  z-index: -1;
}

.button:hover {
  color: #ffffff;
  border: 1px solid #000000;
}

.button:hover:before {
  top: -35%;
  background-color: #000000;
  transform: translateX(-50%) scaleY(1.3) scaleX(0.8);
}

.button:hover:after {
  top: -45%;
  background-color: #000000;
  transform: translateX(-50%) scaleY(1.3) scaleX(0.8);
}