:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-subtle: #fafaf9;
  --surface-muted: #f3f3f1;
  --text: #202124;
  --text-strong: #151618;
  --muted: #6f7075;
  --muted-strong: #55565b;
  --border: #e5e5e2;
  --border-strong: #d6d6d2;
  --accent: #ea4b1f;
  --accent-hover: #d94117;
  --accent-soft: #fff1ec;
  --success: #18794e;
  --success-soft: #edf8f2;
  --warning: #946200;
  --warning-soft: #fff7dc;
  --danger: #c9362b;
  --danger-soft: #fff0ef;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --focus-ring: 0 0 0 3px rgba(234, 75, 31, 0.14);
  --shadow-float: 0 20px 55px rgba(25, 25, 25, 0.16);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 20px 18px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: #fbfbfa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: var(--text-strong);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--accent);
}

.brand-mark::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 9px;
  width: 16px;
  height: 2px;
  background: rgba(255, 255, 255, 0.72);
}

.brand-mark i {
  position: absolute;
  z-index: 1;
  top: 13px;
  width: 7px;
  height: 7px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #fff;
}

.brand-mark i:nth-child(1) { left: 6px; }
.brand-mark i:nth-child(2) { left: 14px; }
.brand-mark i:nth-child(3) { left: 22px; }
.brand small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

.primary-nav { display: grid; gap: 6px; }
.nav-label,
.section-label,
.breadcrumb {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--muted-strong);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.nav-item:hover { color: var(--text-strong); background: var(--surface-muted); }
.nav-item.is-active { color: var(--accent-hover); background: var(--accent-soft); }
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 2px;
  height: 18px;
  border-radius: 2px;
  background: var(--accent);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 9px;
  font-weight: 800;
}

.filter-panel {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.section-header h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.filter-fields { display: grid; gap: 12px; margin-top: 16px; }
.field {
  display: grid;
  gap: 6px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
}
.field.full { grid-column: 1 / -1; }

.field input,
.composer textarea,
.subscription-field select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-strong);
  background: var(--surface);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field input { height: 38px; padding: 0 10px; }
