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

:root {
  --bg: #0a0e14;
  --bg-elevated: #111827;
  --bg-card: #161e2e;
  --bg-hover: #1c2640;
  --border: #1e2a3f;
  --border-light: #2a3a55;
  --text: #e2e8f0;
  --text-secondary: #8b9bb4;
  --text-muted: #5a6b85;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-light: rgba(16, 185, 129, 0.1);
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --purple: #8b5cf6;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; min-height: 100vh; }

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

.sidebar-header { padding: 20px 20px 16px; }

.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; }
.logo-title { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.logo-subtitle { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

.nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item.active svg { color: var(--accent); }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.user-card:hover { background: var(--bg-hover); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ===== Main ===== */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle { display: none; background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 4px; }

.topbar-search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  color: var(--text-muted);
  transition: border-color var(--transition);
}
.topbar-search:focus-within { border-color: var(--accent); }
.topbar-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.topbar-search input::placeholder { color: var(--text-muted); }

.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.btn-icon {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-light); }
.badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg-elevated);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  font-family: inherit;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

/* ===== Content ===== */
.content { padding: 24px; flex: 1; }

.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.page-subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }

/* ===== Stat Cards ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border-light); }

.stat-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-card-label { font-size: 12px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.stat-card-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card-change { font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.stat-card-change.up { color: var(--accent); }
.stat-card-change.down { color: var(--danger); }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ===== Table ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

.cell-artist { display: flex; align-items: center; gap: 10px; }
.cell-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

/* ===== Status Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge-active { background: rgba(16, 185, 129, 0.12); color: var(--accent); }
.badge-active::before { background: var(--accent); }
.badge-pending { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.badge-pending::before { background: var(--warning); }
.badge-draft { background: rgba(139, 155, 180, 0.12); color: var(--text-secondary); }
.badge-draft::before { background: var(--text-secondary); }
.badge-rejected { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.badge-rejected::before { background: var(--danger); }
.badge-live { background: rgba(59, 130, 246, 0.12); color: var(--info); }
.badge-live::before { background: var(--info); }

/* ===== Two Column Layout ===== */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }

/* ===== Chart Placeholder ===== */
.chart-area {
  height: 240px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 20px 0;
}
.chart-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bar {
  width: 100%;
  max-width: 40px;
  background: linear-gradient(180deg, var(--accent), rgba(16, 185, 129, 0.3));
  border-radius: 4px 4px 0 0;
  transition: height 0.5s ease;
  min-height: 4px;
}
.chart-bar:hover { background: linear-gradient(180deg, var(--accent-hover), rgba(5, 150, 105, 0.3)); }
.chart-label { font-size: 11px; color: var(--text-muted); }

/* ===== Store Badges ===== */
.store-list { display: flex; flex-wrap: wrap; gap: 8px; }
.store-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.store-badge.delivered { border-color: rgba(16, 185, 129, 0.3); color: var(--accent); }
.store-badge.pending { border-color: rgba(245, 158, 11, 0.3); color: var(--warning); }

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state-icon { margin-bottom: 12px; opacity: 0.5; }
.empty-state-text { font-size: 14px; }

/* ===== Action Buttons in Table ===== */
.action-btns { display: flex; gap: 4px; }
.action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all var(--transition);
}
.action-btn:hover { background: var(--bg-hover); color: var(--text); }
.action-btn.danger:hover { color: var(--danger); }

/* ===== Section Spacing ===== */
.section { margin-bottom: 24px; }

/* ===== Toast ===== */
#toastContainer { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); opacity: 0; transform: translateX(100px); transition: all 0.3s ease;
  max-width: 400px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-info { background: var(--bg-card); border: 1px solid var(--border-light); color: var(--text); }
.toast-success { background: rgba(16,185,129,0.15); border: 1px solid var(--accent); color: var(--accent); }
.toast-error { background: rgba(239,68,68,0.15); border: 1px solid var(--danger); color: var(--danger); }

/* ===== Loading ===== */
.loading-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; margin: 0 auto 12px; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Topbar Select ===== */
.topbar-select {
  width: auto; min-width: 160px; padding: 8px 12px; font-size: 13px;
  background: var(--bg-card); border: 1px solid var(--border);
}

/* ===== Store Checkboxes ===== */
.store-checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.store-check {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: var(--radius-sm); background: var(--bg-elevated);
  border: 1px solid var(--border); font-size: 13px; cursor: pointer; transition: all var(--transition);
}
.store-check:hover { border-color: var(--border-light); }
.store-check input { accent-color: var(--accent); }

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

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .topbar-search { display: none; }
  .stat-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}
