/* reset & variables */
:root {
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary: #667eea;
  --income: #10b981;
  --expense: #ef4444;
  --text-dark: #1a202c;
  --text-medium: #2d3748;
  --text-light: #4a5568;
  --text-lighter: #718096;
  --bg-white: #fff;
  --bg-light: #f6f8fb;
  --border-color: #e2e8f0;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

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

body {
  background: var(--gradient);
  min-height: 100vh;
  font-family: "Inter", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-medium);
}

/* container & typography */
.container {
  width: 100%;
  max-width: 900px;
  background-color: var(--bg-white);
  padding: 1.5rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

h1 {
  text-align: center;
  color: var(--text-dark);
  margin-bottom: 25px;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

h2 {
  color: var(--text-medium);
  margin-bottom: 0.875rem;
  font-size: 1.1rem; font-weight: 500;
}

/* balance section */
.balance-container {
  text-align: center;
  margin-bottom: 25px;
  padding: 20px;
  background: var(--gradient);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.balance-container h1 { font-size: 2.25rem; margin: 12px 0; color: var(--bg-white); }
.balance-container h2 { color: var(--bg-white); }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.main-content { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* income & expenses */
.income, .expenses {
  background-color: var(--bg-white);
  padding: 18px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease;
}

.income:hover, .expenses:hover { transform: translateY(-2px); }
.income h3 { color: var(--income); font-size: 1rem; font-weight: 500; }
.expenses h3 { color: var(--expense); font-size: 1rem; font-weight: 500; }
.income p, .expenses p { margin-top: 6px; font-size: 1.5rem; font-weight: 600; }
.income p { color: var(--income); }
.expenses p { color: var(--expense); }

/* transaction list */
.transaction-container { height: 100%; display: flex; flex-direction: column; }

#transaction-list {
  list-style: none;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 8px;
  flex-grow: 1;
}

#transaction-list::-webkit-scrollbar { width: 8px; }
#transaction-list::-webkit-scrollbar-track { background-color: #f1f1f1; border-radius: 4px; }
#transaction-list::-webkit-scrollbar-thumb { background-color: #cbd5e0; border-radius: 4px; }
#transaction-list::-webkit-scrollbar-thumb:hover { background-color: #a0aec0; }

.transaction {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem;
  margin-bottom: 10px;
  border-radius: var(--radius-md);
  background-color: var(--bg-white);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  border-right: 5px solid;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0px); }
}

.transaction:hover { transform: translateX(4px); box-shadow: var(--shadow-md); }
.transaction.income { border-right-color: var(--income); }
.transaction.expense { border-right-color: var(--expense); }

.transaction .delete-btn {
  background: none;
  border: none;
  color: var(--expense);
  cursor: pointer;
  font-size: 1.3rem;
  opacity: 0;
  transition: all 0.2s ease;
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: 10px;
}

.transaction:hover .delete-btn { opacity: 1; }
.transaction .delete-btn:hover { background-color: #fee2e2; transform: scale(1.1); }

/* form */
.form-container {
  background: linear-gradient(135deg, var(--bg-light), #f1f4f8);
  padding: 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.form-container form { display: flex; flex-direction: column; }
.form-group { margin-bottom: 16px; }
label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-light);
  font-weight: 500;
  font-size: 0.95rem;
}

input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  background-color: var(--bg-white);
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
input:hover { border-color: #cbd5e0; }
small { color: var(--text-lighter); font-size: 0.8rem; margin-top: 4px; display: block; }

button[type="submit"] {
  width: 100%;
  padding: 12px;
  background: var(--gradient);
  color: var(--bg-white);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
  margin-top: 8px;
}

button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}
button[type="submit"]:active { transform: translateY(0); }

/* responsive */
@media (max-width: 900px) {
  .main-content { grid-template-columns: 1fr; }
  #transaction-list { max-height: 300px; }
}

@media (max-width: 480px) {
  .container { padding: 24px; }
  .summary { grid-template-columns: 1fr; gap: 16px; }
  .balance-container h1 { font-size: 2.5rem; }
  .income p, .expenses p { font-size: 1.5rem; }
  .transaction { padding: 14px 16px; }
  h1 { font-size: 1.8rem; }
}
