/* ════════════════════════════════════════════════════════════
   Support Panel — Mini App components, built on tokens.css.
   Phone-first, RTL, dark. One orange accent; trading green/red
   only for semantic state (active / waiting / sentiment).
   ════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  min-height: 100vh;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 640px; margin: 0 auto; padding: 0 16px 96px; }

/* ─── App bar ──────────────────────────────────────────────── */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 2px 12px;
  background: linear-gradient(var(--bg) 78%, rgba(14,17,23,0));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logomark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  display: grid; place-items: center; box-shadow: var(--shadow-cta);
}
.logomark svg { display: block; }
.brand-txt { min-width: 0; }
.brand-txt .t {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  color: var(--fg); line-height: 1.1; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.brand-txt .s {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px;
}
.rolechip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--accent-tint); color: var(--accent);
  background: var(--accent-soft);
}
.rolechip.op { color: var(--green-2); border-color: rgba(91,194,140,0.3); background: rgba(91,194,140,0.06); }
.rolechip.as { color: var(--accent-2); border-color: var(--accent-tint); background: var(--accent-soft); cursor: pointer; font: inherit; font-family: var(--font-mono); }
.rolechip.as:active { transform: scale(0.97); }

/* ─── Section heading ─────────────────────────────────────── */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 12px; gap: 12px; }
.section-head .ttl { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--fg); }
.section-head .meta { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ─── Tabs (segmented) ────────────────────────────────────── */
.tabs {
  position: sticky; top: 56px; z-index: 15;
  display: flex; gap: 6px; padding: 8px 0 10px;
  background: linear-gradient(var(--bg) 70%, rgba(14,17,23,0));
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; cursor: pointer; user-select: none;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em; color: var(--fg-dim);
  padding: 9px 15px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--bg-card);
  transition: color var(--t-base), border-color var(--t-base), background var(--t-base);
  display: inline-flex; align-items: center; gap: 7px;
}
.tab[aria-selected="true"] {
  color: var(--on-accent); background: var(--accent); border-color: var(--accent);
  box-shadow: var(--shadow-cta);
}
.tab .badge {
  font-size: 10px; min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-grid; place-items: center; border-radius: 999px;
  background: rgba(232,84,84,0.16); color: var(--red-2); border: 1px solid rgba(232,84,84,0.3);
}
.tab[aria-selected="true"] .badge { background: rgba(10,10,11,0.18); color: var(--on-accent); border-color: transparent; }

/* ─── Stat band ───────────────────────────────────────────── */
.statband {
  background: var(--bg-deep);
  border: 1px solid var(--border); border-radius: var(--radius-card);
  display: grid; grid-template-columns: repeat(2, 1fr); overflow: hidden;
}
.stat { padding: 18px 16px; border-top: 1px solid var(--border); border-inline-start: 1px solid var(--border); }
.stat:nth-child(-n+2) { border-top: none; }
.stat:nth-child(odd) { border-inline-start: none; }
.stat .num {
  font-family: var(--font-display); font-weight: 700; font-size: 30px;
  letter-spacing: -0.02em; line-height: 1; color: var(--fg); direction: ltr; text-align: start;
}
[dir="rtl"] .stat .num { direction: rtl; }
.stat .num .acc { color: var(--accent); }
.stat .num.green { color: var(--green-2); }
.stat .num.warn { color: var(--red-2); }
.stat .lbl {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--muted);
  letter-spacing: 0.06em; margin-top: 9px;
}

/* ─── Card ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 16px;
}
.card + .card { margin-top: 12px; }
.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border-soft); }
.kv:first-of-type { border-top: none; }
.kv .k { color: var(--fg-dim); font-size: 13.5px; }
.kv .v { font-family: var(--font-mono); color: var(--fg); font-weight: 600; white-space: nowrap; }
.kv .v.green { color: var(--green-2); }
.kv .v.warn { color: var(--red-2); }
.kv .v.dim { color: var(--muted); }

/* ─── Pills / dots ────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--fg-dim); background: var(--bg-elev);
}
.pill.live { color: var(--green-2); border-color: rgba(91,194,140,0.32); background: rgba(91,194,140,0.06); }
.pill.off  { color: var(--muted); }
.pill.warn { color: var(--red-2); border-color: rgba(232,84,84,0.3); background: rgba(232,84,84,0.06); }
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot.green { background: var(--green-2); }
.dot.off { background: var(--muted); }
.dot.warn { background: var(--red-2); }

@keyframes tr-ping { 0% { box-shadow: 0 0 0 0 rgba(91,194,140,0.55); } 100% { box-shadow: 0 0 0 9px rgba(91,194,140,0); } }
.ping { width: 7px; height: 7px; border-radius: 50%; background: var(--green-2); animation: tr-ping 1.6s ease-out infinite; flex-shrink: 0; }

/* ─── Rows (operators / live / chats) ─────────────────────── */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--bg-card);
  transition: border-color var(--t-base), transform var(--t-fast);
}
.row + .row { margin-top: 8px; }
.row.tap { cursor: pointer; }
.row.tap:active { transform: scale(0.99); border-color: var(--border-strong); }
.row .lead { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.avatar {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-family: var(--font-display);
  font-weight: 700; font-size: 14px; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-tint);
}
.row .name { min-width: 0; }
.row .name .n { color: var(--fg); font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .name .sub { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 2px; }
.row .trail { text-align: end; flex-shrink: 0; }
.row .trail .big { font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--fg); }
.row .trail .small { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.row .chev { color: var(--muted); font-size: 16px; flex-shrink: 0; }

.metricline { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.metricline span { font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); white-space: nowrap; }
.metricline .warn { color: var(--red-2); }

/* ─── Chat (open / waiting) item ──────────────────────────── */
.chat {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-card);
}
.chat + .chat { margin-top: 7px; }
.chat .who { color: var(--fg); font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat .wait { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--red-2); white-space: nowrap; flex-shrink: 0; }
.chat .open-link { font-family: var(--font-mono); font-size: 10px; color: var(--accent); border: 1px solid var(--accent-tint); background: var(--accent-soft); padding: 4px 9px; border-radius: 999px; flex-shrink: 0; }

