:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #293548;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --danger: #ef4444;
  --success: #22c55e;

  --tier-s: #ef4444;
  --tier-a: #f97316;
  --tier-b: #22c55e;
  --tier-c: #3b82f6;
  --tier-d: #a855f7;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}

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

/* ── Layout ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent);
  flex: 1;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-bar input,
.filter-bar select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}

.filter-bar input {
  flex: 1;
  min-width: 160px;
}

.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--accent);
}

.filter-bar select option { background: var(--surface); }

/* ── Table ── */
.tab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tab-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.tab-table th:hover { color: var(--text); }
.tab-table th.no-sort { cursor: default; }

.tab-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tab-table tbody tr:hover { background: var(--surface); }
.tab-table tbody tr:last-child td { border-bottom: none; }

/* ── Tier badge ── */
.tier {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
}
.tier-S { background: var(--tier-s); }
.tier-A { background: var(--tier-a); }
.tier-B { background: var(--tier-b); }
.tier-C { background: var(--tier-c); }
.tier-D { background: var(--tier-d); }

/* ── Status badge ── */
.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.status-pending { background: #78350f; color: #fde68a; }
.status-playing { background: #14532d; color: #86efac; }
.status-played  { background: var(--surface-2); color: var(--text-muted); }
.status-dismissed { background: #450a0a; color: #fca5a5; }

/* ── Buttons ── */
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.78rem; }

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

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.modal-header .info { flex: 1; }
.modal-header h2 { font-size: 1rem; font-weight: 700; }
.modal-header p { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

/* ── Chat ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin: auto;
}

.msg {
  max-width: 80%;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-size: 0.875rem;
  line-height: 1.4;
}

.msg-fan {
  background: var(--surface-2);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.msg-admin {
  background: var(--accent);
  color: #0f172a;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.msg-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.msg-admin .msg-time { color: #78350f; }

.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.chat-input input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
}

.chat-input input:focus { border-color: var(--accent); }

/* ── Auth form ── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 1.5rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
}

.auth-card h2 { font-size: 1.2rem; margin-bottom: 1.25rem; }

.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.85rem; }
.field label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.95rem;
  outline: none;
  width: 100%;
}
.field input:focus { border-color: var(--accent); }

.error-msg { color: #fca5a5; font-size: 0.85rem; margin-top: 0.5rem; }

/* ── Admin layout ── */
.admin-nav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
}

.nav-tab {
  background: transparent;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
}

.nav-tab.active { background: var(--surface); color: var(--text); }
.nav-tab:hover:not(.active) { color: var(--text); }

.nav-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  background: var(--accent);
  color: #0f172a;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

/* ── Queue cards ── */
.queue-list { display: flex; flex-direction: column; gap: 0.75rem; }

.queue-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.queue-card.is-new { border-color: var(--accent); }

.queue-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.queue-card-header .info { flex: 1; }
.queue-card-header h3 { font-size: 0.95rem; font-weight: 700; }
.queue-card-header p { font-size: 0.8rem; color: var(--text-muted); margin-top: 1px; }

.queue-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

/* ── Notes cell ── */
.notes-cell {
  cursor: pointer;
  min-width: 180px;
}

.notes-cell:hover { background: var(--surface-2) !important; }

.notes-text {
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.notes-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Notes modal textarea ── */
.note-modal-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  outline: none;
}

.note-modal-textarea:focus { border-color: var(--accent); }

/* ── Pulse animation for playing status ── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.status-playing { animation: pulse 1.5s ease-in-out infinite; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Mobile ── */
@media (max-width: 640px) {
  .tab-table { font-size: 0.82rem; }
  .tab-table th, .tab-table td { padding: 0.5rem 0.4rem; }
  .hide-mobile { display: none; }
  .container { padding: 1rem; }
}
