:root {
  --panel: rgba(255, 252, 246, 0.92);
  --panel-strong: #fffdf8;
  --border: #ddd1bb;
  --text: #1f2328;
  --muted: #6f6a62;
  --brand: #0f766e;
  --brand-soft: #d7f0ec;
  --user-bg: #eef4ff;
  --assistant-bg: #f3fbf8;
  --shadow: 0 18px 50px rgba(72, 57, 30, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(
      circle at top left,
      rgba(15, 118, 110, 0.12),
      transparent 28%
    ),
    radial-gradient(
      circle at top right,
      rgba(180, 83, 9, 0.13),
      transparent 24%
    ),
    linear-gradient(180deg, #f7f4ed 0%, #f0ebe2 100%);
  padding: 32px 16px;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  height: calc(100vh - 64px);
  background: var(--panel);
  border: 1px solid rgba(221, 209, 187, 0.8);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  padding: 28px 28px 16px;
  border-bottom: 1px solid rgba(221, 209, 187, 0.65);
  background:
    linear-gradient(135deg, rgba(255, 248, 237, 0.9), rgba(242, 250, 247, 0.9)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.2));
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.hero-panel {
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid rgba(221, 209, 187, 0.85);
  border-radius: 20px;
  padding: 18px;
}

.hero-panel-title,
.section-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7c6f5d;
}

.hero-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.content {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 0;
  flex: 1;
}

.sidebar {
  padding: 22px;
  border-right: 1px solid rgba(221, 209, 187, 0.65);
  background: rgba(255, 252, 247, 0.86);
  overflow: auto;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(221, 209, 187, 0.75);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-card {
  border: 1px solid rgba(221, 209, 187, 0.95);
  background: rgba(255, 253, 248, 0.92);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 6px 18px rgba(77, 60, 31, 0.05);
}

.history-card h4,
.history-card p {
  margin: 0;
}

.history-card h4 {
  font-size: 13px;
  line-height: 1.5;
}

.history-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.history-suggestion {
  margin-top: 8px;
  color: #0a5b54;
  font-size: 12px;
  line-height: 1.55;
}

.history-human-flag {
  margin-top: 8px;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.history-human-reason {
  margin-top: 4px;
  color: #7f1d1d;
  font-size: 12px;
  line-height: 1.5;
}

.history-priority {
  margin-top: 8px;
  color: #9a3412;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.history-workflow-status {
  margin-top: 8px;
  color: #0a5b54;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

.history-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(100, 116, 139, 0.14);
  color: #475569;
}

.history-badge.payment {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

.history-badge.technical {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.history-badge.support {
  background: rgba(22, 163, 74, 0.14);
  color: #15803d;
}

.history-badge.general {
  background: rgba(100, 116, 139, 0.14);
  color: #475569;
}

.history-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.chip {
  width: 100%;
  border: 1px solid rgba(221, 209, 187, 0.95);
  background: var(--panel-strong);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

.chip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.chip span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(221, 209, 187, 0.65);
  background: rgba(255, 255, 255, 0.4);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: #0a5b54;
  font-size: 13px;
  font-weight: 700;
}

.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #0f766e;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15);
}

.status-bar small {
  color: var(--muted);
}

.dashboard {
  padding: 18px 22px;
  border-bottom: 1px solid rgba(221, 209, 187, 0.65);
  background: rgba(255, 253, 248, 0.68);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  border: 1px solid rgba(221, 209, 187, 0.9);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  padding: 14px 16px;
}

.metric-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  margin: 0;
  color: var(--text);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.dashboard-table-wrap {
  margin-top: 16px;
  border: 1px solid rgba(221, 209, 187, 0.95);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
  overflow: auto;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.dashboard-table th,
.dashboard-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(221, 209, 187, 0.72);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

.dashboard-table th {
  background: rgba(246, 239, 227, 0.9);
  color: #7a6542;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dashboard-table tr:last-child td {
  border-bottom: none;
}

.dashboard-question {
  max-width: 320px;
  line-height: 1.5;
}

#messages {
  flex: 1;
  min-height: 300px;
  height: 0;
  overflow: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(
    180deg,
    rgba(255, 252, 247, 0.55),
    rgba(247, 244, 238, 0.7)
  );
  scroll-behavior: smooth;
}

.empty-state {
  margin: auto;
  max-width: 440px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed rgba(221, 209, 187, 0.95);
  border-radius: 20px;
  padding: 26px 24px;
}

.empty-state h3 {
  margin: 0 0 10px;
  color: var(--text);
}

.message {
  display: flex;
  gap: 12px;
}

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}

.message.user .avatar {
  background: #dbe8ff;
  color: #2957c8;
}

.message.assistant .avatar {
  background: var(--brand-soft);
  color: #0a5b54;
}

.bubble {
  max-width: min(780px, 100%);
  border-radius: 20px;
  padding: 16px 18px;
  border: 1px solid rgba(221, 209, 187, 0.85);
  line-height: 1.65;
  box-shadow: 0 8px 24px rgba(77, 60, 31, 0.06);
}

.message.user .bubble {
  background: var(--user-bg);
}

.message.assistant .bubble {
  background: var(--assistant-bg);
}

.meta {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.bubble p,
.bubble pre {
  margin: 0;
}

.bubble pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

.suggestion {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(221, 209, 187, 0.95);
  color: #0a5b54;
  font-size: 13px;
  line-height: 1.6;
}

.human-flag {
  margin-top: 10px;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.human-reason {
  margin-top: 4px;
  color: #7f1d1d;
  font-size: 13px;
  line-height: 1.6;
}

.priority {
  margin-top: 10px;
  color: #9a3412;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.workflow-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.workflow-button {
  border: 1px solid rgba(221, 209, 187, 0.95);
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 253, 248, 0.92);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.workflow-status {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: #0a5b54;
  font-size: 12px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid rgba(221, 209, 187, 0.95);
  border-radius: 16px;
  background: #fffdfa;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(221, 209, 187, 0.72);
  text-align: left;
  font-size: 14px;
}

th {
  background: #f6efe3;
  color: #7a6542;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: none;
}

.footer {
  padding: 18px 22px 22px;
  border-top: 1px solid rgba(221, 209, 187, 0.65);
  background: rgba(255, 253, 248, 0.78);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

#question {
  width: 100%;
  border: 1px solid rgba(200, 188, 167, 0.95);
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 15px;
  background: #fffefa;
  color: var(--text);
  outline: none;
}

.send-button {
  border: none;
  border-radius: 18px;
  padding: 0 22px;
  background: linear-gradient(135deg, #0f766e, #115e59);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 860px) {
  .app-shell {
    height: auto;
    min-height: calc(100vh - 32px);
  }

  .hero,
  .content {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(221, 209, 187, 0.65);
    overflow: visible;
  }

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

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
