/* Sentiment Monitor — Mini App design tokens and components (see the design canvas). */
:root {
  --bg: #F4F6F9; --surface: #FFFFFF; --surface2: #EEF2F7; --seg: #E6EBF2;
  --ink: #0F1B2D; --ink2: #44546A; --muted: #5B6B7F; --line: #E3E8EF; --field: #CDD5E0;
  --primary: #2449C2; --primary-ink: #1A378F; --primarySoft: #E8EEFC; --primaryLine: #BFD0F7;
  --btn: #2449C2;
  --pos: #0E7490; --posSoft: #E2F2F5; --neg: #C2410C; --negFill: #EA580C; --negSoft: #FCEDE4; --neu: #A3ADBA;
  --mark: #0F1B2D; --markDot: #6F97FF; --chip: #0F1B2D; --chipInk: #FFFFFF; --gap: #EEF2F7;
  --backdrop: rgba(15, 27, 45, .45); --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0F1720; --surface: #17212B; --surface2: #1F2B38; --seg: #1F2B38;
  --ink: #E9EEF4; --ink2: #C3CDD8; --muted: #93A1B2; --line: #263443; --field: #344456;
  --primary: #7AA2FF; --primary-ink: #A9C2FF; --primarySoft: rgba(122, 162, 255, .16); --primaryLine: rgba(122, 162, 255, .35);
  --btn: #3B66E0;
  --pos: #3CC4D1; --posSoft: rgba(60, 196, 209, .15); --neg: #FF9A62; --negFill: #FF8A4C; --negSoft: rgba(255, 138, 76, .15); --neu: #5E6B7B;
  --mark: #22324A; --markDot: #7AA2FF; --chip: #E9EEF4; --chipInk: #0F1B2D; --gap: #1B2632;
  --backdrop: rgba(0, 0, 0, .55); --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); }
