:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #666666;
  --border: #dddddd;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --danger: #b91c1c;
  --danger-bg: #fdecea;
  --positive: #15803d;
  --negative: #b91c1c;
  --card-bg: #f8f8f8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #eaeaea;
    --muted: #a0a0a0;
    --border: #333333;
    --accent: #3b82f6;
    --accent-fg: #0b0b0b;
    --danger: #f87171;
    --danger-bg: #2a1414;
    --positive: #4ade80;
    --negative: #f87171;
    --card-bg: #1c1c1c;
  }
}

* {
  box-sizing: border-box;
}

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

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

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

header a {
  color: inherit;
  text-decoration: none;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1, h2, h3 {
  line-height: 1.25;
}

a {
  color: var(--accent);
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 420px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

input, select, button, textarea {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
}

button {
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  font-weight: 600;
  white-space: nowrap;
}

button:hover {
  opacity: 0.9;
}

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

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

.error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

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

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

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

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.amount-positive {
  color: var(--positive);
  font-weight: 600;
}

.amount-negative {
  color: var(--negative);
  font-weight: 600;
}

.table-scroll {
  overflow-x: auto;
}

.table-scroll table {
  white-space: nowrap;
}

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

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

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.tabs button {
  background: none;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 0.25rem;
}

.tabs button.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.split-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.split-row input[type="number"] {
  width: 90px;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.inline-form {
  flex-direction: row;
  align-items: flex-end;
  flex-wrap: wrap;
  max-width: none;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}
