:root {
  --bg: #faf9f5;
  --surface: #fffdf8;
  --surface-muted: #f5f0e8;
  --surface-card: #efe9de;
  --surface-strong: #e8e0d2;
  --surface-dark: #181715;
  --surface-dark-soft: #1f1e1b;
  --surface-dark-elevated: #252320;
  --line: #e6dfd8;
  --line-strong: #d6cbbd;
  --text: #141413;
  --body: #3d3d3a;
  --muted: #6c6a64;
  --muted-soft: #8e8b82;
  --teal: #cc785c;
  --teal-dark: #a9583e;
  --teal-soft: #f4e3dc;
  --blue: #5db8a6;
  --amber: #b7791f;
  --amber-soft: #f8ead3;
  --red: #c64545;
  --green: #4f9d63;
  --on-dark: #faf9f5;
  --on-dark-soft: #b8b2a8;
  --shadow: 0 1px 3px rgba(20, 20, 19, 0.08);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 1120px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
  letter-spacing: 0;
}

body[data-locale="zh-Hans"] {
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
}

body[data-locale="en"] {
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(900px, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 14px;
  border-right: 1px solid #2f2c28;
  background: var(--surface-dark);
  color: var(--on-dark);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 16px;
  border-bottom: 1px solid rgba(250, 249, 245, 0.12);
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--teal-dark);
  font-weight: 700;
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--teal);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--on-dark-soft);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d9d2c8;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-dark-elevated);
}

.nav-item.active {
  background: var(--teal);
  color: #ffffff;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 18px;
  min-height: 100vh;
  padding: 20px;
  overflow: hidden;
}

.interaction-center {
  display: grid;
  grid-template-columns: minmax(300px, 0.62fr) minmax(520px, 1fr);
  gap: 16px;
  align-content: start;
  grid-template-rows: auto 1fr;
  min-height: calc(100vh - 36px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.interaction-context {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.agent-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-card);
  color: var(--teal-dark);
  font-size: 14px;
  font-weight: 900;
}

.section-kicker {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.interaction-context h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interaction-context p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.interaction-console {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.interaction-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.interaction-tabs button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--body);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.interaction-tabs button.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.interaction-compose {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 82px;
  gap: 10px;
}

.interaction-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.interaction-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.interaction-prompts button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--body);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.interaction-prompts button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.interaction-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 260px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.interaction-status span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interaction-records {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  border: 1px solid #302d29;
  border-radius: 14px;
  background: var(--surface-dark);
  overflow: hidden;
}

.interaction-records-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #35322d;
  background: var(--surface-dark);
  color: var(--on-dark);
}

.interaction-records-head p {
  margin-top: 4px;
  color: var(--on-dark-soft);
  font-size: 13px;
}

.interaction-table-wrap {
  min-height: 0;
  overflow: auto;
}

.interaction-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  background: var(--surface-dark-soft);
}

.interaction-table th,
.interaction-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #302d29;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.55;
}

.interaction-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-dark-elevated);
  color: var(--on-dark-soft);
  font-weight: 800;
}

.interaction-table td:nth-child(1),
.interaction-table td:nth-child(3) {
  width: 180px;
  color: var(--on-dark);
  font-weight: 700;
}

.interaction-table td:nth-child(4) {
  width: 140px;
}

.interaction-table td:nth-child(5) {
  color: #d8d0c6;
}

.interaction-table td {
  color: var(--on-dark-soft);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", "Noto Serif SC", "Noto Serif TC", serif;
  font-size: 26px;
  font-weight: 500;
  line-height: 1.25;
}

h2 {
  font-size: 17px;
  line-height: 1.35;
}

h3 {
  font-size: 15px;
  line-height: 1.4;
}

.page-header p,
.panel-header p,
.product-panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.language-control {
  display: block;
}

.language-control select {
  width: 150px;
  min-height: 38px;
}

.ghost-button,
.primary-button,
.dark-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}

.ghost-button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
}

.primary-button {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.button-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 800;
}

