:root {
  --bg: #0d0b14; --panel: #17141f; --line: #2a2536; --text: #f1eef8; --muted: #a59fb6;
  --violet: #8b6cf6; --violet-2: #b8a6ff; --green: #3ecf8e; --orange: #f5a524; --red: #f0616d;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--muted); text-decoration: none; font-weight: 600; }
.brand img { height: 28px; width: auto; }
main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 16px; margin-top: 20px; }
.card, .playground, .notice { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.card header, .playground header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.card header { flex-direction: column; gap: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.badge.pilot { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.badge.billable { color: var(--orange); }
.badge.role { color: var(--violet-2); }
.meter { margin: 10px 0; }
.meter-label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--violet); transition: width .3s; }
.bar i.warn { background: var(--orange); }
.bar i.full { background: var(--red); }
button { font: inherit; cursor: pointer; border-radius: 10px; padding: 9px 16px; border: 1px solid var(--line); background: transparent; color: var(--text); }
button.primary { background: var(--violet); border-color: var(--violet); color: #fff; font-weight: 600; }
button.primary:disabled { opacity: .55; cursor: wait; }
button.ghost { padding: 4px 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.actions button { flex: 1 1 30%; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 12px; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--violet); }
.list { display: flex; flex-direction: column; gap: 10px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.item .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.item .btns { display: flex; gap: 8px; }
.item button { padding: 6px 12px; font-size: 14px; }
.badge.draft { color: var(--orange); }
.badge.approved { color: var(--green); }
.badge.handoff { color: var(--orange); }
.doc { white-space: pre-wrap; max-height: 360px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px; font-size: 14px; }
.convo-row { cursor: pointer; }
.convo-row:hover { border-color: var(--violet); }
.msg.tool { font-size: 13px; color: var(--muted); }
.playground { margin-top: 24px; }
textarea, select { font: inherit; width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--violet-2); outline-offset: 2px; }
.row { display: flex; gap: 12px; align-items: flex-end; margin-top: 10px; }
.row label { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.log { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; }
.msg.q { background: transparent; color: var(--muted); }
.msg.a { background: color-mix(in srgb, var(--violet) 10%, var(--panel)); }
.msg.err { border-color: var(--red); color: var(--red); }
.meta { font-size: 13px; color: var(--muted); margin-top: 6px; }
.notice { margin-top: 20px; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 14px; user-select: all; }
#sign-in { display: grid; place-items: center; margin-top: 32px; }
#sign-in > * { margin-left: auto; margin-right: auto; }
@media (max-width: 560px) { .top, main { padding-left: 14px; padding-right: 14px; } .row { flex-direction: column; align-items: stretch; } }

/* Assistant replies rendered like the website widget */
.msg.rich { white-space: normal; line-height: 1.55; }
.msg.rich p { margin: 0 0 8px; }
.msg.rich ul, .msg.rich ol { margin: 4px 0 10px; padding-left: 22px; }
.msg.rich li { margin: 4px 0; }
.msg.rich a { color: var(--violet); font-weight: 600; text-decoration: underline; }
.msg.rich .meta { margin-top: 8px; }

/* Spending limits form */
.limits { display: grid; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.limits label { display: grid; gap: 4px; color: var(--muted); }
.limits input { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg, transparent); color: inherit; }

/* Exchange-rate bar (platform owner) */
.fxbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
         border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 0 0 16px; }
.fxbar.stale { border-color: var(--red); }
.fxbar + .limits { margin: -6px 0 18px; border-top: 0; padding-top: 0; max-width: 420px; }

/* Billing tab */
.balance { margin: 4px 0 14px; }
.balance .big { font-size: 30px; font-weight: 700; margin: 2px 0 6px; }
.row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: space-between;
       padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.row .neg { color: var(--red); } .row .pos { color: #34d399; }
button.danger { border-color: var(--red); color: var(--red); }
h3 { margin: 22px 0 6px; font-size: 15px; }
