:root {
  --bg: #0f1115;
  --card: #171a21;
  --border: #2a2e38;
  --text: #e8eaed;
  --muted: #9aa0ab;
  --accent: #d81e2c;
  --accent-dark: #6e0d14;
  --accent-gradient: linear-gradient(135deg, var(--accent), var(--accent-dark));
  --accent2: #4fd8e8;
  --good: #3ecf8e;
  --bad: #ff6b4a;
  /* Chart series -- validated CVD-safe pair (node scripts/validate_palette.js), distinct
     from --good/--bad so a series color never impersonates a status. */
  --series-income: #3987e5;
  --series-expense: #d95926;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

h1, h2, h3 { font-weight: 600; }

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

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

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1; min-width: 140px; }

input, select, textarea {
  background: #0d0f13;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  width: 100%;
}

label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }

button {
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}
button.secondary { background: #2a2e38; }
button.danger { background: var(--bad); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: rgba(255,255,255,0.03); }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.tabs button.active { background: var(--accent-gradient); color: white; border-color: var(--accent); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.draft { background: #3a3d46; color: var(--muted); }
.badge.confirmed { background: rgba(62,207,142,0.15); color: var(--good); }

.pos { color: var(--good); }
.neg { color: var(--bad); }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.muted { color: var(--muted); font-size: 13px; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
.login-box { width: 320px; }

.logo-img { display: block; height: 40px; width: auto; }
.login-logo { display: block; height: 64px; width: auto; margin: 0 auto 20px; }

.view-toggle { display: flex; gap: 6px; }
.view-toggle button { background: transparent; color: var(--muted); border: 1px solid var(--border); flex: none; width: auto; }
.view-toggle button.active { background: var(--accent-gradient); color: white; border-color: var(--accent); }

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.month-weekday { background: #0d0f13; color: var(--muted); font-size: 11px; text-transform: uppercase; text-align: center; padding: 6px 0; }
.month-cell { background: var(--card); min-height: 92px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.month-cell.empty { background: #0d0f13; }
.month-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.month-day-num { font-size: 12px; color: var(--muted); }
.month-event-chip { font-size: 11px; padding: 2px 5px; border-radius: 4px; background: rgba(255,255,255,0.06); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month-event-chip:hover { background: rgba(255,255,255,0.12); }
.month-event-chip.confirmed { border-left: 3px solid var(--good); }
.month-event-chip.draft { border-left: 3px solid var(--muted); }

@media (max-width: 560px) {
  .month-cell { min-height: 64px; font-size: 11px; }
}

/* ---------- charts ---------- */

.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.chart-legend .swatch { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.diverging-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.diverging-label { flex: 0 0 170px; font-size: 12.5px; color: var(--muted); text-align: right; }
.diverging-track { flex: 1; display: flex; align-items: center; height: 16px; min-width: 0; }
.diverging-half { flex: 1; display: flex; height: 100%; min-width: 0; }
.diverging-half.left { justify-content: flex-end; }
.diverging-half.right { justify-content: flex-start; }
.diverging-bar { height: 12px; border-radius: 3px; min-width: 2px; align-self: center; }
.diverging-zero { width: 2px; align-self: stretch; background: var(--border); flex: none; }
.diverging-value { flex: 0 0 76px; font-size: 12.5px; font-variant-numeric: tabular-nums; }

.month-chart { display: flex; align-items: flex-end; gap: 14px; height: 180px; overflow-x: auto; padding-top: 20px; }
.month-chart-group { display: flex; flex-direction: column; align-items: center; flex: none; width: 64px; height: 100%; justify-content: flex-end; }
.month-chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.month-chart-bar-wrap { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; width: 14px; }
.month-chart-bar { width: 100%; border-radius: 3px 3px 0 0; min-height: 2px; }
.month-chart-value { font-size: 9.5px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.month-chart-label { font-size: 11px; color: var(--muted); margin-top: 8px; white-space: nowrap; }