.op-group { margin-top: 16px; }
.op-group .ghead { display: flex; align-items: center; gap: 9px; margin: 0 2px 9px; }
.op-group .ghead .gn { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; color: var(--fg); }
.op-group .ghead .gc { font-family: var(--font-mono); font-size: 11px; color: var(--red-2); }

/* ─── Sentiment / topics ──────────────────────────────────── */
.sent-bar { display: flex; height: 9px; border-radius: 999px; overflow: hidden; background: var(--bg-elev); margin: 10px 0 8px; border: 1px solid var(--border); }
.sent-bar i { display: block; height: 100%; }
.sent-bar .pos { background: var(--green-2); }
.sent-bar .neu { background: var(--muted); }
.sent-bar .neg { background: var(--red-2); }
.sent-legend { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); }
.sent-legend b { color: var(--fg); font-weight: 700; }
.topics { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.topic { font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-elev); }
.topic b { color: var(--accent); font-weight: 700; }

/* ─── Trend (mini bars) ───────────────────────────────────── */
.trend { display: flex; align-items: flex-end; gap: 7px; height: 110px; padding: 6px 2px 0; }
.trend .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.trend .bars { width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 80px; }
.trend .bar { width: 8px; border-radius: 3px 3px 0 0; background: var(--accent); min-height: 2px; transition: height var(--t-slow) var(--ease-out); }
.trend .bar.b2 { background: var(--green-3); opacity: 0.85; }
.trend .day { font-family: var(--font-mono); font-size: 9.5px; color: var(--muted); }
.trend-legend { display: flex; gap: 16px; margin-top: 10px; font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); }
.trend-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-inline-end: 6px; vertical-align: middle; }

/* ─── Leaderboard ─────────────────────────────────────────── */
.lb-seg { display: flex; gap: 6px; margin: 2px 0 2px; }
.segbtn {
  flex: 1; cursor: pointer; font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  color: var(--fg-dim); padding: 10px 0; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--bg-card);
  transition: color var(--t-base), background var(--t-base), border-color var(--t-base);
}
.segbtn.on { color: var(--on-accent); background: var(--accent); border-color: var(--accent); box-shadow: var(--shadow-cta); }
.lb-sortlabel { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin: 12px 2px 6px; }
.lbrow {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card);
  transition: border-color var(--t-base), transform var(--t-fast);
}
.lbrow + .lbrow { margin-top: 8px; }
.lbrow.tap:active { transform: scale(0.99); border-color: var(--border-strong); }
.lbrank { width: 30px; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--muted); flex-shrink: 0; }
.lbrank.medal { font-size: 19px; }
.lbmid { flex: 1; min-width: 0; }
.lbname { color: var(--fg); font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbbar { height: 7px; border-radius: 999px; background: var(--bg-elev); border: 1px solid var(--border); margin-top: 7px; overflow: hidden; }
.lbbar i { display: block; height: 100%; background: var(--accent); transition: width var(--t-slow) var(--ease-out); }
.lbbar i.bad { background: var(--red-2); }
.lbval { font-family: var(--font-mono); font-weight: 700; font-size: 15px; color: var(--fg); white-space: nowrap; flex-shrink: 0; min-width: 56px; text-align: end; }
.lbval.hi { color: var(--accent); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border: 1px solid transparent; border-radius: var(--radius);
  font-family: var(--font-display); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: transform var(--t-fast), background var(--t-base), border-color var(--t-base);
}
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border-strong); }
.btn-ghost:active { border-color: var(--fg-dim); }
.btn-block { width: 100%; }

/* ─── States ──────────────────────────────────────────────── */
.empty { text-align: center; color: var(--muted); padding: 34px 16px; border: 1px dashed var(--border); border-radius: var(--radius-card); font-size: 14px; }
.empty .big { font-size: 30px; margin-bottom: 8px; }
.center { display: grid; place-items: center; min-height: 70vh; text-align: center; gap: 16px; color: var(--fg-dim); }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted-note { color: var(--muted); font-family: var(--font-mono); font-size: 11px; text-align: center; margin: 18px 0 6px; }
.fadein { animation: fade var(--t-slow) var(--ease-out); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
