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

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --header-bg: #1a1a2e;
  --text: #1f2937;
  --text-light: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --up: #059669;
  --up-bg: #ecfdf5;
  --down: #dc2626;
  --down-bg: #fef2f2;
  --neutral: #6b7280;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* === Login Screen === */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

#login-screen[hidden] {
  display: none;
}

.login-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-img {
  height: 40px;
  width: auto;
  margin-bottom: 8px;
}

.login-logo p {
  color: var(--text-light);
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.btn-primary:hover { background: var(--primary-dark); }

.error-text {
  color: var(--down);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
}

/* === App Header === */
#app-header {
  background: var(--card-bg);
  color: var(--text);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

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

.header-logo {
  height: 30px;
  width: auto;
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.header-subtitle {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-light);
}

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

#current-week {
  font-size: 13px;
  color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* === Navigation Tabs === */
#app-nav {
  background: var(--header-bg);
  padding: 0 24px;
  display: flex;
  gap: 0;
}

.tab-btn {
  background: none;
  border: none;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-btn:hover { color: rgba(255,255,255,0.85); }
.tab-btn.active {
  color: #fff;
  border-bottom-color: #fff;
}

/* === Tab Content === */
.tab-content { display: none; padding: 24px; }
.tab-content.active { display: block; }

/* === Stats Layout === */

/* Hero row: 2 large cards with sparklines */
.stats-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* Primary row: 4 medium cards */
.stats-primary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

/* Secondary row: 5 compact cards */
.stats-secondary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

/* LinkedIn section */
.stats-linkedin-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.section-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  background: #0a66c2;
  border-radius: 4px;
}

.stats-linkedin {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* Base card */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid var(--border);
}

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

.stat-card-header {
  margin-bottom: 8px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat-card-body {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.stat-change.up {
  color: var(--up);
  background: var(--up-bg);
}

.stat-change.down {
  color: var(--down);
  background: var(--down-bg);
}

.stat-change.neutral {
  color: var(--neutral);
  background: #f3f4f6;
}

/* Hero card: larger with sparkline */
.stat-card-hero {
  padding: 24px;
}

.stat-card-hero .stat-value {
  font-size: 36px;
}

.stat-card-hero .stat-label {
  font-size: 13px;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 20px;
}

.hero-stats {
  flex: 0 0 auto;
  min-width: 140px;
}

.hero-stats .stat-card-body {
  margin-top: 8px;
}

.hero-chart {
  flex: 1;
  height: 70px;
  min-width: 0;
}

.hero-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Small card variant */
.stat-card-sm {
  padding: 14px 16px;
}

.stat-card-sm .stat-value {
  font-size: 22px;
}

.stat-card-sm .stat-label {
  font-size: 11px;
}

.stat-card-sm .stat-change {
  font-size: 11px;
  padding: 1px 6px;
}

.stat-card-sm .stat-card-header {
  margin-bottom: 4px;
}

/* === Modals === */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.modal[hidden] { display: none; }

.modal-content {
  background: var(--card-bg);
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-large {
  max-width: 900px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card-bg);
  border-radius: 16px 16px 0 0;
  z-index: 1;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

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

.modal-body {
  padding: 24px;
}

/* === Chart === */
.chart-container {
  height: 300px;
  margin-bottom: 24px;
}

/* === Detail List (sub-items) === */
.detail-items h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
  margin-top: 8px;
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-list-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  gap: 12px;
}

.detail-list-item:hover {
  background: var(--bg);
}

.detail-list-item.selected {
  background: rgba(26, 115, 232, 0.08);
  border-left: 3px solid var(--primary);
}

.item-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.item-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  min-width: 60px;
  text-align: right;
}

.item-change {
  font-size: 12px;
  font-weight: 600;
  min-width: 70px;
  text-align: right;
}

.item-change.up { color: var(--up); }
.item-change.down { color: var(--down); }
.item-change.neutral { color: var(--neutral); }

.item-name-all {
  font-weight: 700;
  color: var(--primary);
}

/* === Reports Tab === */
.reports-toolbar {
  margin-bottom: 20px;
}

.group-toggle {
  display: inline-flex;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.toggle-btn {
  background: none;
  border: none;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

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

.toggle-btn:hover:not(.active) {
  background: var(--bg);
}

/* Report Groups */
.report-group {
  margin-bottom: 20px;
}

.report-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}

.group-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.group-count {
  font-size: 12px;
  color: var(--text-muted);
}

.report-group-list {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.report-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card-bg);
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.report-item:last-child { border-bottom: none; }
.report-item:hover { background: var(--bg); }

.report-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-teal { background: #ccfbf1; color: #0f766e; }

.report-week-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(26, 115, 232, 0.08);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.report-item-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.report-item-date {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Report Modal Content */
.report-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.report-date, .report-week {
  font-size: 13px;
  color: var(--text-light);
}

.report-content h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-top: 20px;
  margin-bottom: 8px;
}

.report-content p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 4px;
}

.report-content .report-bullet {
  padding-left: 16px;
  position: relative;
}

.report-content .report-bullet::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
}

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

/* === Responsive === */
@media (max-width: 1024px) {
  .stats-primary { grid-template-columns: repeat(2, 1fr); }
  .stats-secondary { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .stats-hero { grid-template-columns: 1fr; }
  .stats-primary { grid-template-columns: repeat(2, 1fr); }
  .stats-secondary { grid-template-columns: repeat(2, 1fr); }
  .stats-linkedin { grid-template-columns: repeat(2, 1fr); }

  .stat-card-hero .stat-value { font-size: 28px; }

  .modal-content { margin: 12px; }
  .modal-large { max-width: 100%; }

  #app-header { padding: 0 16px; }
  .tab-content { padding: 16px; }
}

@media (max-width: 480px) {
  .stats-hero { grid-template-columns: 1fr; }
  .stats-primary { grid-template-columns: 1fr 1fr; }
  .stats-secondary { grid-template-columns: 1fr 1fr; }
  .stats-linkedin { grid-template-columns: 1fr; }

  .hero-top { flex-direction: column; align-items: stretch; }
  .hero-chart { height: 60px; }

  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 11px; }

  .report-item { flex-wrap: wrap; }
}
