:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #8a94a6;
  --line: #e6e9f0;
  --line-2: #eef0f5;
  --brand: #2563eb;
  --brand-soft: #eaf1ff;
  --fb: #1877f2;
  --ig: #e1306c;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #b45309;
  --warn-soft: #fff5e6;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --violet: #7c3aed;
  --violet-soft: #f1eafe;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --side: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 "IBM Plex Sans Thai", "Leelawadee UI", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; font-size: 14px; }
a:hover { text-decoration: underline; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 0 5px; border-radius: 5px; font-size: 13px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 20px; }
.brand b { display: block; font-size: 17px; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 12px; }
.logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--fb), var(--ig)); }
.logo svg { width: 20px; height: 20px; stroke-width: 2.4; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: none; padding: 9px 12px; border-radius: 10px;
  font: inherit; font-weight: 500; color: var(--text-2); cursor: pointer;
}
nav button:hover { background: var(--surface-2); color: var(--text); }
nav button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
nav button span:first-of-type { flex: 1; }
.side-foot { margin-top: auto; padding: 10px 12px; }
main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; min-width: 0; }

/* ---------- Page header ---------- */
.tab { display: none; } .tab.on { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 26px; line-height: 1.25; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions select, .actions input { width: auto; margin: 0; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 4px 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack .card { margin: 0; }
.two { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.two > .card { margin: 0; }

/* ---------- Forms ---------- */
label, .label { display: block; font-weight: 500; font-size: 14px; color: var(--text-2); margin: 14px 0 6px; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 15px; color: var(--text);
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-top: 6px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
input[type=checkbox], input[type=radio] { width: auto; margin: 0; accent-color: var(--brand); }
textarea { resize: vertical; line-height: 1.55; }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; color: var(--text); }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px 0 0; }
.row.tight { margin: 0; gap: 6px; }
.spacer, .grow { flex: 1; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.hidden { display: none !important; }

/* segmented control */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; margin: 4px 0 12px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.seg input:checked + span { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, .1); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); }

/* platform chips */
.chip { margin: 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; font-size: 14px; color: var(--text-2); background: var(--surface); }
.chip span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.chip.fb input:checked + span { border-color: var(--fb); color: var(--fb); background: #eef5ff; }
.chip.fb input:checked + span::before { background: var(--fb); }
.chip.ig input:checked + span { border-color: var(--ig); color: var(--ig); background: #fdeef4; }
.chip.ig input:checked + span::before { background: var(--ig); }

/* ---------- Buttons ---------- */
button { font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; border-radius: 10px; padding: 8px 16px; border: 1px solid var(--line); background: var(--surface); color: var(--text); transition: background .15s, border-color .15s, transform .05s; }
button:hover { background: var(--surface-2); }
button:active { transform: translateY(1px); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(37, 99, 235, .3); }
button.primary:hover { background: #1d4ed8; }
button.ghost { background: var(--surface); }
button.small { padding: 4px 11px; font-size: 13px; border-radius: 8px; }
button.danger { color: var(--bad); }
button.danger:hover { background: var(--bad-soft); border-color: #f6c9c9; }
button:disabled { opacity: .55; cursor: wait; }
.icon-btn { width: 36px; padding: 6px 0; font-size: 18px; line-height: 1; }
button.secondary { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border-color: #d1d5db; color: #374151; box-shadow: none; }
button.secondary:hover { background: #f9fafb; border-color: #9ca3af; }
button.primary.big { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; padding: 10px 20px; box-shadow: 0 4px 12px rgba(37, 99, 235, .28); }
.pages-head button svg { width: 16px; height: 16px; flex: none; }
.actions .divider { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.count-badge { display: inline-block; vertical-align: middle; margin-left: 6px; font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--muted); background: var(--surface-2); padding: 2px 10px; border-radius: 999px; }
.count-badge:empty { display: none; }
.pages-head { align-items: center; }
@media (max-width: 760px) {
  .pages-head .actions { width: 100%; }
  .pages-head .divider { display: none; }
  .pages-head button.primary.big { order: -1; flex-basis: 100%; justify-content: center; }
  .pages-head button.secondary { flex: 1; justify-content: center; }
}
.pill { background: var(--brand); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 600; line-height: 20px; }
.pill:empty { display: none; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .num { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; }
.stat .num small { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat .lbl { color: var(--text-2); font-size: 13px; }
.ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.ico svg { width: 20px; height: 20px; }
.ico.blue { background: var(--brand-soft); color: var(--brand); }
.ico.green { background: var(--ok-soft); color: var(--ok); }
.ico.red { background: var(--bad-soft); color: var(--bad); }
.ico.violet { background: var(--violet-soft); color: var(--violet); }
.ico.amber { background: var(--warn-soft); color: var(--warn); }
.ico.gray { background: var(--surface-2); color: var(--text-2); }

/* ---------- Tags & status ---------- */
.tag { display: inline-flex; align-items: center; font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.tag.fb { background: #eef5ff; color: var(--fb); }
.tag.ig { background: #fdeef4; color: var(--ig); }
.tag.off { background: var(--surface-2); color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.fb { background: var(--fb); } .dot.ai { background: linear-gradient(135deg, #4f8df7, #a259ff); }
.st { display: inline-flex; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.st.scheduled { background: var(--brand-soft); color: var(--brand); }
.st.posting, .st.commenting, .st.posted { background: var(--warn-soft); color: var(--warn); }
.st.done { background: var(--ok-soft); color: var(--ok); }
.st.meta_scheduled { background: #e6f4ff; color: #0b63c5; }
.st.pushing { background: var(--brand-soft); color: var(--brand); }
.via { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.via.ok { color: var(--ok); } .via.warn { color: var(--warn); }
.st.failed, .st.comment_failed { background: var(--bad-soft); color: var(--bad); }
.errmsg { color: var(--bad); font-size: 13px; }
.warn { background: var(--warn-soft); border: 1px solid #f6dcb0; color: #7c4a03; border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }

/* ---------- Overview lists ---------- */
.mini { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.mini:last-child { border-bottom: 0; }
.mini img { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--line); object-fit: cover; }
.mini .t { width: 104px; flex: none; color: var(--text-2); font-size: 13px; }
.mini .g { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; font-size: 14px; border-bottom: 1px solid var(--line-2); }
.conn:last-child { border-bottom: 0; }
.steps { margin: 0; padding-left: 22px; }
.steps li { margin: 8px 0; }
.steps li.done { color: var(--muted); text-decoration: line-through; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 20px 0; }

/* ---------- Create ---------- */
.step { display: flex; gap: 16px; }
.step-no { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; display: grid; place-items: center; flex: none; font-size: 14px; }
.step-body { flex: 1; min-width: 0; }
.step-body > h2, .step-body > .card-head { margin-top: 3px; }
.drop { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px; border: 1.5px dashed var(--line); border-radius: 12px; background: var(--surface-2); }
.drop > input, .drop > select { flex: 1; min-width: 160px; margin: 0; }
.drop > select { flex: 0 0 auto; width: auto; }
.upload-btn { margin: 0; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; color: var(--text); font-weight: 500; }
.upload-btn:hover { border-color: var(--brand); color: var(--brand); }
.upload-btn input { display: none; }
.media { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.media:empty { display: none; }
.media figure { margin: 0; width: 112px; position: relative; }
.media img, .media video { width: 112px; height: 112px; object-fit: cover; border-radius: 10px; background: var(--line); display: block; border: 1px solid var(--line); }
.media figcaption { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }
.media button { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; padding: 0; border-radius: 50%; background: rgba(15, 23, 42, .65); color: #fff; border: 0; font-size: 15px; line-height: 1; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.picker label { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; margin: 0; font-weight: 500; color: var(--text); cursor: pointer; transition: border-color .15s, background .15s; }
.picker label:hover { border-color: #c9d6f5; }
.picker label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.picker img { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--line); }
.picker .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; background: var(--surface-2); }
.pv-head { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.pv-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-top: 10px; }
.pv-cols > div > label.inline { margin-bottom: 4px; }
.pv .err { color: var(--bad); font-size: 13px; }

/* ---------- Queue ---------- */
.job { display: grid; grid-template-columns: 150px 1fr auto; gap: 16px; padding: 14px 22px; border-bottom: 1px solid var(--line-2); align-items: start; }
.job:last-child { border-bottom: 0; }
.job:hover { background: var(--surface-2); }
.job .when b { display: block; font-size: 14px; }
.job-head { line-height: 1.6; }
.job-ava { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; vertical-align: -6px; margin-right: 6px; }
.job .when .tag, .job .when .st { margin-top: 4px; }
.job .cap { white-space: pre-wrap; font-size: 13px; color: var(--text-2); max-height: 4.6em; overflow: hidden; margin-top: 2px; }
.job .meta { font-size: 13px; color: var(--muted); }
.job .cmt { font-size: 13px; color: var(--text-2); margin-top: 6px; display: flex; gap: 6px; align-items: flex-start; }
.job .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 230px; }
#queueList > .empty { padding: 40px 0; }

/* ---------- Pages ---------- */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.page-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.page-card.off { opacity: .6; }
.page-card .ph { display: flex; gap: 12px; align-items: center; }
.page-card .ph img { width: 44px; height: 44px; border-radius: 50%; background: var(--line); flex: none; }
.page-card .ph b { display: block; line-height: 1.3; }
.page-card .style-head { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.page-card .style-head b { flex: 1; font-size: 14px; }
.page-card .ph .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.switch { position: relative; width: 38px; height: 22px; flex: none; margin: 0 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); }

.ig-box { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #fff5f9, #f8f4ff); border: 1px solid #f3d9e6; }
.ig-box.bad { background: var(--bad-soft); border-color: #f6c9c9; }
.ig-box.none { background: var(--surface-2); border: 1px dashed var(--line); }
.ig-box b { font-size: 14px; }
.ig-ava { width: 36px; height: 36px; border-radius: 50%; flex: none; object-fit: cover;
  background: linear-gradient(135deg, #feda75, #d62976 50%, #4f5bd5); border: 2px solid #fff; box-shadow: 0 0 0 1.5px #e1306c; }
.ig-box.none .ig-ava { background: var(--line); box-shadow: none; }
.quota { flex-basis: 100%; font-size: 12px; color: var(--text-2); }
.quota .nums { display: flex; justify-content: space-between; margin-bottom: 4px; }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.dot.ig { background: linear-gradient(135deg, #feda75, #d62976, #4f5bd5); }

/* ---------- Auto ---------- */
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.auto-card .auto-top { display: flex; gap: 14px; align-items: center; }
.auto-card .auto-top b { font-size: 17px; }
.auto-card.on { border-color: #bfe5cb; background: linear-gradient(180deg, #f3fbf6, var(--surface) 60%); }
.switch.big { width: 50px; height: 28px; margin: 0; }
.switch.big span::after { width: 22px; height: 22px; }
.switch.big input:checked + span::after { transform: translateX(22px); }
#autoProgress { margin-top: 14px; }
#autoProgress .hint { margin-top: 4px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
.grid4 .span2 { grid-column: span 2; }
@media (max-width: 760px) { .grid4 { grid-template-columns: 1fr 1fr; } }
.autostart-row { display: flex; gap: 12px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-2); font-size: 14px; }
.autostart-row .switch { margin: 0; }
.result { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.result ul { margin: 6px 0 0; padding-left: 18px; }
.stock-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.stock-row:last-child { border-bottom: 0; }
.stock-row .days { font-weight: 600; font-size: 13px; white-space: nowrap; }
.stock-row .days.low { color: var(--bad); } .stock-row .days.mid { color: var(--warn); } .stock-row .days.ok { color: var(--ok); }
.stock-row .hint { grid-column: 1 / -1; }
.page-checks { display: grid; grid-template-columns: 1fr; gap: 6px; }
.page-checks label { display: flex; gap: 10px; align-items: center; margin: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; font-weight: 500; color: var(--text); cursor: pointer; transition: border-color .15s, background .15s; }
.page-checks label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.page-checks img { width: 24px; height: 24px; border-radius: 50%; flex: none; background: var(--line); }
.page-checks .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
#upAll.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }

/* Multi-select dropdown (scales to many pages) */
.msel { position: relative; }
.msel-btn { width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; padding: 9px 12px; font-size: 15px; font-weight: 400; }
.msel-btn .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msel-btn.empty .grow { color: var(--muted); }
.msel.open .msel-btn { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.msel.open .msel-btn svg { transform: rotate(180deg); }
.msel-panel { position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .16); padding: 10px; }
.msel-top { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.msel-top input { margin: 0; padding: 7px 10px; font-size: 14px; }
.msel-top button { flex: none; }
.msel-list { max-height: 280px; overflow-y: auto; padding-right: 2px; }
.msel-list label { padding: 6px 10px; }
.msel-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-2); }
.upload-btn.wide { display: flex; justify-content: center; margin-top: 14px; padding: 14px; border: 1.5px dashed #b9c8ea; background: var(--brand-soft); color: var(--brand); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.lib-item { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.lib-item .thumb { position: relative; aspect-ratio: 1; background: var(--surface-2); }
.lib-item .thumb img, .lib-item .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-item .thumb .count { position: absolute; top: 6px; right: 6px; background: rgba(15, 23, 42, .7); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.lib-item .body { padding: 8px 10px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.lib-item .body b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-item .body .hint { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-item .foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: auto; }
/* Content-library statuses: available blue, scheduled yellow, posted green, skipped black, problem red */
.lst { display: inline-flex; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.lst.available { background: #e3efff; color: #1d5fd6; }
.lst.planned { background: #fff4c2; color: #8a6100; }
.lst.used { background: #dcf5e3; color: #137333; }
.lst.skipped { background: #1f2430; color: #fff; }
.lst.duplicate, .lst.invalid { background: #fde2e2; color: #c62828; }

.status-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: -2px 0 14px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500; background: var(--surface); }
.chip-btn span { font-size: 11px; font-weight: 600; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.chip-btn.on { color: #fff; border-color: transparent; }
.chip-btn.on span { background: rgba(255, 255, 255, .25); color: #fff; }
.chip-btn.all.on { background: var(--text); }
.chip-btn.available.on { background: #1d5fd6; }
.chip-btn.planned.on { background: #e0a400; }
.chip-btn.used.on { background: #137333; }
.chip-btn.skipped.on { background: #1f2430; }
.chip-btn.problem.on { background: #c62828; }

/* Used content: black-and-white and faded so it reads as "don't use again" */
.lib-item.used .thumb img, .lib-item.used .thumb video { filter: grayscale(1); opacity: .45; }
.lib-item.used .body b { color: var(--muted); }
.used-mark { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-8deg); background: rgba(31, 36, 48, .8); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 12px; border-radius: 6px; letter-spacing: .05em; }
.lib-where { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); min-width: 0; }
.lib-where .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf { width: 20px; height: 20px; border-radius: 6px; display: inline-grid; place-items: center; color: #fff; flex: none; }
.pf svg { width: 13px; height: 13px; }
.pf.fb { background: var(--fb); }
.pf.fb svg { fill: #fff; stroke: none; }
.pf.ig { background: linear-gradient(135deg, #feda75, #d62976 55%, #4f5bd5); }
a.pf:hover { text-decoration: none; filter: brightness(1.1); }

/* ---------- Problems ---------- */
nav button.alert { background: var(--bad); color: #fff; font-weight: 600; animation: pulse 2s ease-in-out infinite; }
nav button.alert:hover { background: #b91c1c; color: #fff; }
nav button.alert .pill { background: #fff; color: var(--bad); }
nav button.warn-state { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
nav button.warn-state .pill { background: var(--warn); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .35); } 50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); } }
.alert-banner { display: flex; gap: 10px; align-items: center; background: var(--bad); color: #fff; border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; cursor: pointer; font-weight: 500; box-shadow: 0 6px 18px rgba(220, 38, 38, .25); }
.alert-banner b { font-weight: 700; }
.alert-banner .go { margin-left: auto; white-space: nowrap; font-weight: 700; }
.health-ok { display: flex; gap: 14px; align-items: center; }
.health-ok .big { font-size: 34px; }
.health-checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.health-checks span { font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--text-2); }
.issue-list { display: flex; flex-direction: column; gap: 12px; }
.issue { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--warn); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.issue.critical { border-left-color: var(--bad); }
.issue.info { border-left-color: var(--brand); }
.issue.closed { opacity: .65; border-left-color: var(--line); }
.issue-head { display: flex; gap: 10px; align-items: flex-start; }
.issue-head .sev { font-size: 22px; line-height: 1; }
.issue-head h3 { margin: 0; font-size: 16px; }
.issue-head .meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.issue .detail { margin: 10px 0; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; font-size: 13px; color: var(--text-2); word-break: break-word; }
.issue .fix { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }
.issue .fix li { margin: 4px 0; }
.issue .links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.issue .links a { font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 3px 10px; }
.issue .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.sev-tag { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.sev-tag.critical { background: var(--bad); color: #fff; }
.sev-tag.warning { background: var(--warn-soft); color: var(--warn); }
.sev-tag.info { background: var(--brand-soft); color: var(--brand); }

/* ---------- Overview ---------- */
.ov-hero { display: grid; grid-template-columns: minmax(300px, 1fr) 1.4fr; gap: 16px; margin-bottom: 16px; }
.ov-progress { display: flex; gap: 22px; align-items: center; margin: 0; }
.ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line-2) 0); }
.ring span { width: 104px; height: 104px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 26px; font-weight: 700; }
.ov-progress-body { flex: 1; min-width: 0; }
.ov-big { font-size: 38px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; margin: 2px 0 10px; }
.ov-big small { font-size: 16px; color: var(--muted); font-weight: 500; }
.ov-pf { display: grid; grid-template-columns: 20px 1fr auto auto; gap: 4px 8px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.ov-pf .bar { grid-column: 2 / -1; height: 6px; }
.ov-next { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2); font-size: 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ov-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-content: start; }
.ov-kpis .stat { margin: 0; }
.ov-kpis .sub { font-size: 12px; margin-top: 1px; }
.ov-timeline { display: flex; gap: 6px; align-items: flex-end; height: 150px; padding-top: 6px; overflow-x: auto; }
.tl { flex: 1; min-width: 26px; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tl-n { font-size: 11px; color: var(--text-2); height: 14px; font-weight: 600; }
.tl-bar { flex: 1; width: 100%; max-width: 34px; display: flex; flex-direction: column; justify-content: flex-end; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.tl-bar span { display: block; width: 100%; }
.tl-bar .done { background: var(--ok); } .tl-bar .sched { background: #93b8f8; } .tl-bar .fail { background: var(--bad); }
.tl-h { font-size: 11px; color: var(--muted); }
.tl.now .tl-h { color: var(--brand); font-weight: 700; }
.tl.now .tl-bar { box-shadow: 0 0 0 2px var(--brand); }
.ov-pages-head { margin: 24px 0 12px; }
.ov-pages-head .seg { margin: 0; }
.ov-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.ov-page { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.ov-page.off { opacity: .55; }
.ov-page-head { display: flex; gap: 10px; align-items: center; }
.ov-page-head img { width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--line); }
.ov-page-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-page-num b { font-size: 26px; }
.ov-page-pfs { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.ov-pfcount { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.ov-page-meta { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); padding-top: 8px; border-top: 1px solid var(--line-2); }
.ov-page-meta span { display: inline-flex; gap: 5px; align-items: center; flex-wrap: wrap; }
@media (max-width: 980px) { .ov-hero { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .ov-progress { flex-direction: column; text-align: center; }
  .ring { width: 110px; height: 110px; } .ring span { width: 86px; height: 86px; font-size: 22px; }
  .ov-big { font-size: 30px; }
  .ov-next { justify-content: center; }
  .ov-kpis { grid-template-columns: 1fr 1fr; }
  .ov-pages { grid-template-columns: 1fr; }
}

/* ---------- Library selection ---------- */
.sel-bar { position: sticky; top: 8px; z-index: 6; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--text); color: #fff; box-shadow: 0 8px 24px rgba(15, 23, 42, .2); }
.sel-bar .ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .3); }
.sel-bar .ghost:hover { background: rgba(255, 255, 255, .1); }
.lib-item { position: relative; }
.lib-item .pick { position: absolute; top: 8px; left: 8px; z-index: 2; margin: 0; width: 26px; height: 26px; border-radius: 8px; background: rgba(255, 255, 255, .92); display: grid; place-items: center; cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.lib-item .pick input { width: 16px; height: 16px; cursor: pointer; }
.lib-item.picked { outline: 3px solid var(--brand); outline-offset: -1px; }
.fl-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.fl-row { display: grid; grid-template-columns: 56px minmax(0, 1.3fr) minmax(0, 1.2fr) 190px auto 28px; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.fl-row .th { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.fl-row .th img, .fl-row .th video { width: 100%; height: 100%; object-fit: cover; display: block; }
.fl-row b { font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-row select, .fl-row input[type=datetime-local] { margin: 0; padding: 6px 8px; font-size: 13px; }
.fl-row .lock { font-size: 11px; color: var(--warn); }
.fl-row .x { width: 28px; height: 28px; padding: 0; border-radius: 50%; }
.fl-row .pfs { display: flex; gap: 4px; }
.fl-row .pfs label { margin: 0; }
.fl-row .pfs span { padding: 3px 10px; font-size: 12px; }
.fl-row.err { border-color: var(--bad); background: var(--bad-soft); }
@media (max-width: 900px) { .fl-row { grid-template-columns: 56px 1fr 28px; } .fl-row > :nth-child(3), .fl-row > :nth-child(4), .fl-row > :nth-child(5) { grid-column: 2 / -1; } }

/* ---------- External source preview ---------- */
.pv-sum { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 10px; }
.pv-sum .stat { padding: 10px 14px; box-shadow: none; }
.pv-sum .num { font-size: 20px; }
.pv-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.pv-page { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.pv-page h3 { margin: 0 0 6px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.pv-page .folders { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.pv-page .folders span { display: inline-block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; margin: 2px 4px 2px 0; }
.pv-row { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; border-top: 1px dashed var(--line-2); }
.pv-row .t { width: 44px; flex: none; font-weight: 600; }
.pv-row .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }

/* ---------- Links ---------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 16px; }
.product-list { display: flex; flex-direction: column; gap: 12px; }
.product { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.product.off { opacity: .6; }
.product .ph { display: flex; gap: 12px; align-items: center; }
.product .ph .ico { width: 36px; height: 36px; }
.product .ph b { font-size: 15px; }
.product .uses { font-size: 12px; color: var(--muted); }
.product label { margin-top: 10px; }
.pimgs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pimgs:empty { display: none; }
.pimg { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.pimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pimg button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 0; background: rgba(15, 23, 42, .65); color: #fff; font-size: 14px; line-height: 1; }
.pimg.add { display: grid; place-items: center; cursor: pointer; color: var(--muted); border-style: dashed; margin: 0; font-size: 22px; }
.pimg.add input { display: none; }
.product .ph .thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.prod-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: #9a4b00; background: #fff3e0; padding: 1px 8px; border-radius: 999px; font-weight: 500; }

/* ---------- Plan ---------- */
.rangebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -6px 0 16px; }
.rangebar .seg { margin: 0; }
.custom-range { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.custom-range label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; }
.custom-range input { width: auto; margin: 0; padding: 6px 10px; }
.range-label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.range-label b { color: var(--text); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.done, .bar .done { background: var(--ok); }
.sw.sched, .bar .sched { background: #93b8f8; }
.sw.fail, .bar .fail { background: var(--bad); }
.sw.none { background: var(--line); }
.target-input { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; }
.target-input input { width: 70px; margin: 0; padding: 5px 8px; text-align: center; }
.plan-row { display: grid; grid-template-columns: minmax(190px, 1.1fr) 2fr 2fr 76px; gap: 20px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.plan-row.head { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 4px 0 10px; }
.plan-row:last-child { border-bottom: 0; }
.plan-page { display: flex; gap: 10px; align-items: center; min-width: 0; }
.plan-page img { width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--line); }
.plan-page b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.prog { font-size: 13px; color: var(--text-2); }
.prog .nums { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.prog .nums b { font-size: 17px; color: var(--text); }
.prog .sub { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); }
.prog .sub .c-ok { color: var(--violet); font-weight: 600; }
.bar { display: flex; height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.bar > span { height: 100%; transition: width .3s; }
.met { color: var(--ok); font-weight: 600; font-size: 12px; }
.short { color: var(--warn); font-weight: 600; font-size: 12px; }
.na { color: var(--muted); font-size: 13px; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; display: inline-block; }
.ig-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; }
.ig-line .ig-name { font-weight: 600; color: var(--ig); }
.ig-line .st { font-size: 11px; padding: 0 8px; }
.plan-row input { margin: 0; padding: 6px 8px; text-align: center; }

/* ---------- Toast ---------- */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 10px); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 12px; opacity: 0; transition: .2s; pointer-events: none; max-width: 90vw; z-index: 20; font-size: 14px; box-shadow: 0 8px 24px rgba(15, 23, 42, .25); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .two { grid-template-columns: 1fr; }
  .plan-row { grid-template-columns: 1fr 1fr 70px; }
  .plan-row .plan-page { grid-column: 1 / -1; }
  .plan-row.head { display: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; gap: 8px; }
  .brand { padding: 0 6px 0 0; }
  .brand div:last-child, .side-foot { display: none; }
  nav { flex-direction: row; }
  nav button { width: auto; white-space: nowrap; padding: 7px 10px; }
  nav button svg { display: none; }
  main { padding: 18px 16px 48px; }
  .page-head h1 { font-size: 22px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat .ico { width: 34px; height: 34px; border-radius: 10px; }
  .stat .num { font-size: 22px; }
  .job { grid-template-columns: 1fr; gap: 8px; padding: 14px 16px; }
  .job .acts { justify-content: flex-start; max-width: none; }
  .step { flex-direction: column; gap: 8px; }
  .plan-row { grid-template-columns: 1fr; gap: 10px; }
  .page-grid { grid-template-columns: 1fr; }
}

/* ตัวเลือกช่วงเวลาแบบป๊อปอัป */
.rpick { position: relative; }
.rpick-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 14px; font-weight: 600; min-width: 170px; }
.rpick-btn .grow { flex: 1; text-align: left; white-space: nowrap; }
.rpick-btn svg { transition: transform .15s; color: var(--muted); }
.rpick.open .rpick-btn { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.rpick.open .rpick-btn svg { transform: rotate(180deg); }
.rpick-panel { position: absolute; z-index: 20; left: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .16); padding: 6px; }
.rpick-list { display: flex; flex-direction: column; gap: 2px; }
.rpick-list label { margin: 0; }
.rpick-list input { position: absolute; opacity: 0; pointer-events: none; }
.rpick-list span { display: block; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.rpick-list span:hover { background: var(--surface-2); }
.rpick-list input:checked + span { background: var(--brand-soft, rgba(37, 99, 235, .1)); color: var(--brand); font-weight: 600; }
.rpick-list input:focus-visible + span { outline: 2px solid var(--brand); }
.rpick-panel .custom-range { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 8px 6px; margin-top: 4px; border-top: 1px solid var(--line-2); }
.rpick-panel .custom-range label { justify-content: space-between; }
.rpick-panel .custom-range.hidden { display: none; }

/* สรุปคิวรายวัน */
.qsum { margin-bottom: 14px; }
.qsum-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; color: var(--text-2); }
.qsum-head b { color: var(--text); font-size: 16px; }
.qsum-head button { margin-left: auto; }
.qsum-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.qday { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; font-weight: 400; color: var(--text); display: flex; flex-direction: column; gap: 6px; }
.qday:hover { border-color: var(--brand); }
.qday.on { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.qday.late { border-color: #f59e0b; }
.qday-date { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.qday-tag { background: var(--brand); color: #fff; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 600; }
.qday.late .qday-tag { background: #f59e0b; }
.qday-n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.qday-n small { font-size: 13px; font-weight: 400; color: var(--muted); }
.qday-pf { display: flex; gap: 6px; }
.qday-via { font-size: 12px; color: var(--muted); }

/* ---------- Analytics ---------- */
.an-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: -6px 0 8px; }
.an-filters .seg { margin: 0; }
.an-filters select { width: auto; margin: 0; padding: 8px 12px; min-width: 160px; }
#tab-analytics .range-label { margin-bottom: 14px; flex-wrap: wrap; }
.an-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.an-kpi { align-items: flex-start; padding: 14px; gap: 10px; }
.an-kpi .ico { width: 34px; height: 34px; }
.an-kpi .num { margin: 2px 0; }
.an-kpi .sub { font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.an-delta { font-weight: 600; color: var(--text-2); }
.an-delta.up { color: var(--ok); }
.an-delta.down { color: var(--bad); }
.an-insights ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.an-insights li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; font-size: 14px; color: var(--text-2); }
.an-insights li b { color: var(--text); }
.an-insights li > span { flex: none; }

.an-trend { display: flex; gap: 8px; height: 220px; padding: 6px 0 24px; }
.an-axis { position: relative; width: 44px; flex: none; }
.an-axis span { position: absolute; right: 0; transform: translateY(50%); font-size: 11px; color: var(--muted); }
.an-plot { position: relative; flex: 1; display: flex; align-items: stretch; gap: 3px; border-bottom: 1px solid var(--line); }
.an-gridline { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line-2); }
.an-col { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; cursor: default; }
.an-col:hover { background: var(--surface-2); border-radius: 6px 6px 0 0; }
.an-stack { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; width: 70%; max-width: 36px; margin: 0 auto; gap: 2px; }
.an-stack span { display: block; min-height: 2px; }
.an-stack span:first-child { border-radius: 4px 4px 0 0; }
.an-stack .fb, .an-bar .fb { background: var(--fb); }
.an-stack .ig, .an-bar .ig { background: var(--ig); }
.an-bar .brand { background: var(--brand); }
.an-x { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; font-size: 11px; color: var(--muted); white-space: nowrap; }

.an-table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.an-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 1120px; }
.an-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.an-table th.sort { cursor: pointer; user-select: none; }
.an-table th.sort:hover, .an-table th.on { color: var(--text); }
.an-table td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.an-table .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-table .wide { width: 200px; }
.an-table tr.dim td { color: var(--muted); }
.an-table tbody tr:hover td { background: var(--surface-2); }
.an-ch { display: flex; gap: 10px; align-items: center; min-width: 200px; }
.an-ch img { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--surface-2); }
.an-ch b { display: block; line-height: 1.3; }
.an-cellbar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.an-cellbar .an-bar { flex: 1; }
.an-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.an-bar span { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.an-vs { font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.an-vs.up { background: var(--ok-soft); color: var(--ok); }
.an-vs.down { background: var(--bad-soft); color: var(--bad); }

.an-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }
.an-grid .card { margin-bottom: 16px; }
@media (max-width: 1100px) { .an-grid { grid-template-columns: 1fr; } }
.an-heat-grid { display: grid; gap: 3px; align-items: center; }
.an-hh { font-size: 11px; color: var(--muted); text-align: left; }
.an-wd { font-size: 12px; color: var(--text-2); }
.an-cell { display: block; aspect-ratio: 1; min-height: 14px; border-radius: 4px; }
.an-cell.none { background: var(--surface-2); }
.an-cell:hover { outline: 2px solid var(--text); outline-offset: 1px; }
.an-scale { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.an-scale i { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, color-mix(in srgb, var(--brand) 10%, #fff), var(--brand)); }

.an-group + .an-group { margin-top: 16px; }
.an-glabel { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.an-hrow { display: grid; grid-template-columns: minmax(90px, 140px) 1fr 52px 60px; gap: 10px; align-items: center; padding: 4px 0; font-size: 14px; }
.an-hrow b { text-align: right; font-variant-numeric: tabular-nums; }
.an-hname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.an-top { display: grid; gap: 4px; }
.an-post { display: grid; grid-template-columns: 24px 64px 1fr auto; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.an-post:last-child { border-bottom: 0; }
.an-rank { font-weight: 700; color: var(--muted); text-align: center; }
.an-thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-size: 22px; }
.an-post-body { min-width: 0; }
.an-post-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.an-cap { font-size: 14px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 2px 0; }
.an-metrics { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.an-post-score { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.an-post-score b { font-size: 20px; line-height: 1.2; }
.an-tip { position: fixed; z-index: 1000; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(15, 23, 42, .14); border-radius: 10px; padding: 8px 12px; font-size: 13px; line-height: 1.55; max-width: 280px; }
.an-tip .sw { vertical-align: -1px; }
@media (max-width: 760px) {
  .an-filters > * { flex: 1 1 auto; }
  .an-kpis { grid-template-columns: 1fr 1fr; }
  .an-post { grid-template-columns: 48px 1fr; }
  .an-rank { display: none; }
  .an-thumb { width: 48px; height: 48px; }
  .an-post-score { grid-column: 2; flex-direction: row; align-items: center; gap: 8px; }
  .an-trend { height: 180px; }
}
.an-table th .an-th { border-bottom: 1px dotted var(--muted); cursor: help; }
.an-table th.sort .an-th { cursor: pointer; }

/* ---------- Comment bot ---------- */
.bot-channels { display: grid; gap: 8px; }
.bot-ch { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.bot-ch .an-ch { flex: 1; min-width: 220px; }
.bot-mini { display: inline-flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; }
.bot-mini .switch, .bot-toggle .switch { margin: 0; }
.bot-toggle { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 8px; cursor: pointer; }
.bot-toggle b { display: block; font-size: 14px; }
.bot-toggle .hint { display: block; font-size: 12px; line-height: 1.4; }
.bot-pair { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr); gap: 18px; align-items: start; }
.bot-pair textarea { width: 100%; margin: 0; }
@media (max-width: 900px) { .bot-pair { grid-template-columns: 1fr; } }
.bot-steps { display: grid; gap: 14px; }
.bot-step { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.bot-step.off textarea, .bot-step.off .bot-tags { opacity: .45; }
.bot-preview { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 13px; position: sticky; top: 12px; }
.bot-pv-title { font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.bot-pv-label { font-size: 11px; color: var(--muted); margin: 10px 0 4px; }
.bot-bubble { border-radius: 14px; padding: 7px 11px; margin-bottom: 6px; max-width: 92%; line-height: 1.5; word-break: break-word; }
.bot-bubble b { display: block; font-size: 12px; }
.bot-bubble.user { background: #fff; border: 1px solid var(--line); }
.bot-bubble.page { background: var(--brand-soft); margin-left: 18px; }
.bot-bubble.dm { margin-left: 0; background: var(--brand); color: #fff; }
.bot-pv-none { color: var(--muted); font-style: italic; margin-bottom: 6px; }
.bot-flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--brand-soft); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
.bot-flow > b { margin-right: 6px; }
.bot-flow-step { background: var(--surface); border-radius: 999px; padding: 4px 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, .06); }
.bot-flow i { font-style: normal; color: var(--brand); font-size: 13px; }
.bot-kw-if, .bot-kw-then { font-weight: 600; font-size: 14px; white-space: nowrap; }
.bot-kw-then { margin-bottom: 8px; color: var(--text-2); }
.bot-tags { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.bot-tags .chip { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); border: 0; cursor: pointer; }
.bot-note { margin: 12px 0 0; }
.bot-warn { background: var(--warn-soft); border-color: #fcd9a5; color: var(--warn); font-weight: 600; }
.bot-kw { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; }
.bot-kw-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.bot-kw-head input { margin: 0; }
.bot-kw-head .bot-kw-name { width: 180px; }
.bot-kw-head .grow { flex: 1; min-width: 240px; }
.bot-check { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.bot-posts { display: grid; gap: 8px; max-height: 560px; overflow-y: auto; }
.bot-post { border-bottom: 1px solid var(--line-2); padding: 8px 0; }
.bot-post .bot-pair { margin: 10px 0 6px; }
.bot-post-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.bot-cap { flex: 1; min-width: 160px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-post-head select { width: auto; margin: 0; padding: 6px 10px; font-size: 13px; }
.bot-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
@media (max-width: 900px) { .bot-opts { grid-template-columns: 1fr; } }
.bot-delay { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; grid-column: 1 / -1; font-size: 14px; }
.bot-delay input { width: 80px; margin: 0; padding: 6px 10px; }
.bot-savebar { position: sticky; bottom: 12px; z-index: 5; display: flex; justify-content: flex-end; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.bot-savebar.dirty { border-color: var(--brand); }
.bot-savebar.dirty #botDirty { color: var(--brand); font-weight: 600; }
.bot-log { min-width: 900px; }
.bot-log td { vertical-align: top; }
.bot-cmt { max-width: 280px; }
.bot-cmt a { color: var(--text); }
.bot-pbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.bot-pbar input, .bot-pbar select { width: auto; margin: 0; padding: 8px 12px; }
.bot-pbar #botQ { min-width: 260px; }
.bot-pbar .grow { flex: 1; }
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.bot-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; background: var(--surface); }
.bot-card.skip { opacity: .6; }
.bot-card-head { display: flex; gap: 8px; align-items: flex-start; padding: 12px 12px 10px; }
.bot-card-id { flex: 1; min-width: 0; }
.bot-card-id b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-card-id .hint { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-gear { padding: 6px; }
.bot-card-img { display: grid; place-items: center; aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; color: var(--text-2); font-size: 13px; padding: 0; text-decoration: none; }
.bot-card-img img { width: 100%; height: 100%; object-fit: cover; }
.bot-card-img span { padding: 14px; }
.bot-card-text { font-size: 13px; color: var(--text-2); padding: 8px 12px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bot-card-flags { padding: 6px 12px; }
.bot-flag { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0; padding: 7px 0; font-size: 14px; cursor: pointer; }
.bot-flag .switch { margin: 0; }
.bot-card-inbox { border-top: 1px solid var(--line-2); padding: 10px 12px; font-size: 13px; margin-top: auto; }
.bot-pfoot { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.bot-modal { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .4); display: grid; place-items: center; padding: 16px; }
.bot-modal-box { width: min(860px, 100%); max-height: 90vh; overflow-y: auto; margin: 0; }
.bot-modal-text { font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; max-height: 110px; overflow-y: auto; white-space: pre-wrap; }

/* ---------- Inbox & broadcast ---------- */
.mk-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.mk-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 12px; color: var(--text-2); font-size: 14px; box-shadow: none; }
.mk-tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.mk-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-bottom: 8px; }
.mk-grid3 { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; margin-bottom: 6px; }
.mk-grid2 input, .mk-grid2 select, .mk-grid3 input { margin: 0; }
@media (max-width: 800px) { .mk-grid2, .mk-grid3 { grid-template-columns: 1fr; } }
.mk-sub { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-top: 8px; display: grid; gap: 6px; }
.mk-btnlink { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid #d1d5db; border-radius: 8px; color: #374151; background: #fff; font-size: 13px; cursor: pointer; text-decoration: none; }
.mk-chat { display: grid; grid-template-columns: 300px 1fr 260px; height: calc(100vh - 230px); min-height: 520px; overflow: hidden; }
.mk-chat-list { border-right: 1px solid var(--line); overflow-y: auto; }
.mk-chat-search { display: flex; gap: 6px; padding: 10px; position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line-2); }
.mk-chat-search input, .mk-chat-search select { margin: 0; padding: 6px 8px; font-size: 13px; min-width: 0; }
.mk-chat-item { display: flex; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-2); border-radius: 0; padding: 10px 12px; align-items: flex-start; box-shadow: none; color: var(--text); }
.mk-chat-item.on { background: var(--brand-soft); }
.mk-av { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.mk-ci { flex: 1; min-width: 0; display: grid; font-size: 13px; }
.mk-ci b { font-size: 14px; }
.mk-cl { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 6px; flex: none; }
.mk-w { font-size: 10px; }
.mk-chat-main { display: flex; flex-direction: column; min-width: 0; }
.mk-chat-head { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mk-chat-head .ghost { margin-left: auto; }
.mk-thread { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.mk-msg { max-width: 70%; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; font-size: 14px; display: grid; gap: 4px; }
.mk-msg.me { align-self: flex-end; background: var(--brand); color: #fff; border-color: var(--brand); }
.mk-msg.me .hint { color: rgba(255, 255, 255, .75); }
.mk-msg img { max-width: 220px; border-radius: 8px; }
.mk-msg .hint { font-size: 11px; }
.mk-compose { border-top: 1px solid var(--line); padding: 10px; display: grid; gap: 6px; }
.mk-compose textarea { margin: 0; width: 100%; }
.mk-compose select { width: auto; margin: 0; padding: 6px 8px; font-size: 13px; }
.mk-chat-side { border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; font-size: 13px; display: grid; gap: 10px; align-content: start; }
.mk-chat-side h3 { margin: 0; font-size: 15px; }
.mk-chat-side label { display: grid; gap: 4px; margin: 0; }
.mk-chat-side input, .mk-chat-side textarea, .mk-chat-side select { margin: 0; font-size: 13px; padding: 6px 8px; }
.mk-side-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
@media (max-width: 1100px) { .mk-chat { grid-template-columns: 240px 1fr; } .mk-chat-side { display: none; } }
/* phones: the contact list sits above the thread instead of squeezing it */
@media (max-width: 760px) {
  .mk-chat, #tab-mk .mk-chat { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; height: calc(100vh - 150px); min-height: 480px; }
  .mk-chat-list { border-right: 0; border-bottom: 1px solid var(--line); }
}
.mk-split { display: grid; grid-template-columns: 240px minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
@media (max-width: 1200px) { .mk-split { grid-template-columns: 220px minmax(0, 1fr); } .mk-phone { display: none; } }
.mk-side-list { padding: 14px; }
.mk-folder { font-size: 12px; color: var(--muted); font-weight: 600; margin: 10px 0 4px; }
.mk-flow-item { display: grid; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 8px 10px; box-shadow: none; color: var(--text); }
.mk-flow-item.on { background: var(--brand-soft); }
.mk-flow-item .hint { font-size: 12px; }
.mk-msg-ed { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0; }
.mk-msg-ed textarea { width: 100%; margin: 0; }
.mk-msg-ed-head { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.mk-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.mk-phone { position: sticky; top: 12px; background: #f0f2f5; border-radius: 20px; padding: 14px; display: grid; gap: 6px; align-content: start; }
.mk-phone-head { font-size: 12px; color: var(--muted); text-align: center; font-weight: 600; }
.mk-pmsg { background: #fff; border-radius: 16px; padding: 8px 12px; font-size: 13px; display: grid; gap: 6px; max-width: 92%; }
.mk-pmsg img { width: 100%; border-radius: 10px; }
.mk-pbtn { display: block; text-align: center; border-top: 1px solid var(--line); padding-top: 6px; color: var(--brand); font-weight: 600; }
.mk-qrs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.mk-qr { border: 1px solid var(--brand); color: var(--brand); border-radius: 999px; padding: 3px 10px; font-size: 12px; background: #fff; }
.mk-pdelay { font-size: 11px; color: var(--muted); text-align: center; }
.mk-step { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.mk-step select, .mk-step input { width: auto; margin: 0; padding: 6px 8px; }
.mk-step .errmsg { flex-basis: 100%; }
.mk-step-at { margin-left: auto; }
.mk-bc { border: 1px solid var(--brand); border-radius: 12px; padding: 14px; margin-bottom: 16px; display: grid; gap: 8px; }
.mk-bc select[multiple] { height: auto; }
.mk-aud { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.mk-copy { font-size: 13px; margin-top: 8px; }
.mk-guide { background: var(--surface-2); border-radius: 12px; padding: 12px 16px; margin-top: 14px; font-size: 14px; }
.mk-guide ol { margin: 6px 0; padding-left: 20px; }
.mk-prof-live { font-size: 13px; margin-top: 8px; color: var(--text-2); }
.mk-rules { min-width: 0; table-layout: fixed; }
.mk-rules th, .mk-rules td { vertical-align: top; white-space: normal; overflow-wrap: anywhere; line-height: 1.55; }
.mk-rules th:nth-child(1), .mk-rules td:nth-child(1) { width: 22%; }
.mk-rules th:nth-child(2), .mk-rules td:nth-child(2) { width: 36%; }
.mk-rules td .errmsg { display: block; margin-top: 4px; }

/* ---------- Sub-page layout (left menu + one page at a time) ---------- */
.subnav-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.subnav { position: sticky; top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.subnav-group { font-size: 12px; font-weight: 700; color: #475569; background: #e9edf3; border-radius: 8px; padding: 6px 10px; margin: 10px 0 2px; }
.subnav-group:first-child { margin-top: 0; }
.subnav button { display: flex; gap: 8px; align-items: center; justify-content: space-between; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 8px 10px; font-size: 14px; color: var(--text-2); box-shadow: none; }
.subnav button:hover { background: var(--surface-2); color: var(--text); }
.subnav button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.subnav button .grow { flex: 1; min-width: 0; text-align: left; white-space: normal; }
.subnav button { justify-content: flex-start; height: auto; min-height: 36px; line-height: 1.3; }
.subnav button .st { font-size: 10px; padding: 0 6px; font-weight: 600; }
.subnav-ico { width: 20px; text-align: center; flex: none; }
.subnav-main { min-width: 0; }
.sub-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sub-head h2 { margin: 0; font-size: 20px; }
.sub-head p { margin: 2px 0 0; }
.setup-list { display: grid; gap: 4px; }
.setup-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.setup-row:last-child { border-bottom: 0; }
.setup-row .grow { flex: 1; min-width: 0; }
.setup-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); font-weight: 700; flex: none; }
.setup-n.ok { background: var(--ok); color: #fff; }
.mini-log { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.mini-log .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.bot-flow-step { border: 0; cursor: pointer; font: inherit; color: var(--brand); }
button.bot-flow-step:hover { background: var(--surface-2); }
.mk-quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.mk-quick-item { display: grid; gap: 2px; text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: none; color: var(--text); }
.mk-quick-item:hover { border-color: var(--brand); }
#tab-mk .mk-chat { height: calc(100vh - 260px); }
@media (max-width: 900px) {
  .subnav-layout { grid-template-columns: 1fr; }
  .subnav { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .subnav-group { display: none; }
  .subnav button { white-space: nowrap; width: auto; flex: none; }
  .subnav button .grow { white-space: nowrap; }
}

/* ---------- Page codes & per-channel links ---------- */
.code { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; line-height: 18px; letter-spacing: .02em; }
.code.fb { background: #eef5ff; color: var(--fb); }
.code.ig { background: #fdeef4; color: var(--ig); }
.code.off { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.page-codes { display: grid; gap: 4px; }
.pc-row { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.pc-row:last-child { border-bottom: 0; }
.pc-row .grow { flex: 1; }
.chlinks { display: grid; gap: 6px; margin-top: 8px; }
.chlinks-h, .chlinks-r { display: grid; grid-template-columns: minmax(140px, 1fr) 1.4fr 1.4fr; gap: 10px; align-items: center; }
.chlinks-h { font-size: 12px; color: var(--muted); font-weight: 600; }
.chlinks-r b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chlink { display: flex; gap: 6px; align-items: center; margin: 0; }
.chlink input { margin: 0; flex: 1; min-width: 0; font-size: 13px; padding: 6px 8px; }
.chlink.none { color: var(--muted); font-size: 13px; }
@media (max-width: 800px) { .chlinks-h { display: none; } .chlinks-r { grid-template-columns: 1fr; } }

.ch-pick-wrap { margin: -6px 0 16px; }
.ch-pick { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; }
.ch-pick button { flex: none; display: grid; gap: 2px; text-align: left; min-width: 170px; max-width: 230px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); scroll-snap-align: start; }
.ch-pick button b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-pick button .code { justify-self: start; }
.ch-pick button .hint { font-size: 12px; }
.ch-pick button.on { border-color: var(--brand); background: var(--brand-soft); }
.chl-list { display: grid; gap: 2px; }
.chl-row { display: grid; grid-template-columns: 48px minmax(180px, 1fr) minmax(220px, 1.3fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.chl-row:last-child { border-bottom: 0; }
.chl-row.off { opacity: .55; }
.chl-row .thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }
.chl-noimg { display: grid; place-items: center; background: var(--surface-2); font-size: 20px; }
.chl-name { min-width: 0; display: grid; }
.chl-name .hint { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chl-row input { margin: 0; }
.chl-sum { margin: 6px 0 10px; }
@media (max-width: 800px) { .chl-row { grid-template-columns: 48px 1fr; } .chl-row input, .chl-row .st { grid-column: 1 / -1; } }

/* ---------- Flow list & editor ---------- */
.fl-bar { display: grid; gap: 10px; margin-bottom: 12px; }
.fl-bar input { margin: 0; max-width: 420px; }
.fl-folders { display: flex; gap: 6px; flex-wrap: wrap; }
.fl-folders button { padding: 5px 12px; border-radius: 999px; font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); box-shadow: none; }
.fl-folders button.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.fl-folders button span { font-size: 11px; opacity: .7; margin-left: 2px; }
.fl-table { display: grid; }
.fl-row { display: grid; grid-template-columns: minmax(200px, 2fr) 120px minmax(160px, 1.5fr) auto; gap: 14px; align-items: center; padding: 12px 10px; border-bottom: 1px solid var(--line-2); border-radius: 10px; cursor: pointer; }
.fl-row:hover:not(.fl-th) { background: var(--surface-2); }
.fl-th { font-size: 12px; color: var(--muted); font-weight: 600; cursor: default; padding-top: 0; }
.fl-row > span:first-child { display: grid; min-width: 0; }
.fl-first { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.fl-kinds { display: flex; gap: 4px; flex-wrap: wrap; font-style: normal; }
.fl-kinds i { font-style: normal; font-size: 13px; background: var(--surface-2); border-radius: 6px; padding: 1px 5px; }
.fl-act { display: flex; gap: 4px; }
.fl-empty { text-align: center; padding: 40px 16px; display: grid; gap: 8px; justify-items: center; }
.fl-empty-ico { font-size: 40px; }
.fl-empty p { margin: 0 0 6px; }
.fl-picker { width: min(760px, 100%); }
.fl-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.fl-tpl { display: grid; gap: 4px; text-align: left; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: none; }
.fl-tpl:hover { border-color: var(--brand); background: var(--brand-soft); }
.fl-tpl-ico { font-size: 26px; }

.fl-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.fl-top .grow { flex: 1; }
.fl-name { margin: 0; font-size: 18px; font-weight: 700; padding: 8px 12px; min-width: 260px; flex: 1; max-width: 460px; }
.fl-name.bad { border-color: var(--bad); }
.fl-folder { display: flex; gap: 6px; align-items: center; margin: 0; font-size: 13px; color: var(--text-2); }
.fl-folder input { margin: 0; width: 150px; padding: 7px 10px; }
.fl-issues { background: var(--warn-soft); border: 1px solid #fcd9a5; color: var(--warn); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.fl-issues ul { margin: 4px 0 0; padding-left: 20px; }
.fl-issues.ok { background: var(--ok-soft); border-color: #bfe6cc; color: var(--ok); }
.fl-edit { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1150px) { .fl-edit { grid-template-columns: 1fr; } .fl-phone-col { position: static; order: -1; } }
.fl-col { display: grid; gap: 14px; min-width: 0; }
.fl-steps { display: grid; gap: 0; position: relative; padding-left: 22px; }
.fl-steps::before { content: ""; position: absolute; left: 9px; top: 14px; bottom: 14px; border-left: 2px dashed var(--line); }
.fl-start, .fl-end { position: relative; font-size: 13px; color: var(--text-2); padding: 6px 0 12px; }
.fl-end { padding: 12px 0 0; }
.fl-start > span:first-child, .fl-end > span:first-child { position: absolute; left: -22px; top: 4px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; background: var(--brand); color: #fff; }
.fl-end > span:first-child { top: 10px; background: var(--text-2); }
.fl-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 10px; }
.fl-card.bad { border-color: #f5b4b4; box-shadow: 0 0 0 3px var(--bad-soft); }
.fl-card-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fl-card-head .grow { flex: 1; }
.fl-card-head .ghost { padding: 4px 8px; }
.fl-num { position: absolute; left: -32px; top: 14px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); color: var(--brand); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.fl-text { position: relative; }
.fl-text textarea { width: 100%; margin: 0; padding-bottom: 22px; }
.fl-count { position: absolute; right: 10px; bottom: 6px; font-size: 11px; color: var(--muted); }
.fl-count.bad { color: var(--bad); font-weight: 700; }
.fl-delay { display: flex; gap: 6px; align-items: center; align-self: start; margin: 8px 0; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px dashed var(--line); font-size: 13px; color: var(--text-2); width: max-content; }
.fl-delay input { width: 64px; margin: 0; padding: 3px 6px; text-align: center; }
.fl-drop { display: grid; place-items: center; gap: 4px; min-height: 140px; border: 2px dashed var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; text-align: center; padding: 14px; margin: 0; position: relative; overflow: hidden; }
.fl-drop.over, .fl-drop:hover { border-color: var(--brand); background: var(--brand-soft); }
.fl-drop-ico { font-size: 26px; color: var(--brand); }
.fl-drop.has { padding: 0; min-height: 0; border-style: solid; }
.fl-drop.has img { width: 100%; max-height: 260px; object-fit: contain; background: #fff; }
.fl-drop-change { position: absolute; bottom: 8px; right: 8px; background: rgba(15, 23, 42, .7); color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.fl-more summary { font-size: 13px; color: var(--text-2); cursor: pointer; }
.fl-more input { margin: 6px 0 0; }
.fl-btns { display: grid; gap: 6px; }
.fl-btn-row { display: grid; grid-template-columns: 1fr 110px 1.4fr auto; gap: 6px; }
.fl-btn-row input, .fl-btn-row select { margin: 0; }
.fl-q-row { display: grid; grid-template-columns: 1fr auto 1.4fr auto; gap: 8px; align-items: center; }
.fl-q-row input, .fl-q-row select { margin: 0; }
@media (max-width: 760px) { .fl-btn-row, .fl-q-row { grid-template-columns: 1fr; } .fl-row { grid-template-columns: 1fr; } }
.fl-addline { justify-self: start; background: none; border: 1px dashed var(--brand); color: var(--brand); padding: 6px 12px; border-radius: 10px; font-size: 13px; box-shadow: none; }
.fl-add { margin: 12px 0; padding: 12px; border: 2px dashed var(--line); border-radius: 14px; display: grid; gap: 8px; }
.fl-add-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.fl-add-btns button { display: grid; justify-items: center; gap: 2px; padding: 10px 6px; border-radius: 12px; font-size: 13px; background: var(--surface); box-shadow: none; }
.fl-add-btns button span { font-size: 20px; }
.fl-add-btns button:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.fl-quick { background: #fffdf5; border-color: #f4e3b5; }
.fl-after h3, .fl-test h3 { margin: 0 0 10px; font-size: 15px; }
.fl-phone-col { position: sticky; top: 12px; display: grid; gap: 8px; }
.fl-pv-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.fl-pv-tabs button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 8px; font-size: 13px; box-shadow: none; }
.fl-pv-tabs button.on { background: var(--surface); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, .1); }
.fl-phone { border: 8px solid #1f2937; border-radius: 30px; background: #fff; overflow: hidden; display: flex; flex-direction: column; height: 600px; }
.pv-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.pv-av { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft) center / cover; flex: none; }
.pv-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.pv-user { align-self: flex-end; background: var(--fb); color: #fff; padding: 7px 12px; border-radius: 18px; font-size: 13px; max-width: 80%; }
.fl-phone.ig .pv-user { background: linear-gradient(90deg, #7b3ff2, #e1306c); }
.pv-msg { align-self: flex-start; background: #f0f2f5; border-radius: 18px; padding: 8px 12px; font-size: 13px; max-width: 82%; line-height: 1.45; word-break: break-word; display: grid; gap: 6px; }
.pv-msg.img { padding: 0; background: none; }
.pv-msg.img img { width: 100%; max-width: 220px; border-radius: 16px; display: block; }
.pv-msg.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px 4px; }
.pv-btn { display: block; text-align: center; border-top: 1px solid var(--line); padding: 7px 0; color: var(--fb); font-weight: 600; }
.pv-sub { font-size: 12px; color: var(--muted); }
.pv-ph { color: var(--muted); font-style: italic; }
.pv-typing { align-self: flex-start; display: flex; gap: 3px; align-items: center; background: #f0f2f5; border-radius: 18px; padding: 8px 12px; }
.pv-typing i { width: 6px; height: 6px; border-radius: 50%; background: #9ca3af; animation: pvDot 1.2s infinite; }
.pv-typing i:nth-child(2) { animation-delay: .2s; }
.pv-typing i:nth-child(3) { animation-delay: .4s; }
.pv-typing span { font-size: 10px; color: var(--muted); margin-left: 4px; }
@keyframes pvDot { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
.pv-quick { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-top: 4px; }
.pv-quick span { border: 1px solid var(--fb); color: var(--fb); border-radius: 999px; padding: 4px 12px; font-size: 12px; }
.fl-phone.ig .pv-quick span { border-color: #c13584; color: #c13584; }
.pv-input { border-top: 1px solid var(--line); padding: 10px 14px; color: var(--muted); font-size: 13px; }

/* ---------- Flow editor: steps (Botcake-style) ---------- */
.fx-row { grid-template-columns: minmax(200px, 2fr) 150px minmax(160px, 1.4fr) 150px auto; }
.fx-views { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.fx-views button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; font-size: 13px; box-shadow: none; }
.fx-views button.on { background: var(--surface); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, .1); }
.fx-edit { display: grid; grid-template-columns: 250px minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1350px) { .fx-edit { grid-template-columns: 230px minmax(0, 1fr); } .fx-side { grid-column: 1 / -1; display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; } .fx-side .fl-pv-tabs { grid-column: 1; } }
@media (max-width: 900px) { .fx-edit { grid-template-columns: 1fr; } .fx-side { grid-template-columns: 1fr; } }
.fx-nav { position: sticky; top: 12px; padding: 12px; display: grid; gap: 4px; margin: 0; max-height: calc(100vh - 40px); overflow-y: auto; }
.fx-nav-h { font-size: 12px; font-weight: 700; color: #475569; background: #e9edf3; border-radius: 8px; padding: 5px 10px; margin: 8px 0 2px; }
.fx-nav-h:first-child { margin-top: 0; }
.fx-nav-item { display: flex; gap: 8px; align-items: flex-start; width: 100%; text-align: left; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: none; justify-content: flex-start; height: auto; line-height: 1.35; }
.fx-nav-item:hover { border-color: var(--brand); }
.fx-nav-item.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand-soft); }
.fx-nav-item.bad { border-color: #f5b4b4; }
.fx-nav-item .grow { flex: 1; min-width: 0; display: grid; }
.fx-nav-item b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-nav-item .hint { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-nav-ico { flex: none; }
.fx-add-step { position: relative; margin-top: 8px; }
.fx-add-btn { width: 100%; border: 1.5px dashed var(--line); background: var(--surface); border-radius: 999px; padding: 8px; font-size: 13px; box-shadow: none; }
.fx-add-btn:hover { border-color: var(--brand); color: var(--brand); }
.fx-menu { position: absolute; left: 0; right: -120px; top: calc(100% + 6px); z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18); padding: 6px; display: grid; gap: 2px; }
.fx-menu button { display: flex; gap: 10px; align-items: flex-start; text-align: left; background: none; border: 0; border-radius: 8px; padding: 8px 10px; box-shadow: none; justify-content: flex-start; height: auto; }
.fx-menu button:hover { background: var(--surface-2); }
.fx-menu button > span:last-child { display: grid; }
.fx-menu .hint { font-size: 12px; }
.fx-main { display: grid; gap: 12px; min-width: 0; }
.fx-main > .card { margin: 0; }
.fx-step-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 16px; }
.fx-step-ico { font-size: 22px; }
.fx-step-name { margin: 0; font-size: 17px; font-weight: 700; border-color: transparent; background: transparent; padding: 6px 8px; min-width: 200px; flex: 1; max-width: 360px; }
.fx-step-name:hover, .fx-step-name:focus { border-color: var(--line); background: var(--surface); }
.fx-step-head .grow { flex: 1; }
.fx-msgtype { display: grid; gap: 6px; }
.fx-msgtype label { display: flex; gap: 8px; align-items: center; margin: 0; font-size: 14px; }
.fx-msgtype select { margin: 4px 0 0; }
.fx-block { gap: 10px; }
.fx-block .fl-num { left: auto; position: static; }
.fx-emojis { display: inline-flex; gap: 2px; margin-left: 6px; }
.fx-emojis button { background: none; border: 0; padding: 2px 4px; font-size: 15px; box-shadow: none; }
.fx-btn-row { display: grid; grid-template-columns: 1fr 120px 1.4fr auto; gap: 6px; }
.fx-btn-row input, .fx-btn-row select { margin: 0; }
.fx-q-row, .fx-act-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.fx-q-row input, .fx-q-row select, .fx-act-row input, .fx-act-row select { margin: 0; flex: 1; min-width: 140px; }
.fx-q-row input[type=number], .fx-act-row input[type=number] { flex: none; }
.fx-quick { background: #fffdf5; border-color: #f4e3b5; }
.fx-quick-h { display: grid; margin-bottom: 8px; }
.fx-addblock { display: grid; gap: 8px; }
.fx-bgroup { display: grid; gap: 4px; }
.fx-bgroup .fl-add-btns { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.fx-next label, .fx-branches label { display: grid; gap: 6px; margin: 0; font-weight: 600; }
.fx-branches { display: grid; gap: 12px; }
.fx-yes { color: var(--ok); }
.fx-no { color: var(--bad); }
.fx-ab { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; display: grid; place-items: center; flex: none; }
.fx-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.fx-img-cell { display: grid; gap: 4px; }
.fx-img-cell .fl-drop { min-height: 110px; }
.fx-cards { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.fx-card-ed { flex: none; width: 250px; display: grid; gap: 6px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; align-content: start; }
.fx-card-ed input { margin: 0; }
.fx-card-ed .fl-drop { min-height: 110px; }
.fx-card-h { display: flex; justify-content: space-between; align-items: center; }
.fx-card-add { flex: none; width: 160px; display: grid; place-items: center; align-content: center; gap: 4px; border: 2px dashed var(--line); border-radius: 12px; background: var(--surface-2); font-size: 28px; color: var(--brand); box-shadow: none; }
.fx-card-add span { font-size: 13px; }
.fx-prods { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; margin-bottom: 8px; }
.fx-prod { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; margin: 0; font-size: 12px; cursor: pointer; }
.fx-prod.on { border-color: var(--brand); background: var(--brand-soft); }
.fx-prod img, .fx-prod-ph { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex: none; display: grid; place-items: center; background: var(--surface-2); }
.fx-prod span:last-child { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fx-api { display: grid; grid-template-columns: 100px 1fr; gap: 6px; }
.fx-api select, .fx-api input { margin: 0; }
.fx-filename { font-size: 14px; padding: 20px; }
.fx-note textarea { width: 100%; margin: 8px 0 0; }
.fx-side { display: grid; gap: 10px; position: sticky; top: 12px; }
.fx-side .fl-phone { height: 520px; }
.fx-stats, .fx-side .fl-test { margin: 0; display: grid; gap: 6px; }
.fx-side .fl-test select { margin: 0; }
.fx-stat-h { font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 6px; }
.fx-stat-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; border-bottom: 1px dashed var(--line-2); }
.pv-cards { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.pv-cardx { flex: none; width: 190px; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: grid; font-size: 12px; background: #fff; }
.pv-cardx img, .pv-cardimg { width: 100%; height: 100px; object-fit: cover; display: grid; place-items: center; background: var(--surface-2); }
.pv-cardx b, .pv-cardx .pv-sub { padding: 0 10px; }
.pv-cardx b { padding-top: 8px; }
.pv-cardx .pv-btn { margin: 0 10px; }
.pv-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; max-width: 220px; }
.pv-imgs .pv-msg.img img { max-width: 100%; }
.pv-sys { align-self: center; text-align: center; font-size: 12px; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin: 4px 0; }
.pv-wait { align-self: center; font-size: 11px; color: var(--muted); }
.fx-map-wrap { overflow: auto; }
.fx-map { position: relative; }
.fx-map svg { position: absolute; inset: 0; }
.fx-edge { fill: none; stroke: #94a3b8; stroke-width: 2; }
.fx-edge.yes { stroke: var(--ok); }
.fx-edge.no { stroke: var(--bad); stroke-dasharray: 6 4; }
.fx-edge-l { font-size: 11px; fill: var(--text-2); text-anchor: middle; }
.fx-node { position: absolute; display: grid; align-content: start; gap: 4px; text-align: left; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); height: auto; justify-content: stretch; }
.fx-node:hover { border-color: var(--brand); }
.fx-node.start { border-color: var(--brand); }
.fx-node.bad { border-color: #f5b4b4; }
.fx-node.orphan { opacity: .6; border-style: dashed; }
.fx-node-h { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.fx-node-h b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-node-b { font-size: 12px; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fl-issues a { color: inherit; text-decoration: underline; }

.subnav-layout.fx-full { grid-template-columns: minmax(0, 1fr); }
.subnav-layout.fx-full > .subnav { display: none; }
.fl-issues details summary { cursor: pointer; list-style: none; }
.fl-issues details summary::-webkit-details-marker { display: none; }
.fl-issues ul { max-height: 180px; overflow-y: auto; }

/* ---------- Product details table ---------- */
.pd-table-card { padding: 6px 12px; }
.pd-table { min-width: 1000px; }
.pd-table td { vertical-align: middle; }
.pd-thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; display: grid; place-items: center; background: var(--surface-2); }
.pd-name { max-width: 320px; }
.pd-name b { display: block; }
.pd-name .hint { display: block; font-size: 12px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pd-comm { color: var(--ok); font-weight: 700; }
.pd-table .switch { margin: 0; }
.pd-edit-row td { background: var(--surface-2); }
.pd-edit { display: grid; gap: 8px; padding: 6px 4px; }
.pd-edit label { margin: 0; }
.pd-nums { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 900px) { .pd-nums { grid-template-columns: 1fr 1fr; } }

.pd-add-bar { display: flex; justify-content: space-between; align-items: center; margin: 0 0 12px; }
.pd-nums3 { display: grid; grid-template-columns: 1fr 1fr 1.6fr; gap: 10px; }
@media (max-width: 700px) { .pd-nums3 { grid-template-columns: 1fr; } }

.pd-next { display: block; font-size: 11px; white-space: nowrap; }

.bot-card-ava { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px #1877f2; }
.bot-card-ava.ig { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px #d62976; }

.bot-inbox-mode { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.bot-inbox-mode select { flex: 1; }
.bot-inbox-flow select { width: 100%; }
.bot-inbox-flow .hint { margin: 6px 0 0; font-size: 12px; line-height: 1.5; }

/* ---------- Growth tools (การจัดการเครื่องมือ) ---------- */
.tl-new { white-space: nowrap; }
.tl-card { padding: 18px 20px 14px; }
.tl-search { display: flex; align-items: center; gap: 8px; max-width: 320px; border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; background: var(--surface); }
.tl-search svg { width: 18px; height: 18px; fill: none; stroke: var(--text-2); stroke-width: 2; flex: none; }
.tl-search input { border: 0; outline: 0; box-shadow: none; padding: 9px 0; background: transparent; }
.tl-tabs { display: flex; gap: 4px; margin: 16px 0 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tl-tabs button { display: flex; align-items: center; gap: 6px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 10px 12px; color: var(--text-2); white-space: nowrap; }
.tl-tabs button.on { color: var(--text); font-weight: 700; border-bottom-color: var(--brand); }
.tl-tabs svg, .tl-name svg, .tl-head > svg, .tl-type svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tl-bulk { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); }
.tl-bulk span { flex: 1; font-weight: 600; }
.tl-table-wrap { margin-top: 14px; border: 1px solid var(--line); border-radius: 14px; overflow: auto; max-height: 62vh; }
.tl-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.tl-table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 500; color: var(--text-2); padding: 14px 12px; z-index: 1; }
.tl-table td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.tl-table tr.off td { color: var(--text-2); }
.tl-ck { width: 52px; text-align: center !important; }
.tl-ck input { width: 16px; height: 16px; }
.tl-name { display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; color: var(--text); font-weight: 500; text-align: left; }
.tl-name:hover span { text-decoration: underline; }
.tl-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; flex: none; }
.tl-dot.off { background: #cbd5e1; }
.tl-more { position: relative; width: 52px; text-align: right; }
.tl-dots { font-size: 20px; line-height: 1; padding: 4px 10px; }
.tl-menu { position: absolute; right: 8px; top: 40px; z-index: 5; min-width: 180px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(15, 23, 42, .14); padding: 6px; display: grid; }
.tl-menu button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; }
.tl-menu button:hover { background: var(--surface-2); }
.tl-menu .danger-text { color: var(--bad); }
.tl-empty { text-align: center; color: var(--text-2); padding: 34px 0; }
.tl-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.tl-pager { display: flex; align-items: center; gap: 6px; }
.tl-pager button { min-width: 34px; border: 0; background: none; padding: 6px 8px; border-radius: 8px; }
.tl-pager button.on { background: var(--surface-2); font-weight: 700; }
.tl-pager button:disabled { opacity: .35; }
.tl-pager select { width: auto; margin-left: 8px; }
.tl-gap { color: var(--text-2); }
.tl-box { width: min(720px, 100%); }
.tl-head { display: flex; gap: 12px; align-items: flex-start; }
.tl-head > svg { width: 26px; height: 26px; margin-top: 4px; color: var(--brand); }
.tl-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tl-type { display: grid; gap: 6px; text-align: left; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.tl-type:hover { border-color: var(--brand); background: var(--surface-2); }
.tl-type svg { width: 26px; height: 26px; color: var(--brand); }
.tl-type .hint { font-size: 12.5px; line-height: 1.5; }
@media (max-width: 640px) { .tl-types { grid-template-columns: 1fr; } }
.tl-form { display: grid; gap: 10px; }
.tl-form label { margin: 0; }
.tl-warn { margin: 0 0 12px; font-size: 13px; }
.tl-out { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--surface-2); display: grid; gap: 10px; }
.tl-out-h { display: flex; align-items: center; gap: 8px; }
.tl-out-h b { flex: 1; }
.tl-code { margin: 0; max-height: 260px; overflow: auto; background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.tl-link { display: block; padding: 10px 12px; background: var(--surface); border-radius: 10px; word-break: break-all; font-size: 13px; }
.tl-qr-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.tl-qr { background: #fff; padding: 10px; border-radius: 10px; line-height: 0; }
.tl-qr img, .tl-qr canvas { width: 200px; height: 200px; }
.tl-guide { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.7; color: var(--text-2); }
.tl-stats { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.tl-after { margin: 12px 0 0; }
.tl-actions { justify-content: flex-end; margin-top: 16px; }
a.btn-link { text-decoration: none; display: inline-flex; align-items: center; }
.tl-form input[type=color] { height: 42px; padding: 4px; cursor: pointer; }

/* ---------- Marketing messages (จัดการแคมเปญการตลาด) ---------- */
.mm-card { padding: 20px 22px 16px; }
.mm-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.mm-top h2 { margin: 0; }
.mm-tools { display: flex; align-items: center; gap: 8px; }
.mm-ico { font-size: 18px; padding: 6px 10px; }
.mm-acct { position: relative; }
.mm-acct-btn { display: flex; align-items: center; gap: 10px; min-width: 280px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.mm-acct-btn > span:not(.mm-caret) { flex: 1; display: grid; }
.mm-acct-btn .hint { font-size: 12px; }
.mm-caret { color: var(--text-2); }
.mm-acct-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 360px; max-width: 90vw; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 14px 40px rgba(15, 23, 42, .16); padding: 10px; }
.mm-acct-panel .tl-search { max-width: none; }
.mm-acct-list { max-height: 360px; overflow-y: auto; margin-top: 8px; display: grid; }
.mm-acct-list button { display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 0; background: none; padding: 10px; border-radius: 10px; }
.mm-acct-list button span { display: grid; }
.mm-acct-list button .hint { font-size: 12px; }
.mm-acct-list button:hover, .mm-acct-list button.on { background: var(--surface-2); }
.mm-acct-list .tl-dot { margin-top: 7px; }
.mm-acct-note { font-size: 12px; margin: 8px 4px 0; line-height: 1.5; }
.tl-dot.warn { background: #f59e0b; }
.tl-dot.bad { background: var(--bad); }
.mm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.mm-bar .tl-search { flex: 1; }
.mm-empty { display: grid; justify-items: center; gap: 6px; padding: 70px 0; text-align: center; }
.mm-empty-ico { position: relative; width: 84px; height: 84px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 36px; margin-bottom: 8px; }
.mm-empty-ico span { position: absolute; right: 14px; bottom: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 16px; display: grid; place-items: center; }
.mm-foot { margin-top: 12px; font-weight: 500; }
.mm-list { display: grid; margin-top: 14px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.mm-row { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); }
.mm-row:first-child { border-top: 0; }
.mm-row .tl-dot { align-self: flex-start; margin-top: 8px; }
.mm-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.mm-main .hint { font-size: 12.5px; }
.mm-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-top: 4px; }
.mm-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin: 14px 0; }
.mm-page { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px; }
.mm-page.on { border-color: var(--brand); background: var(--surface-2); }
.mm-page img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.mm-page span { display: grid; min-width: 0; }
.mm-page .hint { font-size: 12px; }
.mm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.mm-kpi { background: var(--surface-2); border-radius: 12px; padding: 12px; display: grid; gap: 4px; }
.mm-kpi b { font-size: 18px; }
.mm-est { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.mm-agree { align-items: flex-start; line-height: 1.5; }
.tl-table td.n, .tl-table th.n { text-align: right; }

/* ---------- Theme picker ---------- */
.side-foot { display: grid; gap: 8px; }
.side-foot .hint { font-size: 12px; }
.theme-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.theme-pick button { border: 0; background: none; padding: 5px 2px; font-size: 11.5px; border-radius: 8px; display: grid; justify-items: center; gap: 0; color: var(--text-2); line-height: 1.3; }
.theme-pick button span { font-size: 14px; }
.theme-pick button.on { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* ---------- Dark mode ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  /* Neon: black + terminal green (outlines, headings, active nav) + purple/magenta palette
     #5515B5 · #794CEC · #92A0FE · #FF00F0 (buttons, links, IG) */
  --neon: #39ff14;
  --neon-soft: rgba(31, 168, 58, .18);
  --neon-mid: #1fa83a;
  --neon-deep: #0e5e24;
  --neon-grad: linear-gradient(90deg, #39ff14, #1fa83a);
  --neon-glow: 0 0 0 1px rgba(57, 255, 20, .35), 0 0 14px rgba(57, 255, 20, .12);
  --bg: #030305;
  --surface: #030305; /* same as the page: frames are outline-only */
  --surface-2: #030305;
  --text: #ffffff;
  --text-2: #e6e6e6;
  --muted: #b3b3b3;
  --line: #0e5e24;
  --line-2: #1a1430;
  --brand: #794cec;
  --brand-soft: #1e1240;
  --ig: #ff00f0;
  --ok: #39ff14;
  --ok-soft: #073816;
  --warn: #ffd23f;
  --warn-soft: #2e2608;
  --bad: #ff4d6d;
  --bad-soft: #35101a;
  --violet: #92a0fe;
  --violet-soft: #1b1a45;
  --shadow: 0 0 0 1px rgba(57, 255, 20, .06), 0 6px 20px rgba(0, 0, 0, .6);
}
/* Neon accents */
:root[data-theme="dark"] a { color: #92a0fe; }
:root[data-theme="dark"] .side { background: #000; border-right-color: var(--neon); box-shadow: 1px 0 12px rgba(57, 255, 20, .15); }
:root[data-theme="dark"] .brand b, :root[data-theme="dark"] .page-head h1, :root[data-theme="dark"] h2 { color: var(--neon); }
:root[data-theme="dark"] .brand b, :root[data-theme="dark"] .page-head h1 { background: var(--neon-grad); -webkit-background-clip: text; background-clip: text; color: transparent; width: fit-content; }
:root[data-theme="dark"] .page-head h1 { filter: drop-shadow(0 0 10px rgba(57, 255, 20, .3)); }
:root[data-theme="dark"] .logo { background: linear-gradient(135deg, #5515b5, #ff00f0); box-shadow: 0 0 12px rgba(255, 0, 240, .45); }
:root[data-theme="dark"] nav button { color: #fff; }
:root[data-theme="dark"] nav button:hover { background: var(--neon-soft); color: var(--neon); }
:root[data-theme="dark"] nav button.on { background: linear-gradient(90deg, var(--neon-mid), var(--neon-deep)); color: #fff; font-weight: 700; box-shadow: inset 0 0 0 1px var(--neon), 0 0 14px rgba(57, 255, 20, .35); }
:root[data-theme="dark"] nav button.on .pill { background: #000; color: var(--neon); box-shadow: none; }
:root[data-theme="dark"] .stat .num { color: var(--neon); }
:root[data-theme="dark"] input, :root[data-theme="dark"] textarea, :root[data-theme="dark"] select { background: #000; border-color: #2c6b25; color: var(--text); }
:root[data-theme="dark"] button { border-color: #2c6b25; }
:root[data-theme="dark"] button.secondary, :root[data-theme="dark"] button.ghost { background: transparent; border-color: rgba(57, 255, 20, .5); color: #fff; }
:root[data-theme="dark"] button.secondary:hover, :root[data-theme="dark"] button.ghost:hover { background: transparent; border-color: var(--neon); box-shadow: 0 0 8px rgba(57, 255, 20, .35); }
:root[data-theme="dark"] button.primary { background: linear-gradient(135deg, #5515b5, #794cec); border-color: #794cec; box-shadow: 0 0 14px rgba(121, 76, 236, .45); }
:root[data-theme="dark"] button.primary:hover { background: linear-gradient(135deg, #794cec, #ff00f0); border-color: #ff00f0; box-shadow: 0 0 18px rgba(255, 0, 240, .45); }
:root[data-theme="dark"] .pill { background: linear-gradient(135deg, #b000a8, #ff00f0); color: #fff; font-weight: 700; text-shadow: 0 1px 1px rgba(0, 0, 0, .5); box-shadow: 0 0 8px rgba(255, 0, 240, .5); }
/* Depth: layered panels so text sits on a tinted surface, not flat black */
/* Frames: thin glowing neon line, no fill. Fill + frame together marks the one focal element. */
:root[data-theme="dark"] { --frame: rgba(57, 255, 20, .7); --frame-glow: 0 0 6px rgba(57, 255, 20, .35), inset 0 0 10px rgba(57, 255, 20, .1); }
:root[data-theme="dark"] .card, :root[data-theme="dark"] .stat { background: transparent; border-color: var(--frame); box-shadow: var(--frame-glow); }
:root[data-theme="dark"] .card:hover { border-color: var(--neon); }
:root[data-theme="dark"] .card .card, :root[data-theme="dark"] .card .result, :root[data-theme="dark"] .bot-flow { background: transparent; border: 1px solid rgba(57, 255, 20, .4); box-shadow: inset 0 0 8px rgba(57, 255, 20, .06); }
/* Focal: fill + frame */
:root[data-theme="dark"] .ov-progress, :root[data-theme="dark"] .auto-card.on, :root[data-theme="dark"] .stat.an-kpi, :root[data-theme="dark"] .qday { background: linear-gradient(180deg, #0e3a1a, #04140a 70%); border-color: var(--neon); box-shadow: 0 0 0 1px rgba(57, 255, 20, .5), 0 0 22px rgba(57, 255, 20, .22), inset 0 0 18px rgba(57, 255, 20, .12); }
:root[data-theme="dark"] .auto-card .auto-top b { color: var(--neon); }
:root[data-theme="dark"] .ig-box { background: linear-gradient(135deg, #2a0a2e, #1b1240); border-color: #5a1f6b; }
:root[data-theme="dark"] .ig-ava { border-color: #000; }
:root[data-theme="dark"] label, :root[data-theme="dark"] .label { color: #fff; }
:root[data-theme="dark"] .hint { color: var(--muted); }
:root[data-theme="dark"] .card-head { padding-bottom: 10px; border-bottom: 1px solid #1a1430; }
:root[data-theme="dark"] code { background: #1e1240; border-color: #3a2a78; color: #fff; }
:root[data-theme="dark"] .switch span::after { background: #fff; }
:root[data-theme="dark"] .theme-pick { background: #000; border-color: var(--line); }
:root[data-theme="dark"] .theme-pick button.on { background: linear-gradient(90deg, var(--neon-mid), var(--neon-deep)); color: #fff; box-shadow: inset 0 0 0 1px var(--neon); }
:root[data-theme="dark"] .switch input:checked + span { background: linear-gradient(90deg, var(--neon-mid), #073816); box-shadow: inset 0 0 0 1px var(--neon); }
:root[data-theme="dark"] .sel-bar { background: #1e1240; border: 1px solid #794cec; }
:root[data-theme="dark"] ::selection { background: #ff00f0; color: #000; }
:root[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
:root[data-theme="dark"] ::-webkit-scrollbar-track { background: #000; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2c6b25; border-radius: 6px; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--neon); }
:root[data-theme="dark"] img { opacity: .96; }
/* light colours written directly in the rules above */
/* Platform colours: official FB blue / IG gradient, white text, logo in the chip */
:root[data-theme="dark"] .chip.fb input:checked + span, :root[data-theme="dark"] .tag.fb, :root[data-theme="dark"] .code.fb { background: #1877f2; border-color: #1877f2; color: #fff; }
:root[data-theme="dark"] .chip.ig input:checked + span, :root[data-theme="dark"] .tag.ig, :root[data-theme="dark"] .code.ig { background: linear-gradient(90deg, #f58529, #dd2a7b, #8134af); border-color: #dd2a7b; color: #fff; }
:root[data-theme="dark"] .chip input:checked + span { font-weight: 600; }
:root[data-theme="dark"] .chip.fb span::before, :root[data-theme="dark"] .chip.ig span::before { width: 14px; height: 14px; border-radius: 0; background: #777 no-repeat center / contain; -webkit-mask: var(--logo) no-repeat center / contain; mask: var(--logo) no-repeat center / contain; }
:root[data-theme="dark"] .chip.fb span::before { --logo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14 8h3V4h-3c-2.8 0-4 1.8-4 4.3V10H7v4h3v8h4v-8h3l1-4h-4V8.6c0-.4.3-.6.6-.6z'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] .chip.ig span::before { --logo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4'%3E%3Crect x='3' y='3' width='18' height='18' rx='5'/%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Ccircle cx='17.3' cy='6.7' r='.6' fill='black'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] .chip.fb input:checked + span::before, :root[data-theme="dark"] .chip.ig input:checked + span::before { background: #fff; }
:root[data-theme="dark"] .code.off { background: #1a1a1a; color: #888; border: 1px solid #333; }
:root[data-theme="dark"] .st.meta_scheduled { background: #10304f; color: #7cc0ff; }
:root[data-theme="dark"] .lst.available { background: #14284a; color: #8fb6ff; }
:root[data-theme="dark"] .lst.planned { background: #3a3110; color: #f5d36b; }
:root[data-theme="dark"] .lst.duplicate, :root[data-theme="dark"] .lst.invalid { background: #3b1a1d; color: #fca5a5; }
:root[data-theme="dark"] .prod-tag { background: #2a2618; border: 0; color: #f3e3a6; box-shadow: none; }
:root[data-theme="dark"] .subnav-group, :root[data-theme="dark"] .fx-nav-h { background: transparent; color: var(--neon); border-bottom: 1px solid rgba(57, 255, 20, .3); border-radius: 0; }
:root[data-theme="dark"] .bot-bubble.user, :root[data-theme="dark"] .mk-msg, :root[data-theme="dark"] .mk-pmsg,
:root[data-theme="dark"] .pv-msg.card, :root[data-theme="dark"] .pv-cardx { background: var(--surface); }
:root[data-theme="dark"] .mk-btnlink, :root[data-theme="dark"] .mk-qr { background: var(--surface); color: var(--text); border-color: var(--line); }
:root[data-theme="dark"] .mk-qr { color: var(--brand); border-color: var(--brand); }
:root[data-theme="dark"] .mk-phone { background: #06040e; }
:root[data-theme="dark"] .fl-phone { border-color: #000; background: #06040e; }
:root[data-theme="dark"] .pv-body { background: #06040e; }
:root[data-theme="dark"] .pv-msg, :root[data-theme="dark"] .pv-typing { background: #1e1240; color: var(--text); }
:root[data-theme="dark"] .fl-quick, :root[data-theme="dark"] .fx-quick { background: #241f10; border-color: #4a3d16; }
:root[data-theme="dark"] .fl-drop.has img { background: var(--surface-2); }
:root[data-theme="dark"] input:focus, :root[data-theme="dark"] textarea:focus, :root[data-theme="dark"] select:focus { border-color: var(--neon); box-shadow: 0 0 0 3px rgba(57, 255, 20, .2); }
:root[data-theme="dark"] .tl-code { background: #060a14; }
/* QR codes stay black on white so phones can scan them */
:root[data-theme="dark"] .tl-qr { background: #fff; }
:root[data-theme="dark"] .chip-btn.all.on { background: var(--brand); }
/* Bot flow strip: solid purple steps, white text */
:root[data-theme="dark"] .bot-flow > b { color: #fff; }
:root[data-theme="dark"] .bot-flow-step, :root[data-theme="dark"] button.bot-flow-step { background: #5515b5; color: #fff; box-shadow: none; }
:root[data-theme="dark"] button.bot-flow-step:hover { background: #794cec; }
:root[data-theme="dark"] .bot-flow i { color: #fff; }
:root[data-theme="dark"] .qday { border: 1px solid var(--frame); }
:root[data-theme="dark"] .qday:hover { border-color: var(--neon); }
:root[data-theme="dark"] .qday.on { border-color: var(--neon); box-shadow: 0 0 0 2px var(--neon), 0 0 26px rgba(57, 255, 20, .35), inset 0 0 18px rgba(57, 255, 20, .15); }
:root[data-theme="dark"] .qday.late { border-color: #ffd23f; }

/* 22. warning boxes readable in dark mode */
:root[data-theme="dark"] .warn { background: #1d1a10; border-color: #6b5f35; color: #f3e3a6; box-shadow: none; }
:root[data-theme="dark"] .an-cell:hover { outline-color: var(--text); }

/* ---------- Dark: big tables — thick neon frame, no inner lines ---------- */
:root[data-theme="dark"] .pd-table-card,
:root[data-theme="dark"] .card:has(> #queueList),
:root[data-theme="dark"] .card:has(.an-table),
:root[data-theme="dark"] .tl-table-wrap {
  background: #000; border: 3px solid var(--neon); border-radius: 14px;
  box-shadow: 0 0 14px rgba(57, 255, 20, .45), inset 0 0 12px rgba(57, 255, 20, .08);
}
:root[data-theme="dark"] .an-table th, :root[data-theme="dark"] .an-table td,
:root[data-theme="dark"] .tl-table th, :root[data-theme="dark"] .tl-table td,
:root[data-theme="dark"] .job { border: 0; }
:root[data-theme="dark"] .an-table th, :root[data-theme="dark"] .tl-table th { color: var(--neon); background: #000; }
:root[data-theme="dark"] .an-table tbody tr:hover td,
:root[data-theme="dark"] .tl-table tbody tr:hover td,
:root[data-theme="dark"] #queueList .job:hover { background: #0a140c; }
:root[data-theme="dark"] .pd-edit-row td { background: #0a0f0b; }

/* Row buttons: gradient fill + inset line like the switch, white text, color by action */
:root[data-theme="dark"] .an-table button.small, :root[data-theme="dark"] .tl-table button.small,
:root[data-theme="dark"] #queueList button.small {
  background: linear-gradient(90deg, #794cec, #1e0a45); border: 0; color: #fff; box-shadow: inset 0 0 0 1px #b69bff; font-weight: 600;
}
:root[data-theme="dark"] #queueList button[data-a="post-now"],
:root[data-theme="dark"] #queueList button[data-a^="retry"],
:root[data-theme="dark"] button.small[data-save] { background: linear-gradient(90deg, var(--neon-mid), #073816); box-shadow: inset 0 0 0 1px var(--neon); }
:root[data-theme="dark"] #queueList button.small.danger,
:root[data-theme="dark"] button.small[data-pdel] { background: linear-gradient(90deg, #e0334f, #3d0f18); color: #fff; box-shadow: inset 0 0 0 1px #ff6b85; }
:root[data-theme="dark"] .an-table button.small:hover, :root[data-theme="dark"] .tl-table button.small:hover,
:root[data-theme="dark"] #queueList button.small:hover { border: 0; filter: brightness(1.18); }

/* Broadcast: page choice shown as a button that opens the picker popup */
.bc-pages { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; cursor: pointer; }
.bc-pages:hover { border-color: var(--brand); }
.bc-pages .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-pages-avs { display: flex; flex: none; }
.bc-pages-avs img { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); background: var(--line); margin-left: -8px; }
.bc-pages-avs img:first-child { margin-left: 0; }
/* Neon theme: cards are see-through, but a popup must cover what is under it */
:root[data-theme="dark"] .bot-modal { background: rgba(0, 0, 0, .7); }
:root[data-theme="dark"] .bot-modal-box.card, :root[data-theme="dark"] .card .bot-modal-box.card { background: #000; border: 1px solid var(--frame); box-shadow: var(--frame-glow); }
/* Broadcast: the "who gets it" conditions as one block */
.bc-cond { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px 2px; }
.bc-cond-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.bc-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bc-dates input { margin: 0; }
.fl-folders .fl-folder-add { border-style: dashed; color: var(--text-2); }
.seq-pages { display: grid; grid-template-columns: auto minmax(220px, 420px); gap: 10px; align-items: center; margin: 6px 0 10px; }

/* ---------- "ทำงานกับฉัน" assistant ---------- */
.as-fab { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 999px; border: 0; background: var(--brand); color: #fff; font: inherit; font-weight: 700; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); cursor: pointer; }
.as-fab:hover { filter: brightness(1.08); }
.as-fab.on { opacity: .85; }
.as-panel { position: fixed; right: 20px; bottom: 76px; z-index: 95; width: min(420px, calc(100vw - var(--side) - 40px)); height: min(600px, calc(100vh - 110px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); overflow: hidden; }
.as-head { display: flex; gap: 6px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.as-head > div { flex: 1; min-width: 0; display: grid; }
.as-head .hint { font-size: 11.5px; }
.as-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.as-msg { max-width: 88%; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.55; word-wrap: break-word; }
.as-msg.me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.as-msg.ai { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.as-msg.err { align-self: flex-start; background: var(--danger-soft, #fde8e8); color: var(--danger, #b42318); }
.as-msg a { color: inherit; text-decoration: underline; }
.as-card { align-self: stretch; border: 1px solid var(--warn, #d97706); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; font-size: 14px; background: var(--warn-soft, #fff7e6); }
.as-card.ok { border-color: var(--ok, #16a34a); }
.as-card.no, .as-card.fail { opacity: .75; }
.as-card-t { font-weight: 700; }
.as-card .row { gap: 8px; }
.as-hello { display: grid; gap: 6px; }
.as-sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.as-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.as-input textarea { flex: 1; margin: 0; resize: none; max-height: 120px; }
.as-typing { display: flex; gap: 4px; }
.as-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); animation: asDot 1s infinite ease-in-out; }
.as-typing span:nth-child(2) { animation-delay: .15s; }
.as-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes asDot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (max-width: 760px) {
  .as-fab { right: 16px; bottom: 16px; }
  .as-panel { left: 8px; right: 8px; bottom: 70px; width: auto; height: calc(100vh - 140px); }
}
:root[data-theme="dark"] .as-panel { background: #000; border-color: var(--frame); box-shadow: var(--frame-glow); }
:root[data-theme="dark"] .as-card { background: rgba(217, 119, 6, .12); color: var(--text); }
/* assistant: chat / shortcuts tabs and the shortcut view */
.as-tabs { display: flex; border-bottom: 1px solid var(--line); }
.as-tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px; font: inherit; font-weight: 600; color: var(--text-2); box-shadow: none; cursor: pointer; }
.as-tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.as-tabs .hint { font-weight: 400; font-size: 11px; }
.as-quick { gap: 12px; }
.as-qsec { display: grid; gap: 6px; }
.as-qh { font-weight: 700; font-size: 13px; }
.as-qh .hint { font-weight: 400; }
.as-qres { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.as-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.as-tile { background: var(--surface-2); border-radius: 10px; padding: 8px; text-align: center; display: grid; }
.as-tile b { font-size: 20px; }
.as-tile span { font-size: 11.5px; color: var(--text-2); }
.as-kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; }
.as-kv span { color: var(--text-2); }
.as-row { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.as-row > div:first-child, .as-row > span { min-width: 0; flex: 1; }
.as-row-act { display: flex; gap: 4px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.as-err { color: var(--danger, #b42318); }
.as-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.as-table th, .as-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.as-table th:first-child, .as-table td:first-child { text-align: left; }
.as-msg .as-go { margin-top: 6px; }
:root[data-theme="dark"] .as-tile { background: rgba(57, 255, 20, .06); border: 1px solid rgba(57, 255, 20, .3); }
/* Overview: content / page quality on each page card */
.ov-page-q { display: grid; gap: 6px; font-size: 13px; padding-top: 8px; margin-top: 2px; border-top: 1px solid var(--line-2); }
.ov-q { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--text-2); }
.ov-q .st { font-size: 11.5px; padding: 1px 8px; }
.ov-q-t { flex-basis: 100%; font-size: 12.5px; }
.ov-q-t b { color: var(--text); }
.q-up { color: var(--ok); font-weight: 600; }
.q-down { color: var(--bad); font-weight: 600; }
.st.off { background: var(--surface-2); color: var(--text-2); }
/* Toast in dark mode: --text is white there, so the light text on it vanished */
:root[data-theme="dark"] #toast { background: #111; color: #fff; border: 1px solid var(--neon, #39ff14); box-shadow: 0 0 10px rgba(57, 255, 20, .35); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-theme="dark"]) #toast { background: #111; color: #fff; } }
/* Segmented choices (ทั้งหมด / Facebook / Instagram, date ranges …): the picked one must stand out.
   In dark mode surface = background, so the old "lighter pill" was invisible. */
.seg input:checked + span { background: var(--brand); color: #fff; box-shadow: 0 1px 4px rgba(15, 23, 42, .2); }
.seg span:hover { color: var(--text); }
:root[data-theme="dark"] .seg input:checked + span { background: var(--neon-soft); color: var(--neon); box-shadow: inset 0 0 0 1px var(--neon), 0 0 8px rgba(57, 255, 20, .3); }
:root[data-theme="dark"] .as-tabs button { background: none; box-shadow: none; }
:root[data-theme="dark"] .as-tabs button.on { color: var(--neon); border-bottom-color: var(--neon); }
.as-sugg .chip-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .as-sugg .chip-btn.on { background: var(--neon-soft); border-color: var(--neon); color: var(--neon); }

/* Page protection (guard.js): auto-pause after a Meta block, new-page warm-up */
.guard-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; margin: 6px 0; font-size: 13px; line-height: 1.5; }
.guard-row.block { background: #fdecec; color: #8a1c1c; border: 1px solid #f3c2c2; }
.guard-row.warm { background: #fff6e5; color: #7a4d00; border: 1px solid #f3ddb0; }
.guard-row button { flex: none; }
html[data-theme="dark"] .guard-row.block { background: rgba(255, 70, 90, .12); color: #ff9aa6; border-color: rgba(255, 70, 90, .45); }
html[data-theme="dark"] .guard-row.warm { background: rgba(255, 190, 60, .10); color: #ffd27a; border-color: rgba(255, 190, 60, .4); }

/* ---------- Status bar (#sysBar): app not answering / Meta paused / page blocked / near limit ---------- */
/* Fixed over the main column only (never over the sidebar); the floating assistant button sits at
   the bottom, so it is never covered. main gets extra top padding while the bar shows. */
.sys-bar { position: fixed; top: 0; left: var(--side); right: 0; z-index: 30; display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; padding: 8px 32px; font-size: 14px; font-weight: 500; border-bottom: 1px solid transparent; }
.sys-bar.warn { background: var(--warn-soft); color: var(--warn); border-bottom-color: var(--warn); }
.sys-bar.bad { background: var(--bad); color: #fff; border-bottom-color: var(--bad); }
.sys-bar span::before { content: "● "; }
body.has-sysbar main { padding-top: 76px; }
:root[data-theme="dark"] .sys-bar.warn { background: var(--warn-soft); color: var(--warn); border-bottom-color: var(--warn); }
:root[data-theme="dark"] .sys-bar.bad { background: var(--bad-soft); color: var(--bad); border-bottom-color: var(--bad); }
@media (max-width: 760px) {
  /* The sidebar becomes a sticky top bar here: the status bar sits above it in the page flow instead. */
  .sys-bar { position: static; padding: 8px 16px; }
  body.has-sysbar main { padding-top: 18px; }
}

/* Signed-in user in the sidebar footer */
.who-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; margin: 8px 0; }
.who-box b { font-weight: 600; }

/* "ประวัติการทำงาน" table */
.act-log { width: 100%; border-collapse: collapse; font-size: 13px; }
.act-log th, .act-log td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.act-log th { color: var(--text-2); font-weight: 500; }
.act-log td.n { white-space: nowrap; }

/* ---------- Batch 4: งานวันนี้, คู่มือ, ⓘ, plain-Thai errors, tab "กฎและพรอมต์" ---------- */
.todo-card .card-head { margin-bottom: 8px; }
.todo-ok { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.todo-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.todo-row:first-of-type { border-top: 0; }
.todo-row .grow { min-width: 0; }
.todo-row .hint { overflow-wrap: anywhere; }
.todo-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.todo-row.bad .todo-dot { background: var(--bad); }
.todo-row.warn .todo-dot { background: var(--warn); }
.todo-row.low { opacity: .75; }
.todo-row.low b { color: var(--text-2); font-weight: 500; }
.manual-card summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; list-style: none; }
.manual-card summary::-webkit-details-marker { display: none; }
.manual-card summary h2 { margin: 0; }
.manual-card summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
.manual-card[open] summary::after { content: '▴'; }
.manual-card[open] summary { margin-bottom: 10px; }
.manual-sec h3 { font-size: 15px; margin: 14px 0 4px; }
.manual-sec ol { margin: 0; padding-left: 22px; font-size: 14px; }
.manual-sec li { margin: 3px 0; }
.gl-tip { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border-radius: 50%; font-size: 12px; line-height: 1; cursor: help; color: var(--brand); background: var(--brand-soft); vertical-align: 1px; user-select: none; font-style: normal; font-weight: 600; }
.gl-tip:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.gl-pair { display: inline-flex; gap: 4px; align-items: center; }
.err-x b { font-weight: 600; }
.err-more { border: 0; background: none; padding: 0 2px; margin-left: 4px; font: inherit; font-size: 12px; color: var(--muted); text-decoration: underline; cursor: pointer; }
.err-raw { display: block; margin-top: 2px; color: var(--text-2); font-size: 12px; overflow-wrap: anywhere; }
.perm-box { margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; font-size: 14px; }
.perm-steps { margin: 6px 0 8px; padding-left: 22px; }
.perm-steps li { margin: 3px 0; }
.perm-list code { display: inline-block; margin: 2px 0; }
.rules-form { display: grid; gap: 2px; }
.rule-row { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line-2); }
.rule-row:first-child { border-top: 0; }
.rule-row.changed .rule-l > b { color: var(--brand); }
.rule-l { min-width: 0; }
.rule-r { display: flex; align-items: center; gap: 8px; flex: none; }
.rule-r input { width: 110px; }
.rule-r select { min-width: 190px; }
.rules-warn { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); font-size: 14px; }
.rules-warn ul { margin: 6px 0 0; padding-left: 20px; }
.why { margin: 0 0 10px; }
.kv-list { display: grid; gap: 6px; font-size: 14px; }
.kv-list > div { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 12px; }
.kv-list > div > b { font-weight: 600; }
.sub-h { font-size: 15px; margin: 14px 0 6px; }
.prompt-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.prompt-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 6px; }
.prompt-head button { margin-left: auto; }
.prompt-pre { margin: 0; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.6 "IBM Plex Sans Thai", ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px; color: var(--text); }
.prompt-extra { margin-top: 6px; font-size: 13px; }
.as-manual { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.6 "IBM Plex Sans Thai", sans-serif; margin: 0; }
@media (max-width: 720px) {
  .rule-row { flex-direction: column; align-items: stretch; }
  .rule-r input, .rule-r select { width: 100%; min-width: 0; }
  .kv-list > div { grid-template-columns: 1fr; gap: 0; }
  .todo-row { flex-wrap: wrap; }
}

/* Settings tab: Botcake-style sub-pages (ตั้งค่า / กฎและพรอมต์) */
.sv { display: none; }
.sv.on { display: block; }
#fromLib:not(.hidden) + #fromLibEmpty { display: none; }

/* ---------- ห้องแชท (inbox) ---------- */
main.wide { max-width: none; padding: 10px 12px 12px; }
#tab-inbox.on { display: block; height: calc(100vh - 22px); }
.ib { display: grid; grid-template-columns: 64px 340px minmax(0, 1fr) 300px; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: 14px; }
.ib .grow { flex: 1; }
.ib button.link { background: none; border: 0; padding: 0; color: var(--brand); font-size: 12px; box-shadow: none; }
.ib-rail { display: flex; flex-direction: column; align-items: stretch; background: var(--surface-2); border-right: 1px solid var(--line); padding: 8px 6px; gap: 4px; overflow-y: auto; }
.ib-rail button { position: relative; border: 0; background: none; padding: 7px 2px 5px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--text-2); box-shadow: none; }
.ib-rail button span { font-size: 10px; line-height: 1.2; }
.ib-rail button svg { width: 20px; height: 20px; }
.ib-rail button.on { background: var(--brand-soft); color: var(--brand); }
.ib-rail button b { position: absolute; top: 2px; right: 4px; background: var(--bad); color: #fff; border-radius: 999px; font-size: 10px; line-height: 15px; min-width: 15px; padding: 0 4px; text-align: center; }
.ib-rail button.spin svg { animation: ibspin 1s linear infinite; }
@keyframes ibspin { to { transform: rotate(360deg); } }
.ib-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; }
.ib-list-head { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line-2); align-items: center; }
.ib-search { flex: 1; display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; min-width: 0; }
.ib-search svg { width: 16px; height: 16px; color: var(--muted); }
.ib-search input { border: 0; background: none; padding: 7px 0; margin: 0; width: 100%; font-size: 13px; outline: none; }
.ib-fbtn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.ib-fbtn svg { width: 15px; height: 15px; }
.ib-fbtn.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft); }
.ib-fbtn b { background: var(--brand); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; line-height: 16px; }
.ib-filters { padding: 8px 10px; border-bottom: 1px solid var(--line-2); display: grid; gap: 6px; background: var(--surface-2); }
.ib-filters select, .ib-filters input { margin: 0; font-size: 13px; padding: 5px 8px; min-width: 0; flex: 1; }
.ib-tagcloud { display: flex; flex-wrap: wrap; gap: 4px; max-height: 150px; overflow-y: auto; margin-top: 4px; }
.ib-bulk { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px 10px; background: var(--brand-soft); border-bottom: 1px solid var(--line-2); font-size: 12px; }
.ib-bulk button, .ib-bulk select, .ib-bulk input { margin: 0; padding: 3px 8px; font-size: 12px; border-radius: 8px; }
.ib-bulk input { width: 110px; }
.ib-status { padding: 3px 12px; font-size: 11px; border-bottom: 1px solid var(--line-2); }
.ib-items { overflow-y: auto; flex: 1; }
.ib-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; align-items: flex-start; }
.ib-item:hover { background: var(--surface-2); }
.ib-item.on { background: var(--brand-soft); }
.ib-item.unread .ib-ci-top b, .ib-item.unread .ib-ci-text { font-weight: 700; color: var(--text); }
.ib-ck { margin: 14px 0 0; }
.ib-avw { position: relative; flex: none; }
.ib-av { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; background: var(--c, var(--brand)); color: #fff; font-weight: 700; font-size: 18px; flex: none; }
.ib-av.big { width: 64px; height: 64px; font-size: 26px; }
.ib-dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--bad); border: 2px solid var(--surface); }
.ib-ci { min-width: 0; flex: 1; display: grid; gap: 2px; }
.ib-ci-top { display: flex; gap: 6px; align-items: center; min-width: 0; }
.ib-ci-top b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.ib-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ib-ci-text { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.ib-reply { width: 13px; height: 13px; color: var(--muted); flex: none; }
.ib-ci-foot { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-size: 11px; }
.ib-page { color: var(--muted); max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-asg { background: var(--violet-soft); color: var(--violet); border-radius: 999px; padding: 0 7px; font-weight: 600; }
.ib-more { color: var(--muted); }
.ib-ico { width: 14px; height: 14px; color: var(--muted); }
.ib-ico.ok { color: var(--ok); }
.ib-star { width: 14px; height: 14px; }
.ib-star.on { color: #f59e0b; fill: #f59e0b; }
.ib-pf { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 5px; line-height: 16px; white-space: nowrap; flex: none; }
.ib-pf.fb { background: #eef5ff; color: var(--fb); }
.ib-pf.ig { background: #fdeef4; color: var(--ig); }
.ib-pf.cm { background: var(--warn-soft); color: var(--warn); }
.ib-tag { display: inline-flex; align-items: center; font-size: 11px; padding: 0 8px; border-radius: 999px; font-weight: 600; line-height: 18px; white-space: nowrap; background: var(--c); color: #fff; border: 1px solid transparent; cursor: pointer; box-shadow: none; }
.ib-tag.off { background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); border-color: color-mix(in srgb, var(--c) 35%, transparent); }
.ib-tag.out { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.ib-tag.in { outline: 2px solid color-mix(in srgb, var(--c) 40%, transparent); }
/* thread */
.ib-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.ib-empty { margin: auto; text-align: center; color: var(--muted); display: grid; gap: 4px; justify-items: center; }
.ib-empty svg { width: 48px; height: 48px; opacity: .4; }
.ib-thead { display: flex; gap: 10px; align-items: center; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.ib-thead .ib-av { width: 40px; height: 40px; font-size: 16px; }
.ib-thead-n { min-width: 0; flex: 1; line-height: 1.3; }
.ib-thead-n b { font-size: 15px; margin-right: 6px; }
.ib-thead-n .hint { font-size: 12px; }
.ib-win.ok { color: var(--ok); } .ib-win.warn { color: var(--warn); } .ib-win.off { color: var(--muted); }
.ib-thead-a { display: flex; gap: 4px; align-items: center; }
.ib-thead-a select { margin: 0; font-size: 12px; padding: 4px 8px; max-width: 150px; }
.ib-ib { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border-radius: 8px; color: var(--text-2); cursor: pointer; border: 1px solid var(--line); background: var(--surface); }
.ib-ib svg { width: 17px; height: 17px; }
.ib-ib.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft); }
.ib-sidetoggle { display: none; }
.ib-msgs { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.ib-day { text-align: center; margin: 10px 0 4px; }
.ib-day span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: 11px; padding: 2px 10px; color: var(--muted); }
.ib-msg { max-width: 72%; align-self: flex-start; display: grid; gap: 2px; }
.ib-msg.me { align-self: flex-end; justify-items: end; }
.ib-bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 7px 12px; display: grid; gap: 6px; word-break: break-word; }
.ib-msg.me .ib-bubble { background: #d9fdd3; border-color: #c3f0bb; border-radius: 14px 14px 4px 14px; }
:root[data-theme="dark"] .ib-msg.me .ib-bubble { background: #1f4d2b; border-color: #2a6a3a; }
.ib-msg.hidden-cm .ib-bubble { opacity: .55; }
.ib-text { white-space: pre-wrap; line-height: 1.5; }
.ib-img { max-width: 260px; max-height: 260px; border-radius: 10px; display: block; }
.ib-sticker { width: 90px; }
.ib-video { max-width: 300px; border-radius: 10px; }
.ib-file { font-size: 13px; }
.ib-meta { font-size: 11px; color: var(--muted); padding: 0 4px; display: flex; gap: 6px; }
.ib-meta i { font-style: normal; font-weight: 600; color: var(--text-2); }
.ib-cm-act { display: flex; gap: 10px; font-size: 12px; padding: 0 4px; align-items: center; }
.ib-tagbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 12px; background: var(--surface); border-top: 1px solid var(--line-2); max-height: 86px; overflow-y: auto; align-items: center; }
.ib-newtag input { margin: 0; font-size: 11px; padding: 1px 8px; width: 100px; border-radius: 999px; }
.ib-compose { background: var(--surface); border-top: 1px solid var(--line); padding: 8px 12px; display: grid; gap: 6px; position: relative; }
.ib-compose textarea { margin: 0; resize: vertical; min-height: 44px; font-size: 14px; }
.ib-ctools { display: flex; gap: 6px; align-items: center; }
.ib-ctools select { margin: 0; font-size: 12px; padding: 4px 8px; max-width: 160px; }
.ib-replyto { font-size: 12px; color: var(--text-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ib-quick { position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; z-index: 5; }
.ib-quick button { display: grid; gap: 1px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line-2); border-radius: 0; padding: 7px 12px; box-shadow: none; }
.ib-quick button span { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* side */
.ib-side { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ib-stabs { display: flex; border-bottom: 1px solid var(--line); }
.ib-stabs button { flex: 1; border: 0; border-radius: 0; background: none; padding: 9px 4px; font-size: 13px; color: var(--text-2); box-shadow: none; border-bottom: 2px solid transparent; }
.ib-stabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.ib-sbody { padding: 12px; overflow-y: auto; font-size: 13px; display: grid; gap: 10px; align-content: start; }
.ib-prof { display: grid; justify-items: center; gap: 4px; text-align: center; }
.ib-name { text-align: center; font-weight: 600; font-size: 15px; border-color: transparent; margin: 0; padding: 2px 6px; width: 100%; }
.ib-name:hover, .ib-name:focus { border-color: var(--line); }
.ib-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin: 0; align-items: center; }
.ib-dl dt { color: var(--muted); font-size: 12px; } .ib-dl dd { margin: 0; min-width: 0; }
.ib-dl input, .ib-dl select { margin: 0; font-size: 13px; padding: 4px 8px; width: 100%; }
.ib-dl code { font-size: 11px; }
.ib-side-tags div { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.ib-links { font-size: 12px; }
.ib-note-add textarea { margin: 0; width: 100%; font-size: 13px; }
.ib-notes { display: grid; gap: 6px; }
.ib-note { background: #fff8d6; border: 1px solid #f3e4a0; border-radius: 10px; padding: 8px 10px; }
:root[data-theme="dark"] .ib-note { background: #3a3415; border-color: #5a5020; }
/* settings modal */
.ib-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.ib-dialog { background: var(--surface); border-radius: var(--radius); padding: 20px 22px; width: min(820px, 100%); max-height: 90vh; overflow-y: auto; display: grid; gap: 12px; }
.ib-set { display: grid; gap: 16px; }
.ib-set h3 { margin: 0 0 2px; font-size: 15px; }
.ib-set section { display: grid; gap: 6px; }
.ib-set input, .ib-set textarea { margin: 0; font-size: 13px; }
.ib-tagdef .tdName { width: 150px; } .ib-tagdef .ib-tag { min-width: 80px; justify-content: center; }
.ib-swatches { display: flex; gap: 3px; }
.ib-sw { width: 18px; height: 18px; border-radius: 50%; padding: 0; border: 2px solid transparent; box-shadow: none; }
.ib-sw.on { border-color: var(--text); transform: scale(1.15); }
.ib-qr .qrS { width: 120px; } .ib-qr .qrT { flex: 1; }
.ib-back { display: none; }
@media (max-width: 1380px) { .ib { grid-template-columns: 64px 300px minmax(0, 1fr); } .ib-side { display: none; } .ib-sidetoggle { display: inline-flex; } .ib { position: relative; } .ib.side-open .ib-side { display: flex; position: absolute; right: 0; top: 0; bottom: 0; width: 300px; background: var(--surface); box-shadow: -4px 0 16px rgba(15, 23, 42, .12); z-index: 4; } }
@media (max-width: 1000px) { .ib { grid-template-columns: 56px minmax(0, 1fr); } .ib-rail button span { display: none; } .ib-thread { display: none; } .ib.has-thread .ib-list { display: none; } .ib.has-thread .ib-thread { display: flex; } .ib-back { display: inline-flex; } .ib-thead { flex-wrap: wrap; } .ib-msg { max-width: 88%; } }

/* "เพิ่มการเชื่อมต่อ" (shopee.js / tiktok.js) in dark mode: those styles use fixed light colours,
   which left light text on white and 45 %-faded labels on black. */
:root[data-theme="dark"] .cx-overlay { background: rgba(0, 0, 0, .7); }
:root[data-theme="dark"] .cx-modal { background: #0b0d10; border: 1px solid rgba(57, 255, 20, .35); }
:root[data-theme="dark"] .cx-head, :root[data-theme="dark"] .cx-main .cx-title { color: var(--text); border-color: rgba(255, 255, 255, .12); }
:root[data-theme="dark"] .cx-head button { color: #cbd5e1; }
:root[data-theme="dark"] .cx-side { border-color: rgba(255, 255, 255, .12); }
:root[data-theme="dark"] .cx-ch { color: #f1f5f9; }
:root[data-theme="dark"] .cx-ch:hover { background: rgba(255, 255, 255, .06); }
:root[data-theme="dark"] .cx-ch.on { background: rgba(57, 255, 20, .14); color: #fff; outline: 1px solid rgba(57, 255, 20, .5); }
:root[data-theme="dark"] .cx-ch.soon { opacity: 1; color: #94a3b8; }
:root[data-theme="dark"] .cx-ch.soon .ic { opacity: .55; }
:root[data-theme="dark"] .cx-hero h3 { color: #fff; }
:root[data-theme="dark"] .cx-hero p { color: #cbd5e1; }
:root[data-theme="dark"] .cx-btn { background: #161a20; color: #fff; border-color: rgba(255, 255, 255, .25); }
:root[data-theme="dark"] .cx-btn:hover { background: #1f242c; }
:root[data-theme="dark"] .cx-btn:disabled { opacity: 1; color: #94a3b8; background: #12151a; border-style: dashed; }
:root[data-theme="dark"] .cx-link { color: #7dd3fc; }
:root[data-theme="dark"] .cx-setup { background: #12151a; border-color: rgba(255, 255, 255, .15); color: var(--text); }
:root[data-theme="dark"] .cx-shop { border-color: rgba(255, 255, 255, .15); }
:root[data-theme="dark"] .cx-shop .meta small, :root[data-theme="dark"] .sp-conv small { color: #94a3b8; }
:root[data-theme="dark"] .sp-card .stats span { background: #161a20; color: #e2e8f0; }
:root[data-theme="dark"] .sp-convs, :root[data-theme="dark"] .sp-reply { border-color: rgba(255, 255, 255, .12); }
:root[data-theme="dark"] .sp-conv { border-color: rgba(255, 255, 255, .06); }
:root[data-theme="dark"] .sp-conv:hover, :root[data-theme="dark"] .sp-conv.on { background: #161a20; }
:root[data-theme="dark"] .sp-msgs { background: #0b0d10; }
:root[data-theme="dark"] .sp-msg { background: #161a20; border-color: rgba(255, 255, 255, .12); color: #f1f5f9; }
:root[data-theme="dark"] .sp-msg.mine { background: #3a1d14; border-color: #7c2d12; }
:root[data-theme="dark"] .sp-table th, :root[data-theme="dark"] .sp-table td { border-color: rgba(255, 255, 255, .08); }
:root[data-theme="dark"] .sp-err { color: #fca5a5; }

/* ---------- batch 6 ---------- */
/* 26. the "ทำงานกับฉัน" button never covers the save bar's buttons */
.bot-savebar { padding-right: 200px; }
@media (max-width: 760px) { .bot-savebar { padding-right: 14px; bottom: 72px; } }
/* 33. comment-bot warning box readable on black */
:root[data-theme="dark"] .bot-warn, :root[data-theme="dark"] .card.bot-warn { background: #1d1a10; border-color: #6b5f35; color: #f3e3a6; box-shadow: none; }
/* 34. phone: the menu scrolls sideways — a fade + arrow at the right edge says there is more */
@media (max-width: 760px) {
  nav { padding-right: 26px; }
  .side::after { content: '›'; position: sticky; right: 0; flex: none; align-self: stretch; width: 30px; margin-left: -30px; display: grid; place-items: center; font-size: 22px; font-weight: 700; color: var(--muted); pointer-events: none; background: linear-gradient(to right, rgba(255, 255, 255, 0), var(--surface) 65%); }
  :root[data-theme="dark"] .side::after { background: linear-gradient(to right, rgba(0, 0, 0, 0), #000 65%); color: var(--neon, #39ff14); }
}
/* 28. queue edit form (uses the .bot-modal shell, which already has its dark style) */
.job-edit { width: min(560px, 100%); }
.job-edit label { display: grid; gap: 4px; margin-bottom: 10px; font-weight: 600; }
.job-edit textarea, .job-edit input { width: 100%; margin: 0; font-weight: 400; }
.job-edit .errmsg:empty { display: none; }
.job-edit .row { justify-content: flex-end; gap: 8px; }

/* สถานะระบบ (ตั้งค่า → การเชื่อมต่อ) — theme tokens only, readable in light and dark */
.sys-table { width: 100%; border-collapse: collapse; font-size: 13px; color: var(--text); }
.sys-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 12px 6px 0; white-space: nowrap; vertical-align: top; width: 1%; }
.sys-table td { padding: 6px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.sys-table tr:last-child td { border-bottom: 0; }

/* ---------- รอบ 2 ชุด C (หน้าจอพนักงาน) ---------- */
/* 27. สีสถานะใน shopee.js / tiktok.js ใช้ token ธีม แทน style="color:#…" — อ่านได้ทั้งสว่างและมืด */
.tx-ok { color: var(--ok); }
.tx-bad { color: var(--bad); }
.tx-warn { color: var(--warn); }
.tx-info { color: var(--brand); }
:root { --tk-ink: #111; }
:root[data-theme="dark"] { --tk-ink: #24262d; }
:root[data-theme="dark"] .tx-info { color: #92a0fe; }
:root[data-theme="dark"] .tk-banner { background: #062a28; color: #a7f3eb; }
:root[data-theme="dark"] .tk-tabs, :root[data-theme="dark"] .tk-acc { border-color: rgba(255, 255, 255, .15); }
:root[data-theme="dark"] .tk-tabs button { border-color: transparent; color: #cbd5e1; }
:root[data-theme="dark"] .tk-tabs button.on { color: #fff; border-bottom-color: var(--neon); }
:root[data-theme="dark"] .tk-card .stats span { background: #161a20; color: #e2e8f0; border-color: rgba(255, 255, 255, .08); }
:root[data-theme="dark"] .tk-scopes, :root[data-theme="dark"] .tk-kv code { background: #161a20; color: #e2e8f0; border-color: rgba(255, 255, 255, .1); }
:root[data-theme="dark"] .cx-setup.sp-aff-hl { background: #1c130b; border-color: #7c3a0e; }
:root[data-theme="dark"] .tag.sp-tag { background: #3a1d14; color: #fdba74; }
/* 28. ปุ่มหน้าตาเป็นลิงก์ (แผนผัง "บอทเลือกข้อความยังไง") */
.linklike { border: 0; background: none; padding: 0; height: auto; min-height: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; box-shadow: none; }
.linklike:hover { background: none; }
:root[data-theme="dark"] .linklike { color: #92a0fe; background: none; }
/* I. ปุ่ม "สร้างลิงก์ที่ขาด" ในตารางสินค้า (ปักตะกร้า → Link Affiliate) */
.pd-mklinks { display: block; margin-top: 4px; white-space: nowrap; }
/* L. โพสต์เอง: ถัดไป/ย้อนกลับท้ายขั้น 1–5 */
.step-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
@media (max-width: 760px) {
  /* มือถือ: เมนูย่อยเลื่อนแนวนอน — ชื่อกลุ่มยังแสดงเป็นป้ายคั่นกลุ่ม แทนที่จะหายไป */
  .subnav-group { display: flex; align-items: center; flex: none; white-space: nowrap; margin: 0 0 0 8px; padding: 4px 9px; font-size: 11.5px; }
  .subnav-group:first-child { margin-left: 0; }
  /* ชื่อกลุ่มติดขอบซ้ายตอนเลื่อน: กลุ่มที่เลื่อนมาถึงทับกลุ่มก่อนหน้า จึงเห็นชื่อกลุ่มปัจจุบันเสมอ */
  .subnav-group { position: sticky; left: -8px; z-index: 1; justify-content: center; box-shadow: 8px 0 8px -6px rgba(15, 23, 42, .25); }
  :root[data-theme="dark"] .subnav-group { border-bottom: 0; border: 1px solid rgba(57, 255, 20, .45); border-radius: 8px; background: #000; box-shadow: 8px 0 8px -6px rgba(0, 0, 0, .9); }
  .step-nav button { flex: 1 1 auto; }
  .step-nav { margin-bottom: 72px; } /* ไม่ให้ปุ่มลอย "ทำงานกับฉัน" บังปุ่มถัดไป */
}

/* Meta API: one chip per business portfolio; details open in a popup */
.port-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.port-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line, #e2e8f0); cursor: pointer; font: inherit; }
.port-chip .dot { background: var(--bad, #e5484d); }
.port-chip .dot.fb { background: var(--fb); }
.port-chip:hover { border-color: var(--fb); }
.port-modal .bot-modal-box label { display: block; margin-bottom: 10px; }
/* Portfolio whose token expired: red frame on the chip, red notice in its popup */
.port-chip.expired, :root[data-theme="dark"] .port-chip.expired { border: 2px solid var(--bad, #e5484d); box-shadow: 0 0 0 3px rgba(229, 72, 77, .18); }
.port-chip.expired .dot { background: var(--bad, #e5484d); }
.port-expired { border: 1px solid var(--bad, #e5484d); background: var(--bad-soft, rgba(229, 72, 77, .1)); color: var(--text); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; line-height: 1.6; }

/* Shopee Affiliate / Shop Now tags on page cards */
.tag.shopee { background: #fff0ea; color: #c8401a; }
.tag.shopnow { background: #e8f8ee; color: #15803d; }
.page-card .tags a { text-decoration: none; }
.shop-summary { grid-column: 1 / -1; font-size: 13px; padding: 2px 2px 4px; }
:root[data-theme="dark"] .tag.shopee { background: rgba(238, 77, 45, .18); color: #ff8a65; }
:root[data-theme="dark"] .tag.shopnow { background: rgba(57, 255, 20, .14); color: #7dff66; }

/* ---------- แพลน: calendar like Meta Business Suite (public/plancal.js) ---------- */
#planCal { padding: 14px; margin-bottom: 18px; }
.pc-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pc-bar select { max-width: 190px; }
.pc-seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.pc-seg button { border: 0; background: none; padding: 4px 12px; border-radius: 8px; font: inherit; font-size: 13px; color: var(--text-2); cursor: pointer; }
.pc-seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.pc-title { margin: 0 0 0 6px; font-size: 18px; }
.pc-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 10px 0; font-size: 13px; color: var(--text-2); }
.pc-legend span { display: inline-flex; align-items: center; gap: 5px; }
.pc-k-sched { background: var(--brand); } .pc-k-live { background: var(--ok); } .pc-k-outside { background: var(--muted); } .pc-k-fail { background: var(--bad); }
.pc-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pc-col { border-right: 1px solid var(--line); min-width: 0; }
.pc-col:last-child { border-right: 0; }
.pc-dh { text-align: center; font-size: 12.5px; color: var(--text-2); padding: 6px 4px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.pc-col.today .pc-dh, .pc-dh.today { background: var(--brand); color: #fff; font-weight: 700; }
.pc-col.today .pc-dh .hint { color: #fff; }
.pc-cell { display: flex; flex-direction: column; gap: 8px; padding: 8px 6px; min-height: 120px; }
.pc-col.today .pc-cell, .pc-cell.today { background: color-mix(in srgb, var(--brand) 4%, transparent); }
.pc-empty { color: var(--muted); text-align: center; font-size: 13px; padding-top: 10px; }
.pc-card { border-radius: 8px; padding: 6px; cursor: pointer; border: 1px solid transparent; font-size: 12.5px; min-width: 0; }
.pc-card:hover { border-color: var(--brand); }
.pc-card.sched { background: color-mix(in srgb, var(--brand) 9%, var(--surface)); }
.pc-card.live { background: color-mix(in srgb, var(--ok) 11%, var(--surface)); }
.pc-card.busy { background: var(--warn-soft); }
.pc-card.fail { background: var(--bad-soft); }
.pc-card.outside { background: var(--surface-2); border-color: var(--line); }
.pc-top { display: flex; align-items: center; gap: 5px; min-width: 0; }
.pc-top b { font-size: 12.5px; }
.pc-pf { width: 15px; height: 15px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font: 700 10px/1 Arial, sans-serif; flex: none; }
.pc-pf.fb { background: var(--fb); } .pc-pf.ig { background: var(--ig); }
.pc-page { display: inline-flex; align-items: center; gap: 3px; min-width: 0; color: var(--text-2); font-size: 11.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pc-page img { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.pc-media { position: relative; margin-top: 5px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #111; }
.pc-media img, .pc-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-media.pc-text { background: var(--surface); color: var(--text-2); padding: 6px; font-size: 11.5px; line-height: 1.4; aspect-ratio: auto; max-height: 64px; }
.pc-media.pc-broken { background: var(--line); }
.pc-play { position: absolute; left: 6px; bottom: 4px; color: #fff; font-size: 11px; text-shadow: 0 0 3px #000; }
.pc-st { margin-top: 4px; font-size: 11.5px; color: var(--text-2); }
.pc-card.live .pc-st { color: var(--ok); } .pc-card.fail .pc-st { color: var(--bad); } .pc-card.busy .pc-st { color: var(--warn); }
.pc-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pc-mcell { min-height: 118px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 5px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; min-width: 0; }
.pc-mcell:nth-child(7n) { border-right: 0; }
.pc-mcell.out { opacity: .45; }
.pc-mcell.today { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.pc-mnum { display: flex; justify-content: space-between; font-weight: 700; font-size: 13px; }
.pc-mcell .pc-card { padding: 3px 5px; }
.pc-more { border: 0; background: none; color: var(--brand); font: inherit; font-size: 12px; cursor: pointer; text-align: left; padding: 0 2px; }
.pc-rows { display: grid; grid-template-columns: 150px repeat(var(--cols), minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 75vh; }
.pc-rows > .pc-dh { position: sticky; top: 0; z-index: 1; }
.pc-rh { display: flex; align-items: flex-start; gap: 6px; padding: 6px; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--surface-2); min-width: 0; }
.pc-rh img { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.pc-rh span { overflow: hidden; text-overflow: ellipsis; }
.pc-rows .pc-cell { min-height: 70px; max-height: none; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-2); }
@media (max-width: 900px) { .pc-week, .pc-month { overflow-x: auto; grid-template-columns: repeat(7, minmax(130px, 1fr)); } }
/* The plan calendar uses the full width, like Meta Business Suite. */
main:has(#tab-plan.on) { max-width: none; }

/* 60. Sidebar groups (navgroups.js): 4 main features; the original tabs are sub-items. */
nav { gap: 4px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-head { font-weight: 600; white-space: nowrap; }
.nav-group.active > .nav-head { color: var(--brand); }
.nav-chev { width: 7px; height: 7px; flex: none; margin: 0 4px 0 2px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); opacity: .55; transition: transform .15s; }
.nav-group.open > .nav-head .nav-chev { transform: rotate(45deg); margin-top: -3px; }
.nav-sub { display: none; flex-direction: column; gap: 2px; margin: 0 0 6px 20px; padding-left: 8px; border-left: 1px solid var(--line); }
.nav-group.open > .nav-sub { display: flex; }
.nav-sub button { padding: 7px 10px; font-size: 14px; }
.nav-sub button svg { width: 16px; height: 16px; }
:root[data-theme="dark"] .nav-group.active > .nav-head:not(.alert):not(.warn-state) { color: var(--neon, #39ff14); }
:root[data-theme="dark"] .nav-sub { border-left-color: #2a2a2a; }
@media (max-width: 760px) {
  /* Phone: group headers in the top row, the open group's features in a second row. */
  .side-foot { display: none; } /* rule 1294 (.side-foot display:grid) otherwise shows it on phones */
  .shell { grid-template-rows: auto 1fr; } /* short pages stretched the top menu bar */
  .side { overflow-x: hidden; }
  .side::after { display: none; }
  nav { display: grid; grid-template-columns: repeat(4, max-content); column-gap: 4px; row-gap: 6px; flex: 1 1 0; min-width: 0; overflow-x: auto; padding-right: 0; scrollbar-width: none; }
  .nav-group { display: contents; }
  .nav-head { grid-row: 1; padding: 7px 9px; }
  .nav-chev { display: none; }
  /* width 0 + min-width 100%: the row of features never widens the header columns; it scrolls instead. */
  .nav-sub { grid-row: 2; grid-column: 1 / -1; width: 0; min-width: 100%; flex-direction: row; overflow-x: auto; margin: 0; padding: 0; border-left: 0; scrollbar-width: none; }
  .nav-sub button { flex: none; }
}

/* ---------- วิเคราะห์ผลงาน → DNA ช่อง (public/dna.js) ---------- */
:root { --dna-a: #2a78d6; --dna-b: #eb6834; }
:root[data-theme="dark"] { --dna-a: #3987e5; --dna-b: #d95926; }
#tab-analytics:has(.sv[data-sv="dna"].on) #anKpis,
#tab-analytics:has(.sv[data-sv="dna"].on) #anPf,
#tab-analytics:has(.sv[data-sv="dna"].on) #anSrc,
#tab-analytics:has(.sv[data-sv="dna"].on) #anMetric,
#tab-analytics:has(.sv[data-sv="dna"].on) .gl-pair { display: none; }
.dna-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.dna-card { display: grid; gap: 14px; }
.dna-who { display: flex; gap: 12px; align-items: center; }
.dna-who img { width: 48px; height: 48px; border-radius: 50%; flex: none; }
.dna-line1 { font-size: 20px; font-weight: 700; line-height: 1.35; }
.dna-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.dna-stat { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.dna-stat .lbl { font-size: 12.5px; color: var(--text-2); }
.dna-stat .num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dna-legend { margin-bottom: 8px; }
.sw.dna-a, .dna-track .dna-a { background: var(--dna-a); }
.sw.dna-b, .dna-track .dna-b { background: var(--dna-b); }
.dna-ages { display: grid; gap: 8px; }
.dna-age { display: grid; grid-template-columns: 50px 1fr 44px; gap: 10px; align-items: center; font-size: 14px; }
.dna-age-l { color: var(--text-2); font-variant-numeric: tabular-nums; }
.dna-age b { text-align: right; font-variant-numeric: tabular-nums; }
.dna-pair { display: grid; gap: 2px; }
.dna-track { height: 9px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.dna-track span { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.dna-hrow { grid-template-columns: minmax(110px, 190px) 1fr 56px 0; }
.dna-ret { width: 100%; height: auto; display: block; }
.dna-grid { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 3 3; }
.dna-axis { fill: var(--muted); font-size: 11px; stroke: none; }
.dna-lbl { fill: var(--text); font-size: 12px; font-weight: 600; stroke: none; }
.dna-line { fill: none; stroke-width: 2; }
.dna-line.dna-a { stroke: var(--dna-a); } .dna-line.dna-b { stroke: var(--dna-b); stroke-dasharray: 5 4; }
.dna-dot { fill: var(--dna-a); stroke: var(--surface); stroke-width: 2; }
.dna-tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.dna-tag.up { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.dna-tag.down { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.dna-table td { vertical-align: middle; }
.dna-row { cursor: pointer; } .dna-row:hover { background: var(--surface-2); }
.dna-clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dna-target { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.dna-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
#dnaRoot .an-insights li { margin-bottom: 6px; }
.dna-ret rect { stroke: none; }
.dna-ret { max-height: 260px; }

/* ---------- simpler UI (public/simple-ui.js) ---------- */
body:not(.ui-adv) #settingsNav [data-sv-go="rules"], body:not(.ui-adv) #settingsNav [data-sv-go="guard"], body:not(.ui-adv) #settingsNav [data-sv-go="prompts"],
body:not(.ui-adv) #settingsNav [data-sv-go="pagerules"], body:not(.ui-adv) #settingsNav [data-sv-go="ruleshist"] { display: none; }
.adv-toggle { margin-top: 10px; width: 100%; text-align: left; white-space: normal; }
#tab-post.onepage .sv[data-sv="s1"], #tab-post.onepage .sv[data-sv="s2"], #tab-post.onepage .sv[data-sv="s3"], #tab-post.onepage .sv[data-sv="s4"], #tab-post.onepage .sv[data-sv="s5"] { display: block; margin-bottom: 18px; }
#tab-post.onepage .step-nav { display: none; }
#postNav [data-sv-go="s2"], #postNav [data-sv-go="s3"], #postNav [data-sv-go="s4"], #postNav [data-sv-go="s5"] { display: none; }
.start-card { border-color: var(--brand); }
.start-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.start-steps li { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.start-steps li.next { border-color: var(--brand); background: var(--brand-soft); }
.start-steps li.ok { opacity: .7; }
.start-n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.start-steps li.ok .start-n { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.queue-quick { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 12px; }
.queue-quick select { max-width: 260px; }
.meta-wait { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.nav-wait { font-size: 10.5px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); vertical-align: middle; }

/* ---------- งานวันนี้: quiet one-line bar (public/todo-compact.js) ---------- */
.todo-bar { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 12px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; box-shadow: none; }
.todo-bar:hover { border-color: var(--muted); }
.todo-bar b { flex: none; font-weight: 600; }
.todo-bar-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ok); }
.todo-bar.warn .todo-bar-dot { background: var(--warn); } .todo-bar.bad .todo-bar-dot { background: var(--bad); }
.todo-bar-list { flex: 1; min-width: 0; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-bar-toggle { flex: none; color: var(--muted); font-size: 13px; }
.todo-bar.open { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
#todoCard.todo-collapsed { display: none; }
#todoCard { padding: 4px 14px; margin-top: 0; border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; box-shadow: none; }
#todoCard .card-head, #todoCard .todo-ok { display: none; }
#todoCard .todo-row { background: none; border: 0; border-top: 1px solid var(--line-2); border-radius: 0; box-shadow: none; padding: 7px 0; margin: 0; gap: 10px; flex-wrap: nowrap; }
#todoCard .todo-row:first-of-type { border-top: 0; }
#todoCard .todo-row .grow { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
#todoCard .todo-row b { flex: none; font-size: 14px; font-weight: 600; color: var(--text); }
#todoCard .todo-row .hint { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
#todoCard .todo-dot { width: 8px; height: 8px; }
#todoCard .todo-row button { padding: 3px 10px; font-size: 12.5px; background: none; color: var(--brand); border: 1px solid var(--line); box-shadow: none; flex: none; }
#todoCard .todo-row button:hover { border-color: var(--brand); }
@media (max-width: 700px) { #todoCard .todo-row .grow { display: block; } #todoCard .todo-row .hint { white-space: normal; } }

/* แพลน: day view + quieter queue buttons (12 Nov) */
.pc-day { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.job .acts { gap: 4px; max-width: 200px; }
.job .acts button, .job .acts button.small, .job .acts button.danger { padding: 2px 8px; font-size: 12px; font-weight: 500; line-height: 1.5; border-radius: 6px; background: none; background-image: none; color: var(--text-2); border: 1px solid var(--line); box-shadow: none; min-height: 0; }
.job .acts button:hover { color: var(--text); border-color: var(--muted); }
.job .acts button.danger { color: var(--bad); }
.job .acts button.danger:hover { border-color: var(--bad); }

/* ---------- คิวโพสต์: easier to scan (12 Nov) ---------- */
/* Day summary: one thin strip that scrolls sideways instead of two rows of big cards. */
#tab-queue .qsum-days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
#tab-queue .qday, :root[data-theme="dark"] #tab-queue .qday { flex: none; min-width: 128px; padding: 7px 10px; gap: 2px; border-radius: 10px; background: var(--surface); background-image: none; box-shadow: none; }
#tab-queue .qday-n { font-size: 18px; }
#tab-queue .qday-date { font-size: 12px; }
#tab-queue .qday-via { display: none; }
#tab-queue .qday-pf .tag { font-size: 11px; padding: 0 6px; }
#tab-queue .qday.on, :root[data-theme="dark"] #tab-queue .qday.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
/* The list: no glowing frame, tighter rows, text cut to a few lines (click a caption to read it all). */
#tab-queue .card:has(> #queueList), :root[data-theme="dark"] #tab-queue .card:has(> #queueList) { box-shadow: none; border: 1px solid var(--line); }
#tab-queue .job { grid-template-columns: 128px minmax(0, 1fr) auto; gap: 12px; padding: 9px 14px; }
#tab-queue .job .when b { font-size: 13px; }
#tab-queue .job .when .tag, #tab-queue .job .when .st { font-size: 11px; padding: 0 7px; margin-top: 3px; }
#tab-queue .job .via { font-size: 11px; line-height: 1.35; margin-top: 3px; }
#tab-queue .job-head { font-size: 14px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tab-queue .job .cap { max-height: none; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; cursor: pointer; }
#tab-queue .job .cap.full { -webkit-line-clamp: unset; white-space: pre-wrap; }
#tab-queue .job .cmt { margin-top: 3px; font-size: 12.5px; color: var(--muted); }
#tab-queue .job .cmt .grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#tab-queue .job .acts { flex-wrap: nowrap; max-width: none; opacity: .55; }
#tab-queue .job:hover .acts, #tab-queue .job:focus-within .acts { opacity: 1; }
@media (max-width: 900px) { #tab-queue .job { grid-template-columns: 1fr; } #tab-queue .job .acts { opacity: 1; flex-wrap: wrap; } }

/* ---------- วิเคราะห์ผลงาน KPI: two rows — big main numbers, small supporting ones (12 Nov) ---------- */
#anKpis { grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 10px; }
#anKpis .stat { grid-column: span 5; min-width: 0; }
#anKpis .stat:nth-child(-n+4) .num { font-size: 30px; }
#anKpis .stat:nth-child(n+5) { grid-column: span 4; padding: 8px 10px; gap: 8px; box-shadow: none; }
#anKpis .stat:nth-child(n+5) .ico { width: 26px; height: 26px; border-radius: 8px; }
#anKpis .stat:nth-child(n+5) .ico svg { width: 14px; height: 14px; }
#anKpis .stat:nth-child(n+5) .lbl { font-size: 12px; }
#anKpis .stat:nth-child(n+5) .num { font-size: 18px; line-height: 1.2; }
#anKpis .stat:nth-child(n+5) .sub { font-size: 11.5px; line-height: 1.35; }
#anKpis .stat:nth-child(n+5) .sub .hint { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1000px) { #anKpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } #anKpis .stat, #anKpis .stat:nth-child(n+5) { grid-column: auto; } }

/* ---------- วิเคราะห์ผลงาน: filters on one line (12 Nov) ---------- */
#tab-analytics .an-filters { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; }
#tab-analytics .an-filters > * { flex: 0 1 auto; min-width: 0; margin: 0; }
#tab-analytics .an-filters .rpick-btn { padding: 5px 10px; font-size: 13px; min-height: 0; white-space: nowrap; }
#tab-analytics .an-filters select { padding: 5px 8px; font-size: 13px; max-width: 190px; min-height: 0; height: auto; }
#tab-analytics .an-filters .seg { padding: 2px; flex-wrap: nowrap; white-space: nowrap; }
#tab-analytics .an-filters .seg label span { padding: 3px 9px; font-size: 12.5px; }
#tab-analytics .an-filters .gl-pair { flex: none; }
@media (max-width: 1100px) { #tab-analytics .an-filters { flex-wrap: wrap; } }
#tab-analytics .an-filters .rpick-btn { height: 34px; padding-top: 0; padding-bottom: 0; }
#tab-analytics .an-filters .rpick-btn .ico { width: auto; height: auto; }

/* ---------- วิเคราะห์ผลงาน → เวลาและประเภทคอนเทนต์ timing page: stacked, full width (12 Nov) ---------- */
#tab-analytics .sv[data-sv="timing"] .an-grid { grid-template-columns: 1fr; }
#tab-analytics .sv[data-sv="timing"] .an-heat .an-cell { min-height: 26px; }
#tab-analytics .sv[data-sv="timing"] #anTypes { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 4px 32px; align-items: start; }
#tab-analytics .sv[data-sv="timing"] #anTypes .an-group + .an-group { margin-top: 0; } /* timing .an-group + .an-group */
#tab-analytics .sv[data-sv="timing"] #anTypes .an-group { margin-bottom: 14px; }

/* โพสต์เด่น: text posts and page-picture fallbacks (12 Nov) */
.an-thumb-text { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1px dashed var(--line); }
.an-thumb-text span { font-size: 10.5px; color: var(--text-2); line-height: 1; }
.an-thumb-text .ix { font-size: 18px; }
.an-thumb-page { border-radius: 50%; opacity: .85; }

/* ---------- วิเคราะห์ผลงาน KPI v2: 4 plain hero numbers + one quiet line of supporting numbers (12 Nov) ---------- */
#anKpis { gap: 10px 12px; margin-bottom: 18px; }
#anKpis .stat, :root[data-theme="dark"] #anKpis .stat.an-kpi { background: var(--surface); background-image: none; box-shadow: none; border: 1px solid var(--line); border-radius: 12px; }
#anKpis .stat .ico { display: none; }
#anKpis .stat .lbl { font-size: 13px; color: var(--text-2); }
#anKpis .stat .num, :root[data-theme="dark"] #anKpis .stat .num { color: var(--text); }
#anKpis .stat:nth-child(-n+4) { padding: 14px 18px; border-left: 4px solid var(--brand); }
#anKpis .stat:nth-child(-n+4) .num { font-size: 36px; line-height: 1.1; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
#anKpis .stat:nth-child(-n+4) .sub { font-size: 12.5px; color: var(--text-2); }
#anKpis .an-delta { font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); }
#anKpis .an-delta.up { background: var(--ok-soft); color: var(--ok); }
#anKpis .an-delta.down { background: var(--bad-soft); color: var(--bad); }
/* Supporting numbers: no boxes, one line each — label, number, change. Details stay in the table below. */
#anKpis .stat:nth-child(n+5), :root[data-theme="dark"] #anKpis .stat.an-kpi:nth-child(n+5) { border: 0; border-left: 1px solid var(--line); border-radius: 0; background: none; padding: 0 0 0 14px; }
#anKpis .stat:nth-child(5), :root[data-theme="dark"] #anKpis .stat.an-kpi:nth-child(5) { border-left: 0; padding-left: 4px; }
#anKpis .stat:nth-child(n+5) > div:last-child { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
#anKpis .stat:nth-child(n+5) .lbl { font-size: 12.5px; color: var(--muted); }
#anKpis .stat:nth-child(n+5) .num { font-size: 18px; font-weight: 700; }
#anKpis .stat:nth-child(n+5) .sub { font-size: 11.5px; }
#anKpis .stat:nth-child(n+5) .sub .hint { display: none; }
#anKpis .stat:nth-child(n+5) .an-delta { font-size: 11px; padding: 0 6px; }
