@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0E1B1D;
  --surface: #152628;
  --surface-hi: #1C3235;
  --line: #2A4548;
  --gold: #C9A227;
  --gold-soft: #E4C866;
  --green: #5FAE7E;
  --red: #D97B6C;
  --text: #EDEBE1;
  --muted: #8FA3A2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
}

.ff-display { font-family: 'Fraunces', serif; }
.ff-num { font-variant-numeric: tabular-nums; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.brand { font-family: 'Fraunces', serif; font-size: 20px; color: var(--gold-soft); }
.who { font-size: 12px; color: var(--muted); }
.who a { color: var(--muted); }

.tabbar {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.tabbar a {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.tabbar a.active { color: var(--gold-soft); border-bottom: 2px solid var(--gold); }

.content { padding: 20px; max-width: 640px; margin: 0 auto; padding-bottom: 60px; }

.hero {
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.hero .label { font-size: 12px; color: var(--muted); }
.hero .value { font-family: 'Fraunces', serif; font-size: 36px; color: var(--gold-soft); margin-top: 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.stat .label { font-size: 11px; color: var(--muted); }
.stat .value { font-family: 'Fraunces', serif; font-size: 18px; margin-top: 4px; }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.section-head h2 { font-family: 'Fraunces', serif; font-size: 17px; color: var(--gold-soft); margin: 0; font-weight: 600; }
.btn-add {
  background: var(--gold);
  color: #20180A;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.row .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.amt.green { color: var(--green); }
.amt.red { color: var(--red); }
.amt.gold { color: var(--gold-soft); }
.empty { color: var(--muted); font-size: 14px; }

.row-actions { display: flex; gap: 10px; margin-top: 4px; }
.row-actions a, .row-actions button {
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-family: 'Inter', sans-serif;
}
.row-actions button.danger, .row-actions a.danger { color: var(--red); }
.row-main { display: flex; justify-content: space-between; align-items: flex-start; }
.cancel-edit { font-size: 12px; color: var(--muted); text-decoration: underline; }

.cat-bar-row { margin-bottom: 12px; }
.cat-bar-row .cat-bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.cat-bar-track { height: 8px; border-radius: 999px; background: var(--line); }
.cat-bar-fill { height: 8px; border-radius: 999px; }
.cat-bar-fill.red { background: var(--red); }
.cat-bar-fill.green { background: var(--green); }

.month-select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  margin-bottom: 16px;
}

.trend-chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; margin-bottom: 8px; }
.trend-month { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend-bars { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.trend-bar { width: 10px; border-radius: 3px 3px 0 0; min-height: 2px; }
.trend-bar.green { background: var(--green); }
.trend-bar.red { background: var(--red); }
.trend-label { font-size: 10px; color: var(--muted); margin-top: 6px; }
.trend-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.trend-legend span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.trend-legend .lg-green::before { background: var(--green); }
.trend-legend .lg-red::before { background: var(--red); }

.pct-badge { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.pct-badge.pos { color: var(--green); background: rgba(95,174,126,0.15); }
.pct-badge.neg { color: var(--red); background: rgba(217,123,108,0.15); }

.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: var(--surface-hi);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 16px 26px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  text-align: center;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); color: var(--red); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.progress-track { height: 6px; border-radius: 999px; background: var(--line); margin-top: 8px; }
.progress-fill { height: 6px; border-radius: 999px; background: var(--gold); }

form.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 20px;
}
form.panel label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  margin-top: 10px;
}
form.panel input, form.panel select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.toggle-row { display: flex; gap: 8px; margin-top: 10px; }
.toggle-row label {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: 6px;
  background: var(--surface-hi);
  cursor: pointer;
  font-size: 13px;
  margin: 0;
}
.toggle-row input { display: none; }
.toggle-row input:checked + span { color: var(--gold-soft); font-weight: 600; }

.btn-submit {
  width: 100%;
  margin-top: 16px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: var(--gold);
  color: #20180A;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.login-wrap {
  max-width: 340px;
  margin: 80px auto;
  padding: 0 20px;
}
.error { color: var(--red); font-size: 13px; margin-top: 10px; }