body { min-height: 100vh; }
a { color: var(--primary); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

.logo rect { fill: var(--mark); }
.logo path { fill: none; stroke: #FFFFFF; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.logo circle { fill: var(--markDot); }

/* ---------------------------------------------------------------- basics -- */
.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--primary);
  display: inline-block; animation: spin .8s linear infinite; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; border-color: rgba(255, 255, 255, .35); border-top-color: #FFFFFF; }
@keyframes spin { to { transform: rotate(360deg); } }
.fade { animation: fade .22s ease-out both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen { min-height: 100vh; display: flex; flex-direction: column; padding: 16px 16px 28px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 2px 0 10px; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head .tile { flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--primarySoft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------------------------------------------------------------- buttons -- */
.btn { height: 48px; border: 0; border-radius: 12px; padding: 0 18px; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; font-size: 15px; font-weight: 600; text-decoration: none; width: 100%; }
.btn.primary { background: var(--btn); color: #FFFFFF; }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--field); }
.btn.small { height: 40px; font-size: 13.5px; border-radius: 10px; }
.icon-btn { flex: none; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.icon-btn.ghost { border: 0; background: transparent; color: var(--muted); }
.link { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; text-decoration: none; }

/* ---------------------------------------------------------------- forms ---- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; }
.input-wrap { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 6px 0 14px; border: 1px solid var(--field);
  border-radius: 12px; background: var(--surface); color: var(--muted); }
.input-wrap:focus-within, .input:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primarySoft); }
.input-wrap input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 15px; }
.input { height: 46px; padding: 0 14px; border: 1px solid var(--field); border-radius: 12px; outline: none; background: var(--surface);
  color: var(--ink); font-size: 15px; width: 100%; }
textarea.input { height: auto; min-height: 92px; padding: 12px 14px; line-height: 1.45; resize: none; }
::placeholder { color: #8792A2; }
.readonly { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: 12px;
  background: var(--surface2); color: var(--ink2); font-size: 14.5px; }
.readonly .hint { margin-left: auto; font-size: 12px; color: var(--muted); }
.form-error { margin: -4px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--negSoft); color: var(--neg);
  font-size: 13px; font-weight: 500; }
.note { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink2); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 3px;
  background: var(--seg); border-radius: 12px; }
.seg button { height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; padding: 0 8px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .14); }
.seg.compact { display: inline-grid; border-radius: 10px; }
.seg.grid2 { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg.compact button { height: 30px; font-size: 13px; padding: 0 11px; border-radius: 8px; }
/* choices with long labels wrap to the next line instead of squeezing or scrolling sideways */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips button { border: 1px solid var(--field); border-radius: 999px; font-weight: 600;
  background: var(--surface); color: var(--ink); }
.chips button { height: 36px; padding: 0 14px; font-size: 13px; }
.chips button[aria-pressed="true"] { background: var(--chip); border-color: var(--chip);
  color: var(--chipInk); }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--surface2); color: var(--ink2); white-space: nowrap; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.active { background: var(--posSoft); color: var(--pos); }
.pill.pending { background: var(--primarySoft); color: var(--primary); }
.pill.blocked { background: var(--negSoft); color: var(--neg); }
.pill.expired { background: var(--surface2); color: var(--muted); }

/* ---------------------------------------------------------------- login ---- */
.login { padding: 20px 20px 32px; }
.lang-row { display: flex; justify-content: flex-end; }
.login-center { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 18px 0; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.brand h1 { margin: 0; font-size: 25px; font-weight: 600; letter-spacing: -.3px; }
.brand p { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.login .card { border-radius: 18px; padding: 20px; }
.foot { margin: 0; text-align: center; font-size: 13px; line-height: 1.5; color: var(--muted); }

.center-msg { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 0 28px 60px; text-align: center; }
.center-msg h2 { margin: 0; font-size: 21px; font-weight: 600; }
.center-msg p { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.center-msg .ring { width: 68px; height: 68px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.ring.ok { background: var(--posSoft); color: var(--pos); }
.ring.warn { background: var(--negSoft); color: var(--neg); }
.ring.info { background: var(--primarySoft); color: var(--primary); }
.center-msg .btn { width: auto; margin-top: 8px; }

/* ---------------------------------------------------------------- admin ---- */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat span { display: block; font-size: 11.5px; color: var(--muted); }
.stat b { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.req { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 12px; background: var(--bg); }
.req + .req { margin-top: 8px; }
.req .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.req .who { font-size: 14px; font-weight: 600; }
.req .meta { font-size: 12.5px; color: var(--ink2); }
.req .msg { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.req .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.req .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.context { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-radius: 10px; background: var(--primarySoft);
  color: var(--primary-ink); font-size: 13px; font-weight: 500; }
.context span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.creds { border: 1px solid var(--primaryLine); background: var(--primarySoft); border-radius: 14px; padding: 14px; display: flex;
  flex-direction: column; gap: 10px; }
.creds .ok { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--primary-ink); }
.secret { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 8px 8px 12px; }
.secret div { flex: 1; min-width: 0; }
.secret small { display: block; font-size: 11px; color: var(--muted); }
.secret .mono { font-size: 15px; overflow-wrap: anywhere; }
.users { padding: 4px 14px; }
.user { display: grid; grid-template-columns: 38px minmax(0, 1fr) 36px; align-items: center; gap: 10px; padding: 10px 0; }
.user + .user { border-top: 1px solid var(--line); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--surface2); color: var(--ink2); font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; }
.user .who { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user .line1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.user .line1 .mono { font-size: 13.5px; }
.user .line2 { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-tabs { margin-bottom: 12px; }
.chan-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.chan-add .btn { width: auto; height: 46px; padding: 0 18px; }
.user .line1 b { font-size: 14px; font-weight: 600; }
.empty { padding: 18px 4px; text-align: center; font-size: 13.5px; color: var(--muted); }
/* tabs: a long label takes more room instead of being cut */
.admin-tabs { display: flex; }
.admin-tabs button { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.seg .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--negFill); color: #FFFFFF;
  font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
#newUser { margin-bottom: 12px; }
button.user { width: 100%; border: 0; background: transparent; color: inherit; text-align: left; font: inherit; }
.user .chev { display: flex; justify-content: flex-end; color: var(--muted); }
.topbar .pill { margin-left: auto; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.label-row .label { font-size: 13px; font-weight: 600; }
.readonly svg { flex: none; color: var(--muted); }
.hint { margin: 0; min-height: 18px; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.hint:empty { display: none; }
.hint.ok { color: var(--pos); }
.hint.bad { color: var(--neg); }
.spinner.xs { width: 12px; height: 12px; border-width: 1.5px; }
.rules { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
.rules li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.rules li svg { flex: none; }
.rules li.ok { color: var(--pos); }
.rules li.bad { color: var(--neg); }
.kv { margin: 0; display: flex; flex-direction: column; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; }
.kv div + div { border-top: 1px solid var(--line); }
.kv dt { font-size: 13px; color: var(--muted); }
.kv dd { margin: 0; font-size: 13.5px; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.menu-card { padding: 4px 14px; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.btn.primary.danger { background: var(--negFill); }
.link.write { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 13px; }
.hist { margin-top: 6px; }
.hrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; }
.hrow + .hrow { border-top: 1px solid var(--line); }
.hrow .who { min-width: 0; display: flex; flex-direction: column; }
.hrow .who b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow .who small { font-size: 12px; color: var(--muted); }

/* --------------------------------------------------------- sheet + toast -- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; }
.sheet-wrap .backdrop { flex: 1; border: 0; background: var(--backdrop); }
.sheet { background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 16px calc(22px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; animation: up .22s ease-out both; max-height: 86vh; overflow-y: auto; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .grip { align-self: center; width: 36px; height: 4px; border-radius: 999px; background: var(--field); }
.sheet .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet .head h2 { margin: 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.menu { display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border: 0; background: transparent; color: var(--ink);
  font-size: 15px; font-weight: 500; text-align: left; }
.menu button + button { border-top: 1px solid var(--line); }
.menu button.danger { color: var(--neg); }
.menu small { display: block; margin-top: 1px; font-size: 12px; font-weight: 400; color: var(--muted); }
.menu .ic { flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--surface2); color: var(--ink2);
  display: flex; align-items: center; justify-content: center; }
.menu button.danger .ic { background: var(--negSoft); color: var(--neg); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--chip); color: var(--chipInk); padding: 10px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(15, 27, 45, .2); animation: fade .2s ease-out both; }

/* ------------------------------------------------------------- dashboard -- */
.app { padding: 16px 16px calc(92px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; gap: 12px; }
.hdr { display: flex; align-items: center; gap: 10px; }
.brand-sm { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-sm b { display: block; font-size: 16px; font-weight: 600; line-height: 1.25; }
.brand-sm span { display: block; font-size: 12px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }
.icon-btn.wide { width: auto; padding: 0 10px; gap: 6px; font-size: 13px; font-weight: 600; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.lg { position: relative; width: 40px; height: 40px; border-radius: 11px; }
.icon-btn.on { background: var(--primarySoft); border-color: var(--primaryLine); color: var(--primary); }
.icon-btn:disabled { opacity: .35; }
.icon-btn .count { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  background: var(--btn); color: #FFFFFF; font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg); }
.page-hdr { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: 2px; }
.page-hdr h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.3px; }
.page-hdr p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.pick-btn { flex: none; height: 36px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--ink); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.app .card + .card { margin-top: 0; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card-title span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.link.more { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 64px 24px; color: var(--muted); text-align: center; }
.empty-state p { margin: 0; font-size: 14px; }
.empty-state.small { padding: 40px 16px; }

/* period switch and KPI cards */
.seg.periods { grid-auto-columns: minmax(0, 1fr); }
.prow { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.plabel { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; color: var(--muted); }
.plabel span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pnav { margin-left: auto; display: flex; gap: 6px; flex: none; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column;
  gap: 8px; min-width: 0; box-shadow: var(--shadow); }
.k-label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .2px; }
.k-val { font-size: 30px; font-weight: 600; letter-spacing: -.6px; line-height: 1; font-variant-numeric: tabular-nums; }
.k-val.pos { color: var(--pos); }
.k-val.neg { color: var(--neg); }
.k-unit { font-size: 18px; font-weight: 500; color: var(--muted); margin-left: 1px; }
.k-cmp { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; min-height: 22px; font-size: 11px; color: var(--muted); line-height: 1.3; }
.k-hint { font-size: 11.5px; color: var(--muted); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  background: var(--surface2); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.pos { background: var(--posSoft); color: var(--pos); }
.delta.neg { background: var(--negSoft); color: var(--neg); }
.delta .turn { display: inline-flex; transform: rotate(90deg); }

/* charts */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.legend .l-line { width: 14px; height: 2px; background: var(--primary); }
.l-pos, .b-pos { background: var(--pos); }
.l-neu, .b-neu { background: var(--neu); }
.l-neg, .b-neg { background: var(--negFill); }
.legend .l-gap { width: 10px; height: 8px; background: var(--gap); border: 1px solid var(--line); }
.charts { margin-top: 10px; }
/* touch or hover a period: a guide line, the EAI point and the period's figures */
.dyn { position: relative; touch-action: pan-y; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.dyn-guide { position: absolute; top: 0; width: 1px; background: var(--ink2); opacity: .45; pointer-events: none; }
.dyn-dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--primary);
  border: 2px solid var(--surface); pointer-events: none; }
.dyn-tip { position: absolute; top: -6px; min-width: 132px; padding: 8px 10px; border-radius: 10px; background: var(--chip);
  color: var(--chipInk); font-size: 12px; line-height: 1.45; box-shadow: 0 6px 18px rgba(15, 27, 45, .18); pointer-events: none;
  z-index: 2; }
.dyn-tip b { display: block; margin-bottom: 2px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.dyn-tip span { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.dyn-tip small { display: block; margin-top: 2px; opacity: .75; font-size: 11px; }
.chart { display: block; overflow: visible; }
.chart + .chart { margin-top: 4px; }
.c-eai { stroke: var(--primary); }
.c-dot { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.c-pos { fill: var(--pos); }
.c-neg { fill: var(--negFill); }
.c-line { stroke: var(--line); stroke-width: 1; }
.c-axis { stroke: var(--muted); stroke-width: 1; }
.c-gap { fill: var(--gap); }
.c-txt { fill: var(--muted); font-size: 10px; font-family: var(--font); }

/* tone split, coverage, topic rows */
.tbar { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; margin-top: 12px; }
.tbar span { display: block; }
.tgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.tgrid div { display: flex; flex-direction: column; gap: 2px; }
.tgrid span { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.tgrid b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.t-pos { color: var(--pos); }
.t-neg { color: var(--neg); }
.tgrid .t-pos, .tgrid .t-neg { color: var(--muted); }
.tgrid .t-pos svg { color: var(--pos); }
.tgrid .t-neg svg { color: var(--neg); }
.cov { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; }
.cov div { padding: 12px 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 2px; min-width: 0; }
.cov div + div { border-left: 1px solid var(--line); }
.cov span { font-size: 11.5px; color: var(--muted); }
.cov b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.toptopics { padding-bottom: 6px; }
.ttrow { display: grid; grid-template-columns: minmax(96px, 124px) minmax(0, 1fr) 40px 48px; align-items: center; gap: 10px; width: 100%;
  padding: 10px 0; border: 0; background: none; color: var(--ink); text-align: left; }
.ttrow + .ttrow { border-top: 1px solid var(--line); }
.ttrow .nm { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ttrow .track { display: block; height: 6px; border-radius: 999px; background: var(--surface2); overflow: hidden; }
.ttrow .track span { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.ttrow .n { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.net { justify-self: end; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; font-variant-numeric: tabular-nums;
  background: var(--surface2); color: var(--muted); white-space: nowrap; }
.net.pos { background: var(--posSoft); color: var(--pos); }
.net.neg { background: var(--negSoft); color: var(--neg); }

/* topics tab */
.tl-head { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 10px; padding: 12px 0 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.tl-head span + span { text-align: right; }
.tlrow { display: grid; grid-template-columns: minmax(0, 1fr) 48px; align-items: center; gap: 10px; width: 100%; padding: 10px 0;
  border: 0; border-top: 1px solid var(--line); background: none; color: var(--ink); text-align: left; }
.tl-head + .tlrow { border-top: 0; }
.tl-main { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
/* topic name, then its positive | neutral | negative counts, the total on the right;
   on a narrow screen the counts move under the name */
.tl-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 13.5px; }
.tl-label { font-weight: 500; }
.tl-tones { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-tones i { font-style: normal; font-weight: 400; color: var(--field); margin: 0 4px; }
.tl-tones .t-neu { color: var(--muted); }
.tl-name b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.tl-track { display: block; height: 8px; border-radius: 999px; background: var(--surface2); overflow: hidden; }
.tl-track > span { display: flex; gap: 2px; height: 100%; }
.tl-track i { display: block; height: 100%; }
.note.how { margin: 6px 0 12px; }
.ctrow { display: grid; grid-template-columns: minmax(96px, 124px) minmax(0, 1fr) 48px; align-items: center; gap: 8px; padding: 5px 0;
  font-size: 12.5px; }
.ctrow b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ct-track { position: relative; display: block; height: 12px; }
.ct-track::before { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--field); }
.ct-track i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.ct-track i.right { left: 50%; }
.ct-track i.left { right: 50%; }
.ct-total { display: grid; grid-template-columns: minmax(0, 1fr) 64px; align-items: center; gap: 8px; margin-top: 8px; padding-top: 10px;
  border-top: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.ct-total b { text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }

/* news tab */
.date-btn { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
  font-size: 14px; display: flex; align-items: center; gap: 10px; padding: 0 12px; text-align: left; }
.date-btn > svg:first-child { color: var(--muted); flex: none; }
.date-btn b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-btn span { font-size: 13px; color: var(--muted); white-space: nowrap; }
.date-btn > svg:last-child { margin-left: auto; color: var(--muted); flex: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 3px 0 11px; border-radius: 999px;
  background: var(--chip); color: var(--chipInk); font-size: 12.5px; font-weight: 600; }
.tag button { width: 24px; height: 24px; border: 0; border-radius: 999px; background: transparent; color: inherit; display: flex;
  align-items: center; justify-content: center; padding: 0; }
.plist { display: flex; flex-direction: column; gap: 10px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column;
  gap: 10px; box-shadow: var(--shadow); }
.pcard.skl { height: 132px; border: 0; background: var(--surface2); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.ptop { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tone-chip { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: 11.5px; font-weight: 600; padding: 3px 8px 3px 6px;
  border-radius: 999px; background: var(--surface2); color: var(--ink2); }
.tone-chip.pos { background: var(--posSoft); color: var(--pos); }
.tone-chip.neg { background: var(--negSoft); color: var(--neg); }
.ptopic { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ptime { margin-left: auto; flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.phead { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.4; letter-spacing: -.1px; color: var(--ink);
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ptext { margin: -4px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--ink2); overflow-wrap: anywhere; display: -webkit-box;
  -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.pfoot { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.pfoot b { font-weight: 600; color: var(--ink); }
.pviews { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.psrc { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; text-decoration: none; }

/* channel filter: one row in the filters, a searchable list inside the same sheet */
.pick-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 10px 10px 12px; border: 1px solid var(--field);
  border-radius: 12px; background: var(--surface); color: var(--ink); text-align: left; }
.pick-row .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-row b { font-size: 14px; font-weight: 600; }
.pick-row small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row svg { flex: none; color: var(--muted); }
.cnt { flex: none; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--primarySoft);
  color: var(--primary); font-variant-numeric: tabular-nums; }
.cp-head { display: flex; align-items: center; gap: 10px; }
.cp-head b { flex: 1; font-size: 15px; font-weight: 600; }
.cp-actions { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.cp-actions .link { font-size: 12.5px; }
.cp-list { display: flex; flex-direction: column; margin-top: -6px; }
.cp-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto 20px; gap: 10px; align-items: center; padding: 8px 0;
  border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; }
.cp-row .avatar { width: 32px; height: 32px; font-size: 12px; }
.cp-row .nm { min-width: 0; display: flex; flex-direction: column; }
.cp-row b { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-row small { font-size: 11.5px; color: var(--muted); }
.cp-row .n { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cp-row .ck { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--field); display: flex; align-items: center;
  justify-content: center; color: transparent; }
.cp-row[aria-pressed="true"] .ck { background: var(--btn); border-color: var(--btn); color: #FFFFFF; }
.cp-more { align-self: center; font-size: 13px; }

/* sheets content: filters, calendar, method */
.sheet-body { display: flex; flex-direction: column; gap: 16px; }
.menu .check { margin-left: auto; color: var(--primary); display: flex; }
.menu button > span:not(.ic):not(.check) { display: flex; flex-direction: column; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sheet-body .chips button { height: 32px; padding: 0 12px; font-size: 12.5px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; }
.cal-nav b { font-size: 15px; font-weight: 600; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px 2px; text-align: center; }
.cal .wd { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 2px 0 4px; }
.cal button { height: 38px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 14px; font-weight: 500;
  font-variant-numeric: tabular-nums; padding: 0; }
.cal button:disabled { color: var(--field); opacity: 1; }
.cal button.in { background: var(--primarySoft); }
.cal button.edge { background: var(--btn); color: #FFFFFF; font-weight: 600; border-radius: 10px; }
.note.muted { color: var(--muted); font-size: 12px; }
.note .grey { color: var(--field); font-weight: 600; }
.cal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cal-foot span { font-size: 13px; color: var(--ink2); }
.cal-foot .btn { width: auto; padding: 0 24px; flex: none; }
.mcard { display: flex; flex-direction: column; gap: 10px; }
.card-head .tile.pos { background: var(--posSoft); color: var(--pos); }
.formula { padding: 12px; border-radius: 10px; background: var(--bg); font-family: var(--mono); font-size: 13.5px; text-align: center; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); z-index: 9;
  background: var(--surface); border-top: 1px solid var(--line); padding: 8px 6px max(12px, env(safe-area-inset-bottom)); }
.tabbar button { background: none; border: 0; color: var(--muted); font-size: 11px; font-weight: 500; display: flex;
  flex-direction: column; align-items: center; gap: 4px; padding: 4px 0; }
.tabbar button[aria-current="page"] { color: var(--primary); font-weight: 600; }

/* ---- wide screens ---- */
@media (min-width: 600px) {
  html { scrollbar-color: var(--field) var(--bg); scrollbar-width: thin; }
  * { scrollbar-color: var(--field) var(--bg); scrollbar-width: thin; }
  :focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
  .app-shell { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: start; }
  .app { grid-column: 2; grid-row: 1; width: 100%; min-width: 0; max-width: 880px; padding: 24px 24px 32px; }
  .app > * { min-width: 0; }
  .tabbar { position: sticky; top: 0; bottom: auto; grid-column: 1; grid-row: 1; width: 96px;
    height: 100vh; height: 100dvh; grid-template-columns: 1fr; align-content: start; gap: 8px;
    border-top: 0; border-right: 1px solid var(--line); padding: 24px 8px; overflow-y: auto; }
  .tabbar button { min-height: 68px; padding: 12px 2px; border-radius: 12px; justify-content: center; overflow-wrap: anywhere; }
  .tabbar button[aria-current="page"] { background: var(--primarySoft); }
  .tabbar button:hover { background: var(--primarySoft); color: var(--primary); }
  .view-home, .view-topics, .view-method { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start; align-items: start; }
  .view-home > .hdr, .view-home > .periods, .view-home > .prow, .view-home > .kpis,
  .view-home > .dynamics-card, .app > .page-hdr, .app > .empty-state { grid-column: 1 / -1; }
  .card, .kpi, .pcard { box-shadow: none; border-radius: 16px; }
  .charts { min-width: 0; }
  .view-home .card-title { flex-wrap: wrap; }
  .view-home .cov { grid-template-columns: 1fr; }
  .view-home .cov div { flex-direction: row; align-items: center; gap: 12px; }
  .view-home .cov div + div { border-left: 0; border-top: 1px solid var(--line); }
  .ctrow { grid-template-columns: minmax(0, 1fr) minmax(50px, 1fr) 56px; }   /* one zero line for every row */
  .formula { overflow-wrap: anywhere; }
  .plist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .plist > .btn, .plist > .empty-state, .plist > .form-error { grid-column: 1 / -1; }
  .pcard { min-width: 0; }
  .pfoot { flex-wrap: wrap; gap: 8px; }
  .pfoot b { overflow-wrap: anywhere; }
  .sheet-wrap { justify-content: center; align-items: center; padding: 24px; }
  .sheet-wrap > .backdrop { position: absolute; inset: 0; width: 100%; height: 100%; }
  .sheet { position: relative; width: 100%; max-width: 480px; max-height: calc(100dvh - 48px);
    border-radius: 20px; padding: 20px; }
  .sheet > .grip { display: none; }
  #root > .screen { max-width: 420px; margin-inline: auto; }
  #root > .screen.admin { max-width: 720px; }
}

@media (min-width: 1024px) {
  .app { max-width: 1280px; padding: 24px 32px 40px; }
  /* the panel spans the 4 rows on the left; the last row (the list) takes its extra height, so few posts
     do not spread the header, date and tags apart */
  .view-posts { display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: auto auto auto 1fr;
    align-content: start; align-items: start; gap: 12px 24px; }
  .view-posts > .page-hdr, .view-posts > .date-btn, .view-posts > .tags, .view-posts > .plist { grid-column: 1; }
  .view-posts #filters { display: none; }
  .view-posts .plist { grid-template-columns: minmax(0, 1fr); }
  .filters-panel { grid-column: 2; grid-row: 1 / span 4; position: sticky; top: 24px;
    display: flex; flex-direction: column; gap: 12px; max-height: calc(100dvh - 48px); overflow-y: auto; }
  /* topics and tone stay in view: only the channel list scrolls (the panel itself only below ~720 px height) */
  .filters-panel > * { flex-shrink: 0; }
  .filters-panel .cp-list { flex: 0 1 auto; min-height: 132px; overflow-y: auto; overscroll-behavior: contain;
    scrollbar-gutter: stable; margin-top: -8px; padding-right: 12px; border-bottom: 1px solid var(--line); }
  .filters-panel .chips button { min-height: 32px; padding: 4px 10px; font-size: 12.5px; }
  .filters-panel .seg button { padding-inline: 4px; min-width: 0; }
  .filters-panel .input-wrap { min-width: 0; }
  .filters-panel .input-wrap input { min-width: 0; padding-right: 36px; }
  .filters-panel [data-cp-search-clear] { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
  .filters-panel input::-webkit-search-cancel-button { -webkit-appearance: none; }
  .filters-panel .cp-row { gap: 8px; }
  .filters-panel .cp-row small { overflow: hidden; text-overflow: ellipsis; }
  .filters-panel .cp-row:hover { background: var(--surface2); }
}

/* ---- leader ---- */
.leader-shell, .leader-overlay {
  --leader-selected: #F2F6FF; --leader-zone-pos: #C3E4EA; --leader-zone-neu: #DCE2EA; --leader-zone-neg: #F6D5C4;
  --leader-white: #FFFFFF; --leader-tooltip: #0F1B2D; --leader-gutter: 16px; --leader-period-height: 92px;
  --leader-sticky-shadow: 0 8px 8px -8px rgba(15,27,45,.18);
}
:root[data-theme="dark"] .leader-shell, :root[data-theme="dark"] .leader-overlay {
  --leader-selected: var(--primarySoft); --leader-zone-pos: #24515D; --leader-zone-neu: #344456; --leader-zone-neg: #714A39;
  --leader-sticky-shadow: 0 8px 8px -8px rgba(0,0,0,.4);
}
.leader-shell { display: grid; grid-template-rows: minmax(0,1fr) auto; height: 100vh; height: 100dvh; width: 100%; }
.leader-shell button, .leader-overlay button { touch-action: manipulation; }
.leader-shell button:focus-visible, .leader-overlay button:focus-visible, .leader-overlay input:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 3px;
}
.leader-content { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.leader-header { flex: none; display: flex; align-items: center; gap: 10px; padding: 14px var(--leader-gutter) 10px; min-height: 66px; }
.leader-header h1 { font-size: 22px; line-height: 1.3; font-weight: 700; margin: 0; }
.leader-shell[data-tab="home"] .leader-header h1 { font-size: 16px; font-weight: 600; }
.leader-header p { font-size: 12px; color: var(--muted); margin: 1px 0 0; }
.leader-header .icon-btn { width: 40px; height: 40px; }
.leader-scroll { min-height: 0; min-width: 0; flex: 1; overflow-y: auto; padding: 0 var(--leader-gutter) 20px; overscroll-behavior: contain; }
.leader-nav { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.leader-nav button { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: transparent; font-size: 11px; font-weight: 500; color: var(--muted); }
.leader-nav button[aria-current] { color: var(--primary); }
.leader-period { position: sticky; top: 0; z-index: 4; height: var(--leader-period-height); display: flex; flex-direction: column; gap: 6px;
  padding: 2px var(--leader-gutter) 6px; margin: 0 calc(-1 * var(--leader-gutter)); background: var(--bg); }
.leader-seg { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); padding: 3px; gap: 3px; background: var(--seg); border-radius: 12px; }
.leader-seg.grid2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.leader-seg button, .leader-tones button { border: 0; border-radius: 9px; background: transparent; min-width: 0; font-size: 13px; font-weight: 500; min-height: 36px; padding: 0 5px; color: var(--ink2); }
.leader-seg button[aria-pressed="true"], .leader-tones button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.leader-date { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 36px; }
.leader-date > svg { color: var(--muted); flex: none; }
.leader-date b { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; line-height: 1.2; }
.leader-card { min-width: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 14px 16px; }
.leader-card h2 { font-size: 15px; font-weight: 600; margin: 0; line-height: 1.4; }
.leader-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.leader-shell small, .leader-overlay small { color: var(--muted); font-size: 12px; font-weight: 400; }
.leader-shell .pos, .leader-overlay .pos { color: var(--pos); }
.leader-shell .neg, .leader-overlay .neg { color: var(--neg); }
.leader-shell .neu, .leader-shell .muted { color: var(--muted); }
.leader-home { display: grid; gap: 12px; }
.leader-info { position: relative; flex: none; }
.leader-info .icon-btn { width: 32px; height: 32px; }
.leader-info [role="tooltip"] { display: none; position: absolute; right: 0; top: 35px; width: min(264px,75vw); z-index: 6; background: var(--leader-tooltip); color: var(--leader-white); font-size: 12px; padding: 10px 12px; border-radius: 10px; box-shadow: var(--shadow); }
.leader-info:hover [role="tooltip"], .leader-info:focus-within [role="tooltip"], .leader-info.open [role="tooltip"] { display: block; }
.leader-gauge { display: flex; flex-direction: column; align-items: center; width: 100%; padding: 0; border: 0; background: transparent; }
.leader-gauge svg { display: block; width: 100%; max-width: 300px; height: auto; }
.leader-gauge strong { font-size: 40px; font-weight: 700; letter-spacing: -1px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.leader-gauge > span { font-size: 13px; font-weight: 600; }
.leader-zone-pos { stroke: var(--leader-zone-pos); }.leader-zone-neu { stroke: var(--leader-zone-neu); }.leader-zone-neg { stroke: var(--leader-zone-neg); }
.leader-ticks { fill: var(--muted); font-size: 11px; }.leader-hub { fill: var(--ink); }.leader-pin { fill: var(--leader-white); }
.leader-compare { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line); }
.leader-compare > div { display: flex; align-items: center; flex-direction: column; gap: 2px; text-align: center; }
.leader-compare > div + div { border-left: 1px solid var(--line); }
.leader-compare b { font-size: 15px; font-weight: 600; }
.leader-change { display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.leader-bar { display: flex; height: 12px; background: var(--surface2); gap: 2px; border-radius: 6px; overflow: hidden; margin: 12px 0; }
.leader-bar > span { flex-basis: 0; transition: flex-grow .55s cubic-bezier(.2,.8,.2,1); }
.leader-bar .pos, .leader-topic-bar .pos, .leader-legend .pos { background: var(--pos); }
.leader-bar .neu, .leader-topic-bar .neu, .leader-legend .neu { background: var(--neu); }
.leader-bar .neg, .leader-topic-bar .neg, .leader-legend .neg { background: var(--neg); }
.leader-shares { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.leader-shares button { display: flex; flex-direction: column; align-items: center; border: 0; padding: 0; background: transparent; min-width: 0; border-radius: 10px; }
.leader-shares button > span { display: inline-flex; align-items: center; font-size: 12.5px; font-weight: 600; }
.leader-shares b { font-size: 22px; font-weight: 700; }
.leader-shares small { font-size: 12px; }
.leader-shares small:last-child { min-height: 18px; }
.leader-distribution .leader-card-head { flex-wrap: wrap; }
.leader-coverage { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); padding: 12px 0; }
.leader-coverage > div { text-align: center; display: flex; flex-direction: column; padding: 0 4px; }
.leader-coverage > div + div { border-left: 1px solid var(--line); }
.leader-coverage b { font-size: 15px; font-weight: 600; }
.leader-shell [data-number], .leader-shell [data-post-count] { font-variant-numeric: tabular-nums; }
.leader-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--ink2); margin-bottom: 4px; }
.leader-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.leader-legend i { width: 10px; height: 10px; border-radius: 3px; }
.leader-legend small { margin-left: auto; }
.leader-topic-rows { display: grid; }
.leader-topic-row { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 11px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; min-width: 0; }
.leader-topic-row:last-child { border-bottom: 0; }
.leader-topic-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; width: 100%; }
.leader-topic-line b { font-size: 14px; font-weight: 500; }
.leader-topic-tones { font-size: 12px; white-space: nowrap; }
.leader-topic-line strong { margin-left: auto; font-size: 14px; font-weight: 600; }
.leader-topic-line small { width: 36px; text-align: right; }
.leader-topic-bar { display: block; height: 8px; width: 100%; border-radius: 4px; overflow: hidden; background: var(--surface2); }
.leader-topic-bar > span { display: flex; height: 100%; gap: 1px; transition: width .55s cubic-bezier(.2,.8,.2,1); }
.leader-topic-bar i { flex-basis: 0; transition: flex-grow .55s cubic-bezier(.2,.8,.2,1); }
.leader-settings { display: grid; gap: 12px; padding-top: 2px; }
.leader-settings .leader-card > h2, .leader-settings .leader-card-head { margin-bottom: 10px; }
.leader-tiles { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.leader-tiles button { display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 9px 10px; text-align: left; background: var(--surface); border: 1px solid var(--field); border-radius: 12px; min-width: 0; }
.leader-tiles button > span:last-child { font-size: 13px; font-weight: 500; line-height: 1.3; overflow-wrap: normal; }
/* two columns cannot hold "Makroiqtisodiyot" in one piece below 390 px */
@media (max-width: 389px) { .leader-tiles { grid-template-columns: 1fr; } }
.leader-tiles button[aria-pressed="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--leader-selected); }
.leader-check { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; border: 1.5px solid var(--field); border-radius: 6px; color: var(--leader-white); }
.leader-check svg { visibility: hidden; }
[aria-pressed="true"] > .leader-check { background: var(--btn); border-color: var(--btn); }
[aria-pressed="true"] > .leader-check svg { visibility: visible; }
.leader-digest { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; border: 0; background: transparent; text-align: left; padding: 0; }
.leader-digest > span:nth-child(2) { flex: 1; min-width: 0; }
.leader-digest b { font-size: 14.5px; font-weight: 600; }
.leader-digest small, .leader-account small { display: block; }
.leader-switch { flex: none; width: 38px; height: 22px; padding: 3px; border-radius: 20px; background: var(--field); }
.leader-switch i { display: block; width: 16px; height: 16px; background: var(--leader-white); border-radius: 50%; }
.leader-digest[aria-checked="true"] .leader-switch { background: var(--btn); }
.leader-digest[aria-checked="true"] .leader-switch i { transform: translateX(16px); }
.leader-account { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; }
.leader-account > div { min-width: 0; overflow-wrap: anywhere; }
.leader-logout { display: flex; align-items: center; gap: 12px; min-height: 48px; width: 100%; padding: 0; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--neg); font-weight: 600; }
.leader-picker-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.leader-picker-meta .link { text-align: right; }
.leader-channel { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; min-height: 64px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.leader-avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--primarySoft); color: var(--primary); font-size: 13px; font-weight: 600; }
.leader-channel-name { flex: 1; min-width: 0; }
.leader-channel-name b { font-size: 14px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-channel-name small { display: block; overflow-wrap: anywhere; }
.leader-onboarding { grid-row: 1 / -1; min-height: 0; display: flex; flex-direction: column; }
.leader-onboard-header { display: flex; align-items: center; gap: 10px; flex: none; padding: 16px; }
.leader-onboard-header b { font-size: 16px; font-weight: 600; }
.leader-onboard-header small { margin-left: auto; white-space: nowrap; }
.leader-onboard-main { overflow-y: auto; min-height: 0; flex: 1; padding: 8px var(--leader-gutter) 24px; }
.leader-onboard-main h1 { font-size: 24px; line-height: 1.2; font-weight: 700; margin: 0 0 10px; letter-spacing: -.4px; }
.leader-onboard-main > p { font-size: 13px; color: var(--muted); line-height: 1.45; margin: 0 0 20px; }
.leader-onboarding footer { display: flex; gap: 8px; padding: 12px var(--leader-gutter) max(16px,env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.leader-onboarding footer .secondary { flex: 1; }.leader-onboarding footer .primary { flex: 2; }
.leader-news { display: grid; grid-template-columns: minmax(0,1fr); }
.leader-news-top { display: contents; }
.leader-news-filters { position: sticky; top: var(--leader-period-height); z-index: 3; background: var(--bg); padding: 4px var(--leader-gutter) 10px; margin: 0 calc(-1 * var(--leader-gutter)); box-shadow: var(--leader-sticky-shadow); }
.leader-tones { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 3px; padding: 3px; border-radius: 12px; background: var(--seg); }
.leader-tones button { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 2px; font-size: 12.5px; }
.leader-tones small { font-size: 11.5px; font-weight: 600; }
.leader-news-count { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.leader-news-count > span { font-size: 13px; color: var(--muted); }
.leader-news-count button { display: inline-flex; align-items: center; justify-content: center; flex: none; height: 36px; gap: 5px; font-size: 13px; font-weight: 600; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.leader-post-list { display: grid; gap: 12px; padding-top: 12px; min-width: 0; align-content: start; }
.leader-post-list .boot { min-height: 120px; }
.leader-post-list .pcard { margin: 0; min-width: 0; }
.leader-post-list .pfoot b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.leader-post-list .pviews, .leader-post-list .psrc { flex: none; }
.leader-empty { text-align: center; color: var(--muted); margin: 24px 0; }
.leader-news-aside { display: none; }
.leader-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.leader-backdrop { position: absolute; inset: 0; background: var(--backdrop); border: 0; }
.leader-dialog { display: flex; flex-direction: column; position: relative; width: 100%; max-height: 90dvh; padding: 16px; border-radius: 18px 18px 0 0; background: var(--surface); box-shadow: var(--shadow); }
.leader-channels-overlay .leader-dialog { height: 100dvh; max-height: 100dvh; border-radius: 0; }
.leader-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; }
.leader-dialog-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.leader-dialog-head button { min-height: 36px; }
.leader-dialog-body { overflow-y: auto; min-height: 0; padding: 3px; margin: -3px; }
.leader-sort-options { display: grid; }
.leader-sort-options button { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.leader-sort-options button > span { flex: 1; }.leader-sort-options b { font-size: 14px; font-weight: 600; }.leader-sort-options small { display: block; }
.leader-sort-options button > svg { color: var(--primary); }
@media (max-width:359px) {
  .leader-shell, .leader-overlay { --leader-gutter: 12px; }
  .leader-card { padding-left: 12px; padding-right: 12px; }.leader-coverage { padding-left: 0; padding-right: 0; }
  .leader-gauge strong { font-size: 34px; }.leader-nav button { font-size: 10.5px; }.leader-tones button { font-size: 12px; }
  .leader-tiles button { padding: 8px; gap: 6px; }.leader-shares { gap: 4px; }.leader-shares button > span { font-size: 12px; }
  .leader-shares small:last-child { font-size: 10.5px; }.leader-news-count button { font-size: 12px; gap: 3px; }
}
@media (min-width:600px) {
  .leader-shell { grid-template-columns: 96px minmax(0,1fr); grid-template-rows: minmax(0,1fr); }
  .leader-shell { --leader-period-height: 60px; }
  .leader-content { grid-column: 2; grid-row: 1; width: 100%; max-width: 880px; margin: 0 auto; }
  .leader-nav { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; padding: 20px 8px; gap: 6px; border-top: 0; border-right: 1px solid var(--line); }
  .leader-nav button { min-height: 72px; border-radius: 12px; font-size: 11px; }.leader-nav button[aria-current] { background: var(--primarySoft); }
  .leader-header { padding-top: 20px; padding-bottom: 16px; }
  .leader-period { flex-direction: row; align-items: center; gap: 12px; padding-top: 4px; padding-bottom: 10px; }
  .leader-period .leader-seg { flex: 1; max-width: 360px; min-width: 135px; }
  .leader-period .leader-date { flex: 1; }.leader-date b { font-size: 12px; }.leader-date { gap: 5px; }
  .leader-home { grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-rows: auto 1fr; align-items: start; }
  .leader-mood { grid-row: span 2; }.leader-coverage { grid-column: 2; }
  .leader-topic-rows { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 24px; }
  .leader-settings { grid-template-columns: repeat(2,minmax(0,1fr)); align-content: start; align-items: start; }
  .leader-settings-topics { grid-column: 1 / -1; }.leader-tiles { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .leader-post-list { grid-template-columns: repeat(2,minmax(0,1fr)); }.leader-post-list > .btn, .leader-post-list > .boot, .leader-post-list > .leader-empty, .leader-post-list > [data-post-error] { grid-column: 1 / -1; }
  .leader-onboarding { grid-column: 1 / -1; width: calc(100% - 32px); max-width: 560px; margin: 24px auto; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); }
  .leader-overlay { align-items: center; padding: 24px; }.leader-dialog { max-width: 400px; max-height: 80dvh; border-radius: 16px; }
  .leader-channels-overlay .leader-dialog { max-width: 520px; max-height: 80dvh; height: auto; border-radius: 16px; }
}
@media (min-width:1024px) {
  .leader-content { max-width: 1200px; }.leader-home { grid-template-columns: minmax(0,1.22fr) minmax(0,1fr); }
  .leader-date b { font-size: 14px; }.leader-home .leader-mood { padding-top: 20px; padding-bottom: 20px; }
  .leader-topic-rows { grid-template-columns: repeat(auto-fit,minmax(320px,1fr)); }
  .leader-news { grid-template-columns: minmax(0,760px) 320px; gap: 20px; align-items: start; }
  .leader-news-top, .leader-news-filters { display: none; }.leader-post-list { grid-template-columns: minmax(0,1fr); padding-top: 0; }
  .leader-news-aside { display: flex; flex-direction: column; position: sticky; top: 0; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
  .leader-news-aside .leader-period { position: static; display: flex; flex-direction: column; height: auto; margin: 0; padding: 0; background: transparent; }
  .leader-news-aside .leader-seg, .leader-news-aside .leader-date { width: 100%; }.leader-news-aside .leader-date b { font-size: 12px; }
  .leader-news-aside .leader-tones { grid-template-columns: 1fr; }.leader-news-aside .leader-tones button { flex-direction: row; justify-content: space-between; padding: 8px 10px; }
  .leader-news-aside .leader-sort-options button[aria-pressed="true"] { color: var(--primary); }.leader-news-aside > span { font-size: 13px; color: var(--muted); }
  .leader-news-aside .leader-sort-options button::before { content: ''; flex: none; width: 16px; height: 16px; border: 1.5px solid var(--field); border-radius: 50%; }
  .leader-news-aside .leader-sort-options button[aria-pressed="true"]::before { border-color: var(--primary); background: radial-gradient(var(--primary) 0 4px,transparent 4px); }
  .leader-news-aside .leader-sort-options button > svg { display: none; }
  .leader-settings { grid-template-columns: repeat(3,minmax(0,1fr)); }.leader-settings-topics { grid-column: 1 / 3; grid-row: 1 / 5; }
  .leader-settings > .leader-card:not(.leader-settings-topics) { grid-column: 3; }.leader-settings-topics .leader-tiles { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .leader-channels-overlay .leader-channels { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); column-gap: 16px; }
}
@media (prefers-reduced-motion:reduce) {
  .leader-shell *, .leader-overlay * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
