:root {
  --accent: #635bff;
  --accent-dark: #4b45cc;
  --bg: #f7f7fb;
  --card: #ffffff;
  --border: #e4e4ec;
  --text: #1a1a2e;
  --muted: #6b7280;
  --danger: #ef4444;
  --ok: #16a34a;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 20px; width: auto; display: block; }
.brand-divider { width: 1px; height: 18px; background: var(--border); display: inline-block; }
.brand-chat { font-weight: 800; font-size: 16px; letter-spacing: .04em; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 80px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 14px; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #fca5a5; }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
select, input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .03em; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.agent-card { cursor: pointer; transition: box-shadow .15s; }
.agent-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.agent-card .name { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 700; }
.badge.on { background: #dcfce7; color: var(--ok); }
.badge.off { background: #f3f4f6; color: var(--muted); }
.badge.status-indexed { background: #dcfce7; color: var(--ok); }
.badge.status-pending, .badge.status-processing { background: #fef3c7; color: #b45309; }
.badge.status-failed { background: #fee2e2; color: var(--danger); }
.agent-layout { display: flex; gap: 28px; align-items: flex-start; }
.sidebar-nav { width: 190px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 78px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 13.5px; font-weight: 500; color: var(--muted); cursor: pointer; border-radius: 8px; }
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: #f0f0f8; }
.nav-item.active { color: var(--accent); background: #ecebff; font-weight: 700; }
.agent-main { flex: 1; min-width: 0; }
@media (max-width: 780px) {
  .agent-layout { flex-direction: column; }
  .sidebar-nav { width: 100%; flex-direction: row; overflow-x: auto; position: static; padding-bottom: 4px; }
  .nav-item { flex-shrink: 0; }
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #ccc; border-radius: 22px; cursor: pointer; transition: .15s; }
.slider:before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: .15s; }
input:checked + .slider { background: var(--accent); }
input:checked + .slider:before { transform: translateX(18px); }
.source-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.source-item:last-child { border-bottom: none; }
.source-item .src-text { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.source-item .src-type { font-size: 11px; color: var(--muted); text-transform: uppercase; margin-right: 8px; }
.meter { background: #f3f4f6; border-radius: 8px; height: 10px; overflow: hidden; margin: 6px 0; }
.meter-fill { height: 100%; background: var(--accent); }
.meter-fill.over { background: var(--danger); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .num { font-size: 26px; font-weight: 800; }
.stat .lbl { font-size: 12.5px; color: var(--muted); }
.embed-box { background: #111827; color: #d1fae5; padding: 16px; border-radius: 8px; font-family: monospace; font-size: 13px; overflow-x: auto; white-space: pre; }
.login-wrap { max-width: 380px; margin: 60px auto; padding: 0 20px; text-align: center; }
.login-lang { text-align: right; margin-bottom: 20px; }
.login-wrap .logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 18px; }
.login-brand-logo { height: 26px; width: auto; }
.login-brand-chat { font-weight: 800; font-size: 20px; letter-spacing: .04em; color: var(--text); }
.convlog-layout { display: flex; gap: 20px; align-items: flex-start; }
.convlog-list-card { width: 320px; flex-shrink: 0; padding: 10px; max-height: 640px; overflow-y: auto; }
.convlog-thread-card { flex: 1; min-width: 0; }
.conv-list { display: flex; flex-direction: column; }
.conv-row { padding: 10px 10px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13.5px; border-radius: 8px; }
.conv-row:hover { background: #f7f7fb; }
.conv-row.active { background: #ecebff; }
.conv-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv-visitor { font-weight: 600; }
.conv-row-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.chat-thread { display: flex; flex-direction: column; gap: 10px; max-height: 640px; overflow-y: auto; padding: 6px; }
@media (max-width: 900px) {
  .convlog-layout { flex-direction: column; }
  .convlog-list-card { width: 100%; max-height: 320px; }
}
.bubble { max-width: 75%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; white-space: pre-wrap; }
.bubble.user { background: var(--accent); color: #fff; align-self: flex-end; }
.bubble.assistant { background: #f0f0f5; align-self: flex-start; }
.bubble a { color: inherit; text-decoration: underline; word-break: break-all; }
.ts { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13.5px; z-index: 9999; }
.chart-wrap { width: 100%; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }
.pg-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; color: #fff; font-weight: 700; font-size: 14.5px; }
.pg-messages { background: #fff; padding: 16px; max-height: 460px; min-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.pg-powered { text-align: center; font-size: 10.5px; color: #999; padding: 5px 0; background: #fff; }
.pg-powered a { color: #666; text-decoration: none; }
.pg-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: #fff; }
.pg-input-row input { flex: 1; }
.pg-custom-footer { padding: 0 16px 10px; font-size: 11px; line-height: 1.4; color: #888; text-align: center; background: #fff; }
.pg-custom-footer a { color: inherit; }
.pg-context { font-size: 11px; color: var(--accent); cursor: pointer; margin-top: -4px; align-self: flex-start; }
.pg-context-detail { font-size: 11.5px; color: var(--muted); background: #f7f7fb; border-radius: 8px; padding: 10px; white-space: pre-wrap; align-self: stretch; }

.pic-row { display: flex; align-items: center; gap: 16px; }
.pic-preview { width: 56px; height: 56px; border-radius: 50%; background: #f0f0f5; border: 1px solid var(--border); overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.pic-preview img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 44px; height: 38px; padding: 2px; flex-shrink: 0; }
.color-row input[type=text] { flex: 1; text-transform: uppercase; }
.bubble-icon-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.bubble-icon-option { width: 56px; height: 56px; border: 1.5px solid var(--border); border-radius: 12px; background: #fff; color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.bubble-icon-option:hover { border-color: #c7c7d6; }
.bubble-icon-option.active { border-color: var(--text); border-width: 2px; }
.rte-toolbar { display: flex; gap: 4px; margin-bottom: 4px; }
.rte-btn { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.rte-btn:hover { background: #f7f7fb; }
.rte-editor { min-height: 70px; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 14px; background: #fff; }
.rte-editor:focus { outline: none; border-color: var(--accent); }
.rl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; margin: 10px 0; }
.rl-row input[type=number] { width: 76px; flex: none; }
.country-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; margin-top: 8px; }
.country-row { display: flex; align-items: center; gap: 6px; padding: 5px 0; font-size: 13.5px; font-weight: 400; text-transform: none; letter-spacing: normal; color: var(--text); cursor: pointer; }
.country-row input { width: auto; }

.general-layout { display: flex; gap: 24px; align-items: flex-start; }
.general-form { flex: 1; min-width: 0; }
.general-preview { width: 320px; flex-shrink: 0; position: sticky; top: 78px; }
.preview-label { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; }
.launcher-preview { background: #f0f0f5; border-radius: 16px; padding: 20px; display: flex; justify-content: flex-end; }
.launcher-btn { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.2); flex-shrink: 0; }
.preview-frame { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.08); background: #fff; }
.preview-frame .pg-messages { min-height: 420px; max-height: 560px; }
.preview-footer { padding: 0 16px 10px; font-size: 11px; line-height: 1.4; color: #888; text-align: center; }
.preview-footer a { color: inherit; }
@media (max-width: 900px) {
  .general-layout { flex-direction: column; }
  .general-preview { width: 100%; position: static; }
}