.field input::placeholder,
.composer textarea::placeholder { color: #a0a0a4; }
.field input:hover,
.composer textarea:hover,
.subscription-field select:hover { border-color: #bcbdb9; }
.field input:focus,
.composer textarea:focus,
.subscription-field select:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }

.primary-button,
.secondary-button,
.send-button,
.order-button,
.suggestion,
.dialog-close {
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.primary-button {
  width: 100%;
  min-height: 38px;
  margin-top: 14px;
  padding: 9px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.primary-button:hover:not(:disabled) { border-color: var(--accent-hover); background: var(--accent-hover); }
.primary-button:focus-visible,
.secondary-button:focus-visible,
.send-button:focus-visible,
.order-button:focus-visible,
.suggestion:focus-visible,
.dialog-close:focus-visible,
.nav-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.primary-button:disabled { opacity: 0.56; }

.sidebar-note {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}
.sidebar-note strong { color: var(--muted-strong); font-size: 11px; }

.app-main { min-width: 0; }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  min-height: 112px;
  padding: 24px 32px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.page-header .breadcrumb { margin-bottom: 6px; text-transform: none; }
.page-header h1 {
  margin: 0;
  color: var(--text-strong);
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.035em;
}
.page-header h1 + p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.page-content { width: min(1440px, 100%); padding: 24px 32px 40px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

.assistant-panel,
.panel-section {
  border: 1px solid var(--border);
  background: var(--surface);
}
.assistant-panel {
  display: flex;
  height: clamp(620px, calc(100vh - 177px), 900px);
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}
.assistant-title { min-width: 0; }
.assistant-title strong,
.assistant-title span { display: block; }
.assistant-title strong { color: var(--text-strong); font-size: 13px; }
.assistant-title span { margin-top: 2px; color: var(--muted); font-size: 11px; }

.secondary-button {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--muted-strong);
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
}
.secondary-button:hover { color: var(--text-strong); border-color: #bdbeba; background: var(--surface-muted); }
.secondary-button:disabled { opacity: 0.5; }

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 460px;
  padding: 22px 20px;
  overflow-y: auto;
  background: var(--surface);
}
.message { display: grid; gap: 5px; max-width: 100%; line-height: 1.65; }
.message.user { align-self: flex-end; justify-items: end; max-width: 78%; }
.message-label { color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .02em; }
.message.bot .message-label { color: var(--accent-hover); }
.bubble { min-width: 0; padding: 10px 12px; font-size: 13px; white-space: pre-wrap; }
.message.bot .bubble {
  width: min(760px, 100%);
  padding: 9px 12px;
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text);
  background: var(--surface-subtle);
}
.message.user .bubble { border-radius: var(--radius-md); color: #fff; background: #35363a; }
.maintenance-action {
  width: fit-content;
  padding: 9px 13px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.maintenance-action:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.maintenance-action:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.bundle-list-heading,
.product-list-heading {
  margin: -4px 0 -8px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
}
.bundle-list { display: grid; gap: 10px; margin: -2px 0 2px; }
.bundle-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.bundle-card:hover,
.product:hover { border-color: var(--border-strong); }
.bundle-badge,
.option-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--accent-hover);
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 700;
}
.bundle-card h3 { margin: 9px 0 4px; color: var(--text-strong); font-size: 15px; }
.bundle-card > p { margin: 0; color: var(--muted); font-size: 12px; }
.bundle-card ul {
  display: grid;
  gap: 0;
  margin: 14px 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  list-style: none;
  overflow: hidden;
}
.bundle-card li { padding: 8px 10px; color: var(--muted-strong); background: var(--surface-subtle); font-size: 11px; }
.bundle-card li + li { border-top: 1px solid var(--border); }
.bundle-card .bundle-consumables {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--success);
  background: var(--success-soft);
  font-size: 11px;
  font-weight: 600;
}
.bundle-footer { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-top: 14px; }
.bundle-price strong,
.bundle-price small { display: block; }
.bundle-price strong { color: var(--text-strong); font-size: 14px; }
.bundle-price small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.product-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: -2px 0 2px;
}
.product {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.product-details { min-width: 0; }
.product small,
.product span { display: block; color: var(--muted); font-size: 11px; }
.product strong { display: block; margin: 5px 0 3px; color: var(--text-strong); font-size: 13px; }
.product .option-badge { display: inline-flex; margin-bottom: 8px; color: var(--success); background: var(--success-soft); }
.product-details a { display: inline-block; margin-top: 8px; color: var(--accent-hover); font-size: 11px; font-weight: 600; text-underline-offset: 2px; }
.product-consumables {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}
.price { color: var(--text-strong) !important; font-size: 14px !important; font-weight: 700; white-space: nowrap; }
.product-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.order-button {
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--accent);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.order-button:hover { border-color: var(--accent-hover); background: var(--accent-hover); }

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}
.composer textarea { min-height: 46px; max-height: 128px; padding: 11px 12px; resize: vertical; }
.send-button {
  align-self: end;
  min-width: 62px;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.send-button:hover:not(:disabled) { border-color: var(--accent-hover); background: var(--accent-hover); }
.send-button:disabled { opacity: 0.55; }
.hint { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }

.detail-panel { display: grid; align-content: start; gap: 16px; }
.panel-section { padding: 16px; border-radius: var(--radius-lg); }
.suggestions { display: grid; gap: 7px; margin-top: 14px; }
.suggestion {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--muted-strong);
  text-align: left;
  background: var(--surface);
  font-size: 11px;
  line-height: 1.45;
}
.suggestion:hover:not(:disabled) { color: var(--text-strong); border-color: var(--border-strong); background: var(--surface-subtle); }
.suggestion:disabled { opacity: 0.5; }

.process-list { display: grid; gap: 12px; margin: 14px 0 0; padding: 0; list-style: none; }
.process-list li { display: flex; align-items: flex-start; gap: 10px; }
.process-list li > span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--muted-strong);
  background: var(--surface-subtle);
  font-size: 10px;
  font-weight: 700;
}
.process-list strong,
.process-list small { display: block; }
.process-list strong { color: var(--text-strong); font-size: 11px; }
.process-list small { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.4; }

