:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-strong: #101723;
  --line: #dbe2ec;
  --text: #172033;
  --muted: #5d697a;
  --soft: #eef3f8;
  --accent: #d82128;
  --accent-dark: #a9151b;
  --ok: #1e7548;
  --shadow: 0 18px 50px rgba(21, 29, 43, .12);
  --quote-shadow: 0 24px 70px rgba(21, 29, 43, .16);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(216, 33, 40, .08), transparent 30rem),
    linear-gradient(135deg, #f8fafc 0%, var(--bg) 50%, #e9eef5 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.ai-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(390px, .72fr);
  align-items: start;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.ai-chat-panel,
.ai-quote-panel {
  min-height: calc(100vh - 36px);
  border: 1px solid rgba(196, 207, 222, .85);
  border-radius: 8px;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.ai-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  height: calc(100vh - 36px);
}

.ai-hero {
  display: block;
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(216, 33, 40, .06), transparent 38%),
    linear-gradient(180deg, #fff, #f8fafc);
}

.ai-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  color: #344259;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-brand-mark {
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(216, 33, 40, .12);
}

.ai-hero h1 {
  max-width: 760px;
  margin: 0 0 8px;
  color: #111827;
  font-size: clamp(22px, 2.1vw, 28px);
  line-height: 1.12;
  letter-spacing: 0;
}

.ai-hero p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.42;
}

.ai-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 22px 30px;
}

.ai-message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  max-width: 900px;
}

.ai-message.user {
  align-self: flex-end;
  grid-template-columns: minmax(0, 1fr);
  max-width: min(760px, 86%);
}

.ai-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--panel-strong);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.ai-bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px 14px;
  line-height: 1.5;
}

.ai-message.user .ai-bubble {
  border-color: #243043;
  background: #182233;
  color: #fff;
}

.ai-bubble p {
  margin: 6px 0 0;
}

.ai-questions {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.ai-questions li {
  border-left: 3px solid var(--accent);
  padding-left: 9px;
  color: #2f3c50;
  font-weight: 700;
}

.ai-detail-sections {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.ai-detail-section {
  border: 1px solid #e1e8f2;
  border-radius: 8px;
  background: #f8fafc;
  padding: 11px 12px;
}

.ai-detail-section h3 {
  margin: 0;
  color: #111827;
  font-size: 14px;
  letter-spacing: 0;
}

.ai-detail-section p {
  margin: 6px 0 0;
  color: #2f3c50;
  font-weight: 800;
}

.ai-detail-section ul {
  display: grid;
  gap: 6px;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}

.ai-detail-section li {
  border-left: 3px solid #263347;
  padding-left: 9px;
  color: #435268;
  font-size: 14px;
  line-height: 1.45;
}

.ai-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.ai-compose textarea {
  width: 100%;
  min-height: 58px;
  max-height: 170px;
  resize: vertical;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--text);
  outline: none;
}

.ai-compose textarea:focus,
.quote-form input:focus,
.quote-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(216, 33, 40, .12);
}

.ai-compose button,
.quote-cta,
.quote-submit {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 900;
}

.ai-compose button[disabled],
.quote-cta[disabled],
.quote-submit[disabled] {
  cursor: not-allowed;
  opacity: .58;
}

.ai-quote-panel {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 18px;
  align-self: start;
  height: calc(100vh - 36px);
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
  box-shadow: var(--quote-shadow);
}

.quote-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(16, 23, 35, .04), transparent 58%),
    #fff;
}

.quote-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.quote-head h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.quote-status {
  border-radius: 999px;
  background: #edf7f2;
  color: #1e7548;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.quote-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.quote-alt {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #253246;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.quote-alt:hover {
  border-color: #9fb0c6;
  background: #f7f9fc;
}

.quote-alt[disabled] {
  cursor: not-allowed;
  opacity: .58;
}

.quote-progress {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 10px 18px 0;
  background: #fff;
}

.quote-progress span {
  height: 4px;
  border-radius: 999px;
  background: #dfe7f1;
}

.quote-progress span:first-child {
  background: var(--accent);
}

.quote-progress span:nth-child(2) {
  background: #263347;
}

.quote-empty {
  margin: 0;
  border: 1px dashed #bdc9d9;
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.quote-empty strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
}

.quote-empty p {
  margin: 0;
}

.quote-scroll {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  scrollbar-width: thin;
  scrollbar-color: #b8c5d6 transparent;
}

.quote-insight {
  margin: 12px 0 0;
  border: 1px solid #d8e1ec;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(247, 250, 252, .96)),
    #fff;
  box-shadow: 0 8px 22px rgba(30, 41, 59, .05);
  overflow: hidden;
}

