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

:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e2e6ec;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- Login ---------- */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.login-card h1 {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-card input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.login-card button {
  width: 100%;
  margin-top: 0.5rem;
}

.error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  text-align: center;
}

/* ---------- Header ---------- */

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.15rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#user-display {
  font-size: 0.85rem;
  color: var(--muted);
}

#logout-btn {
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

#logout-btn:hover {
  background: var(--bg);
}

/* ---------- Main ---------- */

main {
  max-width: 900px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

/* ---------- Summary ---------- */

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-card .label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.summary-card .value {
  font-size: 1.35rem;
  font-weight: 600;
}

.summary-card.income .value { color: var(--green); }
.summary-card.expense .value { color: var(--red); }
.summary-card.balance .value { color: var(--primary); }

/* ---------- Card ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-size: 1.05rem;
  margin-bottom: 1rem;
}

/* ---------- Form ---------- */

.form-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  flex: 0 0 auto;
}

.field.grow {
  flex: 1 1 0;
}

.field label {
  font-size: 0.8rem;
  color: var(--muted);
}

input,
select {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

button {
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  font-weight: 500;
}

button:hover {
  background: var(--primary-hover);
}

/* ---------- Table ---------- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.right {
  text-align: right;
}

.amount-income { color: var(--green); font-weight: 500; }
.amount-expense { color: var(--red); font-weight: 500; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-income { background: #dcfce7; color: var(--green); }
.badge-expense { background: #fee2e2; color: var(--red); }

.delete-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  border-radius: var(--radius);
}

.delete-btn:hover {
  background: #fee2e2;
  color: var(--red);
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1.5rem 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .summary {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
  }

  header {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
}

.screen[hidden] {
  display: none !important;
}
