:root, [data-theme="daylight"] {
  --bg: #f4f7fb; --surface: #ffffff; --surface-2: #f8fafc; --border: #e2e8f0;
  --text: #0f172a; --muted: #64748b; --primary: #0a4da2; --primary-soft: #e0edff;
  --green: #15803d; --green-soft: #dcfce7; --red: #dc2626; --red-soft: #fee2e2;
  --amber: #b45309; --amber-soft: #fef3c7; --shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}
[data-theme="midnight"] {
  --bg: #0f172a; --surface: #1e293b; --surface-2: #162032; --border: #334155;
  --text: #f1f5f9; --muted: #94a3b8; --primary: #3b82f6; --primary-soft: #1e3a8a;
  --green: #22c55e; --green-soft: #14532d; --red: #f87171; --red-soft: #450a0a;
  --amber: #fbbf24; --amber-soft: #451a03; --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
[data-theme="eyecare"] {
  --bg: #f3f1e7; --surface: #fbf9f1; --surface-2: #f5f2e6; --border: #ded8c5;
  --text: #272722; --muted: #6e6c5e; --primary: #145374; --primary-soft: #d9ecf2;
  --green: #2c7a4b; --green-soft: #d8f0e0; --red: #b91c1c; --red-soft: #fae2e2;
  --amber: #92400e; --amber-soft: #fef0d1; --shadow: 0 2px 10px rgba(60, 50, 20, 0.06);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; overflow-x: hidden;
}
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 20px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
}
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.tab-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px;
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.container { max-width: 1440px; margin: 0 auto; padding: 16px 20px 40px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 800; margin: 6px 0 4px; color: var(--text); }
.kpi-sub { font-size: 12px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
input, select, textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; }
.conv-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr) 310px; gap: 14px; min-height: 620px; }
.conv-item { padding: 10px; border: 1px solid var(--border); border-radius: 9px; margin-bottom: 8px; cursor: pointer; background: var(--surface-2); }
.conv-item.handoff { border-left: 4px solid var(--red); background: var(--red-soft); }
.conv-item.active-sel { outline: 2px solid var(--primary); }
.msg-stream { max-height: 430px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px; background: var(--surface-2); border-radius: 9px; border: 1px solid var(--border); }
.msg-bubble { padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); max-width: 90%; }
.msg-bubble.customer { align-self: flex-start; border-left: 3px solid var(--primary); }
.msg-bubble.bot { align-self: flex-end; border-right: 3px solid #7c3aed; }
.msg-bubble.agent { align-self: flex-end; border-right: 3px solid var(--green); }
.msg-bubble.system { align-self: center; font-size: 12px; background: var(--amber-soft); color: var(--amber); max-width: 100%; }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-height: 440px; }
.lead-card { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 11px; margin-bottom: 10px; box-shadow: var(--shadow); }
.fup-mini { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); background: var(--surface-2); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-backdrop.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 99; display: none; }
.toast.show { display: block; }
.row-flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hidden { display: none !important; }
@media (max-width: 1080px) { .grid-4, .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); } .conv-layout { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid-4, .grid-2, .kanban { grid-template-columns: 1fr; } .container, .topbar, .nav-tabs { padding-left: 12px; padding-right: 12px; } }
