/* ------------------------------------------------------------------ tokens */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #ececee;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: #eef2ff;
  --accent-text: #4338ca;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05);
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 8px 24px -12px rgba(24, 24, 27, 0.12);
  --shadow-lg: 0 12px 40px -12px rgba(24, 24, 27, 0.25);
  --radius: 14px;
  --radius-sm: 10px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b;
    --surface: #111113;
    --surface-2: #18181b;
    --surface-3: #232327;
    --border: #232327;
    --border-strong: #2f2f35;
    --text: #fafafa;
    --text-2: #d4d4d8;
    --muted: #a1a1aa;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-ink: #ffffff;
    --accent-soft: rgba(99, 102, 241, 0.14);
    --accent-text: #a5b4fc;
    --ok: #34d399;
    --ok-soft: rgba(52, 211, 153, 0.12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.12);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.12);
    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: 0 16px 48px -12px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09090b;
  --surface: #111113;
  --surface-2: #18181b;
  --surface-3: #232327;
  --border: #232327;
  --border-strong: #2f2f35;
  --text: #fafafa;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-text: #a5b4fc;
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.12);
  --shadow-sm: none;
  --shadow: none;
  --shadow-lg: 0 16px 48px -12px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent-text); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[data-lucide], .lucide { width: 16px; height: 16px; stroke-width: 2; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13px; transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent; color: var(--muted); text-decoration: none;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1440px; margin: 0 auto; height: 60px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.logo, .empty-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #4f46e5 55%, #4338ca);
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 4px 12px -4px rgba(79, 70, 229, .6);
}
.logo svg, .empty-mark svg { width: 22px; height: 22px; }
.logo path, .empty-mark path { stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.logo circle, .empty-mark circle { fill: #fff; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.top-actions .btn { margin-left: 6px; }

/* ------------------------------------------------------------------ layout */
.layout {
  display: grid; gap: 20px; padding: 20px 24px 8px; max-width: 1440px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-areas: "chat side" "activity activity";
}
.chat { grid-area: chat; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.activity { grid-area: activity; }
@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "chat" "side" "activity"; padding: 16px; gap: 16px; }
  .topbar-inner { padding: 0 16px; }
  .hide-sm { display: none; }
}

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-head h2 [data-lucide], .card-head h2 .lucide { color: var(--muted); }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }

/* ------------------------------------------------------------------ chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 60px - 40px); min-height: 560px; max-height: 860px; overflow: hidden; }
.messages { flex: 1; overflow-y: auto; padding: 28px 28px 12px; display: flex; flex-direction: column; gap: 18px; scroll-behavior: smooth; }
/* Chat items keep their natural height; the panel scrolls instead of squashing them. */
.messages > * { flex-shrink: 0; }
.messages::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid var(--surface); }

.empty { margin: auto; max-width: 620px; text-align: center; padding: 12px 0; }
.empty-mark { width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 18px; }
.empty-mark svg { width: 32px; height: 32px; }
.empty h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.empty > p { color: var(--muted); margin: 10px auto 0; max-width: 500px; font-size: 14.5px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 28px; text-align: left; }
@media (max-width: 640px) { .suggestions { grid-template-columns: 1fr; } }
.suggestion {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; text-align: left;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm);
  transition: border-color .15s, background .15s, transform .15s;
}
.suggestion:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.s-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--accent-text); flex: none; }
.suggestion:hover .s-icon { background: var(--surface); }
.s-text { display: flex; flex-direction: column; min-width: 0; }
.s-text strong { font-size: 13.5px; font-weight: 600; }
.s-text small { color: var(--muted); font-size: 12.5px; }

