:root {
  --sidebar: #151b26;
  --sidebar-soft: #202838;
  --sidebar-active: #2d374a;
  --canvas: #f4f6f9;
  --card: #ffffff;
  --border: #dfe4ec;
  --text: #4f5661;
  --strong: #1f2735;
  --muted: #9aa5b5;
  --green: #4fb276;
  --blue: #3f84e5;
  --red: #cf5261;
  --shadow: 0 14px 34px rgba(31, 39, 53, 0.08);
  font-family: "Avenir Next", "Segoe UI", Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--canvas);
  overflow-x: hidden;
}

button,
a,
input,
select,
summary,
[tabindex] {
  -webkit-tap-highlight-color: rgba(79, 178, 118, 0.18);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(63, 132, 229, 0.42);
  outline-offset: 3px;
}

.file-warning {
  display: none;
  padding: 14px 18px;
  color: #7a3b00;
  background: #fff1d6;
  border-bottom: 1px solid #f1c879;
  font-weight: 800;
}

.file-warning code {
  color: #1f2735;
}

.file-protocol .file-warning {
  display: block;
}

button,
input {
  font: inherit;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  transform: translateY(-140%);
  padding: 10px 14px;
  border-radius: 6px;
  background: #fff;
  color: var(--strong);
  box-shadow: var(--shadow);
  font-weight: 900;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ui-icon,
.icon svg {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.ui-icon svg,
.icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  transition: grid-template-columns 0.18s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 84px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  color: #d9e1ee;
  background: var(--sidebar);
  overflow-y: auto;
}

.brand {
  height: 78px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-toggle {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  color: #d9e1ee;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.sidebar-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.brand strong {
  color: #fff;
  letter-spacing: 0;
}

.project-card {
  padding: 22px;
  background: var(--sidebar-soft);
  border-left: 4px solid var(--green);
}

.eyebrow {
  display: block;
  color: #aab5c5;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.project-name {
  margin-top: 18px;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
}

.project-status {
  margin-top: 6px;
  color: #8f9daf;
}

.project-status span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
}

.nav-list {
  display: grid;
  gap: 2px;
  padding: 16px 0;
}

.nav-list a {
  display: flex;
  gap: 13px;
  align-items: center;
  color: #8f9daf;
  text-decoration: none;
  padding: 14px 24px;
  font-weight: 700;
}

.nav-list a.active,
.nav-list a:hover {
  color: #fff;
  background: var(--sidebar-active);
}

.sidebar-collapsed .brand {
  justify-content: center;
  padding: 14px;
}

.sidebar-collapsed .brand strong,
.sidebar-collapsed .project-card,
.sidebar-collapsed .nav-list b {
  display: none;
}

.sidebar-collapsed .brand-logo {
  width: 38px;
  height: 38px;
}

.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  top: 62px;
  right: 12px;
  width: 28px;
  height: 28px;
}

.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar-collapsed .nav-list a {
  justify-content: center;
  padding: 16px;
}

.sidebar-collapsed .nav-list a {
  position: relative;
}

.sidebar-collapsed .nav-list a:hover::after,
.sidebar-collapsed .nav-list a:focus-visible::after {
  content: attr(aria-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  z-index: 20;
  transform: translateY(-50%);
  min-width: max-content;
  padding: 7px 9px;
  border-radius: 6px;
  color: #fff;
  background: var(--strong);
  font-size: 12px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.nav-list span {
  color: var(--green);
}

.workspace {
  min-width: 0;
}

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--card);
  box-shadow: 0 1px 0 var(--border);
}

.search-box {
  width: min(680px, 64vw);
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--strong);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.top-actions button,
.segmented button,
.sort-button,
.filter-toggle {
  border: 1px solid var(--border);
  color: var(--text);
  background: #fff;
  border-radius: 5px;
  padding: 10px 14px;
  cursor: pointer;
}

.filter-toggle {
  display: none;
}

.avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--strong);
  border-radius: 50%;
  font-weight: 800;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  padding: 24px;
}

