/* ===== CSS Variables & Reset ===== */
:root {
  --bg-base: #f5f6fa;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f3ff;
  --border: rgba(99, 102, 241, 0.12);
  --border-bright: rgba(99, 102, 241, 0.3);
  --text-primary: #1a1d3a;
  --text-secondary: #4b5080;
  --text-muted: #9296b8;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #06b6d4;
  --accent-4: #10b981;
  --accent-5: #f59e0b;
  --accent-6: #ef4444;
  --gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(99, 102, 241, 0.08);
  --shadow-card: 0 2px 16px rgba(99, 102, 241, 0.1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f0f1fa;
}

::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 3px;
}

/* ===== LOGIN SCREEN ===== */
/* ===== INFO SCREEN (no token) ===== */
.info-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 65% 25%, rgba(99, 102, 241, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse at 15% 75%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
    #f5f6fa;
  padding: 32px 24px;
}

.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 28px;
  padding: 52px 52px 44px;
  max-width: 560px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 64px rgba(99, 102, 241, 0.1);
  animation: fadeInUp 0.6s ease;
}

.info-logo {
  height: 36px;
  max-width: 180px;
  object-fit: contain;
  margin-bottom: 28px;
  display: inline-block;
}

.info-title {
  font-size: 1.7rem;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 14px;
}

.info-lead {
  color: var(--text-secondary);
  font-size: 0.97rem;
  line-height: 1.65;
  margin-bottom: 32px;
}

.info-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
  margin-bottom: 36px;
}

.info-feature {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: rgba(99, 102, 241, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}

.info-feature-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.info-feature strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.info-feature p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.info-contact {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(139, 92, 246, 0.04));
  border: 1px solid var(--border-bright);
  border-radius: 16px;
  padding: 24px 24px 20px;
}

.info-contact-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  font-size: 1rem;
}

.info-contact p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.info-contact-links {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.info-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  transition: opacity 0.2s, transform 0.15s;
}

.info-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.info-btn-outline {
  background: transparent;
  border: 1.5px solid var(--accent);
  color: var(--accent);
}

.info-btn-outline:hover {
  background: rgba(99, 102, 241, 0.06);
}

/* ===== ERROR SCREEN (invalid token) ===== */
.error-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 30%, rgba(239, 68, 68, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 70%, rgba(239, 68, 68, 0.04) 0%, transparent 50%),
    #f9f9f9;
  padding: 24px;
}

.error-card {
  background: var(--bg-card);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 24px;
  padding: 52px 48px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(239, 68, 68, 0.08), 0 0 0 1px rgba(239, 68, 68, 0.05);
  animation: fadeInUp 0.6s ease;
}

.error-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  display: block;
}

.error-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #dc2626;
  margin-bottom: 12px;
}

.error-message {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 12px;
  line-height: 1.6;
}

.error-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 32px;
  line-height: 1.6;
}

.error-hint a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.error-hint a:hover {
  text-decoration: underline;
}

.error-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.error-logo-link:hover {
  opacity: 1;
}

.error-logo-img {
  height: 30px;
  max-width: 160px;
  object-fit: contain;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 30%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 70%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    #f5f6fa;
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 24px;
  padding: 52px 48px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(99, 102, 241, 0.1), 0 0 0 1px rgba(99, 102, 241, 0.05);
  animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: rgba(99, 102, 241, 0.08);
  border-radius: 50%;
  margin-bottom: 24px;
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.login-title {
  font-size: 1.75rem;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 36px;
  line-height: 1.6;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1.5px solid #e0e3f5;
  color: var(--text-primary);
  padding: 14px 28px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
  width: 100%;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.08);
}

.btn-google:hover {
  background: #f5f6ff;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.login-note {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 20px;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 12px rgba(99, 102, 241, 0.07);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  flex-shrink: 0;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.header-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menabo-logo-link {
  display: flex;
  align-items: center;
  margin-left: auto;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.menabo-logo-link:hover {
  opacity: 1;
}

.menabo-logo-img {
  height: 28px;
  max-width: 200px;
  object-fit: contain;
  display: block;
}

.header-version {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.04);
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.last-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #f5f6fa;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.07);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--accent);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-refresh:hover {
  background: rgba(99, 102, 241, 0.14);
  border-color: var(--accent);
}

.btn-refresh svg {
  transition: transform 0.4s ease;
}

