:root{
  --font-ui:'Bai Jamjuree',sans-serif;
  --font-mono:'IBM Plex Mono',monospace;
  /* legacy aliases (app.js / inline styles reference these) */
  --font-display:'Bai Jamjuree',sans-serif;
  --font-serif:'Bai Jamjuree',sans-serif;
  --font-body:'Bai Jamjuree',sans-serif;

  --page:#F4F6F6;
  --surface:#ffffff;
  --surface-2:#F8FAFA;
  --teal:#3F8F86;
  --teal-dark:#2E6E66;
  --teal-tint:#E6F1EF;
  --teal-tint-2:#D4E7E3;

  --text:#1A1A1A;
  --text-soft:#3f4a48;
  --muted:#6B6F76;
  --faint:#A0A4AB;

  --border:#EDF0F0;
  --border-2:#E9ECEC;
  --border-3:#F0F2F2;
  --border-line:#E6EAEA;

  --pos-text:#256B63;
  --pos-bg:#E6F1EF;
  --neg:#C9605A;

  /* compat tokens still referenced by app.js inline styles */
  --text-primary:#1A1A1A;
  --text-secondary:#6B6F76;
  --text-faint:#A0A4AB;
  --accent:#3F8F86;

  --radius-card:16px;
  --radius-sm:12px;
  --radius-pill:10px;
  --t:0.32s cubic-bezier(0.16,1,0.3,1);

  /* accent palette for bars / pillars */
  --c1:#3F8F86; --c2:#5AA89F; --c3:#7FBDB5; --c4:#9CCEC8; --c5:#C3E0DC;
  --c6:#D98E73; --c7:#E0B36A; --c8:#8B86C4; --c9:#6E7CA8;
}
*{margin:0;padding:0;box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  font-family:var(--font-ui);
  background:var(--page);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  overflow:hidden;
}
::selection{background:var(--teal-tint);color:var(--teal-dark)}
::-webkit-scrollbar{width:9px;height:9px}
::-webkit-scrollbar-thumb{background:#D7DDDC;border-radius:8px}
::-webkit-scrollbar-thumb:hover{background:#B9C2C1}

/* ===== App shell ===== */
.app{display:grid;grid-template-columns:230px 1fr;height:100vh}

/* ===== Login overlay ===== */
.login-overlay{position:fixed;inset:0;z-index:100;display:grid;place-items:center;
  background:radial-gradient(circle at 30% 20%,rgba(63,143,134,0.08),transparent 60%),var(--page)}
.login-card{width:340px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-card);
  padding:38px 34px;display:flex;flex-direction:column;gap:12px;box-shadow:0 18px 48px rgba(40,80,74,0.10)}
.login-brand{display:flex;align-items:center;gap:11px;margin-bottom:2px}
.login-brand .mark{width:32px;height:32px;border-radius:10px;background:var(--teal);
  display:grid;place-items:center;flex-shrink:0}
.login-brand .mark svg{width:16px;height:16px}
.login-brand .name{font-weight:600;font-size:17px;letter-spacing:0.03em}
.login-brand .name span{color:var(--teal)}
.login-sub{color:var(--muted);font-size:12.5px;margin-bottom:14px}
.login-card input{background:var(--surface);border:1px solid var(--border-2);border-radius:var(--radius-pill);
  padding:12px 14px;color:var(--text);font-family:var(--font-ui);font-size:14px;outline:none;transition:border var(--t)}
.login-card input:focus{border-color:var(--teal)}
.login-btn{margin-top:6px;width:100%;justify-content:center}
.login-err{color:var(--neg);font-size:12.5px;min-height:16px;text-align:center}

/* ===== Sidebar ===== */
.sidebar{
  background:var(--surface);
  border-right:1px solid var(--border-2);
  display:flex;flex-direction:column;
  padding:24px 16px;
}
.brand{display:flex;align-items:center;gap:10px;padding:4px 8px 28px}
.brand .mark{
  width:32px;height:32px;border-radius:10px;background:var(--teal);
  display:grid;place-items:center;flex-shrink:0;
}
.brand .mark svg{width:16px;height:16px}
.brand .name{font-weight:600;font-size:16px;letter-spacing:0.03em}
.brand .name span{color:var(--teal)}
.nav-label{font-size:10px;letter-spacing:0.16em;text-transform:uppercase;color:var(--faint);padding:8px 10px;font-weight:600}
.nav-label:not(:first-of-type){padding-top:18px}
.nav-item{
  display:flex;align-items:center;gap:11px;
  padding:11px 14px;margin:1px 0;border-radius:12px;
  color:var(--text-soft);cursor:pointer;
  font-size:14px;font-weight:500;
  transition:background var(--t),color var(--t);
  position:relative;
}
.nav-item svg{width:18px;height:18px;flex-shrink:0}
.nav-item:hover{background:var(--surface-2);color:var(--text)}
.nav-item.active{background:var(--teal-tint);color:var(--teal-dark)}
.nav-item.active svg{color:var(--teal)}
.nav-item .badge{margin-left:auto;font-family:var(--font-mono);font-size:11px;background:var(--teal-tint);color:var(--teal);
  padding:1px 8px;border-radius:20px;font-weight:600}
.nav-item .badge:empty{display:none}
.sidebar-footer{margin-top:auto;border-top:1px solid var(--border-2);padding-top:14px}
.user{display:flex;align-items:center;gap:10px;padding:6px 8px;border-radius:12px}
.avatar{width:34px;height:34px;border-radius:50%;background:var(--teal);
  display:grid;place-items:center;font-size:13px;font-weight:600;color:#fff}
.user .meta{line-height:1.2}
.user .meta b{font-size:13px;font-weight:600;display:block}
.user .meta small{font-size:11px;color:var(--faint)}
.logout-btn{width:100%;margin-top:12px;justify-content:center;font-size:12.5px;padding:9px}

/* ===== Main ===== */
.main{display:flex;flex-direction:column;height:100vh;overflow:hidden;position:relative}
.topbar{
  flex:none;z-index:20;
  display:flex;align-items:flex-end;justify-content:space-between;gap:18px;
  padding:22px 32px 18px;
  background:rgba(244,246,246,0.9);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border-line);
}
.tb-left{display:flex;flex-direction:column;gap:0;min-width:0}
.tb-eyebrow{font-family:var(--font-mono);font-size:11px;letter-spacing:0.14em;text-transform:uppercase;color:#8A9794;margin-bottom:6px}
.topbar h1{font-size:27px;font-weight:600;letter-spacing:-0.01em;line-height:1.1}
.topbar .sub{color:var(--muted);font-size:12.5px;margin-top:3px}
.tb-actions{display:flex;gap:10px;flex:none;padding-bottom:4px}

.view{display:none;padding:14px 28px 28px;max-width:1320px;position:relative;flex:1;min-height:0;overflow-y:auto;width:100%}
.view.active{display:block}

/* ===== Buttons ===== */
.btn{font-family:var(--font-ui);font-size:13px;font-weight:500;
  padding:9px 15px;border-radius:11px;cursor:pointer;border:1px solid var(--border-2);
  background:var(--surface);color:var(--text-soft);transition:all var(--t);display:inline-flex;align-items:center;gap:7px}
.btn:hover{border-color:#D2DAD8;background:var(--surface-2)}
.btn.primary{background:var(--teal);border-color:var(--teal);color:#fff;font-weight:600}
.btn.primary:hover{background:var(--teal-dark);border-color:var(--teal-dark)}
.btn:disabled{opacity:0.55;cursor:default}

/* ===== Cards / panels ===== */
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-card);padding:14px 18px}
.card-h{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:11px}
.card-h h3{font-size:16px;font-weight:600}
.card-sub{font-size:12px;color:var(--faint);margin-top:2px}
.card-tag{font-family:var(--font-mono);font-size:11px;color:var(--faint)}
.empty{text-align:center;color:var(--faint);font-size:13px;padding:30px}
.posts-empty{text-align:center;color:var(--faint);font-size:13px;padding:30px}

/* legacy panel alias (used by detail markup) */
.panel{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-card);padding:14px 18px}
.panel-h{display:flex;align-items:center;justify-content:space-between;margin-bottom:11px;flex:none}
.panel-h h3{font-size:15px;font-weight:600}
.panel-h .hint{font-size:10.5px;color:var(--faint);letter-spacing:0.12em;text-transform:uppercase}
.panel-scroll{flex:1;min-height:0;overflow-y:auto}

/* reveal */
.reveal{opacity:0;transform:translateY(14px);transition:opacity 0.6s cubic-bezier(0.16,1,0.3,1),transform 0.6s cubic-bezier(0.16,1,0.3,1)}
.reveal.visible{opacity:1;transform:none}
@media (prefers-reduced-motion:reduce){.reveal{opacity:1;transform:none}}

/* ============================================================
   OVERVIEW
   ============================================================ */
#view-overview{display:none}
#view-overview.active{display:flex;flex-direction:column;gap:14px}
.ov-kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;flex:none}
.kpi{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:12px 16px}
.kpi-head{display:flex;align-items:center;gap:10px;margin-bottom:9px}
.kpi-ic{width:32px;height:32px;border-radius:10px;display:grid;place-items:center;flex-shrink:0}
.kpi-ic svg{width:18px;height:18px}
.kpi-ic.teal{background:var(--teal-tint);color:var(--teal)}
.kpi-ic.coral{background:#FBEEE6;color:#D98E73}
.kpi-ic.gold{background:#F7EEDC;color:#C99A5B}
.kpi-ic.violet{background:#ECEAF6;color:#8B86C4}
.kpi-label{font-size:12.5px;color:var(--muted)}
.kpi-num{font-family:var(--font-mono);font-size:23px;font-weight:600;line-height:1}
.kpi-num small{font-size:18px;color:#9AA0A0}
.kpi-foot{font-size:11.5px;color:var(--faint);margin-top:8px;font-weight:500}

.ov-grid{flex:1;min-height:0;display:grid;grid-template-columns:1.5fr 1fr;gap:18px}
.ov-grid .card{display:flex;flex-direction:column;min-height:0}
.ov-leaders-body{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:9px}
.ov-media-body{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px}

.lb-row{display:grid;grid-template-columns:24px 38px 1fr 70px;align-items:center;gap:12px;
  padding:8px;margin:0 -8px;border-radius:10px;cursor:pointer;transition:background var(--t)}
.lb-row:hover{background:var(--surface-2)}
.lb-rank{font-family:var(--font-mono);font-size:13px;font-weight:600;color:var(--faint);text-align:center}
.lb-row:first-child .lb-rank{color:var(--teal)}
.lb-logo{width:38px;height:38px;border-radius:50%;background:var(--teal-tint);color:var(--teal-dark);
  display:grid;place-items:center;font-weight:600;font-size:13px;letter-spacing:0.02em}
.lb-row>div:nth-child(3){min-width:0}
.lb-name{font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lb-sub{font-size:11.5px;color:var(--faint);margin-top:2px}
.lb-bar{height:6px;background:var(--border-3);border-radius:4px;margin-top:7px;overflow:hidden}
.lb-bar span{display:block;height:100%;width:0;background:var(--teal);border-radius:4px;
  transition:width 1s cubic-bezier(0.16,1,0.3,1)}
.lb-val{font-family:var(--font-mono);font-size:13px;font-weight:600;text-align:right}
.lb-val small{color:var(--faint);font-weight:400}

/* media breakdown bars (#ov-media built by app.js) */
.ov-bar{display:flex;flex-direction:column}
.ov-bar-top{display:flex;justify-content:space-between;align-items:baseline;font-size:13px;margin-bottom:5px}
.ov-bar-top .nm{font-weight:500}
.ov-bar-top .val{font-family:var(--font-mono);color:var(--muted)}
.ov-bar-track{height:8px;background:var(--border-3);border-radius:5px;overflow:hidden}
.ov-bar-track span{display:block;height:100%;width:0;border-radius:5px;transition:width 1s cubic-bezier(0.16,1,0.3,1)}

/* ===== "เร็วๆ นี้" placeholders ===== */
.soon-card{display:flex;flex-direction:column;align-items:center;text-align:center;
  padding:64px 32px;max-width:560px;margin:24px auto}
.soon-ic{width:60px;height:60px;border-radius:18px;background:var(--teal-tint);color:var(--teal);
  display:grid;place-items:center;margin-bottom:18px}
.soon-ic svg{width:30px;height:30px}
.soon-card h3{font-size:20px;font-weight:600;margin-bottom:8px}
.soon-card p{color:var(--muted);font-size:14px}

.mono{font-family:var(--font-mono)}

/* shared bits still used elsewhere */
.tag{font-family:var(--font-mono);font-size:11px;padding:3px 10px;border-radius:8px;background:var(--surface-2);
  border:1px solid var(--border);color:var(--muted)}
.pav{width:24px;height:24px;border-radius:50%;background:var(--teal-tint);
  display:grid;place-items:center;font-size:11px;font-weight:600;color:var(--teal-dark);flex-shrink:0}
.fb-label{font-size:11px;color:var(--faint);text-transform:uppercase;letter-spacing:0.1em;font-weight:600}
.fb-note{font-size:12px;color:var(--muted)}
.fd{font-size:11.5px;font-weight:600}
.fd.up{color:var(--pos-text)}.fd.down{color:var(--neg)}

/* ============================================================
   FOLLOWERS — LINE OA friends analytics
   ============================================================ */
#view-followers{display:none}
#view-followers.active{display:flex;flex-direction:column;gap:14px}

.brand-add-form{display:flex;gap:10px;flex-wrap:wrap;flex:none;margin-bottom:14px}
.brand-add-form input{font-family:var(--font-ui);font-size:13px;background:var(--surface);
  color:var(--text);border:1px solid var(--border);border-radius:9px;padding:8px 12px}
.brand-add-form input:focus{border-color:var(--teal)}

/* KPI row */
.fo-kpis{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;flex:none}
.fo-kpi{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:12px 16px}
.fo-kpi-l{font-size:12.5px;color:var(--muted);margin-bottom:10px}
.fo-kpi-v{font-size:22px;font-weight:600;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.fo-kpi-v.mono{font-family:var(--font-mono);font-size:21px}
.fo-kpi-s{font-size:11.5px;color:var(--faint);margin-top:8px;font-weight:500}
.fo-kpi-s.teal{color:var(--teal-dark)}

/* trend card + legend */
.fo-trend-card{flex:none}
.fo-trend-card>.card-h{flex-wrap:wrap;gap:12px}
.fo-legend{display:flex;gap:14px;flex-wrap:wrap;font-size:12px;color:var(--muted)}
.fo-legend span{display:inline-flex;align-items:center;gap:6px}
.fo-legend .ln{width:12px;height:3px;border-radius:2px;display:inline-block}
/* Chart.js sizes to the canvas's parent and requires the canvas to be that
   parent's only child, so the plot gets its own fixed-height box and any note
   sits outside it. */
.fo-trend{position:relative}
.fo-trend-box{position:relative;height:236px}
.fo-trend-box canvas{display:block}
.fo-trend-cap{font-size:11px;color:var(--muted);padding-top:8px}
.fo-xaxis{display:flex;justify-content:space-between;font-family:var(--font-mono);font-size:10px;
  color:var(--faint);margin-top:4px;padding-left:46px}
.fo-trend-note{display:flex;align-items:center;justify-content:center;text-align:center;
  min-height:150px;color:var(--faint);font-size:13px;line-height:1.5;
  border:1px dashed var(--border-2);border-radius:12px;padding:20px}

/* per-brand table */
.fo-table-card{flex:1;min-height:0;display:flex;flex-direction:column;padding:0}
.fo-table-card>.card-h{padding:18px 22px 12px;margin-bottom:0}
.fo-table{flex:1;min-height:0;overflow-y:auto}
.fo-table>.empty{padding:30px}
.fo-tr{display:grid;grid-template-columns:minmax(0,1.4fr) 92px 68px 84px 64px 110px 92px;gap:10px;align-items:center;
  padding:9px 22px;border-bottom:1px solid var(--border-3);font-size:13px}
.fo-thead{background:var(--surface-2);font-family:var(--font-mono);font-size:10px;letter-spacing:0.04em;
  text-transform:uppercase;color:var(--faint);border-top:1px solid var(--border-3);position:sticky;top:0;z-index:1}
.fo-tr .ar{text-align:right}
.fo-tr b{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.fo-dim{font-size:12px;color:var(--muted)}
.fo-fval{font-weight:600}
.fo-rm-chg{font-family:var(--font-mono);font-weight:600;color:var(--teal-dark)}
.fo-mom{text-align:right;font-size:11.5px;font-weight:600;color:var(--teal-dark);
  background:var(--teal-tint);border-radius:6px;padding:3px 7px;justify-self:end}
.fo-mom.muted{color:var(--faint);background:var(--border-3)}

/* ============================================================
   PUSH MESSAGE — OA broadcast analytics
   ============================================================ */
#view-push{display:none}
#view-push.active{display:flex;flex-direction:column;gap:14px}

/* KPI row */
.pu-kpis{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;flex:none}
.pu-kpi{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:12px 16px}
.pu-kpi-l{font-size:12.5px;color:var(--muted);margin-bottom:10px}
.pu-kpi-v{font-size:22px;font-weight:600;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pu-kpi-v.mono{font-family:var(--font-mono);font-size:21px}
.pu-kpi-s{font-size:11.5px;color:var(--faint);margin-top:8px;font-weight:500}
.pu-kpi-s.teal{color:var(--teal-dark)}

/* bars + pillar grid */
.pu-grid{flex:none;display:grid;grid-template-columns:1fr 1fr;gap:18px}
.pu-grid .card{display:flex;flex-direction:column;min-height:0}
.pu-bars-body{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:9px}
.pu-bar{display:flex;align-items:center;gap:12px}
.pu-bar-nm{font-size:13.5px;font-weight:500;width:150px;flex-shrink:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pu-bar-track{flex:1;height:9px;background:var(--border-3);border-radius:5px;overflow:hidden}
.pu-bar-track span{display:block;height:100%;width:0;border-radius:5px;transition:width 1s cubic-bezier(0.16,1,0.3,1)}
.pu-bar-val{font-family:var(--font-mono);font-size:13px;width:46px;text-align:right;flex-shrink:0}
.pu-pillar-body{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px}

/* legend (top-right of heatmap card) */
.pu-legend{display:flex;align-items:center;gap:6px;font-size:10.5px;color:var(--faint)}
.pu-legend .sw{width:11px;height:11px;border-radius:3px;display:inline-block}

/* send-time heatmap */
.pu-heat-card{flex:none}
.pu-heat{display:flex;flex-direction:column;gap:6px}
.pu-heat-row{display:grid;gap:5px;align-items:center}
.pu-heat-head .pu-h-lbl{font-family:var(--font-mono);font-size:9.5px;color:var(--faint);text-align:center}
.pu-d-lbl{font-size:11px;color:var(--muted)}
.pu-cell{height:16px;border-radius:4px;transition:background var(--t)}
.pu-cell:hover{outline:2px solid var(--teal);outline-offset:-1px}

/* ============================================================
   CHAT
   ============================================================ */
#view-chat{display:none}
#view-chat.active{display:flex;flex-direction:column}
.chat-note{display:flex;align-items:center;gap:10px;padding:13px 18px;margin-bottom:14px;border-radius:12px;
  background:var(--teal-tint);border:1px solid var(--teal-tint-2);font-size:13px;color:var(--teal-dark);flex:none}
.chat-note svg{width:17px;height:17px;color:var(--teal);flex-shrink:0}
.chat-toolbar{display:flex;align-items:center;gap:10px;margin-bottom:14px;flex:none}
.chat-grid{flex:1;min-height:0;display:grid;grid-template-columns:300px 1fr;gap:18px}
.chat-list{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-card);padding:10px;overflow-y:auto}
.chat-it{display:flex;gap:12px;padding:11px;border-radius:10px;cursor:pointer;transition:background var(--t)}
.chat-it:hover{background:var(--surface-2)}
.chat-it.on{background:var(--teal-tint)}
.chat-it .av{width:40px;height:40px;border-radius:50%;background:var(--teal-tint);
  display:grid;place-items:center;font-size:15px;flex-shrink:0}
.chat-it .tx{flex:1;min-width:0}
.chat-it .tx b{font-size:13.5px;font-weight:600;display:flex;justify-content:space-between;gap:8px}
.chat-it .tx b .nm{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-it .tx b small{font-weight:400;color:var(--faint);font-size:11px;flex-shrink:0;font-family:var(--font-mono)}
.chat-it .tx p{font-size:12.5px;color:var(--faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:3px}
.conv{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-card);display:flex;flex-direction:column;overflow:hidden}
.conv-top{padding:16px 22px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:12px}
.conv-top .av{width:38px;height:38px;border-radius:50%;background:var(--teal-tint);display:grid;place-items:center;flex-shrink:0}
.conv-body{flex:1;overflow-y:auto;padding:24px;display:flex;flex-direction:column;gap:14px;background:var(--surface-2)}
.msg{max-width:64%;padding:11px 15px;border-radius:14px;font-size:13.5px;line-height:1.5;word-break:break-word}
.msg.in{background:var(--surface);border:1px solid var(--border);border-bottom-left-radius:4px;align-self:flex-start}
.msg.out{background:var(--teal-tint);border:1px solid var(--teal-tint-2);border-bottom-right-radius:4px;align-self:flex-end}
.msg .who{font-size:11px;color:var(--teal);font-weight:600;margin-bottom:4px}
.msg small{display:block;font-size:10px;color:var(--faint);margin-top:5px;font-family:var(--font-mono)}
.msg img{max-width:240px;border-radius:8px;cursor:zoom-in;display:block}
.msg.enc{font-style:italic;color:var(--faint)}
.msg .rich-note{display:block;margin-top:6px;font-size:11.5px;font-style:italic;color:var(--faint)}
.conv-name{font-weight:600}
.conv-type{font-size:11.5px;color:var(--faint)}

/* image zoom */
.imgview{position:fixed;inset:0;z-index:200;background:rgba(20,30,28,0.78);display:none;place-items:center;cursor:zoom-out}
.imgview.show{display:grid}
.imgview img{max-width:92vw;max-height:92vh;border-radius:10px}

/* ============================================================
   LINE ACCOUNTS
   ============================================================ */
.section-title{font-weight:600;font-size:15px;margin:6px 0 16px;color:var(--text)}
.acc-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:18px}
.acc{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-card);padding:22px;display:flex;gap:18px;align-items:center}
.acc .av{width:52px;height:52px;border-radius:14px;background:#06c755;display:grid;place-items:center;flex-shrink:0}
.acc .av svg{width:26px;height:26px;color:#fff}
.acc .info b{font-weight:600;font-size:16px;display:block}
.acc .info .st{display:inline-flex;align-items:center;gap:6px;font-size:12px;margin-top:6px;color:var(--muted)}
.acc .info .st .d{width:7px;height:7px;border-radius:50%}
.st.live{color:var(--pos-text)}
.st.live .d{background:var(--teal)}
.st.off .d{background:var(--faint)}
.connect-card{max-width:520px;flex-direction:column;text-align:center;padding:40px}
.connect-title{font-weight:600;font-size:15px}
.connect-help{color:var(--faint);font-size:13px;margin:8px 0 18px}
.qr-box{width:190px;height:190px;border-radius:18px;background:#fff;border:1px solid var(--border-2);display:grid;place-items:center;margin-bottom:20px;overflow:hidden}
.qr-box img{width:100%;height:100%;object-fit:contain}
.cn-pin{font-family:var(--font-mono);font-size:22px;letter-spacing:0.18em;color:var(--teal);margin-bottom:14px;min-height:6px}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;transition-duration:.01ms!important}}

/* short viewports: denser overview so it fits one screen */
@media (min-width:1101px) and (max-height:780px){
  .topbar{padding:14px 28px 12px}
  .topbar h1{font-size:23px}
  .kpi{padding:11px 14px}
  .kpi-num{font-size:21px}
  .kpi-foot{margin-top:6px}
}

@media (max-width:1100px){
  .app{grid-template-columns:1fr}
  .sidebar{display:none}
  .ov-kpis{grid-template-columns:repeat(2,1fr)}
  .ov-grid{display:flex;flex-direction:column}
  .acc-grid{grid-template-columns:1fr}
  .pu-grid,.chat-grid{grid-template-columns:1fr}
  .pu-kpis,.fo-kpis{grid-template-columns:1fr}
  /* single-screen views fall back to normal page scroll */
  #view-overview,#view-push,#view-chat,#view-followers{overflow-y:auto}
  #view-overview.active,#view-push.active,#view-chat.active,#view-followers.active{display:block}
  #view-followers.active>*{margin-bottom:14px}
  .chat-grid{height:auto}
  .conv{min-height:60vh}
}
@media (max-width:640px){
  /* drop หมวดหมู่/ตลาด/เปลี่ยน on narrow screens; keep แบรนด์ · Rich menu · Followers · MoM */
  .fo-tr{grid-template-columns:minmax(0,1.3fr) 58px 88px 72px;gap:8px;padding:9px 16px}
  .fo-tr>*:nth-child(2),.fo-tr>*:nth-child(3),.fo-tr>*:nth-child(5){display:none}
}

/* ===== push per-brand detail panel ===== */
.pu-bar-click{cursor:pointer;border-radius:8px;padding:2px 4px;transition:background .12s}
.pu-bar-click:hover{background:#F5F7F7}
.pu-bar-click.on{background:#EEF3F2}
/* the detail card is a size container so its inner columns respond to the
   PANEL width, not the viewport (the sidebar makes viewport width misleading).
   overflow:hidden is a hard guard: even if some inner row refuses to shrink,
   it clips inside the card instead of widening the whole page. */
/* flex:none matters: overflow!=visible drops the flex min-height:auto floor,
   so without it the column-flex view squashes this card to its header. */
#pu-detail-card{margin-top:4px;flex:none;container-type:inline-size;container-name:pudetail;overflow:hidden}
.pu-detail-head{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:8px}
.pu-detail-head b{font-size:15px}
.pu-detail-kpi{color:#6B7280;font-size:12px}
.pu-badges{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:12px}
.pu-badge{background:#EEF3F2;color:#3F8F86;border-radius:12px;padding:2px 10px;font-size:12px;font-weight:600}
/* pillar column narrow (little data); recent list takes the rest. min-width:0
   on both cells lets the nowrap recent text ellipsize instead of overflowing. */
.pu-detail-cols{display:grid;grid-template-columns:minmax(160px,240px) minmax(0,1fr);gap:24px;align-items:start}
.pu-detail-cols>div{min-width:0}
.pu-detail-cols h4{margin:0 0 10px;font-size:11px;color:#6B7280;text-transform:uppercase;letter-spacing:.04em;white-space:nowrap}
.pu-recent-row{display:flex;gap:8px;align-items:center;padding:5px 0;border-bottom:1px solid #F0F2F2}
.pu-recent-badge{background:#F0F2F2;color:#6B7280;border-radius:6px;padding:1px 7px;font-size:11px;white-space:nowrap;flex:none}
.pu-recent-tx{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}
.pu-recent-at{color:#A0A4AB;font-size:11px;white-space:nowrap;flex:none}
/* collapse to one column only when the PANEL itself is narrow (container query),
   so a visible sidebar can't force a mis-collapse on a wide screen. */
@container pudetail (max-width:560px){.pu-detail-cols{grid-template-columns:1fr;gap:16px}}

/* ===== rich-menu tracking table (Followers view) ===== */
.fo-rm-tr{display:grid;grid-template-columns:2fr 1fr .6fr 2fr;gap:12px;align-items:center;padding:9px 16px;border-bottom:1px solid #F0F2F2;font-size:13px}
.fo-rm-head{color:#A0A4AB;font-size:11px;text-transform:uppercase;letter-spacing:.03em;border-bottom:1px solid #E5E7E7}
.fo-rm-on{color:#3F8F86;font-weight:600}
.fo-rm-off{color:#C0C4CB}
.fo-rm-dates{color:#6B7280;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.fo-rm-tr .ar{text-align:right}
@media(max-width:640px){.fo-rm-tr{grid-template-columns:1.4fr .8fr .5fr;gap:8px}.fo-rm-dates{display:none}}

/* ===== followers brand-compare chips ===== */
.fo-chips{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 14px}
.fo-chip{border:1px solid #E5E7E7;background:#fff;color:#6B7280;border-radius:16px;padding:4px 14px;font-size:12px;cursor:pointer;transition:all .12s}
.fo-chip:hover{border-color:#9CCEC8}
.fo-chip.on{background:#EEF3F2;border-color:#3F8F86;color:#3F8F86;font-weight:600}

/* ===== recent-push hover card (full text + image) ===== */
.pu-recent-row{cursor:default}
.pu-recent-row:hover{background:#F5F7F7;border-radius:6px}
.pu-hovercard{position:absolute;z-index:60;background:#fff;border:1px solid #E5E7E7;
  border-radius:12px;box-shadow:0 8px 28px rgba(20,40,38,.16);padding:12px 14px;pointer-events:none}
.pu-hc-meta{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-bottom:8px}
.pu-hc-meta small{color:#A0A4AB;font-size:11px;white-space:nowrap}
.pu-hc-imgwrap{position:relative;margin-bottom:8px;min-height:36px;border-radius:8px;overflow:hidden;background:#F0F2F2}
.pu-hc-imgwrap::after{content:"กำลังโหลดรูป…";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:11px;color:#A0A4AB}
.pu-hc-imgwrap.ok::after{content:none;display:none}
.pu-hc-imgwrap.err::after{content:"โหลดรูปไม่ได้"}
.pu-hc-img{display:block;width:100%;max-height:280px;object-fit:contain}
.pu-hc-imgwrap.err .pu-hc-img{display:none}
.pu-hc-text{font-size:13px;line-height:1.5;color:#374151;white-space:pre-wrap;word-break:break-word;max-height:220px;overflow:auto}
.pu-hovercard .rich-note{display:block;margin-top:8px;font-size:11.5px;font-style:italic;color:#A0A4AB}
