@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #7c3aed;
  --primary-light: #f5f3ff;
  --primary-hover: #6d28d9;
  --x-blue: #1D9BF0;
  --x-blue-hover: #1a8cd8;
  --success: #00ba7c;
  --success-light: #f0fdf4;
  --success-border: #bbf7d0;
  --success-text: #166534;
  --danger: #e0245e;
  --danger-light: #fff0f0;
  --danger-border: #ffc0c0;
  --danger-text: #c0392b;
  --warning: #ad6800;
  --warning-light: #fffbe6;
  --warning-border: #ffe58f;
  
  --bg: #f9fafb;
  --card-bg: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --sidebar-width: 240px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Sidebar ------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  margin-bottom: 32px;
  text-decoration: none;
  color: var(--text);
}

.sidebar-brand svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.sidebar-brand span {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.sidebar-section {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 0 24px;
  margin: 24px 0 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

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

.sidebar-link.active {
  color: var(--primary);
  background: var(--primary-light);
  border-left-color: var(--primary);
  font-weight: 600;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.sidebar-link.active svg {
  opacity: 1;
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  margin-top: 16px;
}

.sidebar-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-handle {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-signout {
  font-size: 11px;
  color: var(--danger-text);
  text-decoration: none;
  display: inline-block;
  margin-left: 48px;
  font-weight: 600;
  transition: color 0.15s ease;
}

.sidebar-signout:hover {
  text-decoration: underline;
}

/* --- Main Content -------------------------------------------------------- */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 40px 48px;
  max-width: 1200px;
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .main {
    margin-left: 0;
    padding: 24px 16px;
  }
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.7px;
  color: var(--text);
}

.page-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-meta {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* --- Cards --------------------------------------------------------------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.card-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

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

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  transform: none !important;
}

.btn-ai {
  background: var(--primary);
  color: #fff;
}

.btn-ai:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
}

.btn-blue {
  background: var(--x-blue);
  color: #fff;
}

.btn-blue:hover {
  background: var(--x-blue-hover);
  box-shadow: 0 4px 12px rgba(29, 155, 240, 0.15);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--border-light);
  color: var(--text);
}

.btn-danger {
  background: var(--card-bg);
  color: var(--danger-text);
  border-color: var(--border);
}

.btn-danger:hover {
  background: var(--danger-light);
  border-color: var(--danger-border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--border-light);
  color: var(--text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: var(--text);
  color: #fff;
}

.btn-primary:hover {
  background: #1f2937;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.1);
}

.btn-primary-lg {
  background: var(--text);
  color: #fff;
  padding: 14px 32px;
  font-size: 16px;
  border-radius: var(--radius-sm);
}

.btn-primary-lg:hover {
  background: #1f2937;
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.15);
}

/* --- Feedback messages --------------------------------------------------- */
.error {
  background: var(--danger-light);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--danger-text);
  font-size: 13px;
  margin-bottom: 20px;
}

.success-msg {
  background: var(--success-light);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--success-text);
  font-size: 13px;
  margin-bottom: 20px;
}

.success-box {
  background: var(--success-light);
  border: 1px solid var(--success-border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-bottom: 24px;
}

.success-box h3 {
  color: var(--success-text);
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 700;
}

.success-box p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.success-box a {
  color: var(--success-text);
  font-weight: 600;
  font-size: 14px;
  text-decoration: underline;
}

.warning-box {
  background: var(--warning-light);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--warning);
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* --- Loading Overlay ------------------------------------------------------ */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.loading-overlay.show {
  display: flex;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  margin-bottom: 16px;
}

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

.loading-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.loading-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.empty-note {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
}

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
  font-size: 14px;
}

/* --- Tables -------------------------------------------------------------- */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

thead th {
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s ease;
}

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

tbody tr.highlight {
  background: var(--primary-light);
}

tbody tr.dimmed {
  opacity: 0.35;
}

tbody td {
  padding: 14px 16px;
  vertical-align: top;
  line-height: 1.5;
}

.tweet-text {
  max-width: 480px;
  word-break: break-word;
}

.author {
  white-space: nowrap;
  font-weight: 500;
}

.handle {
  color: var(--text-muted);
  font-size: 11px;
}

.date {
  color: var(--text-muted);
  white-space: nowrap;
}

.metric {
  text-align: right;
  color: var(--text-muted);
}

.link a {
  color: var(--x-blue);
  text-decoration: none;
  font-weight: 600;
}

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

/* --- Landing Page specific styles ---------------------------------------- */
nav {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-light);
  padding: 16px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.nav-brand svg {
  width: 24px;
  height: 24px;
}

.nav-brand span {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.hero {
  text-align: center;
  padding: 100px 24px 60px;
  max-width: 720px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 24px;
  letter-spacing: 0.3px;
}

.hero h1 {
  font-size: 52px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -1.8px;
  margin-bottom: 24px;
  color: var(--text);
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(135deg, var(--primary), var(--x-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  padding-right: 2px;
}

.hero p {
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 40px;
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
}

.hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-note {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 16px;
}

.features {
  max-width: 1000px;
  margin: 0 auto;
  padding: 60px 24px 100px;
}

.features-label {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 40px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 768px) {
  .features-grid {
    grid-template-columns: 1fr;
  }
  .hero h1 {
    font-size: 38px;
  }
  .hero p {
    font-size: 16px;
  }
}

.feature-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.feature-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 20px;
}

.feature-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.feature-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.how-it-works {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 80px 24px;
}

.how-inner {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.how-inner h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 48px;
  letter-spacing: -0.7px;
}

.steps {
  display: flex;
  gap: 48px;
  justify-content: center;
  flex-wrap: wrap;
}

.step {
  flex: 1;
  min-width: 200px;
  max-width: 240px;
}

.step-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.step h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.step p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.final-cta {
  text-align: center;
  padding: 80px 24px 100px;
  max-width: 600px;
  margin: 0 auto;
}

.final-cta h2 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -0.7px;
}

.final-cta p {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-light);
  background: var(--card-bg);
}

/* --- Stat Cards Grid & Layout --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.stat-icon-bm {
  background: #f3edff;
  color: var(--primary);
}

.stat-icon-tw {
  background: #e8f4fd;
  color: var(--x-blue);
}

.stat-icon-dr {
  background: #f0fdf4;
  color: var(--success);
}

.stat-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

.stat-badge-ok {
  background: var(--success-light);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.2;
}

.stat-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.stat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
  font-size: 12px;
}

.stat-meta {
  color: var(--text-light);
}

.stat-link {
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-card:hover .stat-link {
  text-decoration: underline;
}

/* --- Sync Bar ------------------------------------------------------------- */
.sync-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 16px;
}

.sync-info {
  font-size: 13px;
  color: var(--text-muted);
}

.sync-info strong {
  color: var(--text);
}

.sync-confirm {
  display: none;
  align-items: center;
  gap: 8px;
}

.sync-confirm.show {
  display: inline-flex;
}