.btn-refresh:hover svg {
  transform: rotate(180deg);
}

.header-pending-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: default;
  user-select: none;
}

.header-pending-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.header-pending-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 99px;
  background: #2fdc26;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
  font-family: 'Inter', sans-serif;
}

.tab-pending-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: #dc2626;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  font-family: 'Inter', sans-serif;
  vertical-align: middle;
  margin-left: 3px;
}

.tab-pending-badge--note {
  background: #0ea5e9;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  border: 2px solid rgba(99, 102, 241, 0.25);
  transition: all 0.2s ease;
  overflow: hidden;
}

.user-avatar:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 65px;
  z-index: 99;
  box-shadow: 0 1px 12px rgba(99, 102, 241, 0.07);
}

/* Riga superiore: periodo + contatore righe */
.filter-bar-top {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Il filter-group dei profili occupa tutta la larghezza */
.filter-group--profiles {
  width: 100%;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-select,
.filter-input {
  background: #f7f8fc;
  border: 1px solid #e0e3f5;
  color: var(--text-primary);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.2s ease;
  min-width: 180px;
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.filter-input::placeholder {
  color: var(--text-muted);
}

.btn-clear {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-clear:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
}

.filter-stats {
  font-size: 0.82rem;
  color: var(--text-muted);
  align-self: center;
  padding-bottom: 2px;
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== KPI GRID ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 24px 32px 8px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  animation: fadeInUp 0.5s ease both;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--kpi-color, var(--gradient));
  border-radius: 99px 99px 0 0;
}

.kpi-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-bright);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.12);
}

.kpi-card--ai {
  border-color: rgba(99, 102, 241, 0.22);
  grid-column: 1 / -1;
  /* full row width */
  --kpi-color: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.kpi-ai-body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-top: 2px;
  white-space: pre-line;
}

.kpi-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-icon {
  font-size: 1.1rem;
  opacity: 0.8;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.kpi-value--small {
  font-size: 1.15rem;
  word-break: break-word;
  white-space: normal;
  line-height: 1.3;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ===== PROFILE HEADER WIDGETS ===== */
.profile-header-widgets {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 16px;
  padding: 8px 32px 4px;
  animation: fadeInUp 0.35s ease both;
}

.profile-info-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
}

.profile-info-avatar {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.profile-info-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

/* Badge nome gruppo (INDUSTRY NARRATIVE SHAPER / ORG / MEDIA) */
.profile-group-badge {
  display: inline-block;
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #3d3d3d;
  background: color-mix(in srgb, var(--group-color, #9ca3af) 30%, transparent);
  border: 1.5px solid var(--group-color, #9ca3af);
  border-radius: 4px;
  padding: 2px 8px;
  margin-bottom: 4px;
  width: fit-content;
}

.profile-info-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.profile-pending-count-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.profile-pending-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: #dc2626;
}

.profile-pending-count--note {
  color: #0ea5e9;
}

.profile-pending-count--note {
  color: #0ea5e9;
}

.profile-pending-anchors {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.profile-pending-anchor {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 1rem;
  color: #dc2626;
  transition: transform 0.2s ease;
  line-height: 1;
}

.profile-pending-anchor:hover {
  transform: scale(1.25);
}

.profile-info-company {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.profile-info-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: rgba(99, 102, 241, 0.09);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 99px;
  padding: 2px 8px;
  margin-top: 2px;
  width: fit-content;
}

.profile-info-bio {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.profile-info-bio--empty {
  color: var(--text-muted);
  font-style: italic;
}

.profile-info-link {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  margin-top: 4px;
  opacity: 0.8;
  transition: opacity 0.15s ease;
  width: fit-content;
}

.profile-info-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.profile-priority-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.profile-priority-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.profile-priority-select {
  appearance: none;
  -webkit-appearance: none;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  padding: 3px 24px 3px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--border-bright);
  background: var(--bg-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  outline: none;
}

.profile-priority-select:hover {
  border-color: var(--accent);
}

.profile-priority-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.profile-priority-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


.profile-followers-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  text-align: center;
}

.profile-followers-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.profile-followers-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.profile-followers-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.profile-ai-card {
  background: var(--bg-card);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 220px;
}

.profile-ai-header {
  display: flex;
  align-items: center;
  gap: 7px;
}

.profile-ai-icon {
  font-size: 1rem;
  line-height: 1;
}

.profile-ai-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.profile-ai-body {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ===== RANKING WIDGET ===== */

.rankings-row {
  display: flex;
  gap: 16px;
  margin: 0 32px 8px;
}

.rankings-row .ranking-section {
  margin: 0;
  flex: 1 1 0;
  min-width: 0;
}

.ranking-section {
  margin: 0 32px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow-card);
  animation: fadeInUp 0.5s ease both;
}

.ranking-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.ranking-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.ranking-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.period-tabs {
  display: flex;
  gap: 6px;
  background: #f5f6fa;
  border-radius: 8px;
  padding: 4px;
  border: 1px solid var(--border);
}

/* Barra profili: pulsanti singoli che vanno a capo su più righe */
.profile-tabs-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}

.period-btn {
  background: transparent;
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.period-btn:hover {
  color: var(--accent);
}

.period-btn.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 6px rgba(99, 102, 241, 0.15);
}

/* Pulsanti profilo: variante standalone con bordo */
.profile-tabs-wrap .period-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 20px;
  white-space: nowrap;
}

.profile-tabs-wrap .period-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
}

.profile-tabs-wrap .period-btn.active {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  /* Il box-shadow del gruppo (applicato via inline style) viene preservato
     combinando con il box-shadow di elevazione tramite JS */
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.ranking-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ranking-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
}

.rank-num {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  width: 28px;
}

.rank-num.rank-1 {
  color: #f59e0b;
}

.rank-num.rank-2 {
  color: #9296b8;
}

.rank-num.rank-3 {
  color: #cd7c3a;
}

.rank-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rank-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.rank-bar-bg {
  height: 6px;
  background: #f0f1fa;
  border-radius: 99px;
  overflow: hidden;
}

.rank-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--gradient);
  transition: width 0.6s ease;
}

