/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:   #228b56;
  --green-l: #e8f5ef;
  --red:     #c0392b;
  --red-l:   #fdecea;
  --grey:    #6b7280;
  --border:  #e5e7eb;
  --bg:      #f9fafb;
  --white:   #ffffff;
  --text:    #111827;
  --radius:  8px;
  --shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
header {
  background: var(--green);
  color: #fff;
  padding: .75rem 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
.header-inner {
  max-width: 960px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -.5px; }
header nav a {
  color: rgba(255,255,255,.9);
  text-decoration: none;
  margin-left: 1.25rem;
  font-size: .9rem;
}
header nav a:hover { color: #fff; text-decoration: underline; }

/* ─── Main ───────────────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

/* ─── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-success { background: var(--green-l); color: #145a32; border: 1px solid #a9d9bc; }
.alert-error   { background: var(--red-l);   color: #7b241c; border: 1px solid #f5c6c2; }

/* ─── Card ────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 1rem;
}
.card--narrow { max-width: 480px; }

/* ─── Form ────────────────────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}
.form-group { display: flex; flex-direction: column; gap: .35rem; min-width: 140px; }
.form-group--wide { flex: 1; }
.form-group--btn { justify-content: flex-end; }
.entry-form--stacked .form-group { margin-bottom: .75rem; }

label { font-size: .8rem; font-weight: 600; color: var(--grey); }

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"] {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
  background: var(--white);
  color: var(--text);
}
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(34,139,86,.15); }

/* ─── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--green); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger    { background: var(--red);   color: #fff; }
.btn-primary:hover, .btn-danger:hover { opacity: .88; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

.form-actions { display: flex; gap: .75rem; margin-top: .5rem; }

/* ─── Table ───────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  text-align: left;
  padding: .5rem .75rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--grey);
  border-bottom: 2px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: .6rem .75rem; vertical-align: middle; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--green); }
.actions { display: flex; gap: .4rem; }
.empty { color: var(--grey); font-size: .9rem; padding: .5rem 0; }

/* ─── Chart header with year filter ─────────────────────────────────────────── */
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}
.chart-header h2 { margin-bottom: 0; }

.year-filter {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}
.year-btn {
  display: inline-block;
  padding: .25rem .6rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--border);
  color: var(--text);
  transition: background .15s, color .15s;
}
.year-btn:hover { background: #d1d5db; }
.year-btn.active { background: var(--green); color: #fff; }

/* ─── Chart ───────────────────────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 280px; }

/* ─── Footer ──────────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1rem;
  color: var(--grey);
  font-size: .8rem;
}

/* ─── Login page ──────────────────────────────────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-box h1 { font-size: 1.6rem; margin-bottom: .25rem; }
.login-box .subtitle { color: var(--grey); font-size: .9rem; margin-bottom: 1.5rem; }
.login-box label { display: block; text-align: left; margin-bottom: .35rem; font-size: .8rem; font-weight: 600; color: var(--grey); }
.login-box input[type="password"] { width: 100%; margin-bottom: 1rem; }
.login-box button { width: 100%; padding: .65rem; font-size: 1rem; }
