:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --credit: #50c878;
  --debit: #e06c75;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-start {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

header h1 { margin: 0; font-size: 1.25rem; }

.build-version {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  letter-spacing: -0.02em;
}

nav { display: flex; gap: 1rem; }

nav a {
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

nav a.active, nav a:hover { color: var(--text); background: var(--bg); }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

.grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.panel h2, .panel h3 { margin-top: 0; }

.balances {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.balance-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.balance-card .name { font-weight: 600; }
.balance-card .amount { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

.txn-form, .filter-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}

input, select, button {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

button {
  cursor: pointer;
  background: #4a90d9;
  border-color: #4a90d9;
  font-weight: 600;
}

button:hover { filter: brightness(1.1); }

.txn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.txn-table th, .txn-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.txn-table th { color: var(--muted); font-weight: 500; }

.credit { color: var(--credit); }
.debit { color: var(--debit); }

.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  border: 1px solid var(--accent);
}

.muted { color: var(--muted); }

.hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.multi-toggle {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.875rem;
}

.multi-toggle input {
  width: auto;
  margin: 0;
}

.form-error {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--debit) 15%, transparent);
  border: 1px solid var(--debit);
  color: var(--debit);
  font-size: 0.875rem;
}

.child-multiselect {
  height: 2.5rem;
  overflow: hidden;
}

.child-multiselect:focus {
  height: auto;
  min-height: 2.5rem;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.pager-disabled {
  color: var(--muted);
}

.pager-status {
  color: var(--muted);
}

.allowance-page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.allowance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.allowance-header h2 { margin: 0; }

.allowance-table td:last-child { text-align: right; }

.btn-secondary {
  background: var(--bg);
  border-color: var(--border);
  font-weight: 500;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: #4a90d9;
  font-weight: 500;
}

.edit-dialog {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  background: var(--surface);
  color: var(--text);
  max-width: 400px;
}

.edit-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.edit-dialog h3 { margin-top: 0; }

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