.row { display: flex; gap: 12px; align-items: flex-start; }
.row.user { justify-content: flex-end; }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; flex: none; margin-top: 1px;
  background: linear-gradient(135deg, #6366f1, #4338ca); }
.avatar svg { width: 18px; height: 18px; }
.avatar path { stroke: #fff; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.avatar circle { fill: #fff; }
.bubble { max-width: min(640px, 85%); overflow-wrap: anywhere; }
.row.agent .bubble { color: var(--text-2); padding-top: 3px; }
.row.user .bubble { background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 16px 16px 4px 16px; }
.row.error .bubble { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 12px; display: flex; gap: 8px; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 4px 0 8px; padding-left: 18px; }
.bubble li { margin: 3px 0; }
.bubble strong { color: var(--text); font-weight: 600; }
.row.user .bubble strong { color: inherit; }

/* agent activity timeline */
.activity-block { margin-left: 40px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); max-width: min(600px, calc(100% - 40px)); overflow: hidden; }
.activity-block summary {
  list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; font-size: 12.5px; font-weight: 500; color: var(--text-2);
}
.activity-block summary::-webkit-details-marker { display: none; }
.activity-block summary .chev { margin-left: auto; color: var(--muted); transition: transform .2s; }
.activity-block[open] summary .chev { transform: rotate(180deg); }
.activity-block ol { list-style: none; margin: 0; padding: 2px 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.step { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 5px 0; font-size: 12.5px; position: relative; }
.step .ic { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.step .ic [data-lucide], .step .ic .lucide { width: 12px; height: 12px; }
.step .lbl { color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .res { color: var(--muted); font-size: 12px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.step.ok .res .lucide { color: var(--ok); width: 14px; height: 14px; }
.step.bad .res { color: var(--bad); }
.step.bad .res .lucide { width: 14px; height: 14px; }
.step.warn .res { color: var(--warn); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.reasoning { margin-left: 40px; font-size: 12.5px; color: var(--muted); max-width: min(600px, calc(100% - 40px)); }
.reasoning summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; user-select: none; list-style: none; }
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning div { white-space: pre-wrap; padding: 8px 12px; margin-top: 6px; border-left: 2px solid var(--border-strong); }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.shimmer {
  background: linear-gradient(90deg, var(--muted) 0%, var(--text) 50%, var(--muted) 100%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.composer { padding: 12px 20px 14px; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 14px; border-radius: 14px;
  border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.composer textarea { flex: 1; resize: none; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; padding: 7px 0; max-height: 160px; }
.composer textarea::placeholder { color: var(--muted); }
.send-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-ink); flex: none; transition: background .15s, opacity .15s; }
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }
.composer-hint { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 8px; }

/* ------------------------------------------------------------------ wallet */
.wallet { padding: 18px; }
.wallet-top { display: flex; justify-content: space-between; align-items: center; }
.wallet-amount { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; margin: 6px 0 12px; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #6366f1, #4f46e5); }
.progress-fill.high { background: linear-gradient(90deg, #f59e0b, #d97706); }
.progress-fill.full { background: linear-gradient(90deg, #f87171, #dc2626); }
.wallet-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.wallet-stats div { display: flex; flex-direction: column; gap: 1px; font-size: 12px; }
.wallet-stats strong { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ cart */
.cart { padding: 16px 18px 18px; }
.cart-empty { text-align: center; padding: 18px 8px 10px; color: var(--muted); }
.cart-empty .lucide, .cart-empty [data-lucide] { width: 28px; height: 28px; stroke-width: 1.5; margin-bottom: 8px; }
.cart-empty p { color: var(--text); font-weight: 600; }
.cart-empty small { display: block; margin-top: 4px; font-size: 12.5px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.proposed { background: var(--accent-soft); color: var(--accent-text); }
.badge.checkout { background: var(--warn-soft); color: var(--warn); }
.badge.paid { background: var(--ok-soft); color: var(--ok); }
.badge.blocked, .badge.rejected { background: var(--bad-soft); color: var(--bad); }
.rationale { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; display: flex; gap: 8px; }
.rationale .lucide { color: var(--accent-text); margin-top: 2px; width: 14px; height: 14px; }
.violations { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.violations li { display: flex; gap: 8px; align-items: flex-start; background: var(--bad-soft); color: var(--bad); padding: 8px 10px; border-radius: 10px; font-size: 12.5px; }
.violations .lucide { width: 14px; height: 14px; margin-top: 2px; }
.cart-items { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; }
.cart-items li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.cart-items li:last-child { border-bottom: 0; }
.thumb { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--surface-2); color: var(--muted); flex: none; }
.thumb .lucide { width: 16px; height: 16px; }
.item-main { flex: 1; min-width: 0; }
.item-main .nm { display: block; font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-main .meta { display: block; font-size: 12px; color: var(--muted); }
.item-price { font-variant-numeric: tabular-nums; font-weight: 500; font-size: 13px; }
.totals { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 1px 0; }
.totals .grand { color: var(--text); font-weight: 700; font-size: 15px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.cart-actions { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.cart-actions .row-btns { display: flex; gap: 8px; }
.cart-actions .row-btns .btn { flex: 1; }
.paid-note { display: flex; align-items: center; gap: 10px; background: var(--ok-soft); color: var(--ok); padding: 12px; border-radius: 10px; font-weight: 500; font-size: 13px; }
.paid-note small { display: block; color: var(--muted); font-weight: 400; font-family: var(--mono); font-size: 11.5px; }
.secure-note { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.secure-note .lucide { width: 12px; height: 12px; }
.blocked-note { font-size: 12.5px; color: var(--muted); }
/* PayPal's iframes are light-scheme; matching it avoids the opaque white
   backdrop browsers paint behind iframes with a different color-scheme. */
#paypal-buttons { min-height: 45px; color-scheme: light; }

/* ------------------------------------------------------------------ policy */
.collapsible { width: 100%; background: transparent; border: 0; border-bottom: 1px solid transparent; text-align: left; }
.policy-card .card-head.collapsible[aria-expanded="true"] { border-bottom-color: var(--border); }
.collapsible h2 { white-space: nowrap; flex: none; }
.policy-summary { margin-left: auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collapsible .chev { color: var(--muted); transition: transform .2s; }
.collapsible[aria-expanded="true"] .chev { transform: rotate(180deg); }
.policy[hidden] { display: none; }
.policy { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 16px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.input { display: flex; align-items: center; height: 36px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); padding-left: 10px; transition: border-color .15s, box-shadow .15s; }
.input span { color: var(--muted); font-size: 13px; }
.input input { border: 0; outline: 0; background: transparent; color: var(--text); padding: 0 10px 0 6px; width: 100%; height: 100%; font: inherit; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.policy fieldset { border: 0; padding: 0; margin: 0; }
.policy legend { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.toggle-chip { position: relative; }
.toggle-chip input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-chip span {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border-strong); color: var(--text-2); cursor: pointer; transition: all .15s; text-transform: capitalize;
}
.toggle-chip input:checked + span { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.toggle-chip input:checked + span::before { content: "⊘"; }
.toggle-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch-row strong { display: block; font-size: 13px; font-weight: 600; }
.switch-row small { color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: background .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.policy-note { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.policy-note .lucide { width: 13px; height: 13px; }

/* ------------------------------------------------------------------ activity */
.tabs { position: relative; display: flex; gap: 4px; }
.tab { display: inline-flex; align-items: center; gap: 7px; background: transparent; border: 0; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-weight: 600; font-size: 13px; position: relative; z-index: 1; transition: color .15s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab-indicator { position: absolute; z-index: 0; top: 0; bottom: 0; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.count { font-size: 11px; background: var(--surface-3); border-radius: 99px; padding: 0 7px; color: var(--muted); font-variant-numeric: tabular-nums; }
.grid { height: 340px; }
.grid .ag-root-wrapper { border: 0; border-radius: 0 0 var(--radius) var(--radius); }
.cell-pill { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 99px; text-transform: capitalize; }
.cell-pill.ok, .cell-pill.COMPLETED { background: var(--ok-soft); color: var(--ok); }
.cell-pill.blocked, .cell-pill.error, .cell-pill.REFUNDED { background: var(--bad-soft); color: var(--bad); }
.cell-pill.warning, .cell-pill.PARTIALLY_REFUNDED { background: var(--warn-soft); color: var(--warn); }
.actor { font-family: var(--mono); font-size: 12px; }
.actor.guardrail { color: var(--bad); } .actor.paypal { color: var(--accent-text); } .actor.agent { color: var(--ok); } .actor.user { color: var(--muted); }
.grid-btn { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); border-radius: 7px; padding: 2px 9px; font-size: 12px; font-weight: 500; line-height: 20px; }
.grid-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.mono { font-family: var(--mono); font-size: 12px; }

/* ------------------------------------------------------------------ toasts */
.toasts { position: fixed; top: 72px; right: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 280px; max-width: 360px;
  padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13px;
}
@media (max-width: 640px) { .toasts { left: 12px; right: 12px; } .toast { min-width: 0; max-width: none; } }
.toast .lucide { width: 18px; height: 18px; margin-top: 1px; }
.toast.ok .lucide { color: var(--ok); }
.toast.bad .lucide { color: var(--bad); }
.toast.info .lucide { color: var(--accent-text); }
.toast strong { display: block; font-weight: 600; }
.toast small { color: var(--muted); font-size: 12.5px; }

.foot { display: flex; justify-content: center; gap: 8px; color: var(--muted); font-size: 12px; padding: 12px 16px 28px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------------ rule proposals */
.proposal { margin-left: 40px; max-width: min(560px, calc(100% - 40px)); border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.proposal-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; }
.proposal-head strong { display: block; font-size: 13.5px; }
.proposal-head small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.proposal-head .badge { margin-left: auto; flex: none; }
.proposal-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.diff { list-style: none; margin: 0; padding: 0 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.diff li { display: grid; grid-template-columns: 1fr auto 14px auto; align-items: center; gap: 8px; font-size: 12.5px; padding: 7px 10px; border-radius: 9px; background: var(--surface-2); }
.diff .lucide { width: 14px; height: 14px; color: var(--muted); }
.d-label { font-weight: 500; }
.d-from { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); }
.d-to { font-weight: 600; color: var(--accent-text); }
.proposal-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ------------------------------------------------------------------ plain-English rule + limits */
.input-action { padding-left: 10px; padding-right: 4px; gap: 4px; }
.input-action > .lucide, .input-action > [data-lucide] { color: var(--accent-text); width: 15px; height: 15px; }
.btn-sm { height: 28px; padding: 0 11px; font-size: 12.5px; border-radius: 7px; }
.limits { display: flex; flex-direction: column; gap: 8px; }
.limits[hidden] { display: none; }
.limit { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; }
.limit-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); color: var(--muted); flex: none; }
.limit-icon .lucide { width: 14px; height: 14px; }
.limit-main { flex: 1; min-width: 0; }
.limit-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; font-weight: 500; text-transform: capitalize; margin-bottom: 5px; }
.limit-top .muted { text-transform: none; font-weight: 400; font-variant-numeric: tabular-nums; }
.progress.thin { height: 4px; }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 7px; }
.icon-btn.sm .lucide { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ category colors */
.cat-outdoor { --c1: #10b981; --c2: #059669; }
.cat-electronics { --c1: #6366f1; --c2: #4f46e5; }
.cat-home { --c1: #f59e0b; --c2: #d97706; }
.cat-grocery { --c1: #f97316; --c2: #ea580c; }
.cat-gift_cards { --c1: #ec4899; --c2: #db2777; }
.cat-books { --c1: #0ea5e9; --c2: #0284c7; }
.thumb[class*="cat-"] { background: color-mix(in srgb, var(--c1) 14%, var(--surface)); color: var(--c2); }

/* ------------------------------------------------------------------ product cards */
.products { margin-left: 40px; max-width: calc(100% - 40px); }
.products-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.products-head strong { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.products-head strong .lucide { color: var(--muted); width: 15px; height: 15px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.product { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; transition: border-color .15s, box-shadow .15s, transform .15s; }
.product:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.p-media {
  position: relative; display: grid; place-items: center; height: 84px;
  background: radial-gradient(120% 120% at 0% 0%, color-mix(in srgb, var(--c1) 30%, var(--surface)) 0%, color-mix(in srgb, var(--c2) 12%, var(--surface)) 100%);
  color: var(--c2);
}
.p-media > .lucide { width: 30px; height: 30px; stroke-width: 1.6; }
.p-tag { position: absolute; top: 8px; left: 8px; font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface); color: var(--warn); box-shadow: var(--shadow-sm); }
.p-tag.bad { color: var(--bad); left: auto; right: 8px; }
.p-body { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; flex: 1; }
.p-merchant { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.p-merchant .lucide { width: 13px; height: 13px; color: var(--accent-text); }
.product h4 { margin: 0; font-size: 13px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 35px; }
.p-rating { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.p-rating b { color: var(--text); font-weight: 600; }
.stars { --r: 0%; display: inline-block; font-size: 11px; letter-spacing: 1px; line-height: 1; background: linear-gradient(90deg, #f59e0b var(--r), var(--surface-3) var(--r)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stars::before { content: "★★★★★"; }
.p-note { margin: 2px 0 0; font-size: 12px; color: var(--text-2); line-height: 1.45; flex: 1; }
.p-foot { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 8px; }
.p-price { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.p-compare { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.p-compare input { accent-color: var(--accent); margin: 0; }
.p-add .lucide, .compare .btn .lucide { width: 14px; height: 14px; }
.item-remove { margin-left: -4px; opacity: .6; }
.cart-items li:hover .item-remove { opacity: 1; }

/* ------------------------------------------------------------------ compare dialog */
.compare { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.compare::backdrop { background: rgba(9, 9, 11, .45); backdrop-filter: blur(3px); }
.compare-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.compare-head h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.compare-body { overflow: auto; padding: 6px 18px 18px; }
.compare table { width: 100%; border-collapse: collapse; font-size: 13px; }
.compare th, .compare td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.compare thead th { font-weight: 600; vertical-align: bottom; min-width: 160px; }
.compare tbody th { color: var(--muted); font-weight: 500; white-space: nowrap; width: 1%; }
.compare tbody tr:last-child th, .compare tbody tr:last-child td { border-bottom: 0; }
.compare td.best { color: var(--ok); font-weight: 600; }
.compare td .lucide { width: 13px; height: 13px; color: var(--accent-text); vertical-align: -2px; }
.c-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; margin-bottom: 6px; background: color-mix(in srgb, var(--c1) 16%, var(--surface)); color: var(--c2); }
.c-icon .lucide { width: 15px; height: 15px; }
@media (max-width: 640px) { .products, .proposal, .activity-block, .reasoning { margin-left: 0; max-width: 100%; } }

/* ------------------------------------------------------------------ insights */
.insights { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 16px; }
.insights[hidden] { display: none; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); min-width: 0; }
.stat-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-label .lucide { width: 13px; height: 13px; flex: none; }
.stat-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.stat-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }
.chart-card { margin: 0; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px 8px; min-width: 0; }
.chart-card figcaption { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.chart-card figcaption strong { display: block; font-size: 13px; font-weight: 600; }
.chart-card figcaption small { display: block; font-size: 12px; color: var(--muted); }
.chart-card .view-toggle .lucide { width: 14px; height: 14px; }
.chart { height: 240px; position: relative; }
.chart[hidden] { display: none; }
.chart.is-empty > * { display: none; }
.chart.is-empty::after { content: attr(data-empty); position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12.5px; border: 1px dashed var(--border-strong); border-radius: 10px; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.chart-table th, .chart-table td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--border); }
.chart-table th { color: var(--muted); font-weight: 500; }
.chart-table td:last-child, .chart-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