.dark-button {
  border-color: var(--surface-dark);
  background: var(--surface-dark);
  color: var(--on-dark);
  font-weight: 700;
}

.add-menu {
  position: relative;
}

.upload-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: none;
  width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-menu.open {
  display: grid;
}

.upload-menu button {
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.upload-menu button:hover {
  background: var(--surface-muted);
}

.top-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.4fr) minmax(360px, 0.8fr);
  gap: 16px;
  min-height: 210px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 350px minmax(620px, 1fr);
  gap: 16px;
  min-height: 0;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
}

.panel-header.compact {
  padding-bottom: 8px;
}

.search-panel {
  padding-bottom: 16px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 86px;
  gap: 10px;
  padding: 0 16px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: 0;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.16);
}

textarea {
  width: 100%;
  min-height: 132px;
  padding: 12px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.55;
  outline: 0;
}

textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.16);
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  padding: 14px 16px 0;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.agent-panel {
  overflow: hidden;
}

.status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.idle {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.status-pill.running {
  background: var(--amber-soft);
  color: var(--amber);
}

.progress-wrap {
  padding: 0 16px 12px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.progress-label strong {
  color: var(--text);
}

.progress-track {
  height: 9px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #e8a55a);
  transition: width 0.35s ease;
}

.agent-log {
  display: grid;
  gap: 8px;
  max-height: 92px;
  overflow: auto;
  padding: 0 16px 16px;
  color: var(--body);
  font-size: 13px;
  line-height: 1.45;
}

.agent-log div {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-muted);
}

.file-panel,
.product-panel {
  min-height: 0;
  overflow: hidden;
}

.category-search {
  display: grid;
  grid-template-columns: 1fr 70px;
  gap: 8px;
  padding: 0 14px 12px;
}

.category-search button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-card);
  color: var(--text);
  font-weight: 700;
}

.file-tree {
  height: calc(100vh - 390px);
  min-height: 360px;
  overflow: auto;
  padding: 0 12px 16px;
}

.tree-group {
  margin-bottom: 12px;
}

.tree-category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 800;
  text-align: left;
}

.tree-category:hover,
.tree-category.active {
  background: var(--surface-strong);
  color: var(--teal-dark);
}

