*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --page:            #0d0d0d;
  --surface:         #1a1a19;
  --text-primary:    #ffffff;
  --text-secondary:  #c3c2b7;
  --text-muted:      #898781;
  --gridline:        #2c2c2a;
  --baseline:        #383835;
  --border:          rgba(255,255,255,0.10);
  --series-1:        #3987e5;
  --status-good:     #0ca30c;
  --status-critical: #d03b3b;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.app-name { font-weight: 600; letter-spacing: 0.02em; color: var(--text-primary); }
.logout-link { color: var(--text-muted); text-decoration: none; font-size: 13px; }
.logout-link:hover { color: var(--text-primary); }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.9rem; font-weight: 500; }

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.9rem; }
.card-header h2 { margin-bottom: 0; }

.pills { display: flex; gap: 0.35rem; }
.pill {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 0.3rem 0.65rem;
  text-decoration: none;
}
.pill:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }
.pill.active { background: rgba(57,135,229,0.18); color: var(--text-primary); border-color: rgba(57,135,229,0.4); }
.pill-ghost { cursor: pointer; }
.account-switcher { margin-bottom: 0.5rem; flex-wrap: wrap; }
#new-account-form { margin-top: 0.75rem; }

/* forms */
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 12px; color: var(--text-muted); }
input, select, button {
  font-family: inherit;
  font-size: 13px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 0.5rem 0.65rem;
}
input:focus, select:focus { outline: none; border-color: rgba(57,135,229,0.5); }
button {
  background: rgba(57,135,229,0.16);
  border-color: rgba(57,135,229,0.35);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 500;
}
button:hover { background: rgba(57,135,229,0.28); }

.inline-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.settings-card { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }

.command-form { display: flex; gap: 0.6rem; margin-bottom: 0.4rem; }
.command-form input[type="text"] { flex: 1; }
.command-hint { color: var(--text-muted); font-size: 11px; margin-bottom: 1rem; }
.command-hint code { font-family: ui-monospace, monospace; }
.muted-inline { color: var(--text-muted); }
.row-actions { display: flex; gap: 0.6rem; align-items: center; white-space: nowrap; }

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  text-decoration: underline;
}
.link-btn:hover { color: var(--status-critical); }
.delete-form { display: inline; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--text-muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
td.amt-pos { color: var(--status-good); font-variant-numeric: tabular-nums; }
td.amt-neg { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
td.amt-transfer { color: var(--series-1); font-variant-numeric: tabular-nums; }
.empty { color: var(--text-muted); text-align: center; padding: 1.5rem 0; }
code { font-family: ui-monospace, monospace; background: rgba(255,255,255,0.06); padding: 0.1rem 0.3rem; border-radius: 3px; }

.transactions-table { display: block; max-height: 360px; overflow-y: auto; }
.transactions-table thead, .transactions-table tbody { display: table; width: 100%; table-layout: fixed; }

/* chart */
.viz-root { position: relative; color-scheme: dark; }
#chart { display: block; }
.gridline { stroke: var(--gridline); stroke-width: 1; }
.zero-baseline { stroke: var(--baseline); stroke-width: 1; }
.axis-label { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-area { fill: var(--series-1); opacity: 0.1; stroke: none; }
.chart-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-end-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.crosshair { stroke: var(--text-muted); stroke-width: 1; }
.chart-hover-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart-hit-area { fill: transparent; cursor: crosshair; }
.chart-empty { color: var(--text-muted); padding: 2rem 0; text-align: center; }

.chart-tooltip {
  position: absolute;
  transform: translateX(-50%);
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  pointer-events: none;
  white-space: nowrap;
}
.tooltip-value { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip-label { color: var(--text-muted); font-size: 11px; }

.warning-callout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(208,59,59,0.12);
  border: 1px solid rgba(208,59,59,0.3);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.9rem;
  font-size: 13px;
  color: var(--text-secondary);
}
.callout-icon { color: var(--status-critical); }

.flash {
  background: rgba(208,59,59,0.12);
  border-bottom: 1px solid rgba(208,59,59,0.3);
  color: var(--text-primary);
  padding: 0.6rem 1.5rem;
  font-size: 13px;
  text-align: center;
}

/* auth */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-box { display: flex; flex-direction: column; gap: 0.75rem; width: 260px; }
.auth-appname { text-align: center; font-weight: 600; margin-bottom: 0.5rem; letter-spacing: 0.02em; }