.main-column {
  display: grid;
  gap: 22px;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.panel,
.filter-panel,
.mentions-panel {
  background: var(--card);
  border: 1px solid #edf0f4;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.chart-panel {
  padding: 28px 30px 22px;
}

.chart-hint,
.filter-hint {
  margin: 14px 0 0;
  color: #6f7a8c;
  font-size: 13px;
  line-height: 1.45;
}

.date-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr)) minmax(120px, auto) minmax(170px, auto);
  gap: 10px;
  margin-top: 16px;
  align-items: end;
}

.date-tools label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.date-tools input,
.date-tools select {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 10px;
  color: var(--strong);
  background: #fff;
}

.comparison-toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
}

.panel-toolbar,
.section-head,
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--border);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented .selected {
  color: #fff;
  background: var(--green);
}

.segmented.compact .selected {
  background: #fff;
  color: var(--strong);
}

.chart-wrap {
  position: relative;
  margin-top: 22px;
  width: 100%;
  overflow: visible;
}

#trendChart {
  width: 100%;
  min-width: 0;
  height: auto;
  display: block;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  padding-left: 4px;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend span::after {
  content: "";
  width: 26px;
  height: 3px;
  order: -1;
}

.legend-blue::after {
  background: var(--blue);
}

.legend-green::after {
  background: var(--green);
}

.legend-red::after {
  background: var(--red);
}