.tree-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tree-company {
  margin: 8px 0 4px 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: calc(100% - 22px);
  min-height: 34px;
  margin-left: 22px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.tree-item:hover {
  background: var(--surface-muted);
}

.tree-item.file {
  color: var(--body);
}

.file-type {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.product-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

.product-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.product-scroll {
  height: calc(100vh - 390px);
  min-height: 360px;
  overflow: auto;
  padding: 16px;
  scroll-behavior: smooth;
}

.category-section {
  scroll-margin-top: 14px;
  margin-bottom: 22px;
}

.category-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.category-section-header p {
  max-width: 760px;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.6;
}

.category-tag {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}

.product-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.product-card.pending {
  border-color: #e8c66a;
  background: #fff8e8;
}

.product-card-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.product-card h3 {
  min-width: 0;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.summary {
  color: var(--body);
  font-size: 14px;
  line-height: 1.6;
}

/* 產品卡片：保費 / 交費 / 續保 規格塊 + 推薦人群 */
.spec-list {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
}

.spec-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.spec-key {
  color: var(--teal-dark);
  font-weight: 800;
}

.spec-val {
  color: var(--body);
  overflow-wrap: anywhere;
}

.spec-note {
  color: var(--muted-soft);
}

.best-for {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
  line-height: 1.55;
  color: var(--body);
}

.best-for-key {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.reviewed {
  background: #e7f3e9;
  color: var(--green);
}

.status.pending {
  background: var(--amber-soft);
  color: var(--amber);
}

.status.processing {
  background: #dff3ee;
  color: var(--blue);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-actions button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.card-actions button.primary-link {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.drawer.open {
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 19, 0);
  transition: background 0.2s ease;
}

.drawer.open .drawer-backdrop {
  background: rgba(20, 20, 19, 0.46);
}

.drawer-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(1180px, calc(100vw - 32px));
  max-height: min(92vh, 1040px);
  padding: 24px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translate(-50%, -48%) scale(0.98);
  opacity: 0;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.drawer.open .drawer-panel {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.drawer-title {
  padding-right: 42px;
  font-size: 22px;
}

.drawer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.drawer-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.drawer-section h3 {
  margin-bottom: 10px;
}

.drawer-section p,
.drawer-section li {
  color: var(--body);
  line-height: 1.65;
}

.drawer-section ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.citation-list {
  display: grid;
  gap: 8px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field-item {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-value {
  margin-top: 5px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.field-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.source-file-list {
  display: grid;
  gap: 8px;
}

.source-file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
}

.source-file-item.needs-review {
  border-color: #e8c66a;
  background: #fff8e8;
}

.source-file-item strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  word-break: break-word;
}

.source-file-item p {
  margin-top: 4px;
  color: var(--body);
  font-size: 13px;
  line-height: 1.45;
}

.source-file-item span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.citation-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--body);
  font-size: 14px;
}

.document-list {
  display: grid;
  gap: 14px;
}

.document-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
}

.document-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.document-card-head h4 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.document-card-head p,
.document-card-head a {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.document-card-head a {
  white-space: nowrap;
  color: var(--teal-dark);
  font-weight: 800;
  text-decoration: none;
}

.document-text {
  max-height: 460px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--body);
  font: inherit;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.document-image {
  display: block;
  max-width: 100%;
  max-height: min(80vh, 900px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  object-fit: contain;
}

.document-frame {
  width: 100%;
  min-height: 72vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.recommendation-input-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding-bottom: 16px;
}

.need-textarea {
  width: calc(100% - 32px);
  margin: 0 16px;
}

.recommendation-agent-panel,
.recommendation-history-panel,
.recommendation-products-panel,
.policy-entry-panel,
.policy-service-panel,
.policy-list-panel,
.renewal-panel,
.commission-summary-panel,
.commission-team-panel,
.commission-table-panel {
  min-width: 0;
  overflow: hidden;
}

.recommendation-history-panel .file-tree,
.recommendation-products-panel .product-scroll,
.policy-list-panel .product-scroll,
.renewal-panel .dashboard-list,
.commission-team-panel .dashboard-list {
  max-height: calc(100vh - 420px);
  overflow: auto;
}

.policy-entry-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 16px 16px;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px 16px;
}

.service-card {
  min-height: 104px;
}

.commission-detail-layout {
  grid-template-columns: 1fr;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.review-actions button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.review-actions .approve {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
  font-weight: 700;
}

.view {
  display: none;
  min-width: 0;
  min-height: 0;
}

.view.active {
  display: grid;
  gap: 16px;
}

.dashboard-grid,
.proposal-layout,
.customer-layout,
.admin-grid {
  display: grid;
  gap: 16px;
  min-width: 0;
  min-height: 0;
}

.dashboard-grid {
  grid-template-columns: minmax(560px, 1fr) minmax(320px, 0.42fr);
  align-items: start;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  min-width: 0;
}

.metric-card,
.work-list,
.risk-list,
.conversation-list,
.message-thread,
.composer,
.insight-panel,
.proposal-list,
.proposal-detail,
.compliance-box,
.candidate-list,
.approval-bar,
.customer-list,
.customer-profile,
.timeline,
.settings-section,
.member-table,
.channel-grid,
.activity-log {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.metric-card {
  display: grid;
  gap: 7px;
  min-height: 112px;
  padding: 14px;
}

.metric-card small,
.metric-card .metric-label,
.work-list small,
.risk-list small,
.conversation-item small,
.proposal-list small,
.customer-list small,
.activity-log small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong,
.metric-card .metric-value {
  color: var(--text);
  font-size: 28px;
  line-height: 1.15;
}

.metric-card p {
  color: var(--body);
  font-size: 13px;
  line-height: 1.45;
}

.work-list,
.risk-list,
.activity-log,
.timeline {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.work-list > *,
.risk-list > *,
.activity-log > *,
.timeline > * {
  min-width: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.work-list > *:last-child,
.risk-list > *:last-child,
.activity-log > *:last-child,
.timeline > *:last-child {
  border-bottom: 0;
}

.risk-list > *,
.compliance-box {
  border-left: 3px solid #e8c66a;
}

.conversation-layout {
  display: grid;
  grid-template-columns: 330px minmax(720px, 1fr);
  gap: 16px;
  min-width: 0;
  min-height: calc(100vh - 148px);
}

.conversation-list,
.message-thread,
.insight-panel {
  min-height: 0;
  overflow: auto;
}

.conversation-list {
  display: grid;
  align-content: start;
}

.conversation-item {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.conversation-item:hover,
.conversation-item.active {
  background: var(--surface-muted);
}

.conversation-item.active {
  box-shadow: inset 3px 0 0 var(--teal);
}

.conversation-item strong,
.conversation-item p,
.message p,
.proposal-list p,
.candidate-list p,
.customer-list p,
.customer-profile p,
.timeline p,
.activity-log p {
  min-width: 0;
  overflow-wrap: anywhere;
}

.message-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
}

.message {
  display: grid;
  gap: 5px;
  width: fit-content;
  max-width: min(680px, 78%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--body);
  line-height: 1.55;
}

.message.agent,
.message.advisor,
.message.outgoing,
.message.sent {
  align-self: flex-end;
  border-color: #e4c7ba;
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.message.customer,
.message.incoming {
  align-self: flex-start;
}

.message.system,
.message.notice {
  align-self: center;
  max-width: 86%;
  border-color: var(--line);
  background: var(--surface-card);
  color: var(--body);
  font-size: 13px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
}

.composer textarea {
  width: 100%;
  min-height: 72px;
  max-height: 180px;
  padding: 10px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  outline: 0;
}

.composer textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.16);
}

.composer button {
  align-self: end;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--teal);
  color: #ffffff;
  font-weight: 700;
  white-space: nowrap;
}

.insight-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.insight-panel section,
.settings-section section,
.customer-profile section,
.proposal-detail section {
  min-width: 0;
}

.proposal-layout {
  grid-template-columns: 330px minmax(720px, 1fr);
  align-items: start;
}

.proposal-list,
.customer-list {
  display: grid;
  align-content: start;
  overflow: hidden;
}

.proposal-list > *,
.customer-list > * {
  min-width: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.proposal-list > *:last-child,
.customer-list > *:last-child {
  border-bottom: 0;
}

.proposal-detail {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.compliance-box {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  background: #fff8e8;
}

.compliance-box.high,
.compliance-box.risk,
.compliance-box.danger {
  border-left-color: var(--red);
  background: #fff0ed;
}

.compliance-box.low,
.compliance-box.passed,
.compliance-box.safe {
  border-left-color: var(--green);
  background: #e7f3e9;
}

.candidate-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.candidate-list > * {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.approval-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  box-shadow: 0 -8px 20px rgba(20, 20, 19, 0.08);
}

.approval-bar .actions,
.approval-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.customer-layout {
  grid-template-columns: 320px minmax(720px, 1fr);
  align-items: start;
}

.customer-profile {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.timeline {
  position: relative;
  padding: 6px 0;
}

.timeline > * {
  position: relative;
  padding-left: 34px;
}

.timeline > *::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 14px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--teal);
  border-radius: 999px;
  background: var(--surface);
}

.timeline > *::after {
  content: "";
  position: absolute;
  top: 31px;
  bottom: -1px;
  left: 18px;
  width: 1px;
  background: var(--line);
}

.timeline > *:last-child::after {
  display: none;
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  align-items: start;
}

.settings-section {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.member-table {
  overflow: auto;
}

.member-table table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.member-table th,
.member-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--body);
  font-size: 13px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.member-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-weight: 800;
}

.member-table tr:last-child td {
  border-bottom: 0;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  padding: 12px;
}

.channel-grid > * {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.activity-log {
  max-height: 420px;
  overflow: auto;
}

.status-pill.pending-review,
.status-pill.review,
.status-pill.pending,
.status-pill[data-status="待審核"],
.status.pending-review,
.status.review,
.status[data-status="待審核"] {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.needs-source,
.status-pill.needs-info,
.status-pill.incomplete,
.status-pill[data-status="需補充"],
.status.needs-source,
.status.needs-info,
.status.incomplete,
.status[data-status="需補充"] {
  background: #e3f2ed;
  color: #327565;
}

.status-pill.sent,
.status-pill.delivered,
.status-pill[data-status="已發送"],
.status.sent,
.status.delivered,
.status[data-status="已發送"] {
  background: #e7f3e9;
  color: var(--green);
}

.status-pill.rejected,
.status-pill.declined,
.status-pill[data-status="已駁回"],
.status.rejected,
.status.declined,
.status[data-status="已駁回"] {
  background: #fff0ed;
  color: var(--red);
}

.status-pill.risk,
.status-pill.warning,
.status-pill.high-risk,
.status-pill[data-status="風險"],
.status.risk,
.status.warning,
.status.high-risk,
.status[data-status="風險"] {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.approved,
.status-pill.active,
.status-pill.passed,
.status-pill[data-status="已通過"],
.status.approved,
.status.active,
.status.passed,
.status[data-status="已通過"] {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.status-pill.draft,
.status-pill.paused,
.status-pill[data-status="草稿"],
.status.draft,
.status.paused,
.status[data-status="草稿"] {
  background: var(--surface-card);
  color: var(--muted);
}

.metric-card,
.conversation-item,
.message,
.proposal-list > *,
.proposal-detail,
.candidate-list > *,
.customer-list > *,
.customer-profile,
.settings-section,
.channel-grid > *,
.activity-log > * {
  overflow-wrap: anywhere;
}

@media (max-width: 1260px) {
  body {
    min-width: 980px;
  }

  .app-shell {
    grid-template-columns: 190px minmax(790px, 1fr);
  }

  .top-grid {
    grid-template-columns: 1fr;
  }

  .bottom-grid {
    grid-template-columns: 320px minmax(520px, 1fr);
  }

  .product-list {
    grid-template-columns: 1fr;
  }

  .dashboard-grid,
  .conversation-layout,
  .proposal-layout,
  .customer-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .message {
    max-width: 88%;
  }
}

/* 保單錄入表單（保單中心） */
.drawer-meta-text {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.policy-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.policy-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.policy-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.policy-form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.policy-form-field .required {
  color: var(--red);
}

.policy-form-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted-soft);
}

.policy-form-error {
  margin: 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(198, 69, 69, 0.1);
  color: var(--red);
  font-size: 13px;
}

.policy-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

.policy-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.ghost-button.danger {
  color: var(--red);
  border-color: rgba(198, 69, 69, 0.4);
}

.ghost-button.danger:hover {
  background: rgba(198, 69, 69, 0.08);
}

.policy-note {
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 720px) {
  .policy-form-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== 保险资讯（Insurance News） ===== */
.news-updated {
  color: var(--muted);
  font-size: 13px;
}
.news-updated strong {
  color: var(--text);
}

.news-top-layout {
  grid-template-columns: minmax(520px, 1.4fr) minmax(360px, 0.8fr);
}

.news-keyword-panel {
  padding-bottom: 16px;
}
.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}
.kw-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 6px 0 12px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
}
.kw-chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(169, 88, 62, 0.16);
  color: var(--teal-dark);
  font-size: 13px;
  line-height: 1;
}
.kw-chip button:hover {
  background: var(--teal);
  color: #fff;
}
.keyword-add {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 10px;
  padding: 0 16px 14px;
}
.keyword-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
}
.suggest-label {
  color: var(--muted);
  font-size: 12px;
  margin-right: 2px;
}
.kw-suggest {
  height: 28px;
  padding: 0 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--body);
  font-size: 12px;
  font-weight: 600;
}
.kw-suggest:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: var(--teal-soft);
}
.empty-inline {
  color: var(--muted-soft);
  font-size: 13px;
  padding: 0 2px 4px;
}

.status-pill.done {
  background: #e3f0e7;
  color: var(--green);
}

.news-result-layout {
  grid-template-columns: 300px minmax(620px, 1fr);
}

.news-filter-panel {
  overflow: hidden;
}
.news-date-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 16px 14px;
}
.news-date-tabs button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--body);
  font-size: 13px;
  font-weight: 600;
}
.news-date-tabs button.active {
  border-color: var(--surface-dark);
  background: var(--surface-dark);
  color: var(--on-dark);
}
.filter-divider {
  margin: 4px 16px 12px;
  border-top: 1px solid var(--line);
}
.news-source-list {
  display: grid;
  gap: 4px;
  padding: 0 12px 8px;
}
.news-source-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
}
.news-source-list button:hover {
  background: var(--surface-muted);
}
.news-source-list button.active {
  background: var(--surface-card);
  font-weight: 700;
}
.news-source-list button span {
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}
.news-source-list button.active span {
  background: var(--amber-soft);
  color: var(--amber);
}
.news-relevant-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 16px 14px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--body);
  font-size: 13px;
  cursor: pointer;
}
.news-relevant-toggle input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--teal);
}

