:root {
  --ink: #0d0d12;
  --ink-2: #4a4d5e;
  --ink-3: #8a8fa3;
  --line: #e7e8ef;
  --bg: #f7f7fa;
  --card: #ffffff;
  --orange: #f97316;      /* fse mark */
  --indigo: #5b5bd6;      /* actions, matches widget */
  --indigo-soft: #ecebfb;
  --green: #16a34a;
  --red: #dc2626;
  --amber-bg: #fef7e6;
  --radius: 14px;
  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); background: var(--bg); color: var(--ink); font-size: 14px; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }
a { color: var(--indigo); }

/* wordmark */
.wordmark { font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: -0.5px; color: var(--ink); }
.wordmark .fse { color: var(--orange); }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 44px 40px; width: 400px; box-shadow: 0 20px 60px rgba(20,20,50,.08); }
.login-card .mark { width: 62px; height: 62px; border-radius: 17px; background: var(--orange); color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 24px; display: flex; align-items: center; justify-content: center; margin-bottom: 22px; }
.login-card h1 { font-family: var(--font-display); font-size: 22px; margin-bottom: 6px; }
.login-card p { color: var(--ink-3); margin-bottom: 26px; }

/* ── Layout ── */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 0 28px; height: 62px; display: flex; align-items: center; gap: 20px; position: sticky; top: 0; z-index: 10; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--ink-3); font-size: 13px; }
.main { max-width: 1100px; margin: 0 auto; padding: 30px 24px 80px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-display); font-size: 24px; letter-spacing: -0.4px; }
.page-head .sub { color: var(--ink-3); }
.page-head .grow { flex: 1; }

/* ── Buttons & inputs ── */
.btn { border: none; border-radius: 10px; padding: 10px 18px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #26263a; }
.btn-indigo { background: #ff6300; color: #fff; }
.btn-indigo:hover { background: #4c4cc4; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--ink-3); }
.btn-danger { background: transparent; border: 1px solid #f3c1c1; color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--ink-3); font-size: 12px; margin-top: 5px; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number], .field input[type=url], .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; background: #fff; outline: none; color: var(--ink);
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.color-field { display: flex; gap: 10px; align-items: center; }
.color-field input[type=color] { width: 44px; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: #fff; cursor: pointer; }

/* ── Cards / list ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.bot-card { cursor: pointer; transition: box-shadow .15s, transform .15s; }
.bot-card:hover { box-shadow: 0 10px 30px rgba(20,20,50,.09); transform: translateY(-2px); }
.bot-card .row1 { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.bot-card .avatar { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; color: #fff; font-size: 16px; overflow: hidden; flex: none; }
.bot-card .avatar img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.bot-card h3 { font-size: 16px; }
.bot-card .site { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.badge { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge-green { background: #eafaf0; color: var(--green); }
.badge-gray { background: #f0f0f5; color: var(--ink-3); }
.badge-red { background: #fdecec; color: var(--red); }
.stats-row { display: flex; gap: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.stat b { display: block; font-size: 17px; font-family: var(--font-display); }
.stat span { font-size: 11.5px; color: var(--ink-3); }
.usage-bar { height: 6px; background: #eef0f6; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.usage-bar i { display: block; height: 100%; background: var(--indigo); border-radius: 99px; }
.usage-bar i.warn { background: var(--orange); }
.usage-bar i.over { background: var(--red); }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 26px; overflow-x: auto; }
.tab { background: none; border: none; padding: 11px 16px; font-weight: 600; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 14px; }
.tab.active { color: var(--ink); border-bottom-color: var(--orange); }

.two-col { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } .field-row { grid-template-columns: 1fr; } }

/* ── Quick actions editor ── */
.qa-row { display: grid; grid-template-columns: 130px 1fr 36px; gap: 10px; margin-bottom: 10px; align-items: center; }
.qa-row select, .qa-row input { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.qa-del { background: none; border: none; color: var(--ink-3); font-size: 18px; }
.qa-del:hover { color: var(--red); }

/* ── Preview panel ── */
.preview { border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: #f6f7fb; position: sticky; top: 86px; }
.preview .p-title { padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; color: var(--ink-2); }
.pv-hdr { background: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); }
.pv-mark { width: 38px; height: 38px; border-radius: 11px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.13); display: flex; align-items: center; justify-content: center; font-weight: 800; font-family: var(--font-display); overflow: hidden; }
.pv-mark img { width: 100%; height: 100%; object-fit: contain; }
.pv-body { padding: 30px 20px 36px; text-align: center; }
.pv-biglogo { width: 72px; height: 72px; border-radius: 19px; background: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.12); margin: 0 auto 18px; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: 26px; overflow: hidden; }
.pv-biglogo img { width: 100%; height: 100%; object-fit: contain; }
.pv-body h4 { font-size: 16px; margin-bottom: 18px; }
.pv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pv-btn { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px 11px; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; text-align: left; }
.pv-ic { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; }
.pv-ic svg { width: 14px; height: 14px; }
.pv-sub { margin-top: 16px; color: var(--ink-3); font-size: 12px; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fafafd; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* ── Embed / code ── */
.codebox { background: #14141d; color: #d8e8d0; border-radius: 12px; padding: 18px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.6; word-break: break-all; position: relative; }
.copy-btn { position: absolute; top: 10px; right: 10px; }
.steps { counter-reset: s; margin-top: 20px; }
.step { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: none; }
.step .n { counter-increment: s; width: 28px; height: 28px; border-radius: 50%; background: var(--indigo-soft); color: var(--indigo); font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; font-size: 13px; }
.step .n::before { content: counter(s); }
.step h4 { font-size: 14px; margin-bottom: 3px; }
.step p { color: var(--ink-2); line-height: 1.5; }

/* ── Analytics ── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.kpi b { display: block; font-family: var(--font-display); font-size: 26px; }
.kpi span { color: var(--ink-3); font-size: 12.5px; }
.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 10px; }
.bar-chart .bar { flex: 1; background: var(--indigo); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bar-chart .bar:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; margin-bottom: 4px; }
.kw { display: inline-flex; align-items: center; gap: 6px; background: var(--indigo-soft); color: var(--indigo); border-radius: 999px; padding: 5px 13px; font-size: 12.5px; font-weight: 600; margin: 0 6px 8px 0; }
.kw b { font-weight: 800; }

/* ── Misc ── */
.notice { background: var(--amber-bg); border: 1px solid #f3e3b5; color: #7a5b12; padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 13px; }
.error-msg { color: var(--red); font-size: 13px; margin-top: 10px; }
.save-bar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 6px; display: flex; gap: 10px; align-items: center; }
.saved-flash { color: var(--green); font-weight: 600; font-size: 13px; }
.empty { text-align: center; color: var(--ink-3); padding: 50px 20px; }
.empty h3 { color: var(--ink); font-family: var(--font-display); margin-bottom: 8px; }
.spin { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: sp 1s linear infinite; display: inline-block; }
.spin.dark { border-color: rgba(0,0,0,.15); border-top-color: var(--ink-2); }
@keyframes sp { to { transform: rotate(360deg); } }
.modal-back { position: fixed; inset: 0; background: rgba(10,10,25,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 18px; padding: 30px; width: 460px; max-width: 100%; max-height: 85vh; overflow-y: auto; }
.modal h2 { font-family: var(--font-display); font-size: 19px; margin-bottom: 18px; }