.typing {
  display: flex;
  gap: 4px;
  align-items: center;
  width: fit-content;
  min-height: 32px;
  padding: 9px 11px;
  border-left: 2px solid var(--accent);
  background: var(--surface-subtle);
}
.typing i { width: 5px; height: 5px; border-radius: 50%; background: #9a9b9f; animation: pulse 800ms infinite alternate; }
.typing i:nth-child(2) { animation-delay: 120ms; }
.typing i:nth-child(3) { animation-delay: 240ms; }

.checkout-dialog {
  width: min(720px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
}
.checkout-dialog::backdrop { background: rgba(20, 21, 23, 0.54); }
.checkout-form { padding: 22px; }
.checkout-form > header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.checkout-form h2 { margin: 0; color: var(--text-strong); font-size: 18px; }
.dialog-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--muted-strong);
  background: var(--surface-subtle);
  font-size: 19px;
}
.dialog-close:hover { color: var(--text-strong); border-color: var(--border-strong); }
.checkout-product {
  margin: 18px 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}
.checkout-product strong,
.checkout-product span { display: block; }
.checkout-product span { margin-top: 4px; color: var(--muted); }
.checkout-product ul { display: grid; gap: 4px; margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 11px; }
.checkout-consumables { display: grid; gap: 8px; margin: -2px 0 18px; }
.checkout-consumables h3 { margin: 0 0 2px; color: var(--text-strong); font-size: 13px; }
.consumable-empty { margin: 0; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--muted); background: var(--surface-subtle); font-size: 11px; }
.consumable-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.consumable-add-label { display: flex; gap: 9px; align-items: flex-start; min-width: 0; }
.consumable-add-label input,
.consent input { accent-color: var(--accent); }
.consumable-add-label input { margin-top: 3px; }
.consumable-add-label strong,
.consumable-add-label small { display: block; }
.consumable-add-label strong { color: var(--text-strong); font-size: 11px; }
.consumable-add-label small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.subscription-field { display: grid; gap: 5px; color: var(--muted-strong); font-size: 10px; font-weight: 600; }
.subscription-field select { height: 34px; padding: 0 8px; }
.subscription-field select:disabled { color: #9b9ca0; background: var(--surface-muted); }
.checkout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.consent { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; color: var(--muted); font-size: 11px; }
.checkout-submit { margin-top: 16px; }
.checkout-error { min-height: 18px; margin: 8px 0 0; color: var(--danger); font-size: 11px; }

@keyframes pulse { to { opacity: 0.3; transform: translateY(-1px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 250px minmax(0, 1fr); }
  .page-content { padding-inline: 24px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 270px; }
  .product-list { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .app-sidebar {
    position: static;
    display: grid;
    grid-template-columns: auto minmax(180px, 1fr);
    gap: 16px 24px;
    width: 100%;
    height: auto;
    padding: 14px 20px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .primary-nav { justify-self: end; }
  .primary-nav .nav-label { display: none; }
  .filter-panel { grid-column: 1 / -1; padding-top: 14px; }
  .filter-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-panel .primary-button { width: auto; min-width: 180px; }
  .sidebar-note { display: none; }
  .page-header { min-height: 104px; padding: 20px 24px; }
  .page-content { padding: 20px 24px 32px; }
  .workspace { grid-template-columns: 1fr; }
  .assistant-panel { height: 680px; }
  .detail-panel { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .app-sidebar { grid-template-columns: 1fr; padding-inline: 16px; }
  .primary-nav { justify-self: stretch; }
  .filter-fields,
  .detail-panel,
  .checkout-grid,
  .consumable-row { grid-template-columns: 1fr; }
  .filter-panel .primary-button { width: 100%; }
  .page-header { min-height: auto; padding: 18px 16px; }
  .page-header h1 { font-size: 21px; }
  .page-content { padding: 16px 12px 28px; }
  .assistant-panel { height: max(580px, calc(100vh - 160px)); }
  .assistant-header { align-items: flex-start; padding: 12px; }
  .assistant-title span { max-width: 220px; }
  .messages { min-height: 420px; padding: 18px 12px; }
  .message.user { max-width: 92%; }
  .bundle-list,
  .bundle-list-heading,
  .product-list,
  .product-list-heading { margin-left: 0; }
  .bundle-footer,
  .product-actions { align-items: stretch; flex-direction: column; }
  .order-button { width: 100%; white-space: normal; }
  .composer { padding: 12px; }
  .send-button { min-width: 58px; }
  .checkout-form { padding: 18px 14px; }
}
