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

:root {
  --ink: #0b0f14;
  --ink-panel: #121821;
  --ink-panel-2: #171f2b;
  --line: #263042;
  --paper: #eee7d8;
  --paper-dim: #a8a08e;
  --gold: #e3ac4c;
  --gold-dim: #8a6a2f;
  --green: #7fb88f;
  --red: #d97b6c;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 1200px 600px at 15% -10%, rgba(227, 172, 76, 0.08), transparent 60%),
    radial-gradient(ellipse 900px 500px at 100% 0%, rgba(127, 184, 143, 0.06), transparent 55%),
    var(--ink);
  color: var(--paper);
  font-family: 'IBM Plex Mono', monospace;
  min-height: 100vh;
  background-attachment: fixed;
}

h1, h2, h3, .brand {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand {
  font-size: 1.5rem;
  color: var(--gold);
  letter-spacing: 0.03em;
}

.brand small {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--paper-dim);
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ---- Login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: linear-gradient(180deg, var(--ink-panel), var(--ink-panel-2));
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2.5rem 2.75rem;
  width: 340px;
  box-shadow: var(--shadow);
  position: relative;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), transparent 70%);
}

.login-card h1 { margin: 0 0 0.25rem; }
.login-card p.sub { color: var(--paper-dim); font-size: 0.8rem; margin: 0 0 1.75rem; }

label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--paper-dim);
  margin-bottom: 0.4rem;
  margin-top: 1.1rem;
}

input[type="password"], input[type="text"], input[type="number"], select {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.6rem 0.7rem;
  color: var(--paper);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--gold-dim);
}

button {
  font-family: 'IBM Plex Mono', monospace;
  cursor: pointer;
  border: 1px solid var(--gold-dim);
  background: transparent;
  color: var(--gold);
  padding: 0.6rem 1.1rem;
  border-radius: 3px;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  transition: background 0.15s ease, color 0.15s ease;
}

button:hover { background: var(--gold); color: var(--ink); }
button.primary { width: 100%; margin-top: 1.75rem; }
button.ghost { border-color: var(--line); color: var(--paper-dim); }
button.ghost:hover { background: var(--ink-panel-2); color: var(--paper); }

.error-msg {
  color: var(--red);
  font-size: 0.78rem;
  margin-top: 0.9rem;
  min-height: 1em;
}

/* ---- Dashboard ---- */
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.75rem 5rem;
}

header.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2.5rem;
}

.balance-card {
  background: linear-gradient(160deg, var(--ink-panel), var(--ink-panel-2));
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.75rem;
}

.balance-card .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--paper-dim);
}

.balance-card .amount {
  font-family: 'Fraunces', serif;
  font-size: 3rem;
  font-weight: 600;
  color: var(--paper);
  margin: 0.25rem 0 0;
}

.balance-card .amount .cents { font-size: 1.6rem; color: var(--paper-dim); }

.grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.5rem;
}

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

.panel {
  background: var(--ink-panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1.5rem 1.6rem;
  margin-bottom: 1.5rem;
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--gold);
}

.panel h2 small {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--paper-dim);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 0.5rem;
}

#forecast-chart { width: 100%; height: 220px; display: block; }

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}

.week-day {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.6rem 0.4rem;
  text-align: center;
}

.week-day.today { border-color: var(--gold-dim); }

.week-day .dow {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--paper-dim);
}

.week-day .dom {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  color: var(--paper);
  margin: 0.15rem 0 0.35rem;
}

.week-day .bal {
  font-size: 0.78rem;
  font-weight: 600;
}

.week-day .bal.amount-neg { color: var(--red); }
.week-day .bal.amount-pos { color: var(--green); }

@media (max-width: 620px) {
  .week-strip { grid-template-columns: repeat(4, 1fr); }
}

.ai-note {
  background: rgba(227, 172, 76, 0.08);
  border-left: 2px solid var(--gold-dim);
  padding: 0.7rem 0.9rem;
  font-size: 0.8rem;
  color: var(--paper);
  border-radius: 0 3px 3px 0;
  margin-top: 0.75rem;
}

table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--line); }
th { color: var(--paper-dim); font-weight: 500; text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.08em; }
td.amount-pos { color: var(--green); }
td.amount-neg { color: var(--red); }
tr.uncategorized { background: rgba(217, 123, 108, 0.06); }
tr.todo-done td { color: var(--paper-dim); text-decoration: line-through; }

select.cat-select { font-size: 0.78rem; padding: 0.3rem 0.4rem; }

.badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--paper-dim);
}
.badge.on { border-color: var(--green); color: var(--green); }
.badge.off { border-color: var(--line); color: var(--paper-dim); }

.upload-row { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.5rem; }
.small-note { font-size: 0.72rem; color: var(--paper-dim); margin-top: 0.5rem; }

.recurring-form { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 0.5rem; margin-bottom: 1rem; align-items: end; }
.recurring-form label { margin-top: 0; }

.connections { display: flex; gap: 0.6rem; flex-wrap: wrap; }
