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

/* ===== CSS Variables ===== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-indigo: #6366f1;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-green: #10b981;
  --accent-orange: #f97316;
  --accent-purple: #a855f7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(6, 182, 212, 0.06) 0%, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ===== Layout ===== */
.dashboard {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 48px;
}

@media (max-width: 768px) {
  .dashboard {
    padding: 16px;
  }
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header .subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.header-meta {
  text-align: right;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-meta .live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--accent-green);
  border-radius: 50%;
  margin-right: 5px;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding: 16px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.filter-bar label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.filter-bar input,
.filter-bar select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-width: 140px;
}

.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.filter-bar select option {
  background: #1a1a2e;
  color: var(--text-primary);
}

.filter-bar input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent-indigo), #818cf8);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  margin-left: auto;
}

.btn-refresh:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

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

.btn-refresh.loading .refresh-icon {
  animation: spin 0.8s linear infinite;
}

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

/* ===== Summary Cards Grid ===== */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  position: relative;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0.8;
}

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

.stat-card.indigo::before { background: linear-gradient(90deg, var(--accent-indigo), #818cf8); }
.stat-card.amber::before  { background: linear-gradient(90deg, var(--accent-amber), #fbbf24); }
.stat-card.red::before     { background: linear-gradient(90deg, var(--accent-red), #f87171); }
.stat-card.cyan::before    { background: linear-gradient(90deg, var(--accent-cyan), #22d3ee); }
.stat-card.orange::before  { background: linear-gradient(90deg, var(--accent-orange), #fb923c); }

.stat-card .card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.stat-card.indigo .card-icon { background: rgba(99, 102, 241, 0.15); color: var(--accent-indigo); }
.stat-card.amber .card-icon  { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.stat-card.red .card-icon     { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.stat-card.cyan .card-icon    { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.stat-card.orange .card-icon  { background: rgba(249, 115, 22, 0.15); color: var(--accent-orange); }

.stat-card .card-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.stat-card .card-value {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-card .card-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ===== Charts Grid ===== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

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

.chart-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.chart-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.chart-wrapper {
  position: relative;
  width: 100%;
  max-height: 320px;
}

/* ===== Tables Section ===== */
.tables-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 20px;
}

@media (max-width: 1080px) {
  .tables-section {
    grid-template-columns: 1fr;
  }
}

.table-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.table-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

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

.table-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-search {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 7px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  outline: none;
  width: 220px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.table-search:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.table-search::placeholder {
  color: var(--text-muted);
}

.table-scroll {
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

table th {
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  white-space: nowrap;
}

table tbody tr {
  transition: background var(--transition);
}

table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

table tbody tr:hover {
  background: rgba(99, 102, 241, 0.06);
}

table td.amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

table td.amount.positive {
  color: var(--accent-green);
}

table td.amount.negative {
  color: var(--accent-red);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.unresolved {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.badge.resolved {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

/* ===== Loading Skeleton ===== */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 32px;
  width: 60%;
}

.skeleton-chart {
  height: 260px;
  width: 100%;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.empty-state .empty-icon {
  font-size: 2.4rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .header h1 {
    font-size: 1.25rem;
  }

  .stat-card .card-value {
    font-size: 1.5rem;
  }

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

  .filter-bar input,
  .filter-bar select {
    min-width: 100%;
  }

  .btn-refresh {
    margin-left: 0;
  }

  .summary-cards {
    grid-template-columns: 1fr 1fr;
  }

  .tables-section {
    grid-template-columns: 1fr;
  }

  .table-search {
    width: 100%;
  }
}

/* ===== Migration Section ===== */
.migration-section {
  margin-top: 48px;
  margin-bottom: 32px;
  padding-top: 32px;
  border-top: 1px solid rgba(249, 115, 22, 0.2);
}

.section-title h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--accent-orange), #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.migration-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.mini-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  text-align: center;
  transition: transform var(--transition), border-color var(--transition);
}

.mini-stat:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
}

.mini-stat .mini-val {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.mini-stat .mini-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.mini-stat.perfect .mini-val  { color: var(--accent-green); }
.mini-stat.newcx .mini-val    { color: var(--accent-cyan); }
.mini-stat.cxhigher .mini-val { color: var(--accent-amber); }
.mini-stat.flagged .mini-val  { color: var(--accent-red); }

.flagged-card {
  border-color: rgba(239, 68, 68, 0.2) !important;
}

.migration-section .tables-section {
  grid-template-columns: 1fr;
}

/* Status badges for migration */
.badge.status-perfect   { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.badge.status-newcx     { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.badge.status-cxhigher  { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.badge.status-ashigher  { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.badge.status-missing   { background: rgba(239, 68, 68, 0.25); color: #fca5a5; }
.badge.status-review    { background: rgba(168, 85, 247, 0.15); color: var(--accent-purple); }
