* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --color-green: #52C41A;
  --color-blue: #1890FF;
  --color-yellow: #FAAD14;
  --color-red: #F5222D;
  --bg: #f0f2f5;
  --bg-panel: #fff;
  --border: #e8e8e8;
  --text: #333;
  --text-secondary: #888;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app-container { height: 100vh; display: flex; flex-direction: column; }

/* Header */
.app-header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow); z-index: 10;
}
.app-header h1 { font-size: 18px; font-weight: 600; }
.header-subtitle { color: var(--text-secondary); font-size: 13px; }
.header-actions { margin-left: auto; display: flex; gap: 8px; }

/* Buttons */
.btn {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 14px; transition: all 0.2s;
}
.btn:hover { border-color: var(--color-blue); color: var(--color-blue); }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-outline { background: transparent; }
.btn-send {
  width: 40px; height: 40px; background: var(--color-blue); color: #fff;
  border: none; border-radius: 50%; font-size: 18px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.btn-send:hover { background: #40a9ff; }
.btn-send:disabled { background: #ccc; cursor: not-allowed; }
.btn-mic {
  width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 50%;
  background: #fff; cursor: pointer; font-size: 18px; flex-shrink: 0; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.btn-mic:hover { border-color: var(--color-blue); }
.btn-mic.recording { background: var(--color-red); color: #fff; border-color: var(--color-red); animation: pulse 1s infinite; }
.btn-submit {
  width: 100%; padding: 12px;
  background: var(--color-green); color: #fff; border: none; border-radius: 6px;
  font-size: 16px; cursor: pointer; font-weight: 600;
}
.btn-submit:hover { background: #73d13d; }
.btn-submit:disabled { background: #ccc; cursor: not-allowed; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,34,45,0.4); }
  50% { box-shadow: 0 0 0 12px rgba(245,34,45,0); }
}

/* Main Content */
.main-content {
  flex: 1; display: flex; overflow: hidden; padding: 16px; gap: 16px;
}

/* Panels */
.panel {
  background: var(--bg-panel); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.panel-header {
  padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--border);
  background: #fafafa; font-size: 14px;
}
.chat-panel-header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.panel-header-title { white-space: nowrap; }
.customer-info-inputs { display: flex; gap: 8px; flex: 1; }
.customer-info-inputs input {
  flex: 1; padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 12px; font-weight: 400; outline: none; min-width: 80px;
  background: #fff;
}
.customer-info-inputs input:focus { border-color: var(--color-blue); }
.customer-info-inputs input::placeholder { color: #bbb; }
.panel-left { flex: 1; min-width: 0; }
.panel-right { width: 420px; flex-shrink: 0; }

/* Chat */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.chat-loading { text-align: center; color: var(--text-secondary); padding: 40px; }

.message { max-width: 80%; padding: 10px 14px; border-radius: 12px; line-height: 1.6; font-size: 14px; word-wrap: break-word; }
.message.user { align-self: flex-end; background: var(--color-blue); color: #fff; border-bottom-right-radius: 4px; }
.message.assistant { align-self: flex-start; background: #f5f5f5; border-bottom-left-radius: 4px; }
.message.assistant p { margin: 4px 0; }
.message.assistant ul, .message.assistant ol { padding-left: 20px; margin: 4px 0; }
.message.assistant code { background: #e8e8e8; padding: 2px 6px; border-radius: 3px; font-size: 13px; }

/* Chat Input */
.chat-input-area { padding: 12px 16px; border-top: 1px solid var(--border); }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input {
  flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  font-size: 14px; resize: none; outline: none; font-family: inherit;
}
.chat-input:focus { border-color: var(--color-blue); }
.voice-status { text-align: center; color: var(--text-secondary); font-size: 12px; margin-top: 4px; min-height: 18px; }

/* Score Content */
.score-content { flex: 1; overflow-y: auto; padding: 16px; }
.panel-footer {
  padding: 12px 16px; border-top: 1px solid var(--border);
  background: #fafafa; flex-shrink: 0;
}

.score-total-section { text-align: center; margin-bottom: 12px; }
.score-total-label { font-size: 13px; color: var(--text-secondary); }
.score-total-value { font-size: 48px; font-weight: 700; line-height: 1.2; }
.score-total-level { font-size: 14px; font-weight: 600; margin-top: 4px; }

/* Radar */
.radar-container { width: 100%; max-width: 280px; margin: 0 auto 16px; }

/* Dimension Bars */
.dimension-bars { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.dim-bar { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dim-label { width: 90px; text-align: right; flex-shrink: 0; }
.dim-progress { flex: 1; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.dim-fill { height: 100%; border-radius: 4px; transition: width 0.3s, background 0.3s; }
.dim-value { width: 30px; text-align: center; font-weight: 600; font-size: 13px; }

/* Improvement Hints */
.improvement-hints { margin-bottom: 16px; }
.hints-header { font-weight: 600; font-size: 13px; margin-bottom: 8px; color: #389e0d; }
.hints-list { display: flex; flex-direction: column; gap: 6px; }
.hint-item {
  padding: 8px 10px; border-radius: 4px; font-size: 12px; line-height: 1.5;
  background: #f6ffed; border-left: 3px solid #52C41A;
}
.hint-item .hint-reason { font-weight: 600; color: #389e0d; margin-bottom: 2px; }
.hint-item .hint-text { color: #555; }
.hint-item .hint-field { color: #888; font-size: 11px; margin-top: 2px; }

/* System Tips */
.system-tips { margin-bottom: 16px; }
.tips-header { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.tips-list { display: flex; flex-direction: column; gap: 6px; }
.tip-item { padding: 8px 10px; border-radius: 4px; font-size: 12px; line-height: 1.5; }
.tip-item.WARNING { background: #fff7e6; border-left: 3px solid var(--color-yellow); color: #ad6800; }
.tip-item.SUGGEST { background: #e6f7ff; border-left: 3px solid var(--color-blue); color: #096dd9; }

/* Draft Fields */
.draft-fields { margin-bottom: 16px; }
.draft-header { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.draft-list { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.draft-item { padding: 6px 8px; background: #fafafa; border-radius: 4px; display: flex; justify-content: space-between; gap: 8px; }
.draft-item-name { color: var(--text-secondary); flex-shrink: 0; }
.draft-item-value { color: var(--text); word-break: break-all; text-align: right; }
.draft-item-score { font-weight: 600; flex-shrink: 0; }
.draft-item.score-ok { border-left: 3px solid var(--color-green); }
.draft-item.score-warn { border-left: 3px solid var(--color-yellow); }
.draft-item.score-empty { border-left: 3px solid var(--color-red); }

/* History Page */
.history-container { padding: 24px; max-width: 900px; margin: 0 auto; }
.history-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; }

/* Toolbar */
.history-toolbar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.history-search { display: flex; gap: 8px; flex: 1; min-width: 200px; }
.history-search input {
  flex: 1; padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; outline: none;
}
.history-search input:focus { border-color: var(--color-blue); }
.history-sort { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.history-sort select {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 12px; outline: none; background: #fff;
}

/* History List */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  padding: 16px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  transition: all 0.2s; display: flex; align-items: flex-start; gap: 8px;
}
.history-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.history-item-main { flex: 1; cursor: pointer; min-width: 0; }
.history-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.history-item-category { font-weight: 600; }
.history-customer-info {
  font-size: 13px; color: var(--text-secondary); margin-bottom: 6px;
  padding: 4px 8px; background: #f5f5f5; border-radius: 4px; display: inline-block;
}
.history-item-score { font-size: 24px; font-weight: 700; }
.history-item-meta { font-size: 12px; color: var(--text-secondary); }
.history-empty { text-align: center; color: var(--text-secondary); padding: 60px 0; }
.history-back { margin-bottom: 16px; }

/* Delete button on history item */
.btn-delete-item {
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: transparent; color: #ccc; font-size: 14px; cursor: pointer;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; margin-top: 2px;
}
.btn-delete-item:hover { background: #fff1f0; color: var(--color-red); }

/* Pagination */
.history-pagination {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  margin-top: 20px; flex-wrap: wrap;
}
.btn-page {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px;
  background: #fff; cursor: pointer; font-size: 12px; color: var(--text);
  transition: all 0.15s;
}
.btn-page:hover:not(:disabled):not(.active) { border-color: var(--color-blue); color: var(--color-blue); }
.btn-page.active { background: var(--color-blue); color: #fff; border-color: var(--color-blue); }
.btn-page:disabled { color: #ccc; cursor: not-allowed; }
.btn-search {
  background: var(--color-blue); color: #fff; border-color: var(--color-blue);
}
.btn-search:hover { background: #40a9ff; border-color: #40a9ff; }
.btn-danger { background: var(--color-red); color: #fff; border-color: var(--color-red); }
.btn-danger:hover { background: #ff7875; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-box {
  background: #fff; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  width: 380px; max-width: 90vw;
}
.modal-header { padding: 16px 20px; font-weight: 600; font-size: 15px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; font-size: 14px; color: var(--text-secondary); }
.modal-footer { padding: 12px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }

/* Responsive */
@media (max-width: 768px) {
  .main-content { flex-direction: column; }
  .panel-right { width: 100%; max-height: 50vh; }
}
