:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --border: #e2e0db;
  --text: #24231f;
  --muted: #6b6a65;
  --accent: #2f6f4f;
  --accent-dark: #234f39;
  --danger: #b3432b;
  --debit: #24231f;
  --credit: #2f6f4f;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.25rem;
  margin: 0;
}

header .user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  gap: 1.5rem;
}

section.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

section.panel h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

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

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

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

tbody tr:hover {
  background: #fafaf8;
  cursor: pointer;
}

td.amount, th.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.balance-positive { color: var(--credit); }
.balance-negative { color: var(--danger); }

form.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
  align-items: end;
}

form.inline-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

form.inline-form label {
  font-size: 0.78rem;
  color: var(--muted);
}

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

button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: #f0efec;
  color: var(--text);
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #8c3521;
}

a.secondary-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

a.secondary-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

#totp-qr {
  display: block;
  margin: 0.75rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  background: #fff;
}

ul.backup-codes {
  columns: 2;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
  font-variant-numeric: tabular-nums;
}

ul.backup-codes li {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 0.2rem 0;
}

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

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 320px;
}

.login-card h1 {
  font-size: 1.3rem;
  margin: 0 0 1.25rem;
  text-align: center;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-card form[hidden] {
  display: none;
}

.login-card label {
  font-size: 0.82rem;
  color: var(--muted);
}

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

.login-card p.hint {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin: 0.5rem 0 0;
}

/* --- Transaction detail dialog --- */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: 420px;
  max-width: 90vw;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

dialog .dialog-body {
  padding: 1.25rem;
}

dialog h3 {
  margin-top: 0;
}

dialog .lines-table td:first-child {
  color: var(--muted);
}

dialog footer {
  margin-top: 1rem;
  text-align: right;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

dialog form > div {
  margin-bottom: 0.75rem;
}

dialog form label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

dialog form input,
dialog form select {
  width: 100%;
}
