:root {
  --ink: #1a1a1a;
  --ink-dim: #5a5a5a;
  --line: #ddd;
  --accent: #2b5a8c;
  --bg: #fafafa;
  --surface: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar .brand { font-weight: 700; }
.topbar nav { flex: 1; display: flex; gap: 1rem; }
.topbar nav a { color: var(--ink); text-decoration: none; }
.topbar nav a:hover { color: var(--accent); }

.link-button {
  background: none;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
}
.link-button:hover { color: var(--accent); }

.link-danger {
  background: none;
  border: none;
  color: #a33;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}
.link-danger:hover { color: #7a2020; }

.link-accent {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}
.link-accent:hover { color: #1e3f61; }

.link-success {
  background: none;
  border: none;
  color: #2e7d32;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}
.link-success:hover { color: #1b5e20; }

.content { max-width: 60rem; margin: 0 auto; padding: 2rem 1.5rem; }

.login-card {
  max-width: 22rem;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.login-card h1 { margin-top: 0; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; }
.login-card label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--ink-dim); }
.login-card input {
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 1rem;
}
.login-card button, .content button[type="submit"]:not(.link-button):not(.link-danger):not(.link-accent):not(.link-success) {
  padding: 0.6rem;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}
.error { color: #a33; }

.lede { color: var(--ink-dim); }

.accounts-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.accounts-table th, .accounts-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: capitalize;
  background: #eee;
}
.chip-asset { background: #dbe9f6; }
.chip-liability { background: #f6e3db; }
.chip-equity { background: #e7dbf6; }
.chip-income { background: #dbf6e0; }
.chip-expense { background: #f6dbdb; }

.report-list { list-style: none; padding: 0; }
.report-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.report-list a { font-weight: 600; color: var(--accent); text-decoration: none; }

.report-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.csv-link {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
  white-space: nowrap;
}
.csv-link:hover { background: #f0f4f8; }

.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.filter-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--ink-dim); }
.filter-form input, .filter-form select { padding: 0.4rem; border: 1px solid var(--line); border-radius: 4px; font-size: 0.95rem; }
.filter-form button { padding: 0.45rem 0.9rem; }

.entity-form {
  max-width: 32rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.25rem;
}
.entity-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; color: var(--ink-dim); }
.entity-form input, .entity-form textarea, .entity-form select {
  padding: 0.5rem; border: 1px solid var(--line); border-radius: 4px; font-size: 1rem; font-family: inherit;
}
.entity-form .checkbox-label { flex-direction: row; align-items: center; gap: 0.5rem; }
.entity-form .checkbox-label input { width: auto; }
.form-actions { display: flex; align-items: center; gap: 1rem; }
.form-actions a { color: var(--ink-dim); text-decoration: none; }
.form-actions a:hover { color: var(--accent); }

.invoice-actions { display: flex; align-items: center; gap: 1.25rem; margin-top: 1rem; }
.invoice-actions a { color: var(--accent); }
.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form input { padding: 0.4rem 0.6rem; border: 1px solid var(--line); border-radius: 4px; }

.report-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  margin-bottom: 1.5rem;
}
.report-table th, .report-table td {
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.report-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tfoot .totals td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: none; }
.report-table.net-income { margin-top: -1rem; }
.report-table.net-income tfoot .totals td { border-top: 2px solid var(--ink); font-size: 1.05rem; }
