:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --good: #006300;
  --bad: #d03b3b;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --good: #0ca30c;
    --bad: #e66767;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --good: #0ca30c;
  --bad: #e66767;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
}

a {
  color: var(--series-1);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}

.app-header .brand {
  font-weight: 600;
}

.app-header nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.app-header nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
}

.app-header nav a.active {
  color: var(--text-primary);
  font-weight: 600;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.stat-tile .label {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-tile .value {
  font-size: 48px;
  font-weight: 600;
  line-height: 1.1;
  margin: 4px 0;
}

.stat-tile .delta {
  font-size: 14px;
  font-weight: 600;
}

.stat-tile .delta.up {
  color: var(--good);
}

.stat-tile .delta.down {
  color: var(--bad);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.range-group {
  display: flex;
  gap: 4px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}

.range-group button {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
}

.range-group button.active {
  background: var(--surface-1);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px var(--border);
}

.account-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.account-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.account-check .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.custom-range {
  display: flex;
  gap: 8px;
  align-items: center;
}

.custom-range input[type="date"] {
  font-size: 13px;
}

.chart-wrap {
  position: relative;
  height: 360px;
}

.view-toggle {
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table th,
table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}

table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}

.table-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cell-delete {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  visibility: hidden;
}

tr:hover .cell-delete {
  visibility: visible;
}

.cell-delete:hover {
  color: var(--bad);
  background: var(--page);
}

.account-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.account-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--gridline);
}

.account-list li:last-child {
  border-bottom: none;
}

.account-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.account-type {
  color: var(--text-muted);
  font-size: 12px;
}

.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
}

.btn.primary {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #ffffff;
}

.btn.danger {
  color: var(--bad);
}

form.stacked {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
}

form.stacked label {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

form.stacked input,
form.stacked select {
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
}

.error {
  color: var(--bad);
  font-size: 13px;
}

.quick-add-table input[type="number"] {
  width: 140px;
}

.login-wrap {
  max-width: 360px;
  margin: 80px auto;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 24px 0 8px;
}
