/* ─── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  /* Background layers — warm light neutrals */
  --bg:       #f0f2f5;
  --surface:  #ffffff;
  --surface2: rgba(255,255,255,0.72);
  --surface3: #f3f4f6;

  /* Borders — very soft */
  --border:   #e5e7eb;
  --border2:  #d1d5db;

  /* Single accent — clean blue */
  --accent:      #3b82f6;
  --accent-dim:  #1d4ed8;
  --accent-lit:  #2563eb;
  --accent2:     #3b82f6;
  --accent2-dim: #1d4ed8;

  /* Text */
  --text:     #111827;
  --text-sec: #6b7280;
  --text-dim: #9ca3af;

  /* Semantic colours */
  --green:     #10b981;
  --green-dim: rgba(52,211,153,0.12);
  --red:       #ef4444;
  --red-dim:   rgba(248,113,113,0.12);
  --yellow:    #f59e0b;

  /* Geometry */
  --radius:    8px;
  --radius-sm: 5px;
  --radius-lg: 12px;

  /* Elevation */
  --shadow:    0 4px 24px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 6px rgba(0,0,0,0.06);

  --transition: 0.14s ease;
}

/* ─── Read-only mode ─────────────────────────────────────────────────────────── */
body.read-only .btn-primary,
body.read-only .btn-danger,
body.read-only #add-artist-btn,
body.read-only #add-artist-btn-2,
body.read-only #add-artist-btn-3,
body.read-only #clear-data-btn,
body.read-only #save-settings-btn,
body.read-only #cm-token,
body.read-only #toggle-token-vis,
body.read-only #test-token-btn,
body.read-only #import-btn,
body.read-only #create-user-btn,
body.read-only #cloud-save-now-btn,
body.read-only #upload-section,
body.read-only #user-list button,
body.read-only #artist-sync-list button,
body.read-only [onclick^="syncArtist"] {
  opacity: 0.35 !important;
  pointer-events: none !important;
  user-select: none;
}
/* Alerts tab buttons are always interactive — they validate admin in JS and show
   an error toast when the user lacks permission, rather than silently blocking. */
body.read-only #alerts-save-btn,
body.read-only #alerts-results-wrap .btn {
  opacity: 1 !important;
  pointer-events: auto !important;
  user-select: auto;
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 99px; }

/* ─── Typography ─────────────────────────────────────────────────────────────── */
h1 { font-size: 1.875rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.015em; }
h3 { font-size: 1.0625rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: 0.9375rem; font-weight: 500; }
p  { color: var(--text-sec); line-height: 1.65; }

.stat-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: -0.01em;
}

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-green  { background: var(--green-dim);  color: var(--green); }
.badge-red    { background: var(--red-dim);    color: var(--red); }
.badge-blue   { background: rgba(59,130,246,0.10); color: var(--accent); }
.badge-dim    { background: transparent;       color: var(--text-dim); }
.badge-accent { background: rgba(59,130,246,0.10); color: var(--accent); }
.badge-complete { background: var(--green-dim); color: var(--green); }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.4375rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  transition: background var(--transition), color var(--transition), opacity var(--transition), box-shadow var(--transition);
  letter-spacing: -0.005em;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary       { background: var(--accent);     color: #fff; }
.btn-primary:hover { background: var(--accent-dim); }

.btn-secondary       { background: rgba(255,255,255,0.8); color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #ffffff; color: #111827; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

.btn-cyan       { background: var(--accent);     color: #fff; }
.btn-cyan:hover { background: var(--accent-dim); }

.btn-danger       { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.18); }

.btn-ghost       { background: transparent; color: #374151; border: 1px solid #e5e7eb; }
.btn-ghost:hover { background: rgba(0,0,0,0.04); color: #111827; border-color: #d1d5db; }

.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.625rem 1.25rem;  font-size: 0.9375rem; }
.btn-icon { padding: 0.4375rem; }

/* ─── Form Elements ──────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-sec);
  letter-spacing: 0.03em;
}
.form-input, .form-select, .form-textarea {
  background: rgba(255,255,255,0.9);
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  width: 100%;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-input::placeholder { color: var(--text-dim); }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.form-select option { background: #ffffff; color: var(--text); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.75rem; color: var(--text-dim); }

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 2px 16px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ─── Divider ────────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

/* ─── Tags ───────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: #f3f4f6;
  color: var(--text-sec);
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
}
.tag-accent { background: rgba(59,130,246,0.08); color: var(--accent); border-color: rgba(59,130,246,0.2); }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-footer { display: flex; gap: 0.625rem; justify-content: flex-end; margin-top: 1.5rem; }
.modal-close {
  background: none; border: none;
  color: var(--text-dim); font-size: 1.125rem;
  padding: 0.25rem; line-height: 1;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  z-index: 2000;
}
.toast {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 1rem;
  font-size: 0.8125rem;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: slideIn 0.18s ease;
  max-width: 320px;
}
.toast.toast-success { border-left: 2px solid var(--green); }
.toast.toast-error   { border-left: 2px solid var(--red); }
.toast.fade-out      { animation: fadeOut 0.25s ease forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(4px); } }

/* ─── Utility ────────────────────────────────────────────────────────────────── */
.hidden          { display: none !important; }
.text-center     { text-align: center; }
.text-right      { text-align: right; }
.text-dim        { color: var(--text-dim); }
.text-sec        { color: var(--text-sec); }
.text-green      { color: var(--green); }
.text-red        { color: var(--red); }
.text-accent     { color: var(--accent); }
.text-cyan       { color: var(--accent); }
.mt-auto         { margin-top: auto; }
.w-full          { width: 100%; }
.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* ─── Nav ────────────────────────────────────────────────────────────────────── */
.app-nav {
  background: rgba(255,255,255,0.80);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
}
.app-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
}
.app-nav-brand:hover { text-decoration: none; }
.app-nav-logo {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
}
.app-nav-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.app-nav-actions { display: flex; align-items: center; gap: 0.5rem; }

/* ─── Page wrapper ──────────────────────────────────────────────────────────── */
.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ─── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-state h3   { margin-bottom: 0.5rem; }
.empty-state p    { margin-bottom: 1.5rem; }

/* ─── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
