:root {
  --bg: #0d1220; --panel: #141b2e; --panel2: #1a2338; --line: #26304b;
  --text: #e8ecf4; --muted: #8fa0bd; --accent: #6ea8fe; --good: #57d98a; --warn: #f0b45c;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); height: 100vh;
  display: grid; grid-template-rows: auto 1fr; grid-template-columns: 1fr 340px;
  grid-template-areas: "header header" "main aside";
}
header {
  grid-area: header; display: flex; justify-content: space-between; align-items: center;
  padding: 0.8rem 1.4rem; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-weight: 700; font-size: 1.05rem; }
.logo { margin-right: 0.4rem; }
.badges { display: flex; gap: 0.5rem; }
.chip { font-size: 0.72rem; padding: 0.25rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip.agent { color: var(--accent); border-color: var(--accent); }
.chip.sandbox { color: var(--warn); border-color: var(--warn); }

main { grid-area: main; display: flex; flex-direction: column; min-width: 0; }
#chat { flex: 1; overflow-y: auto; padding: 1.4rem; display: flex; flex-direction: column; gap: 0.9rem; }
.bubble { max-width: 78%; padding: 0.75rem 1rem; border-radius: 14px; line-height: 1.45; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: #2b4c8c; border-bottom-right-radius: 4px; }
.bubble.avo { align-self: flex-start; background: var(--panel2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.sys { align-self: center; color: var(--muted); font-size: 0.8rem; background: none; }

.order-card {
  align-self: flex-start; width: min(420px, 90%); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 14px; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.order-card .row { display: flex; justify-content: space-between; align-items: center; }
.order-card .title { font-weight: 600; }
.order-card .amount { font-size: 1.2rem; font-weight: 700; }
.order-card .meta { color: var(--muted); font-size: 0.78rem; }
/* Pay Later messaging (E3): PayPal's text-layout iframe draws dark text on
   transparency, so the slot carries the light "offer chip" look; empty until
   the component renders, removed entirely when messages are unavailable. */
.order-card .paylater-messages { margin: 0.1rem 0; min-height: 0; }
.order-card .paylater-messages iframe { border-radius: 8px; background: #f5f7fa; max-width: 100%; }
.status { font-size: 0.72rem; padding: 0.2rem 0.55rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.status.COMPLETED { color: var(--good); border-color: var(--good); }
.status.APPROVED { color: var(--accent); border-color: var(--accent); }

#composer { display: flex; gap: 0.6rem; padding: 1rem 1.4rem; border-top: 1px solid var(--line); background: var(--panel); }
#message { flex: 1; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 0.75rem 1rem; font-size: 0.95rem; outline: none; }
#message:focus { border-color: var(--accent); }
#composer button { background: var(--accent); color: #0b1224; border: none; border-radius: 10px;
  padding: 0 1.4rem; font-weight: 700; cursor: pointer; }
#composer button:disabled { opacity: 0.5; cursor: wait; }

aside { grid-area: aside; border-left: 1px solid var(--line); background: var(--panel);
  overflow-y: auto; padding: 1.2rem; }
aside h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 1rem 0 0.6rem; }
aside h2:first-child { margin-top: 0; }
.item { padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 0.5rem; background: var(--panel2); }
.item .t { font-weight: 600; font-size: 0.88rem; }
.item .b { color: var(--muted); font-size: 0.76rem; margin-top: 0.15rem; }
.item .p { float: right; font-weight: 700; }
.order-rail-item { font-size: 0.8rem; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.muted { color: var(--muted); font-size: 0.8rem; }
.typing { color: var(--muted); font-style: italic; }
