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

/* ── Base ── */
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #0f0c29;
  background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  min-height: 100vh;
  color: #e2e8f0;
  position: relative;
  overflow-x: hidden;
}

/* ── Animated background blobs ── */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
  animation: drift 12s ease-in-out infinite alternate;
}
body::before {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #e94560, #ff6b6b);
  top: -150px; left: -150px;
}
body::after {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #4facfe, #00f2fe);
  bottom: -100px; right: -100px;
  animation-delay: -6s;
}

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(40px, 60px) scale(1.08); }
}

/* ── Header ── */
header {
  position: relative;
  z-index: 10;
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 1.4rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.header-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #e94560, #ff6b6b);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 16px rgba(233,69,96,0.4);
  flex-shrink: 0;
}

.header-text h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.3px;
}
.header-text p {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
  margin-top: 1px;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.tier-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, #c0392b, #7f1d1d);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 10px rgba(192,57,43,0.4);
}
.aws-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 10px rgba(217,119,6,0.4);
}

/* ── Main container ── */
main {
  position: relative;
  z-index: 5;
  max-width: 940px;
  margin: 2rem auto;
  padding: 0 1rem 3rem;
  display: grid;
  gap: 1.5rem;
}

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.stat-card {
  border-radius: 16px;
  padding: 1.25rem 1.4rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-3px); }

.stat-card::after {
  content: '';
  position: absolute;
  top: -24px; right: -24px;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
}

.stat-card.sc-total {
  background: linear-gradient(135deg, #e94560, #c0392b);
}
.stat-card.sc-count {
  background: linear-gradient(135deg, #4facfe, #00a8cc);
}
.stat-card.sc-cat {
  background: linear-gradient(135deg, #43e97b, #1a9e4e);
}

.stat-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}
.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  margin-top: 0.2rem;
  line-height: 1.1;
  word-break: break-all;
}

/* ── Cards ── */
.card {
  background: rgba(255,255,255,0.97);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
}

/* decorative top stripe */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #e94560, #4facfe, #43e97b);
}

.card h2 {
  font-size: 1rem;
  font-weight: 800;
  color: #1a1a2e;
  margin-bottom: 1.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card h2 .icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.card h2 .icon.red   { background: #fee2e2; }
.card h2 .icon.blue  { background: #dbeafe; }

/* ── Form ── */
form { display: grid; gap: 1.1rem; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field.full { grid-column: 1 / -1; }

label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, select {
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  background: #f9fafb;
  color: #111827;
  width: 100%;
}
input:focus, select:focus {
  border-color: #4facfe;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79,172,254,0.15);
}
input.error, select.error {
  border-color: #e94560;
  box-shadow: 0 0 0 3px rgba(233,69,96,0.12);
}

.field-error {
  font-size: 0.76rem;
  color: #e94560;
  min-height: 1rem;
  font-weight: 500;
}

/* ── Buttons ── */
.btn-row { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 0.4rem; }

button {
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}
button:active { transform: scale(0.96); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #c0392b, #7f1d1d);
  color: #fff;
  box-shadow: 0 4px 14px rgba(192,57,43,0.4);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(192,57,43,0.55);
  transform: translateY(-1px);
}
.btn-danger {
  background: linear-gradient(135deg, #c0392b, #7f1d1d);
  color: #fff;
  box-shadow: 0 3px 10px rgba(192,57,43,0.35);
}
.btn-danger:hover:not(:disabled) { opacity: 0.88; }

.btn-ghost {
  background: transparent;
  color: #4b5563;
  border: 2px solid #e5e7eb;
}
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; border-color: #d1d5db; }

.btn-outline-blue {
  background: transparent;
  color: #4facfe;
  border: 2px solid #4facfe;
  font-size: 0.8rem;
  padding: 0.4rem 1rem;
}
.btn-outline-blue:hover:not(:disabled) { background: #0369a1; color: #fff; border-color: #0369a1; }

/* ── Alert banner ── */
#alert {
  display: none;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
#alert.success {
  background: #d1fae5;
  color: #065f46;
  border-left: 4px solid #10b981;
}
#alert.failure {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid #e94560;
}

/* ── Table header row ── */
.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid #f0f0f0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead tr {
  background: linear-gradient(90deg, #1a1a2e, #302b63);
  color: #fff;
}
th {
  padding: 0.85rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
}
td { padding: 0.75rem 1rem; border-bottom: 1px solid #f3f4f6; white-space: nowrap; color: #374151; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8faff; }

/* ── Category badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-Food          { background: #fef3c7; color: #92400e; }
.badge-Travel        { background: #dbeafe; color: #1e40af; }
.badge-Entertainment { background: #f3e8ff; color: #6b21a8; }
.badge-Shopping      { background: #fce7f3; color: #9d174d; }
.badge-Health        { background: #d1fae5; color: #065f46; }
.badge-Utilities     { background: #e0e7ff; color: #3730a3; }
.badge-Other         { background: #f1f5f9; color: #475569; }

/* ── Amount cell ── */
.amount-cell {
  font-weight: 700;
  color: #1a1a2e;
}

/* ── Delete row button ── */
.btn-icon {
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
  line-height: 1;
}
.btn-icon:hover { background: #fee2e2; color: #9f1239; }

/* ── States ── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: #9ca3af;
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }

#loading {
  text-align: center;
  padding: 2rem;
  color: #9ca3af;
}
.spinner {
  display: inline-block;
  width: 28px; height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: #4facfe;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 0.6rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ── */
footer {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 1.5rem;
  font-size: 0.76rem;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.3px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .stats-row { grid-template-columns: 1fr; }
  .form-row  { grid-template-columns: 1fr; }
  .btn-row   { flex-direction: column; }
  .table-header { flex-direction: column; align-items: flex-start; }
  header { flex-wrap: wrap; }
  .header-right { margin-left: 0; }
}