.news-scroll {
  height: calc(100vh - 390px);
  min-height: 360px;
  overflow: auto;
  padding: 14px 16px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.news-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.news-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 4px 14px rgba(20, 20, 19, 0.07);
}
.news-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.kw-tag {
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--surface-card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}
.kw-tag.hit {
  background: var(--teal-soft);
  color: var(--teal-dark);
}
.news-relevant-badge {
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.news-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text);
}
.news-title a {
  color: inherit;
  text-decoration: none;
}
.news-title a:hover {
  color: var(--teal-dark);
}
.news-summary {
  margin-top: 6px;
  color: var(--body);
  font-size: 13.5px;
  line-height: 1.6;
}
.news-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
}
.news-source {
  font-weight: 700;
  color: var(--body);
}
.news-dot {
  color: var(--line-strong);
}
.news-link {
  margin-left: auto;
  color: var(--teal-dark);
  font-weight: 700;
  text-decoration: none;
}
.news-link:hover {
  text-decoration: underline;
}
.news-relate {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--body);
  font-size: 12.5px;
}
.news-relate b {
  color: var(--teal-dark);
}
.news-scroll .empty-state {
  margin: 8px 0;
}

.news-analysis {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 8px;
  border-left: 3px solid var(--teal);
  background: var(--surface-muted);
  color: var(--body);
  font-size: 12.5px;
  line-height: 1.6;
}
.news-analysis-tag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  margin-top: 1px;
  border-radius: 5px;
  background: var(--teal);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* ===== 营销工具 ===== */
