:root {
  --bg: #f6f7f5; --surface: #ffffff; --surface-2: #eef1ee; --ink: #16231f; --muted: #5b6b66; --line: #dbe2de;
  --accent: #0b6e5f; --accent-ink: #ffffff; --accent-soft: #dcefea;
  --held: #8a5a00; --held-bg: #fdf0d2; --paid: #0b6e3a; --paid-bg: #d9f1e3; --released: #3b5a78; --released-bg: #dfe9f3;
  --refunded: #6b3a8a; --refunded-bg: #ece0f4; --planned: #55625e; --planned-bg: #e8ecea; --danger: #a4262c; --danger-bg: #fbe3e4;
  --radius: 14px; --shadow: 0 1px 2px rgba(20,40,34,.06), 0 6px 20px rgba(20,40,34,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1613; --surface: #17211d; --surface-2: #1e2b26; --ink: #e8f0ec; --muted: #9fb2aa; --line: #2b3a34;
    --accent: #3fb59f; --accent-ink: #04201a; --accent-soft: #183b34;
    --held: #f0c36a; --held-bg: #3a2d10; --paid: #6fd39a; --paid-bg: #12341f; --released: #9cc0e4; --released-bg: #1b2d40;
    --refunded: #cfa6ea; --refunded-bg: #2d1c3a; --planned: #a9b8b2; --planned-bg: #24312c; --danger: #ff8d92; --danger-bg: #3d1a1c;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
button { font: inherit; cursor: pointer; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 16px; max-width: 1240px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.tagline { color: var(--muted); font-size: .9rem; flex: 1; }
.badge { font-size: .75rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.badge.sandbox { background: var(--held-bg); color: var(--held); }
.badge.judge { background: var(--accent-soft); color: var(--accent); }
.badge[hidden] { display: none; }
main { max-width: 1240px; margin: 0 auto; padding: 8px 16px 40px; }
.foot { max-width: 1240px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: .8rem; }

.hero { max-width: 760px; margin: 28px auto 0; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); letter-spacing: -.02em; }
.hero p.lead { color: var(--muted); font-size: 1.1rem; margin: 12px 0 22px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
textarea, input[type=text] { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; resize: vertical; }
textarea:focus, input:focus, button:focus-visible { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.btn { border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 600; background: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.small { padding: 7px 12px; font-size: .88rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.chip { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: 6px 12px; font-size: .85rem; text-align: left; }
.chip:hover { border-color: var(--accent); }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 26px; }
.how div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; font-size: .92rem; color: var(--muted); }
.how b { color: var(--ink); display: block; margin-bottom: 2px; }

.err { background: var(--danger-bg); color: var(--danger); border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-size: .92rem; }
.err .row { margin-top: 6px; }
.notice { background: var(--accent-soft); color: var(--ink); border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-size: .92rem; }
.notice.closed { margin: 0 0 14px; }
.expired { background: var(--held-bg); color: var(--held); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: .92rem; }

.tripbar { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 12px 0 14px; }
.tripbar h1 { font-size: clamp(1.4rem, 4vw, 2rem); }
.tripbar .sub { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat small { color: var(--muted); display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.col { display: grid; gap: 16px; min-width: 0; }
.card h2 { font-size: 1.05rem; margin-bottom: 12px; }
.day { margin-bottom: 14px; }
.day:last-child { margin-bottom: 0; }
.day h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; background: var(--surface); }
.item .t { font-weight: 600; }
.item .meta { color: var(--muted); font-size: .85rem; grid-column: 1; }
.item .amt { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.item .st { grid-column: 2; text-align: right; }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.pill.planned { background: var(--planned-bg); color: var(--planned); }
.pill.held { background: var(--held-bg); color: var(--held); }
.pill.paid { background: var(--paid-bg); color: var(--paid); }
.pill.released { background: var(--released-bg); color: var(--released); }
.pill.refunded, .pill.part-refunded { background: var(--refunded-bg); color: var(--refunded); }
.ag-cell .pill { line-height: 1.5; vertical-align: middle; white-space: nowrap; }

.grid-wrap { width: 100%; }
.ag-theme-quartz { --ag-font-family: system-ui, -apple-system, "Segoe UI", sans-serif; --ag-font-size: 13px; --ag-background-color: var(--surface); --ag-foreground-color: var(--ink); --ag-header-background-color: var(--surface-2); --ag-border-color: var(--line); --ag-odd-row-background-color: var(--surface); --ag-row-hover-color: var(--accent-soft); --ag-accent-color: var(--accent); width: 100%; }
/* tighter cells so amounts and PayPal statuses are not cut off (the theme sets this on the same element, so the id wins) */
#grid.ag-theme-quartz { --ag-cell-horizontal-padding: 8px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 999px; font-size: .85rem; }
.tab[aria-selected=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.verify { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: .9rem; }
.verify .ok { color: var(--paid); font-weight: 600; }
.verify .bad { color: var(--danger); font-weight: 600; }

.feed { display: grid; gap: 8px; max-height: 280px; overflow: auto; margin-bottom: 10px; }
.msg { font-size: .9rem; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.msg.user { background: var(--accent-soft); }
.msg.error { background: var(--danger-bg); color: var(--danger); }
.msg b { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: block; }
.proposal { border: 2px solid var(--accent); }
.proposal h2 { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.acts { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.acts li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: .92rem; }
.acts .k { font-weight: 700; margin-right: 6px; }
.acts .hold .k, .acts .allocate .k { color: var(--held); } .acts .void .k, .acts .release .k { color: var(--released); } .acts .capture .k { color: var(--paid); } .acts .refund .k { color: var(--refunded); }
.acts li.done { opacity: .6; }
.acts li.hold, .acts li.allocate { border-left: 3px solid var(--held); } .acts li.void, .acts li.release { border-left: 3px solid var(--released); } .acts li.capture { border-left: 3px solid var(--paid); } .acts li.refund { border-left: 3px solid var(--refunded); }
.sumline { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); margin: 6px 0; flex-wrap: wrap; gap: 6px; }
.sumline b { color: var(--ink); font-variant-numeric: tabular-nums; }
#pp { margin-top: 10px; min-height: 0; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: s .7s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes s { to { transform: rotate(360deg); } }
.per { display: flex; gap: 8px; flex-wrap: wrap; }
.per span { background: var(--surface-2); border-radius: 999px; padding: 4px 10px; font-size: .85rem; font-variant-numeric: tabular-nums; }

/* ---- the agent card: authority line, work trail, limits, terms, demo ---- */
.hint { color: var(--muted); font-size: .85rem; margin-top: 8px; }
.linkbtn { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 0 2px; font-size: inherit; }
.date { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); }
.date input { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.check { display: flex; gap: 8px; align-items: center; font-size: .92rem; }
.budget { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: .92rem; border: 1px solid var(--line); background: var(--surface); }
.budget.warn { background: var(--held-bg); color: var(--held); border-color: transparent; }
.budget.ok b { font-variant-numeric: tabular-nums; }
.notice.waits { background: var(--held-bg); color: var(--held); }
.notice.waits ul { margin: 4px 0 0; padding-left: 18px; }
.notice.viewonly { margin: 0 0 12px; }
.budget .why { color: var(--muted); margin-left: 6px; }
.notice.simclock { margin: 0 0 14px; background: var(--held-bg); color: var(--held); }
.notice.lost { margin: 0 0 14px; background: var(--danger-bg); color: var(--danger); }
.agentnote { margin: 10px 0; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; font-size: .92rem; }
.agentnote b { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.effect { font-size: .92rem; padding: 8px 10px; background: var(--accent-soft); border-radius: 8px; margin: 8px 0; }
.mandate { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; margin: 12px 0; display: grid; gap: 8px; }
.mandate input[type=number] { width: 6.5em; }
.authority { font-size: .88rem; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); color: var(--muted); margin-bottom: 10px; }
.authority.ok { background: var(--paid-bg); color: var(--paid); }
.trailbox { margin: 4px 0 12px; }
.runhead { font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.trail { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ev { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 10px; border-left: 3px solid var(--line); }
.ev.tool { border-left-color: var(--released); }
.ev.decision { border-left-color: var(--accent); background: var(--accent-soft); }
.ev.compare { border-left-color: var(--accent); }
.opts { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; font-size: .86rem; }
.opts li { padding: 4px 8px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); overflow-wrap: anywhere; }
.opts li.chosen { border-color: var(--accent); background: var(--accent-soft); }
.opts .evs { display: block; }
.ev.result { border-left-color: var(--paid); }
.ev.result.wait { border-left-color: var(--held); }
.ev.rej, .ev.bad { border-left-color: var(--danger); }
.ev.good { border-left-color: var(--paid); }
.ev.sim { border-left-color: var(--held); background: var(--held-bg); }
.ev.working { opacity: .7; }
.evtag { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-top: 2px; }
.evt { font-weight: 600; font-size: .92rem; }
.evd { font-size: .86rem; color: var(--muted); overflow-wrap: anywhere; }
.evs { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.simbadge { display: inline-block; font-size: .64rem; font-weight: 800; letter-spacing: .06em; padding: 1px 7px; border-radius: 999px; background: var(--held); color: var(--surface); vertical-align: 1px; }
blockquote { margin: 6px 0 0; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; font-size: .88rem; overflow-wrap: anywhere; }
blockquote small { display: block; color: var(--muted); font-size: .78rem; }
.basis { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }
.terms { margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.terms summary { cursor: pointer; font-size: .9rem; font-weight: 600; }
.terms textarea { margin-top: 8px; }
.doc { margin-top: 8px; font-size: .82rem; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.rules { margin-top: 8px; font-size: .88rem; }
.demo { margin-top: 12px; padding: 10px 12px; border: 1px dashed var(--held); border-radius: 10px; font-size: .88rem; color: var(--muted); }
.demo .row { margin-top: 8px; }
.feed-wrap { margin-top: 12px; }
.feed-wrap summary { cursor: pointer; font-size: .85rem; color: var(--muted); }
.feed-wrap .feed { margin-top: 8px; }
.sumlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.sumlist li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: .9rem; }
.sumlist b { font-variant-numeric: tabular-nums; }
.sumlist small { grid-column: 1 / -1; color: var(--muted); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .how { grid-template-columns: 1fr; }
  .tagline { display: none; }
  .top .badge { margin-left: auto; }
}
@media (max-width: 600px) {
  main { padding: 4px 12px 32px; }
  .tripbar { margin: 6px 0 10px; }
  .stats { gap: 8px; }
  .stat b { font-size: 1.05rem; }
  .card { padding: 14px; }
  .ev { grid-template-columns: 1fr; gap: 2px; }
  .ev .evtag { padding-top: 0; }
  .tabs { flex-wrap: wrap; }
  .mandate input[type=number] { width: 5.5em; }
}