.rank-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(99, 102, 241, 0.07);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 20px;
  padding: 4px 12px;
  white-space: nowrap;
}

.ranking-row--multi {
  align-items: flex-start;
}

.rank-metric-row {
  display: grid;
  grid-template-columns: 80px 1fr 48px;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.rank-metric-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.rank-metric-val {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: right;
}

.rank-details {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ===== TOP POSTS WIDGETS ===== */
.top-posts-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  padding: 8px 32px 0;
}

.top-post-widget {
  margin: 0 !important;
}

.top-posts-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.top-post-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: #fafbff;
  transition: all 0.2s ease;
}

.top-post-card:hover {
  border-color: var(--border-bright);
  background: #f0f3ff;
}

.top-post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.top-post-medal {
  font-size: 1.2rem;
}

.top-post-profile {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.top-post-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: auto;
}

.top-post-excerpt {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.top-post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top-post-metrics {
  display: flex;
  gap: 8px;
}

.top-post-metric {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(99, 102, 241, 0.06);
  padding: 3px 8px;
  border-radius: 6px;
}

.top-post-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.top-post-link:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--accent);
}

.top-post-anchor {
  font-size: 0.85rem;
  background: none;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--primary);
  transition: all 0.2s ease;
  line-height: 1;
}

.top-post-anchor:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--accent);
}

/* ===== CHARTS ROW ===== */
.charts-row {
  display: grid;
  gap: 16px;
  padding: 16px 32px;
}

.charts-row.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.charts-row.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.charts-row.cols-1 {
  grid-template-columns: 1fr;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.25s ease;
  animation: fadeInUp 0.5s ease both;
}

.chart-card:hover {
  border-color: var(--border-bright);
}

.chart-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.chart-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.chart-container {
  position: relative;
  width: 100%;
}

.chart-links-row {
  display: flex;
  justify-content: space-around;
  margin-top: 8px;
  padding: 6px 40px 0;
}

.chart-post-link {
  font-size: 0.82rem;
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.chart-post-link:hover {
  background: rgba(99, 102, 241, 0.1);
  transform: scale(1.2);
}

/* ===== PROFILE POST LIST ===== */
.profile-posts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 20px;
  align-items: start;
  transition: border-color 0.2s ease;
}

.profile-post-card:hover {
  border-color: var(--border-bright);
}

