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

:root {
  /* Base neutrals */
  --bg: #f6f5f3;
  --bg-card: #ffffff;
  --text: #3d3a37;
  --text-secondary: #6e6a65;
  --text-muted: #a09a93;
  --border: #e5e2dc;
  
  /* Section colors */
  --stats-color: #5a7c6f;
  --stats-light: #e8eeeb;
  
  --artists-color: #9e4a5b;
  --artists-light: #f5e8eb;
  
  --songs-color: #7c5c99;
  --songs-light: #f0eaf5;
  
  --activity-color: #c17f4e;
  --activity-light: #f8f0e8;
  
  --hour-color: #5874a6;
  --hour-light: #e8edf5;
  
  --day-color: #b86565;
  --day-light: #f8ebeb;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
}

.hidden { display: none !important; }

/* Header */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-input input[type="file"] { display: none; }

.file-button, .btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.file-button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.file-button:hover { 
  background: var(--border);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border: none;
}

.btn-primary:hover { opacity: 0.85; }

.year-select {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

/* Dashboard */
.dashboard {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
  width: 100%;
}

/* Empty State */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}

.empty-state-content { text-align: center; }

.empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.empty-state h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p { color: var(--text-secondary); }

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

/* Section Titles */
.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1.25rem;
}

.card-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: -1rem;
  margin-bottom: 1.25rem;
}

/* Cards base */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

/* ===== STATS SECTION ===== */
.stats-section {
  margin-bottom: 3.5rem;
}

.stats-title {
  color: var(--stats-color);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.stat-card {
  background: var(--stats-light);
  border: none;
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(90, 124, 111, 0.15);
}

.stat-value {
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--stats-color);
  display: block;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--stats-color);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
  opacity: 0.7;
}

/* ===== TOP LISTS ===== */
.top-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 3.5rem;
}

.top-list {
  list-style: none;
  counter-reset: ranking;
}

.top-list li {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  counter-increment: ranking;
}

.top-list li:last-child { border-bottom: none; }

.top-list li::before {
  content: counter(ranking);
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 0.875rem;
}

.list-item-info {
  flex: 1;
  min-width: 0;
}

.list-item-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
}

.list-item-stat {
  font-size: 0.8rem;
  margin-left: 1rem;
  white-space: nowrap;
}

/* Artists list styling */
.top-list-artists .card-title {
  color: var(--artists-color);
}

.top-list-artists .top-list li::before {
  background: var(--artists-light);
  color: var(--artists-color);
}

.top-list-artists .top-list li:nth-child(1)::before {
  background: var(--artists-color);
  color: white;
}

.top-list-artists .list-item-stat {
  color: var(--artists-color);
}

/* Songs list styling */
.top-list-songs .card-title {
  color: var(--songs-color);
}

.top-list-songs .top-list li::before {
  background: var(--songs-light);
  color: var(--songs-color);
}

.top-list-songs .top-list li:nth-child(1)::before {
  background: var(--songs-color);
  color: white;
}

.top-list-songs .list-item-stat {
  color: var(--songs-color);
}

/* ===== ACTIVITY HEATMAP ===== */
.heatmap-section {
  margin-bottom: 3.5rem;
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.heatmap-section .card-title {
  color: var(--activity-color);
}

.heatmap-section .card-hint {
  color: var(--activity-color);
  opacity: 0.6;
}

#heatmap { min-width: 900px; }

.heatmap-tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* ===== PATTERN CHARTS ===== */
.patterns-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.25rem;
  margin: -0.25rem;
  border-radius: 6px;
  transition: background 0.15s;
}

.bar-label {
  width: 32px;
  font-size: 0.7rem;
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  height: 24px;
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s ease, opacity 0.15s;
}

.bar-value {
  width: 70px;
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Hour chart styling */
.chart-hour .card-title {
  color: var(--hour-color);
}

.chart-hour .card-hint {
  color: var(--hour-color);
  opacity: 0.6;
}

.chart-hour .bar-row:hover {
  background: var(--hour-light);
}

.chart-hour .bar-label {
  color: var(--hour-color);
}

.chart-hour .bar-track {
  background: var(--hour-light);
}

.chart-hour .bar-fill {
  background: var(--hour-color);
}

.chart-hour .bar-row:hover .bar-fill {
  opacity: 0.8;
}

.chart-hour .bar-value {
  color: var(--hour-color);
}

/* Day chart styling */
.chart-day .card-title {
  color: var(--day-color);
}

.chart-day .card-hint {
  color: var(--day-color);
  opacity: 0.6;
}

.chart-day .bar-row:hover {
  background: var(--day-light);
}

.chart-day .bar-label {
  color: var(--day-color);
}

.chart-day .bar-track {
  background: var(--day-light);
}

.chart-day .bar-fill {
  background: var(--day-color);
}

.chart-day .bar-row:hover .bar-fill {
  opacity: 0.8;
}

.chart-day .bar-value {
  color: var(--day-color);
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(61, 58, 55, 0.3);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2rem;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.12);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg);
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.375rem 0.625rem;
  line-height: 1;
  border-radius: 6px;
  transition: all 0.15s;
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text);
}

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

.modal-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.modal-stat-value {
  font-size: 1.75rem;
  font-weight: 600;
  display: block;
}

.modal-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.modal-list-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 0.875rem;
}

.modal-list-section .top-list li {
  padding: 0.5rem 0;
  font-size: 0.875rem;
}

.modal-list-section .top-list li::before {
  background: var(--bg);
  color: var(--text-muted);
}

.modal-list-section .list-item-stat {
  color: var(--text-secondary);
}

.list-item-streams {
  color: var(--text-muted);
}

/* Modal color themes */
.modal-content[data-theme="activity"] .modal-stat-value {
  color: var(--activity-color);
}

.modal-content[data-theme="hour"] .modal-stat-value {
  color: var(--hour-color);
}

.modal-content[data-theme="day"] .modal-stat-value {
  color: var(--day-color);
}

/* Footer */
.footer {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .top-lists, .patterns-section, .modal-lists { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .header-content { flex-direction: column; }
  .dashboard { padding: 2rem 1rem; }
  .stats-grid { grid-template-columns: 1fr; }
}
