:root {
  --bg: #0b0e14;
  --bg-elevated: #12161f;
  --bg-card: #161b26;
  --bg-card-hover: #1a2030;
  --border: #252b3a;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f97316;
  --blue: #3b82f6;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem 1.25rem;
  text-decoration: none;
  color: var(--text);
}

.sidebar-brand:hover { text-decoration: none; }

.brand-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border-radius: 10px;
  font-size: 1.1rem;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 0.95rem; }
.brand-text small {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.nav-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 1rem 0.75rem 0.35rem;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
}

.nav-item.is-active {
  background: rgba(139, 92, 246, 0.18);
  color: var(--text);
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.nav-icon { opacity: 0.85; font-size: 0.9rem; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  min-width: 1.25rem;
  text-align: center;
}

.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.topbar-chip {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}

.topbar-chip:hover { background: var(--bg-card-hover); text-decoration: none; }

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec4899, var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.main-content {
  flex: 1;
  padding: 1.5rem;
  overflow-x: auto;
}

/* Page header */
.page-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-hero h1 {
  margin: 0 0 0.25rem;
  font-size: 1.65rem;
  font-weight: 700;
}

.page-hero .subtitle { color: var(--text-muted); margin: 0; }

.page-hero-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.page-hero-actions .btn {
  white-space: nowrap;
}

.page-hero-actions select,
.analytics-business-select {
  min-width: 220px;
  max-width: 360px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.85rem;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
}

.kpi-card.is-clickable {
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.kpi-card.is-clickable:hover {
  background: var(--bg-card-hover);
  border-color: #3d4658;
  transform: translateY(-1px);
}

.kpi-card.is-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.kpi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.kpi-icon.loc { background: rgba(59, 130, 246, 0.2); }
.kpi-icon.neg { background: rgba(239, 68, 68, 0.2); }
.kpi-icon.pending { background: rgba(249, 115, 22, 0.2); }
.kpi-icon.ok { background: rgba(34, 197, 94, 0.2); }

.kpi-trend {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.kpi-trend.up { color: var(--green); background: rgba(34, 197, 94, 0.15); }
.kpi-trend.down { color: var(--red); background: rgba(239, 68, 68, 0.15); }

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.25rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.kpi-foot {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

/* Analytics insights */
.analytics-insights .panel {
  margin-bottom: 1.25rem;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

@media (max-width: 1024px) {
  .insights-grid { grid-template-columns: 1fr; }
}

.insight-box {
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(2, 6, 23, 0.35);
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
}

.insight-box h3 {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.insight-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.insight-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.insight-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.2;
}

.insight-link:hover {
  text-decoration: underline;
}

.insight-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
  text-align: right;
}

.insight-avg {
  color: var(--text);
  font-weight: 600;
}

.insight-avg--up {
  color: var(--green);
}

.insight-avg--down {
  color: var(--red);
}

.insight-neg {
  color: var(--red);
  font-weight: 700;
}

.insight-n {
  font-weight: 500;
}

/* Charts row */
.charts-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
  .charts-row { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.badge-live {
  font-size: 0.7rem;
  background: rgba(34, 197, 94, 0.2);
  color: var(--green);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.chart-wrap { position: relative; height: 260px; }

.chart-wrap-trend {
  height: 300px;
}

/* Sentiment / star-distribution period selector */
.sentiment-panel-header {
  margin-bottom: 1rem;
}

.sentiment-panel-header h2 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  font-weight: 600;
}

.sentiment-panel-sub {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  line-height: 1.35;
  min-height: 1.1rem;
}

.chart-period-tabs--segmented {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  /* Make the control feel more "separate" from the panel */
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chart-period-tabs--segmented::-webkit-scrollbar {
  display: none;
}

.chart-period-tabs--segmented button {
  flex: 1 1 0;
  min-width: 3.25rem;
  padding: 0.42rem 0.35rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.chart-period-tabs--segmented button:hover:not(.is-active) {
  color: var(--text);
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.22);
}

.chart-period-tabs--segmented button.is-active {
  color: var(--text);
  font-weight: 600;
  /* Red active pill */
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.26), rgba(239, 68, 68, 0.12));
  border-color: rgba(239, 68, 68, 0.55);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.chart-period-tabs--segmented button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.donut-layout {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.donut-chart { width: 160px; height: 160px; flex-shrink: 0; }

.star-legend { flex: 1; }
.star-legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.star-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.star-dot.s5 { background: var(--green); }
.star-dot.s4 { background: #86efac; }
.star-dot.s3 { background: var(--orange); }
.star-dot.s2 { background: #fb923c; }
.star-dot.s1 { background: var(--red); }

.star-legend-row span:last-child,
.star-legend-count {
  margin-left: auto;
  color: var(--text-muted);
  min-width: 5ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: #3d4658;
  color: var(--text);
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #6366f1 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover) 0%, #4f46e5 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
}

.btn-yellow {
  background: rgba(234, 179, 8, 0.18);
  border-color: rgba(250, 204, 21, 0.75);
  color: #fde047;
  font-weight: 600;
}

.btn-yellow:hover {
  background: rgba(234, 179, 8, 0.32);
  border-color: #facc15;
  color: #fef9c3;
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.25);
}

.btn-red {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(248, 113, 113, 0.7);
  color: #fca5a5;
  font-weight: 600;
}

.btn-red:hover {
  background: rgba(239, 68, 68, 0.26);
  border-color: #f87171;
  color: #fecaca;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-ghost {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.35);
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: rgba(148, 163, 184, 0.16);
  border-color: #64748b;
  color: var(--text);
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--red);
  color: #fecaca;
}

.btn-sm {
  padding: 0.38rem 0.72rem;
  font-size: 0.78rem;
  border-radius: 6px;
}

.action-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

td.actions {
  vertical-align: middle;
}

td.actions .action-group {
  min-width: max-content;
}

select.btn-sm,
.filter-bar select,
.reviewer-tag-form select,
.review-tags-cell + td select {
  appearance: none;
  padding: 0.38rem 1.75rem 0.38rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--bg-elevated);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.45rem center;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.2;
}

select.btn-sm:hover,
.filter-bar select:hover {
  border-color: #3d4658;
  background-color: var(--bg-card-hover);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:hover td { background: var(--bg-card-hover); }

/* Filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.filter-bar select,
.filter-bar input[type="text"],
.filter-bar input[type="search"] {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.85rem;
}

.reviewers-search-wrap {
  flex: 1 1 14rem;
  min-width: 10rem;
  max-width: 24rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.filter-bar-reviewers .filter-bar-search {
  width: 100%;
  border-color: rgba(99, 102, 241, 0.35);
}

.reviewers-search-status {
  min-height: 1rem;
  font-size: 0.72rem;
  color: #a5b4fc;
  padding-left: 0.15rem;
}

.reviewers-search-status:empty {
  display: none;
}

.filter-bar-reviewers .filter-bar-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
}

.filter-bar-reviewers .reviewer-search-btn {
  flex-shrink: 0;
}

#reviewers-results.is-loading,
#reviews-results.is-loading,
#businesses-results.is-loading {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.filter-bar-businesses .businesses-search-wrap {
  flex: 1 1 14rem;
  min-width: 10rem;
  max-width: 26rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.filter-bar-businesses .filter-bar-search {
  width: 100%;
  border-color: rgba(99, 102, 241, 0.35);
}

.businesses-search-status {
  min-height: 1rem;
  font-size: 0.72rem;
  color: #a5b4fc;
  padding-left: 0.15rem;
}

.businesses-search-status:empty {
  display: none;
}

.business-table th.num-col,
.business-table td.num-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 3.5rem;
}

.business-table th.num-col {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: right;
  white-space: normal;
  max-width: 5.5rem;
}

.business-table td.num-col strong {
  color: var(--text);
}

.filter-bar-reviews .reviews-search-wrap {
  flex: 1 1 14rem;
  min-width: 10rem;
  max-width: 24rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.filter-bar-reviews .filter-bar-search {
  width: 100%;
  border-color: rgba(99, 102, 241, 0.35);
}

.reviews-search-status {
  min-height: 1rem;
  font-size: 0.72rem;
  color: #a5b4fc;
  padding-left: 0.15rem;
}

.reviews-search-status:empty {
  display: none;
}

.reviewer-tag-filter-wrap {
  position: relative;
}

.reviewer-tag-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  white-space: nowrap;
}

.reviewer-tag-filter-btn.is-active {
  border-color: rgba(139, 92, 246, 0.55);
  background: rgba(99, 102, 241, 0.18);
  color: #e9d5ff;
}

.reviewer-tag-filter-chevron {
  font-size: 0.65rem;
  opacity: 0.7;
}

.reviewer-tag-filter-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 200;
  min-width: 11rem;
  max-width: 16rem;
  max-height: 16rem;
  overflow-y: auto;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.reviewer-tag-filter-panel[hidden] {
  display: none !important;
}

.reviewer-tag-filter-option {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.reviewer-tag-filter-option:hover {
  background: var(--bg-card-hover);
}

.reviewer-tag-filter-option.is-selected {
  background: rgba(99, 102, 241, 0.2);
  color: #e9d5ff;
  font-weight: 600;
}

.reviewer-tag-filter-option[data-tag]:not([data-tag=""]) {
  border-left: 3px solid var(--tag-color, #6b7280);
}

/* Tags */
.tag-pill-wrap {
  display: inline-block;
  margin: 0 0.25rem 0.25rem 0;
}

.tag-pill-wrap .tag-pill {
  margin-right: 0;
}

.review-tags-cell {
  white-space: normal;
  max-width: 220px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 0.25rem;
}

.tag-pill-removable {
  margin-right: 0.35rem;
  margin-bottom: 0.35rem;
}

.tag-pill-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
}

.tag-pill-remove:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.35);
}

.rating-stars { color: #fbbf24; font-weight: 600; }
.rating-bad { color: var(--red); }

.reply-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
}

.reply-badge.replied { background: rgba(34, 197, 94, 0.2); color: var(--green); }
.reply-badge.none { background: rgba(249, 115, 22, 0.2); color: var(--orange); }

.review-snippet {
  max-width: 360px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }

.inline { display: inline; }

/* Flash */
.flash-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}
.flash-success { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.flash-error { background: rgba(239, 68, 68, 0.15); color: var(--red); }

/* Pagination */
.pagination {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  align-items: center;
}

.pagination a {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.72rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pagination a:hover {
  background: var(--bg-card-hover);
  border-color: #3d4658;
  text-decoration: none;
}

.pagination .muted {
  font-size: 0.85rem;
}

/* Legacy form pages */
.form-grid label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 500;
}

.form-grid input[type="text"],
.form-grid input[type="url"],
.form-grid textarea,
.form-grid select {
  width: 100%;
  max-width: 480px;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
}

.form-actions { margin-top: 1rem; display: flex; gap: 0.5rem; }

.badge-ok { color: var(--green); font-weight: 600; }
.badge-warn { color: var(--orange); font-weight: 600; }

/* Businesses */
.id-badge {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.id-badge-sm {
  font-size: 0.72rem;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.label-chip {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.platform-tag {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.business-table .address-cell {
  max-width: 220px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.business-name-link {
  font-weight: 500;
}

.business-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.business-meta div {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
}

.business-meta dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.business-meta dd {
  margin: 0;
}

.field-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

.form-grid label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-grid label.checkbox input {
  width: auto;
  margin: 0;
}

/* Review table row → detail modal */
.review-row {
  cursor: pointer;
  transition: background 0.12s ease;
}

.review-row:hover {
  background: var(--bg-card-hover);
}

.review-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

body.review-modal-open {
  overflow: hidden;
}

#review-detail-modal {
  z-index: 1100;
}

.review-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.review-modal[hidden] {
  display: none;
}

.review-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.review-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem 1.75rem 1.25rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.businesses-modal-dialog {
  max-width: 980px;
}

.businesses-modal-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.businesses-modal-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.businesses-modal-table th,
.businesses-modal-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
}

.businesses-modal-table tr:hover td {
  background: var(--bg-card-hover);
}

.businesses-modal-table tr.review-row {
  cursor: pointer;
}

.businesses-modal-table tr.review-row:hover td {
  background: var(--bg-card-hover);
}

.review-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.review-modal-close:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.review-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-right: 2rem;
}

.review-modal-author {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.review-modal-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #166534, var(--green));
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.reviewer-filter-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(22, 101, 52, 0.12);
  border: 1px solid rgba(22, 101, 52, 0.35);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.review-modal-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
}

.review-modal-name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.review-modal-show-all-by {
  flex-shrink: 0;
  white-space: nowrap;
}

.review-modal-reviewer-link {
  color: inherit;
  text-decoration: none;
}

.review-modal-reviewer-link:hover {
  color: var(--green);
  text-decoration: underline;
}

.review-modal-reviewer-meta-link {
  color: var(--green);
  font-weight: 500;
  text-decoration: none;
}

.review-modal-reviewer-meta-link:hover {
  text-decoration: underline;
}

.review-modal-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.review-modal-stars {
  color: #facc15;
  letter-spacing: 0.05em;
}

.review-modal-dot {
  opacity: 0.5;
}

.review-modal-status {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.review-modal-status.is-resolved {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.review-modal-business {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.review-modal-business-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.review-modal-business-text {
  flex: 1;
  min-width: 0;
}

.review-modal-business-name {
  font-weight: 600;
}

.review-modal-maps-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.review-modal-block {
  margin-bottom: 1.25rem;
}

.review-modal-label {
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.review-modal-body-box {
  padding: 1rem 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.55;
  white-space: pre-wrap;
}

.review-modal-reply-box {
  padding: 1rem 1.1rem 1rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary, #2563eb);
  border-radius: var(--radius);
}

.review-modal-reply-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.review-modal-reply-author {
  font-weight: 600;
  color: var(--text);
}

.review-modal-reply-date {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.review-modal-reply-dot {
  color: var(--text-muted);
}

.review-modal-reply-body {
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--text);
}

.review-modal-legit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .review-modal-legit-grid {
    grid-template-columns: 1fr;
  }
  .review-modal-footer {
    flex-direction: column;
  }
}

.review-modal-legit-card {
  padding: 0.85rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.review-modal-legit-title {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.review-modal-legit-value {
  font-weight: 600;
  font-size: 0.95rem;
}

.review-modal-pending {
  color: var(--orange);
}

.review-modal-legit-card-tags {
  min-height: 3.25rem;
}

.review-modal-legit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  min-height: 1.25rem;
}

.review-modal-legit-tags.muted {
  font-weight: 600;
  font-size: 0.95rem;
}

.review-modal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.review-modal-report-group,
.review-modal-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.review-modal-report {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}

.review-modal-report:hover {
  background: rgba(239, 68, 68, 0.18);
}

.review-modal-resolve {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.review-modal-resolve:hover {
  filter: brightness(1.08);
}

.review-modal-toast {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}

.review-modal-toast.is-ok {
  background: rgba(34, 197, 94, 0.12);
  color: var(--green);
}

.review-modal-toast.is-err {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

/* App login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at top, rgba(139, 92, 246, 0.12), transparent 55%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-brand h1 {
  margin: 0.75rem 0 0.25rem;
  font-size: 1.5rem;
}

.login-brand .brand-icon {
  margin: 0 auto;
}

.login-flash {
  margin-bottom: 1rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-field span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.login-field input {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.95rem;
}

.login-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-submit {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.7rem;
}

.nav-logout-form {
  margin: 0;
  padding: 0;
}

.nav-logout {
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.nav-logout:hover {
  background: var(--bg-card);
  color: var(--text);
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-decoration: none;
  color: var(--text);
}

.sidebar-user-card:hover {
  background: var(--bg-card-hover);
  text-decoration: none;
}

.sidebar-user-card.is-active {
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.12);
}

.sidebar-user-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ec4899, var(--accent));
}

.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.sidebar-user-meta strong {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-meta small {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-grid {
  display: grid;
  gap: 1rem;
  max-width: 520px;
}

.account-profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.account-profile-header h2 {
  margin: 0 0 0.2rem;
  font-size: 1.25rem;
}

.account-avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ec4899, var(--accent));
  flex-shrink: 0;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 400px;
}

.account-form .btn {
  align-self: flex-start;
  margin-top: 0.25rem;
}

.panel-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.reviewer-import-panel {
  margin-bottom: 1.25rem;
}

.reviewer-import-form,
.reviewer-sync-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-top: 0.75rem;
}

.reviewer-sync-form {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.reviewer-import-form input[type="file"] {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.field-label {
  display: block;
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: -0.35rem;
}

.reviewer-table td.actions .reviewer-tag-form {
  display: inline-flex;
  margin: 0;
}

.reviewer-reviews-cell {
  min-width: 14rem;
  max-width: 26rem;
  vertical-align: top;
}

.reviewer-review-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.reviewer-review-links-item {
  list-style: none;
  margin: 0;
  padding: 0;
}

.reviewer-review-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0.6rem 0.7rem 0.6rem 0.85rem;
  border: 1px solid rgba(99, 102, 241, 0.45);
  border-radius: 10px;
  background: linear-gradient(
    118deg,
    rgba(67, 56, 202, 0.38) 0%,
    rgba(30, 27, 75, 0.55) 38%,
    rgba(22, 27, 38, 0.98) 100%
  );
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.35;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 2px 10px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.12s ease;
}

.reviewer-review-chip::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #818cf8, #6366f1);
  border-radius: 10px 0 0 10px;
}

.reviewer-review-chip:hover {
  border-color: rgba(129, 140, 248, 0.75);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 6px 20px rgba(99, 102, 241, 0.28);
  transform: translateY(-1px);
}

.reviewer-review-chip:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
}

/* 1–2★ — đỏ nổi */
.reviewer-review-chip.is-rating-low {
  border-color: rgba(248, 113, 113, 0.55);
  background: linear-gradient(
    118deg,
    rgba(185, 28, 28, 0.45) 0%,
    rgba(127, 29, 29, 0.35) 40%,
    rgba(28, 20, 22, 0.98) 100%
  );
}

.reviewer-review-chip.is-rating-low::before {
  background: linear-gradient(180deg, #fca5a5, #ef4444);
}

.reviewer-review-chip.is-rating-low:hover {
  border-color: rgba(252, 165, 165, 0.7);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 6px 22px rgba(239, 68, 68, 0.32);
}

/* 3★ — cam */
.reviewer-review-chip.is-rating-mid {
  border-color: rgba(251, 146, 60, 0.5);
  background: linear-gradient(
    118deg,
    rgba(194, 65, 12, 0.4) 0%,
    rgba(124, 45, 18, 0.3) 40%,
    rgba(28, 24, 20, 0.98) 100%
  );
}

.reviewer-review-chip.is-rating-mid::before {
  background: linear-gradient(180deg, #fdba74, #f97316);
}

.reviewer-review-chip.is-rating-mid:hover {
  border-color: rgba(253, 186, 116, 0.65);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 6px 22px rgba(249, 115, 22, 0.28);
}

/* 4–5★ — xanh */
.reviewer-review-chip.is-rating-high {
  border-color: rgba(74, 222, 128, 0.5);
  background: linear-gradient(
    118deg,
    rgba(21, 128, 61, 0.42) 0%,
    rgba(20, 83, 45, 0.32) 40%,
    rgba(18, 28, 24, 0.98) 100%
  );
}

.reviewer-review-chip.is-rating-high::before {
  background: linear-gradient(180deg, #86efac, #22c55e);
}

.reviewer-review-chip.is-rating-high:hover {
  border-color: rgba(134, 239, 172, 0.65);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 6px 22px rgba(34, 197, 94, 0.28);
}

.reviewer-review-chip-inner {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.reviewer-review-chip-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reviewer-review-chip.is-rating-low .reviewer-review-chip-title {
  color: #fee2e2;
}

.reviewer-review-chip.is-rating-mid .reviewer-review-chip-title {
  color: #ffedd5;
}

.reviewer-review-chip.is-rating-high .reviewer-review-chip-title {
  color: #dcfce7;
}

.reviewer-review-chip-code {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: #cbd5e1;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reviewer-review-chip-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-top: 0.12rem;
}

.reviewer-review-rating {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.55);
  color: #e2e8f0;
}

.reviewer-review-chip.is-rating-low .reviewer-review-rating {
  border-color: rgba(252, 165, 165, 0.55);
  background: rgba(127, 29, 29, 0.65);
  color: #fecaca;
}

.reviewer-review-chip.is-rating-mid .reviewer-review-rating {
  border-color: rgba(253, 186, 116, 0.55);
  background: rgba(124, 45, 18, 0.55);
  color: #fed7aa;
}

.reviewer-review-chip.is-rating-high .reviewer-review-rating {
  border-color: rgba(134, 239, 172, 0.55);
  background: rgba(20, 83, 45, 0.55);
  color: #bbf7d0;
}

.reviewer-review-date {
  font-size: 0.68rem;
  font-weight: 500;
  color: #94a3b8;
}

.reviewer-review-chip-arrow {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #c4b5fd;
  background: rgba(99, 102, 241, 0.25);
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.reviewer-review-chip.is-rating-low .reviewer-review-chip-arrow {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.28);
}

.reviewer-review-chip.is-rating-mid .reviewer-review-chip-arrow {
  color: #fed7aa;
  background: rgba(249, 115, 22, 0.28);
}

.reviewer-review-chip.is-rating-high .reviewer-review-chip-arrow {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.28);
}

.reviewer-review-chip:hover .reviewer-review-chip-arrow {
  color: #fff;
  background: rgba(139, 92, 246, 0.55);
  transform: translateX(2px);
}

.reviewer-review-chip.is-rating-low:hover .reviewer-review-chip-arrow {
  background: rgba(239, 68, 68, 0.65);
}

.reviewer-review-chip.is-rating-mid:hover .reviewer-review-chip-arrow {
  background: rgba(249, 115, 22, 0.65);
}

.reviewer-review-chip.is-rating-high:hover .reviewer-review-chip-arrow {
  background: rgba(34, 197, 94, 0.65);
}

.reviewer-review-more {
  display: inline-flex;
  align-items: center;
  margin-top: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #a5b4fc;
  text-decoration: none;
}

.reviewer-review-more:hover {
  color: #c4b5fd;
  text-decoration: underline;
}

/* App modals (confirm / progress) */
.app-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.app-modal[hidden] {
  display: none !important;
}

.app-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.app-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.app-modal-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.app-modal-warning {
  margin: 0 0 0.65rem;
  line-height: 1.5;
}

.app-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.sync-progress-spinner {
  width: 40px;
  height: 40px;
  margin: 0.5rem auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sync-spin 0.85s linear infinite;
}

@keyframes sync-spin {
  to { transform: rotate(360deg); }
}

.sync-progress-status {
  text-align: center;
  margin: 0 0 0.5rem;
  font-weight: 500;
}

/* ------------------------------------------------------------------ */
/* Mobile layout (≤900px)                                             */
/* ------------------------------------------------------------------ */

.mobile-topbar,
.sidebar-overlay,
.sidebar-close {
  display: none;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-responsive > table {
  width: 100%;
}

.table-responsive--reviews > table {
  min-width: 880px;
}

.table-responsive--reviewers > table {
  min-width: 620px;
}

.table-responsive--businesses > table {
  min-width: 720px;
}

@media (max-width: 900px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.65rem 1rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
  }

  .mobile-topbar-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
  }

  .nav-toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0 auto;
    background: currentColor;
    border-radius: 1px;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay[hidden] {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1200;
    width: min(288px, 88vw);
    max-width: 100%;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: 0.75rem;
  }

  .app-shell.is-nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
  }

  body.nav-open {
    overflow: hidden;
  }

  .sidebar-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding-right: 0.25rem;
  }

  .sidebar-top .sidebar-brand {
    flex: 1;
    min-width: 0;
    padding-bottom: 0.75rem;
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-top: 0.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
  }

  .sidebar-close:hover {
    color: var(--text);
    background: var(--bg-card-hover);
  }

  .main-wrap {
    width: 100%;
    min-width: 0;
  }

  .main-content {
    padding: 1rem;
  }

  .page-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .page-hero h1 {
    font-size: 1.35rem;
  }

  .page-hero-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-hero-actions select,
  .analytics-business-select {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar select,
  .filter-bar input[type="text"],
  .filter-bar input[type="search"],
  .filter-bar .btn {
    width: 100%;
    max-width: none;
  }

  .filter-bar-reviews .reviews-search-wrap,
  .filter-bar-reviewers .reviewers-search-wrap,
  .filter-bar-businesses .businesses-search-wrap {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .reviewer-tag-filter-wrap,
  .reviewer-tag-filter-btn {
    width: 100%;
  }

  .reviewer-filter-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .reviewer-filter-banner .btn {
    width: 100%;
    justify-content: center;
  }

  .panel {
    padding: 1rem;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .donut-layout {
    flex-direction: column;
    align-items: stretch;
  }

  .donut-chart {
    width: 100%;
    max-width: 200px;
    height: auto;
    aspect-ratio: 1;
    margin: 0 auto;
  }

  .chart-wrap {
    height: 220px;
  }

  .chart-wrap-trend {
    height: 240px;
  }

  .sentiment-panel-header h2 {
    font-size: 0.95rem;
  }

  .chart-period-tabs--segmented {
    width: 100%;
    max-width: 100%;
  }

  .pagination {
    flex-wrap: wrap;
    justify-content: center;
  }

  .review-modal {
    padding: 0;
    align-items: flex-end;
  }

  .review-modal-dialog {
    max-width: none;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 1.25rem 1rem 1rem;
    margin-top: auto;
  }

  .businesses-modal-dialog {
    max-width: none;
    max-height: 95vh;
    border-radius: 12px 12px 0 0;
  }

  .review-modal-header {
    flex-direction: column;
    padding-right: 2rem;
  }

  .review-modal-name {
    font-size: 1.15rem;
  }

  .review-modal-show-all-by {
    white-space: normal;
  }

  .review-modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .review-modal-report-group,
  .review-modal-action-group {
    width: 100%;
  }

  .review-modal-report-group .btn,
  .review-modal-action-group .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .account-grid {
    max-width: none;
  }

  .account-form {
    max-width: none;
  }

  .account-form .btn {
    width: 100%;
    align-self: stretch;
    justify-content: center;
  }

  .business-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  .app-modal-dialog {
    width: calc(100vw - 2rem);
    max-width: none;
    margin: 1rem;
  }

  td.actions .action-group {
    flex-wrap: wrap;
  }

  /* Businesses: card list instead of wide table (no clipped columns) */
  #businesses-results.panel {
    overflow: visible;
    padding: 0.75rem;
  }

  .table-responsive--businesses {
    overflow: visible;
    margin: 0;
    padding: 0;
  }

  .table-responsive--businesses > .business-table {
    min-width: 0;
    display: block;
  }

  .table-responsive--businesses .business-table thead {
    display: none;
  }

  .table-responsive--businesses .business-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .table-responsive--businesses .business-table tbody tr.business-card-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
  }

  .table-responsive--businesses .business-table tbody tr:hover td {
    background: transparent;
  }

  .table-responsive--businesses .business-table td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    padding: 0.25rem 0;
    border: none;
    text-align: left;
    white-space: normal;
    min-width: 0;
  }

  .table-responsive--businesses .business-table td::before {
    content: attr(data-label);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
  }

  .table-responsive--businesses .business-table td.num-col {
    text-align: left;
  }

  .table-responsive--businesses .business-card-name {
    order: 1;
    grid-column: 1 / -1;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
  }

  .table-responsive--businesses .business-card-name .business-name-link {
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
  }

  .table-responsive--businesses .address-cell {
    order: 2;
    grid-column: 1 / -1;
    max-width: none;
    font-size: 0.85rem;
    line-height: 1.4;
  }

  .table-responsive--businesses td[data-label="ID"] {
    order: 3;
  }

  .table-responsive--businesses td[data-label="Label"] {
    order: 4;
  }

  .table-responsive--businesses td[data-label="1 month"] {
    order: 5;
  }

  .table-responsive--businesses td[data-label="3 months"] {
    order: 6;
  }

  .table-responsive--businesses td[data-label="1 year"] {
    order: 7;
  }

  .table-responsive--businesses td[data-label="All time"] {
    order: 8;
  }

  .table-responsive--businesses .business-card-actions {
    order: 9;
    grid-column: 1 / -1;
    padding-top: 0.5rem;
    margin-top: 0.15rem;
    border-top: 1px solid var(--border);
  }

  .table-responsive--businesses .business-card-actions::before {
    display: none;
  }

  .table-responsive--businesses .business-card-actions .action-group {
    width: 100%;
  }

  .table-responsive--businesses .business-card-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 0.75rem;
  }

  .kpi-value {
    font-size: 1.45rem;
  }

  .insight-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }

  .insight-meta {
    text-align: left;
    white-space: normal;
  }

  .review-snippet {
    max-width: none;
  }
}