.legend-muted::after {
  background: repeating-linear-gradient(90deg, #8792a2 0 8px, transparent 8px 14px);
}

.chart-tooltip {
  position: fixed;
  z-index: 50;
  width: min(360px, calc(100vw - 24px));
  max-height: min(460px, calc(100vh - 48px));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(31, 39, 53, 0.18);
}

.chart-tooltip strong,
.chart-tooltip > span,
.chart-tooltip > b {
  display: block;
}

.chart-tooltip > span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.chart-tooltip > b {
  margin-top: 12px;
  color: var(--strong);
  font-size: 13px;
}

.chart-tooltip.mobile {
  max-height: 55vh;
  border-radius: 12px 12px 8px 8px;
}

.tooltip-posts {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.tooltip-posts button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border: 0;
  padding: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.tooltip-posts small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.analysis-panel {
  padding: 24px;
}

.section-head h2,
.top-mentions h3,
.filter-panel h3 {
  margin: 0;
  color: var(--strong);
  font-size: 18px;
}

.section-head span {
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.kpi-card {
  min-height: 92px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-areas:
    "icon value"
    "icon label"
    "icon delta";
  align-content: center;
  gap: 4px 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}

.kpi-card .icon {
  grid-area: icon;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef7f2;
  color: #aeb8c6;
}

.kpi-card .value {
  grid-area: value;
  color: var(--green);
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  overflow-wrap: anywhere;
}

.kpi-card .label {
  grid-area: label;
  color: #8995a6;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
}

.kpi-delta {
  grid-area: delta;
  width: fit-content;
  padding: 4px 7px;
  border-radius: 999px;
  background: #f2f4f7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.kpi-delta.above {
  background: #eaf7ef;
  color: #2f7d50;
}

.kpi-delta.below {
  background: #fff0f2;
  color: #a63a48;
}

.mentions-panel {
  padding: 0;
  overflow: hidden;
}

.list-head {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.sort-button {
  font-weight: 800;
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  font-weight: 800;
}

.sort-control select {
  border: 0;
  color: var(--text);
  background: transparent;
  font-weight: 800;
}

.result-count {
  color: var(--muted);
}

.mentions-list {
  display: grid;
}

.mention-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 124px;
  gap: 18px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
}

.mention-body {
  min-width: 0;
}

.mention-card:last-child {
  border-bottom: 0;
}

.source-avatar {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: var(--green);
  background: #f3f7f5;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-weight: 900;
}

.thumb-frame {
  position: relative;
  display: block;
  flex: 0 0 auto;
  aspect-ratio: 1 / 1;
}

.thumb-frame.thumb {
  width: 58px;
  height: 58px;
}

.thumb-frame.mini {
  width: 38px;
  height: 38px;
}

.thumb-frame.tiny {
  width: 34px;
  height: 34px;
}

.thumb-frame.large {
  width: 116px;
  height: 116px;
}

.thumb-frame .thumb-fallback {
  display: none;
  position: absolute;
  inset: 0;
}

.thumb-frame.thumb-failed .post-thumb {
  display: none;
}

.thumb-frame.thumb-failed .thumb-fallback {
  display: grid;
}

.source-avatar.thumb,
.post-thumb.thumb {
  width: 58px;
  height: 58px;
}

.source-avatar.mini,
.post-thumb.mini {
  width: 38px;
  height: 38px;
}

.source-avatar.tiny,
.post-thumb.tiny {
  width: 34px;
  height: 34px;
}

.source-avatar.large,
.post-thumb.large {
  width: 116px;
  height: 116px;
  border-radius: 8px;
}

.post-thumb {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f3f7f5;
}

.mention-body h3 {
  margin: 0 0 7px;
  color: var(--strong);
  font-size: 17px;
}

.mention-body p {
  margin: 0;
  color: #6b7280;
  line-height: 1.55;
}

.mention-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mention-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}

.sentiment-pill {
  display: inline-block;
  align-self: start;
  border: 0;
  border-radius: 18px;
  padding: 8px 14px;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.sentiment-positive {
  background: var(--green);
}

.sentiment-negative {
  background: var(--red);
}

.sentiment-neutral,
.sentiment-unknown {
  background: #8792a2;
}

.mention-actions {
  display: grid;
  gap: 10px;
  justify-items: end;
  align-self: start;
}

.mention-actions button,
.pagination button,
.dialog-close {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
}

.mention-actions button:hover,
.pagination button:hover,
.dialog-close:hover {
  border-color: var(--green);
  color: var(--green);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.post-dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: min(90vh, 980px);
  border: 0;
  border-radius: 8px;
  padding: 26px;
  box-shadow: 0 30px 90px rgba(21, 27, 38, 0.25);
  overflow: auto;
}

.post-dialog::backdrop {
  background: rgba(21, 27, 38, 0.55);
}

.dialog-close {
  float: right;
  font-size: 22px;
  line-height: 1;
}

.post-dialog h2 {
  margin: 0 42px 10px 0;
  color: var(--strong);
  font-size: 22px;
  line-height: 1.25;
}

.dialog-hero {
  display: grid;
  grid-template-columns: 156px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.dialog-hero-copy {
  min-width: 0;
}

.dialog-kicker {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dialog-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.instagram-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

.instagram-link:hover {
  background: #3b9a62;
}

.instagram-link.disabled {
  background: #eef2f6;
  color: var(--muted);
}

.metric-warning {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid #f0c774;
  border-radius: 6px;
  background: #fff8e6;
  color: #7a5a0d;
  font-weight: 700;
}

.dialog-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.dialog-meta-row span {
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.dialog-meta-row b {
  color: var(--text);
}

.dialog-section {
  margin-top: 22px;
}

.dialog-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.dialog-section h3,
.dialog-section-head h3 {
  margin: 0;
  color: var(--strong);
}

.dialog-section-head span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.detail-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.detail-stat-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.detail-stat-card span,
.comparison-card small,
.comparison-line small {
  color: var(--muted);
  font-size: 12px;
}

.detail-stat-card strong {
  display: block;
  margin: 6px 0;
  color: var(--strong);
  font-size: 21px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.detail-stat-card small {
  display: block;
  color: var(--muted);
  line-height: 1.35;
}

.ranking-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.rank-chip {
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf7f1;
  color: #2f7d50;
  font-weight: 900;
  font-size: 13px;
}

.rank-chip.unavailable {
  background: #f2f4f7;
  color: var(--muted);
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.comparison-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}

.comparison-card h4 {
  margin: 0 0 3px;
  color: var(--strong);
}

.comparison-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.comparison-card small + .comparison-line {
  margin-top: 8px;
}

.comparison-line span {
  color: var(--text);
  font-weight: 800;
}

.comparison-line b {
  color: var(--strong);
}

.comparison-line small {
  grid-column: 1 / -1;
}

.video-analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.video-analysis-grid article,
.video-feature-comparison article {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}

.video-analysis-grid h4,
.video-feature-comparison h4 {
  margin: 0 0 8px;
  color: var(--strong);
}

.video-analysis-grid p,
.timeline-list,
.video-feature-comparison span,
.video-feature-comparison small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.timeline-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.color-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.color-row span {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
}

.video-feature-comparison {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.video-feature-comparison article {
  display: grid;
  gap: 4px;
}

.video-feature-comparison strong {
  color: var(--strong);
}

.dialog-comments {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
}

.dialog-comments article {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.dialog-comments p {
  margin: 6px 0;
}

.dialog-comments small {
  color: var(--muted);
}

.right-rail {
  display: grid;
  gap: 22px;
  align-content: start;
  position: relative;
  z-index: 0;
}

.filter-panel {
  padding: 22px;
}

.filter-close {
  display: none;
}

.date-range {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  margin-bottom: 24px;
}

.filter-panel h3 {
  margin-top: 16px;
  margin-bottom: 12px;
  font-size: 14px;
}

.filter-group {
  padding: 15px 0;
  border-top: 1px solid var(--border);
}

.filter-group summary {
  color: var(--strong);
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}

.filter-group summary::-webkit-details-marker {
  display: none;
}

.filter-group summary::after {
  content: "⌄";
  float: right;
  color: var(--muted);
}

.filter-group[open] summary::after {
  content: "⌃";
}

.filter-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.filter-list.single {
  grid-template-columns: 1fr;
}

.filter-list label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  min-width: 0;
  padding: 4px 0;
}

.filter-list input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.filter-list small {
  color: var(--muted);
}

.filter-list .filter-active {
  color: var(--green);
}

.filter-list .filter-zero {
  color: #b4bdca;
}

.filter-list .filter-zero input {
  cursor: not-allowed;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag-cloud button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 18px;
  padding: 7px 10px;
  cursor: pointer;
}

.tag-cloud button.active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.tag-cloud button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.help-button {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  margin-left: 6px;
  border: 1px solid #cfd7e3;
  border-radius: 50%;
  color: #7f8da0;
  background: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
}

.help-button:hover,
.help-button:focus-visible {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.help-tooltip {
  position: fixed;
  z-index: 80;
  width: min(340px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - 48px));
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(31, 39, 53, 0.2);
}

.help-tooltip strong,
.help-tooltip span {
  display: block;
}

.help-tooltip strong {
  color: var(--strong);
  font-size: 15px;
}

.help-tooltip span {
  margin-top: 10px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.help-tooltip p {
  margin: 4px 0 0;
  color: #5e6877;
  font-size: 13px;
  line-height: 1.45;
}

.help-tooltip.mobile {
  border-radius: 12px 12px 8px 8px;
}

.recommendation-panel,
.video-queue-panel {
  padding: 22px;
}

.recommendation-panel p,
.video-queue-panel p,
.empty-state {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.recommendation-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.recommendation-card:last-child,
.queue-item:last-child {
  border-bottom: 0;
}

.recommendation-card strong,
.queue-item strong {
  color: var(--strong);
}

.recommendation-card span,
.recommendation-card small,
.queue-item small,
.queue-summary small {
  color: var(--muted);
  font-size: 12px;
}

.recommendation-card > b {
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.recommendation-card small,
.recommendation-card button {
  grid-column: 1 / -1;
}

.recommendation-card button,
.queue-item button,
.video-analysis-button {
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  font-weight: 800;
  cursor: pointer;
}

.recommendation-card button:hover,
.queue-item button:hover,
.video-analysis-button:hover {
  border-color: var(--green);
  color: var(--green);
}

.queue-summary {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}

.queue-api-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #657186;
  background: #fbfcfe;
  font-size: 12px;
  font-weight: 800;
}

.queue-api-status.offline {
  color: #9c3d49;
  background: #fff4f5;
  border-color: #f3cbd1;
}

.queue-api-status.online {
  color: #2f7d50;
  background: #eef8f2;
  border-color: #cce9d7;
}

.queue-summary strong {
  color: var(--strong);
  font-size: 24px;
}

.queue-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.queue-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.queue-list {
  display: grid;
  margin-top: 10px;
}

.queue-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #aeb8c6;
}

.status-dot.completed {
  background: var(--green);
}

.status-dot.failed {
  background: var(--red);
}

.status-dot.downloading,
.status-dot.extracting,
.status-dot.analyzing {
  background: var(--blue);
}

.top-mentions {
  padding: 22px;
}

.top-rank {
  display: grid;
  grid-template-columns: 34px 38px minmax(0, 1fr);
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.top-rank:last-child {
  border-bottom: 0;
}

.rank-badge {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 50%;
  font-weight: 900;
}

.top-rank p {
  margin: 0;
  color: var(--strong);
  line-height: 1.45;
}

.top-rank small {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .brand strong,
  .project-card,
  .nav-list b {
    display: none;
  }

  .brand {
    justify-content: center;
    padding: 14px;
  }

  .nav-list a {
    justify-content: center;
    padding: 16px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .right-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .date-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  }

  .filter-panel {
    order: 2;
  }

  .top-mentions {
    order: 1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .app-shell.sidebar-collapsed {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
  }

  .sidebar-collapsed .brand strong,
  .sidebar-collapsed .project-card,
  .sidebar-collapsed .nav-list b {
    display: block;
  }

  .sidebar-collapsed .sidebar-toggle {
    position: static;
    width: 34px;
    height: 34px;
  }

  .brand strong,
  .project-card,
  .nav-list b {
    display: block;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding: 8px;
  }

  .nav-list a {
    flex: 0 0 auto;
    justify-content: flex-start;
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 6px;
  }

  .topbar {
    height: auto;
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
  }

  .search-box {
    width: 100%;
  }

  .top-actions {
    justify-content: space-between;
  }

  .filter-toggle {
    display: inline-flex;
  }

  .date-tools {
    grid-template-columns: 1fr;
  }

  .comparison-toggle {
    display: flex;
    gap: 8px;
  }

  .dashboard-grid {
    padding: 12px;
    gap: 12px;
  }

  .panel-toolbar,
  .section-head,
  .list-head {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    padding-inline: 8px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .kpi-card {
    min-height: 88px;
    grid-template-columns: 28px minmax(0, 1fr);
    padding: 12px;
  }

  .kpi-card .icon {
    width: 28px;
    height: 28px;
  }

  .kpi-card .value {
    font-size: 20px;
  }

  .chart-panel,
  .analysis-panel,
  .mentions-panel,
  .top-mentions {
    border-radius: 8px;
    box-shadow: none;
  }

  .chart-panel,
  .analysis-panel,
  .top-mentions {
    padding: 16px;
  }

  .filter-panel {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 60;
    width: min(420px, 100vw);
    height: 100vh;
    overflow: auto;
    padding: 16px;
    transform: translateX(105%);
    transition: transform 0.2s ease;
    border-radius: 0;
    box-shadow: 0 0 0 999px rgba(21, 27, 38, 0);
  }

  body.filters-open .filter-panel {
    transform: translateX(0);
    box-shadow: 0 0 0 999px rgba(21, 27, 38, 0.45);
  }

  .filter-close {
    display: grid;
    place-items: center;
    margin-left: auto;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--strong);
    font-size: 22px;
  }

  #trendChart {
    height: 230px;
  }

  .legend {
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
  }

  .right-rail {
    grid-template-columns: 1fr;
  }

  .top-mentions {
    order: -1;
  }

  .filter-list {
    grid-template-columns: 1fr;
  }

  .filter-group:not([open]) {
    padding-bottom: 12px;
  }

  .mention-card {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .source-avatar {
    width: 44px;
    height: 44px;
  }

  .post-thumb.thumb {
    width: 44px;
    height: 44px;
  }

  .thumb-frame.thumb {
    width: 44px;
    height: 44px;
  }

  .mention-body h3 {
    font-size: 15px;
  }

  .mention-body p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    font-size: 14px;
  }

  .mention-meta {
    gap: 6px;
  }

  .mention-meta span {
    padding: 4px 7px;
    border-radius: 12px;
    background: #f3f6fa;
    font-size: 12px;
  }

  .sentiment-pill {
    width: fit-content;
  }

  .mention-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    justify-items: start;
  }

  .post-dialog {
    margin: auto 0 0;
    width: 100vw;
    max-width: 100vw;
    max-height: 92vh;
    padding: 18px;
    border-radius: 14px 14px 0 0;
  }

  .post-dialog h2 {
    margin-right: 34px;
    font-size: 19px;
  }

  .dialog-hero {
    grid-template-columns: 1fr;
  }

  .dialog-section-head {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .dialog-section-head span {
    text-align: left;
  }

  .detail-stat-grid,
  .comparison-grid,
  .video-analysis-grid {
    grid-template-columns: 1fr;
  }

  .dialog-meta-row span,
  .comparison-line {
    font-size: 13px;
  }
}
