/* Same colour tokens as agent-watch-web, so the hosted tools look like one family. */
:root {
  color-scheme: dark;
  --bg-canvas: #09090b;
  --bg-surface: #121215;
  --bg-subtle: #18181b;
  --border-muted: #27272a;
  --border-focus: #52525b;
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --status-error: #ef4444;
  --status-ok: #10b981;
  --brand-accent: #6366f1;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg-canvas: #ffffff;
    --bg-surface: #f4f4f5;
    --bg-subtle: #e4e4e7;
    --border-muted: #d4d4d8;
    --border-focus: #a1a1aa;
    --text-primary: #18181b;
    --text-secondary: #52525b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-surface);
}
header .brand { font-weight: 700; color: var(--text-primary); text-decoration: none; }
header nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; }
header nav a, header nav button {
  color: var(--text-secondary);
  text-decoration: none;
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
header nav a:hover, header nav button:hover { color: var(--text-primary); }
header nav form { margin: 0; }

main { max-width: 960px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
main.narrow { max-width: 400px; margin-top: 10vh; }

h1 { font-size: 1.5rem; margin: 0.25rem 0 1rem; }
h2 { font-size: 1rem; margin: 1.75rem 0 0.6rem; }
.muted { color: var(--text-secondary); font-size: 0.9em; }
.error { color: var(--status-error); }
.flash { padding: 0.6rem 0.8rem; border: 1px solid var(--status-ok); border-radius: 0.5rem; }
code { font-size: 0.9em; word-break: break-all; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; }
.card { padding: 0.9rem 1rem; border: 1px solid var(--border-muted); border-radius: 0.6rem; background: var(--bg-surface); }
.card h2 { margin: 0 0 0.25rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
.spend-total { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.spend-split { color: var(--text-secondary); font-size: 0.85rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border-muted); vertical-align: top; }
th { color: var(--text-secondary); font-weight: 600; font-size: 0.8rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.voided td { opacity: 0.5; text-decoration: line-through; }
tr.voided td:last-child { text-decoration: none; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin: 0 0.25rem 0.25rem 0;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--border-muted);
  border-radius: 999px;
  background: var(--bg-subtle);
  font-size: 0.8rem;
  white-space: nowrap;
}
.tag-remove { margin: 0 0.25rem 0.25rem 0; }
.tag-remove button { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 0 0.1rem; font-size: 1rem; line-height: 1; }
.badge { font-size: 0.7rem; text-transform: uppercase; color: var(--status-error); }

.form { display: grid; gap: 0.75rem; max-width: 520px; }
.inline-form { max-width: 640px; }
.form label { display: grid; gap: 0.25rem; font-size: 0.9rem; color: var(--text-secondary); }
.help { font-size: 0.8rem; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  border-radius: 0.4rem;
  padding: 0.5rem 0.6rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--border-focus); outline: none; }
button, .button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  color: white;
  background: var(--brand-accent);
  border: none;
  border-radius: 0.4rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  text-decoration: none;
  justify-self: start;
}
button.danger { background: var(--status-error); }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; align-items: center; }
.filters select, .filters input[type="search"] { width: auto; flex: 1 1 160px; }
.filters .check { display: flex; align-items: center; gap: 0.3rem; color: var(--text-secondary); font-size: 0.9rem; }
.filters .check input { width: auto; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; }
.facts dt { color: var(--text-secondary); }
.facts dd { margin: 0; }
.note { padding: 0.5rem 0; border-bottom: 1px solid var(--border-muted); }
.new-token { padding: 0.9rem 1rem; margin-bottom: 1rem; border: 1px solid var(--status-ok); border-radius: 0.6rem; }
.token-value { display: block; padding: 0.5rem; background: var(--bg-subtle); border-radius: 0.4rem; user-select: all; }
