:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #182033;
  --muted: #667085;
  --border: #d9e1ec;
  --primary: #2f5cff;
  --primary-dark: #2046d6;
  --danger: #c0392b;
  --shadow: 0 18px 50px rgba(25, 36, 64, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }
a { color: var(--primary); }

.app-shell { display: grid; grid-template-columns: 280px minmax(520px, 1fr) 380px; min-height: 100vh; }
.sidebar, .cart-panel { background: var(--panel); border-right: 1px solid var(--border); padding: 24px; }
.cart-panel { border-right: 0; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 18px; max-height: 100vh; overflow: auto; }
.workspace { padding: 28px; overflow: auto; }

.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-mark { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; background: var(--primary); color: white; font-weight: 800; font-size: 24px; }
.brand h1, .brand p, .topbar h2, .topbar p, .cart-header h2, .cart-header p, .section-title h3, .section-title p { margin: 0; }
.brand p, .eyebrow, .session span, .product-card p, .cart-line span, .muted p, small { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; font-weight: 700; }
.side-section { margin-top: 26px; }
.side-section h2 { font-size: 14px; margin: 0 0 10px; }
.session, .supplier-pill { border: 1px solid var(--border); border-radius: 16px; padding: 14px; display: grid; gap: 4px; margin-bottom: 10px; background: var(--panel-soft); }
.session.active { border-color: rgba(47, 92, 255, 0.4); box-shadow: inset 4px 0 0 var(--primary); }
.supplier-statuses { display: grid; gap: 8px; }
.supplier-pill { margin-bottom: 0; padding: 10px 12px; }
.supplier-pill strong { font-size: 13px; }
.supplier-pill span { color: var(--muted); font-size: 12px; }
.topbar, .section-title, .cart-header, .product-bottom, .cart-line-actions, .product-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar { margin-bottom: 22px; }

.chat-card { background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 24px; overflow: hidden; margin-bottom: 28px; }
.messages { height: 260px; overflow: auto; padding: 22px; display: grid; align-content: start; gap: 14px; }
.message { max-width: 86%; border-radius: 18px; padding: 14px 16px; background: var(--panel-soft); border: 1px solid var(--border); }
.message p { margin: 6px 0 0; line-height: 1.45; }
.message.user { justify-self: end; background: #edf2ff; border-color: rgba(47, 92, 255, 0.25); }
.prompt-form { display: flex; gap: 12px; padding: 16px; border-top: 1px solid var(--border); background: var(--panel-soft); }
.prompt-form input { flex: 1; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; outline: none; }
.prompt-form input:focus, textarea:focus { border-color: var(--primary); outline: none; }

.primary, .secondary, .link-button, .ghost-link { border: 0; border-radius: 14px; cursor: pointer; text-decoration: none; }
.primary { background: var(--primary); color: white; padding: 12px 16px; font-weight: 700; display: inline-block; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: #e9eef8; color: var(--text); padding: 12px 16px; font-weight: 700; }
.small { padding: 9px 12px; border-radius: 12px; }
.full { width: 100%; }
.link-button { background: none; color: var(--primary); padding: 0; }
.danger { color: var(--danger); }
.ghost-link { border: 1px solid var(--border); color: var(--text); padding: 10px 14px; background: white; }

.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.product-card { background: var(--panel); border: 1px solid var(--border); border-radius: 22px; overflow: hidden; box-shadow: 0 10px 30px rgba(25, 36, 64, 0.07); }
.product-card img { width: 100%; height: 150px; object-fit: cover; background: var(--panel-soft); }
.product-body { padding: 16px; display: grid; gap: 12px; }
.product-body h4 { margin: 0; line-height: 1.25; }
.product-body p { margin: 0; line-height: 1.4; }
.product-meta { font-size: 12px; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badges span { background: var(--panel-soft); border: 1px solid var(--border); border-radius: 999px; padding: 5px 8px; color: var(--muted); font-size: 12px; }
.add-row { display: flex; gap: 8px; }
.add-row input, .cart-line-actions input { width: 72px; border: 1px solid var(--border); border-radius: 12px; padding: 9px; }

.session-banner, .post-target { border: 1px solid var(--border); background: var(--panel-soft); border-radius: 14px; padding: 12px; color: var(--muted); line-height: 1.4; }
.post-target:empty { display: none; }
.cart-lines { display: grid; gap: 12px; }
.cart-line { border: 1px solid var(--border); border-radius: 16px; background: var(--panel-soft); padding: 12px; display: grid; gap: 10px; }
.cart-line strong { display: block; margin-bottom: 4px; }
.line-total { font-weight: 800; }
.totals { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-size: 18px; }
.empty { border: 1px dashed var(--border); border-radius: 16px; padding: 18px; color: var(--muted); background: rgba(255,255,255,0.5); }
.cxml-preview { display: none; white-space: pre-wrap; overflow: auto; background: #101828; color: #f2f4f7; border-radius: 16px; padding: 14px; font-size: 12px; line-height: 1.45; max-height: 360px; }
.cxml-preview.visible { display: block; }

.demo-page { min-height: 100vh; display: grid; place-items: start center; padding: 42px 20px; }
.demo-card { width: min(1080px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow); padding: 28px; }
.demo-card h1 { margin: 6px 0 10px; }
.demo-card form { display: grid; gap: 10px; margin: 20px 0; }
.demo-card label { font-weight: 700; }
.demo-card input, .demo-card textarea { width: 100%; border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.demo-link { margin-top: 16px; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar, .cart-panel { border: 0; max-height: none; }
}
