:root {
  --ic-green: #43B02A;
  --ic-green-dark: #0AAD0A;
  --ic-bg: #FAF1E5;
  --ic-card: #FFFFFF;
  --ic-text: #343538;
  --ic-text-secondary: #7B7B7B;
  --ic-carrot: #FF7009;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--ic-bg);
  color: var(--ic-text);
  margin: 0;
  min-height: 100vh;
}

/* Top Nav */
.topnav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 64px; padding: 0 24px;
  background: #fff;
  border-bottom: 3px solid var(--ic-green);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.topnav-logo { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.wordmark { font-weight: 700; font-size: 20px; color: var(--ic-green-dark); }
.topnav-search {
  flex: 1; max-width: 680px;
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px;
  background: #f6f7f8; border-radius: 24px;
}
.topnav-search input {
  border: none; background: transparent; outline: none;
  font-family: inherit; font-size: 14px;
  color: var(--ic-text-secondary); width: 100%;
}
.topnav-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; margin-left: auto; }
.loc { font-size: 13px; color: var(--ic-text-secondary); white-space: nowrap; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--ic-green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.cart-icon-btn { position: relative; background: none; border: none; cursor: pointer; padding: 4px; }
#cart-badge {
  position: absolute; top: -4px; right: -6px;
  background: var(--ic-carrot); color: #fff;
  font-size: 10px; font-weight: 700;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* Hero */
.hero {
  height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--ic-text-secondary);
}

/* Layout */
.layout {
  display: grid; grid-template-columns: 2fr 1fr;
  gap: 24px; max-width: 1440px;
  margin: 0 auto; padding: 0 24px 24px;
}
.chat-pane, .cart-pane {
  background: var(--ic-card); border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  padding: 20px; display: flex; flex-direction: column;
  height: calc(100vh - 64px - 44px - 48px);
}

/* Messages */
.messages {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 10px; padding-bottom: 8px;
}
.msg-user {
  align-self: flex-end;
  background: var(--ic-green); color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px; max-width: 70%;
  font-size: 14px; line-height: 1.45;
}
.msg-agent-row {
  display: flex; align-items: flex-start;
  gap: 8px; max-width: 80%;
}
.msg-agent-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--ic-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.msg-agent {
  background: var(--ic-bg); color: var(--ic-text);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px; font-size: 14px; line-height: 1.45;
}
.tool-line {
  font-style: italic; color: var(--ic-text-secondary);
  font-size: 12px; margin: 4px 0;
}
.tool-count { font-style: normal; font-weight: 600; opacity: 0.85; }

/* Thinking indicator (three pulsing dots) shown while the agent is processing */
.thinking-indicator { display: inline-flex; gap: 4px; padding: 2px 0; align-items: center; }
.thinking-indicator span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ic-text-secondary); opacity: 0.4;
  animation: thinking-pulse 1.2s infinite ease-in-out;
}
.thinking-indicator span:nth-child(2) { animation-delay: 0.2s; }
.thinking-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking-pulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
  30% { opacity: 0.9; transform: scale(1.25); }
}
.agent-text { white-space: pre-wrap; }
.agent-text:empty { display: none; }
.agent-text + .agent-text { margin-top: 6px; }