.profile-post-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-post-date {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-post-type {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(99, 102, 241, 0.07);
  padding: 2px 8px;
  border-radius: 99px;
  display: inline-block;
}

.profile-post-content {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.profile-post-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.profile-post-stat {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(99, 102, 241, 0.06);
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.profile-post-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 5px 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 6px;
  margin-top: 4px;
  transition: all 0.2s ease;
}

.profile-post-link:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--accent);
}

.profile-post-link--repost {
  border-color: rgba(6, 182, 212, 0.4);
  color: #0891b2;
}

.profile-post-link--repost:hover {
  background: rgba(6, 182, 212, 0.08);
  border-color: #06b6d4;
}

/* ===== POST TAB BAR ===== */
.profile-post-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.post-tab-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.post-tab {
  font-size: 0.73rem;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: 'Inter', sans-serif;
}

.post-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
}

.post-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.post-tab[data-tab="pc"].active {
  background: #6366f1;
  border-color: #6366f1;
}

.post-tab[data-tab="note"].active {
  background: #b45309;
  border-color: #b45309;
}

.post-tab--insert {
  border-style: dashed;
  color: var(--text-muted);
  opacity: 0.7;
}

.post-tab--insert:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
}

.post-eng-level {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.post-eng-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.post-eng-select {
  appearance: none;
  -webkit-appearance: none;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  padding: 2px 20px 2px 8px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--bg-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 6px center;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.post-eng-select:hover {
  border-color: var(--accent);
}

.post-eng-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.post-eng-select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.post-ai-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  width: 100%;
  margin-top: 4px;
}

.post-ai-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 99px;
  padding: 2px 10px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.post-approved-icon {
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  cursor: default;
  user-select: none;
}

.post-approve-btn {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1.5px solid rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.post-approve-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #92400e;
}

.post-approve-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.post-approve-btn--note {
  border-color: rgba(14, 165, 233, 0.5);
  background: rgba(14, 165, 233, 0.1);
  color: #0284c7;
}

.post-approve-btn--note:hover {
  background: rgba(14, 165, 233, 0.2);
  border-color: #0ea5e9;
  color: #0369a1;
}

.post-tab-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.post-tab-edit:hover {
  opacity: 1;
  color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}

/* ── Inline Editor ── */
.post-inline-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(99, 102, 241, 0.04);
  border: 1.5px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px;
  animation: fadeInUp 0.15s ease;
}

.post-editor-textarea {
  width: 100%;
  min-height: 80px;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  background: #fff;
  color: var(--text-primary);
  resize: vertical;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
}

.post-editor-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.post-editor-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.post-editor-btn {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  border: none;
  transition: all 0.18s ease;
}

.post-editor-btn--save {
  background: var(--accent);
  color: #fff;
}

.post-editor-btn--save:hover {
  background: #4f46e5;
}

.post-editor-btn--save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.post-editor-btn--cancel {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.post-editor-btn--cancel:hover {
  color: #ef4444;
  border-color: #ef4444;
}

/* ===== DATA TABLE ===== */
.table-section {
  padding: 8px 32px 40px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

.btn-export {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.07);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #059669;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-export:hover {
  background: rgba(16, 185, 129, 0.14);
  border-color: var(--accent-4);
}

.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 480px;
  box-shadow: var(--shadow-card);
}

#data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

#data-table th {
  position: sticky;
  top: 0;
  background: #f7f8fc;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

#data-table td {
  padding: 10px 16px;
  color: var(--text-secondary);
  border-bottom: 1px solid #f0f2fa;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#data-table tr:last-child td {
  border-bottom: none;
}

#data-table tbody tr {
  transition: background 0.15s ease;
}

#data-table tbody tr:hover {
  background: #f5f6ff;
}

/* ===== LOADING & STATES ===== */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(245, 246, 250, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 999;
  backdrop-filter: blur(4px);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(99, 102, 241, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #fff;
  border: 1px solid var(--border-bright);
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.15);
  z-index: 9999;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.4);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .header {
    padding: 14px 20px;
  }

  .filter-bar {
    padding: 14px 20px;
  }

  .kpi-grid {
    padding: 16px 20px 8px;
  }

  .charts-row {
    padding: 10px 20px;
  }

  .table-section {
    padding: 8px 20px 32px;
  }

  .charts-row.cols-2,
  .charts-row.cols-3 {
    grid-template-columns: 1fr;
  }

  .header-right .last-updated {
    display: none;
  }
}

@media (max-width: 600px) {
  .login-card {
    padding: 36px 24px;
  }

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