.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 4px;
}
.nav-item.nav-new {
  display: flex;
  align-items: center;
}
.nav-item.nav-new::after {
  content: "NEW";
  margin-left: auto;
  font-size: 9px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.nav-item.nav-new.active::after {
  background: rgba(255, 255, 255, 0.28);
}

.marketing-layout {
  grid-row: 2 / 4;
  overflow-y: auto;
  align-content: start;
}
.marketing-kicker {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--teal-dark);
  font-weight: 700;
  margin-bottom: 14px;
}
.marketing-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 1360px) {
  .marketing-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.marketing-card {
  position: relative;
  text-align: left;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  transition: 0.15s;
}
.marketing-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.marketing-card .mk-ico {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--teal-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 13px;
}
.marketing-card .mk-ico svg {
  width: 22px;
  height: 22px;
  color: var(--teal-dark);
}
.marketing-card .mk-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.marketing-card .mk-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}
.mk-tag {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.mk-tag.new {
  background: var(--teal-soft);
  color: var(--teal-dark);
}
.mk-tag.core {
  background: #fbeae3;
  color: #a9583e;
  border: 1px solid #e9c3b4;
}
.mk-tag.reuse {
  background: var(--surface-strong);
  color: var(--muted);
}

.mk-toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface-dark);
  color: var(--on-dark);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(20, 20, 19, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: 0.22s;
  z-index: 200;
}
.mk-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