/* Suggestions */
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.suggestions button {
  background: #f6f7f8; border: none; border-radius: 999px;
  padding: 8px 14px; font-family: inherit; font-size: 13px;
  color: var(--ic-text); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.suggestions button:hover { background: var(--ic-green); color: #fff; }

/* Input Row */
.input-row {
  display: flex; gap: 8px; margin-top: auto;
  padding-top: 12px; border-top: 1px solid #eee;
}
#chat-input {
  flex: 1; height: 48px; border-radius: 999px;
  background: #f6f7f8; padding: 0 20px;
  border: 1px solid transparent; outline: none;
  font-family: inherit; font-size: 14px; color: var(--ic-text);
  transition: border-color 0.15s;
}
#chat-input:focus { border-color: var(--ic-green); }
.send-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--ic-carrot); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s;
}
.send-btn:hover { background: #e56200; }

/* Cart Pane */
.cart-heading {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--ic-text-secondary); margin: 0 0 4px; font-weight: 600;
}
.cart-divider { border: none; border-top: 1px solid #eee; margin: 0 0 12px; }
.cart-items {
  display: flex; flex-direction: column; gap: 10px;
  flex: 1; overflow-y: auto;
}
.cart-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 8px; transition: background 0.15s;
}
.cart-item:hover { background: #fafafa; }
.cart-item img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item-unit { font-size: 12px; color: var(--ic-text-secondary); }
.cart-item-right { text-align: right; flex-shrink: 0; min-width: 72px; margin-left: auto; }
.cart-item-qty { font-size: 13px; color: var(--ic-text-secondary); }
.cart-item-price { font-size: 14px; font-weight: 700; white-space: nowrap; }
.cart-item.flash { animation: flash 0.8s ease-out; }
@keyframes flash {
  0% { background: #dff5d6; }
  100% { background: transparent; }
}
.cart-empty {
  text-align: center; font-style: italic;
  color: var(--ic-text-secondary); padding: 24px 0;
}
.cart-footer { margin-top: auto; }
.subtotal-row {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid #eee; padding-top: 12px;
  font-size: 15px; margin-bottom: 12px;
}
.subtotal-label { color: var(--ic-text-secondary); }
#subtotal { font-weight: 700; color: var(--ic-text); }
.checkout-btn {
  width: 100%; height: 44px; border-radius: 8px;
  background: var(--ic-green); color: #fff; border: none;
  font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.checkout-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.clear-cart-btn {
  width: 100%; margin-top: 8px; height: 36px;
  background: transparent; color: var(--ic-text-secondary);
  border: 1px solid #e3e3e3; border-radius: 8px;
  font-family: inherit; font-size: 13px; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.clear-cart-btn:hover { background: #fafafa; color: var(--ic-text); border-color: #ccc; }
.clear-cart-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Scrollbar (WebKit) */
.messages::-webkit-scrollbar, .cart-items::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb, .cart-items::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 3px; }
.messages::-webkit-scrollbar-track, .cart-items::-webkit-scrollbar-track { background: transparent; }

/* ── Topnav links (Agent / Catalog) ─────────────────────────── */
.topnav-nav { display: flex; gap: 4px; margin-left: 12px; }
.topnav-nav a {
  padding: 8px 12px; border-radius: 8px; text-decoration: none;
  color: var(--ic-text-secondary); font-size: 14px; font-weight: 500;
}
.topnav-nav a:hover { background: #f6f7f8; color: var(--ic-text); }
.topnav-nav a.active { color: var(--ic-green-dark); background: #eaf7e6; }

/* ── Catalog page ────────────────────────────────────────────── */
.cat-search-input {
  height: 36px; padding: 0 14px; border-radius: 18px;
  background: #f6f7f8; border: 1px solid transparent;
  font-family: inherit; font-size: 13px; color: var(--ic-text);
  min-width: 220px; outline: none;
}
.cat-search-input:focus { border-color: var(--ic-green); background: #fff; }

.catalog-main { max-width: 1440px; margin: 0 auto; padding: 24px; }
.catalog-header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.catalog-header h1 { font-size: 24px; margin: 0; color: var(--ic-text); }
.cat-count { color: var(--ic-text-secondary); font-size: 14px; }
.cat-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.cat-filter {
  background: #f6f7f8; border: none; border-radius: 999px;
  padding: 6px 12px; font-family: inherit; font-size: 13px;
  color: var(--ic-text); cursor: pointer;
}
.cat-filter:hover { background: #eaf7e6; }
.cat-filter.active { background: var(--ic-green); color: #fff; }

.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.cat-card {
  background: var(--ic-card); border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.cat-card img { width: 100%; height: 160px; object-fit: cover; background: #f6f7f8; }
.cat-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.cat-name { font-size: 14px; font-weight: 600; color: var(--ic-text); line-height: 1.3; }
.cat-brand { font-size: 12px; color: var(--ic-text-secondary); }
.cat-tags { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0; }
.cat-tag { font-size: 10px; padding: 2px 6px; border-radius: 10px; background: #eaf7e6; color: var(--ic-green-dark); }
.cat-row { display: flex; align-items: baseline; gap: 4px; margin-top: auto; padding-top: 4px; }
.cat-price { font-size: 16px; font-weight: 700; color: var(--ic-text); }
.cat-unit { font-size: 12px; color: var(--ic-text-secondary); }
