:root {
  --bg: #0f1117;
  --bg-elevated: #171b26;
  --bg-card: #1c2230;
  --border: #2a3344;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --accent: #7c5cff;
  --accent-2: #00d4aa;
  --danger: #ff5c7a;
  --success: #3dd68c;
  --warning: #ffb020;
  --radius: 14px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --sidebar-width: 260px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: radial-gradient(circle at top left, #1a2040 0%, var(--bg) 45%);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: rgba(17, 20, 30, 0.95);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
}

.brand-logo-img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex-shrink: 0;
}

.brand h1 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-section {
  margin-bottom: 1.25rem;
}

.nav-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 0.25rem;
  transition: background 0.2s, color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(124, 92, 255, 0.15);
  color: #fff;
  text-decoration: none;
}

.nav-link i { width: 18px; text-align: center; color: var(--accent-2); }

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: 10px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.status-pill.ok { color: var(--success); border-color: rgba(61, 214, 140, 0.35); }
.status-pill.bad { color: var(--danger); border-color: rgba(255, 92, 122, 0.35); }

.main {
  padding: 1.5rem 2rem 2rem;
  max-width: 1200px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
}

.page-header p {
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.action-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: transform 0.2s, border-color 0.2s;
}

.action-card:hover {
  transform: translateY(-3px);
  border-color: rgba(124, 92, 255, 0.5);
}

.action-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.action-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5a3fd4);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn:hover { filter: brightness(1.05); text-decoration: none; color: #fff; }

.flash-stack { margin-bottom: 1rem; }

.flash {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  border: 1px solid transparent;
}

.flash-success { background: rgba(61, 214, 140, 0.12); border-color: rgba(61, 214, 140, 0.35); color: var(--success); }
.flash-danger, .flash-error { background: rgba(255, 92, 122, 0.12); border-color: rgba(255, 92, 122, 0.35); color: var(--danger); }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.95rem;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.2);
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 1rem;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.08);
}

.drop-zone i { font-size: 2.5rem; color: var(--accent-2); margin-bottom: 0.75rem; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-card h1 {
  text-align: center;
  margin-bottom: 0.5rem;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
  }
  .main { padding: 1rem; }
}

/* Data tables */
.toolbar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}

.toolbar .form-input {
  flex: 1;
  min-width: 200px;
}

.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table tr:hover td {
  background: rgba(124, 92, 255, 0.06);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-success { background: rgba(61, 214, 140, 0.15); color: var(--success); }
.badge-warning { background: rgba(255, 176, 32, 0.15); color: var(--warning); }
.badge-danger { background: rgba(255, 92, 122, 0.15); color: var(--danger); }
.badge-muted { background: var(--bg-elevated); color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

.alert-panel {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert-panel.success {
  background: rgba(61, 214, 140, 0.1);
  border-color: rgba(61, 214, 140, 0.35);
  color: var(--success);
}

.alert-panel.error {
  background: rgba(255, 92, 122, 0.1);
  border-color: rgba(255, 92, 122, 0.35);
  color: var(--danger);
}

.alert-panel.info {
  background: rgba(124, 92, 255, 0.1);
  border-color: rgba(124, 92, 255, 0.35);
  color: var(--accent-2);
}

.result-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.result-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

.audio-player {
  width: 220px;
  max-width: 100%;
  height: 36px;
  margin-right: 0.5rem;
}

.song-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.song-card h4 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.song-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0.2rem 0;
}

.song-card .meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}

.loading-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.loading-state i { font-size: 2rem; color: var(--accent); margin-bottom: 0.75rem; }