.quote-insight-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 12px 14px;
  color: #111827;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.quote-insight-toggle strong {
  border-radius: 999px;
  background: #eef2f7;
  padding: 5px 9px;
  color: #435268;
  font-size: 12px;
}

.quote-insight-body {
  border-top: 1px solid #e2e8f0;
  padding: 12px 14px 14px;
}

.quote-insight-body p {
  margin: 0;
  color: #4f5d70;
  font-size: 13px;
  line-height: 1.45;
}

.quote-insight-body ul {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.quote-insight-body li {
  position: relative;
  padding-left: 14px;
  color: #2f3c50;
  font-size: 13px;
  line-height: 1.4;
}

.quote-insight-body li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .58em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.quote-items {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 0;
}

.quote-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, .72), rgba(255, 255, 255, .92)),
    #fff;
  padding: 13px;
  box-shadow: 0 8px 22px rgba(30, 41, 59, .05);
}

.quote-image,
.quote-image-placeholder {
  width: 74px;
  height: 74px;
  border: 1px solid #d7e0eb;
  border-radius: 8px;
  background: #f1f5f9;
  object-fit: contain;
}

.quote-image {
  display: block;
  padding: 6px;
}

.quote-image-placeholder {
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  line-height: 1.15;
}

.quote-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.quote-item h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  color: #111827;
}

.quote-sku {
  display: inline-flex;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--soft);
  padding: 3px 7px;
  color: #4b5b70;
  font-size: 12px;
  font-weight: 900;
}

.quote-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.quote-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.qty-control {
  display: inline-grid;
  grid-template-columns: 30px 42px 30px;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
  min-height: 34px;
}

.qty-control button,
.quote-remove {
  border: 0;
  background: transparent;
  color: #263347;
  cursor: pointer;
  font-weight: 900;
}

.qty-control button {
  min-height: 34px;
}

.qty-control span {
  text-align: center;
  font-weight: 900;
}

.quote-remove {
  color: #8b1d24;
}

.quote-price {
  color: var(--muted);
  font-size: 13px;
}

.quote-subtotal {
  font-weight: 900;
  text-align: right;
}

.quote-actions {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  padding: 14px 18px 16px;
  box-shadow: 0 -12px 28px rgba(30, 41, 59, .06);
}

.quote-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding-bottom: 12px;
}

.quote-total span {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-weight: 800;
}

.quote-total small {
  color: #718197;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.quote-total strong {
  font-size: 22px;
}

.quote-cta,
.quote-submit {
  min-height: 46px;
  margin: 0;
}

.quote-form {
  display: grid;
  gap: 12px;
  margin: 0 18px 18px;
  flex: 0 0 auto;
  max-height: 56vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  box-shadow: 0 12px 30px rgba(30, 41, 59, .08);
}

.quote-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 10px;
}

.quote-form-head strong {
  color: #111827;
  font-size: 15px;
}

.quote-form-head button {
  border: 0;
  border-radius: 999px;
  background: #eef2f7;
  padding: 6px 10px;
  color: #435268;
  cursor: pointer;
  font-weight: 900;
}

.quote-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quote-form label {
  display: grid;
  gap: 5px;
  color: #344259;
  font-size: 13px;
  font-weight: 800;
}

.quote-form input,
.quote-form textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--text);
  outline: none;
}

.quote-consent {
  display: flex !important;
  grid-template-columns: none;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted) !important;
  font-weight: 700 !important;
}

.quote-consent input {
  width: auto;
  margin-top: 3px;
}

.quote-submit {
  margin: 0;
}

.quote-notice {
  flex: 0 0 auto;
  min-height: 24px;
  padding: 0 18px 16px;
  color: var(--ok);
  font-weight: 800;
  line-height: 1.4;
}

.quote-notice.error {
  color: #a9151b;
}

@media (max-width: 960px) {
  .ai-shell {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 10px;
  }

  .ai-chat-panel,
  .ai-quote-panel {
    min-height: auto;
  }

  .ai-chat-panel {
    height: auto;
    min-height: 76vh;
  }

  .ai-quote-panel {
    position: static;
    height: auto;
    max-height: none;
  }

  .quote-items {
    max-height: none;
    overflow: visible;
  }

  .quote-form {
    max-height: none;
  }

  .ai-hero,
  .ai-messages {
    padding-left: 16px;
    padding-right: 16px;
  }

  .ai-hero {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .ai-compose {
    grid-template-columns: 1fr;
  }

  .ai-compose button {
    min-height: 44px;
  }

  .quote-form-grid,
  .quote-row {
    grid-template-columns: 1fr;
  }

  .quote-subtotal {
    text-align: left;
  }

  .quote-item {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .quote-image,
  .quote-image-placeholder {
    width: 64px;
    height: 64px;
  }
}
