:root {
  --bg: #07070f;
  --bg2: #0c0c18;
  --surface: rgba(255,255,255,0.04);
  --surface-solid: #111120;
  --surface2: rgba(255,255,255,0.07);
  --surface3: rgba(255,255,255,0.1);
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text: #f0f0f8;
  --text-muted: #7878a0;
  --text-dim: #404060;

  --accent: #e8193c;
  --accent2: #ff4d6a;
  --accent-glow: rgba(232,25,60,0.25);
  --accent-grad: linear-gradient(135deg, #e8193c, #ff4d6a);

  --b: #6699ff;
  --b-dim: rgba(102,153,255,0.15);
  --b-glow: rgba(102,153,255,0.3);
  --w: #44cc77;
  --w-dim: rgba(68,204,119,0.15);
  --w-glow: rgba(68,204,119,0.3);
  --k: #aa77ff;
  --k-dim: rgba(170,119,255,0.15);
  --k-glow: rgba(170,119,255,0.3);
  --a: #ffaa44;
  --a-dim: rgba(255,170,68,0.15);
  --a-glow: rgba(255,170,68,0.3);

  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 5px;
  --transition: 0.18s ease;
  --transition-slow: 0.3s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(100,60,200,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(232,25,60,0.08) 0%, transparent 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

/* ── HEADER ── */
.site-header {
  background: rgba(7,7,15,0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  max-width: 1400px;
  margin: 0 auto;
}

.logo { display: flex; align-items: center; gap: 14px; }

.logo-icon {
  font-size: 26px;
  filter: drop-shadow(0 0 8px rgba(232,25,60,0.5));
}

.logo-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--text);
  text-transform: uppercase;
}

.logo-sub {
  font-size: 10px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1.5px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 2px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: all var(--transition);
  letter-spacing: 0.3px;
}
.nav-link:hover {
  color: var(--text);
  border-color: var(--border2);
  background: var(--surface2);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-auth {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.4px;
  transition: all var(--transition);
}
.btn-auth:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* Edit-only elements hidden until admin logs in */
.edit-only { display: none !important; }
.is-admin .edit-only { display: inline-flex !important; }

/* ── LOGIN MODAL ── */
.login-modal { max-width: 360px; }
.login-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}
.login-error {
  font-size: 12px;
  color: var(--accent2);
  display: none;
  margin-bottom: 8px;
}
.remember-label {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── MAIN ── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 28px;
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 28px;
  width: fit-content;
}

.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 9px 22px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 9px;
  transition: all var(--transition);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--surface2); }
.tab.active {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

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

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-right { display: flex; align-items: center; gap: 12px; }

.member-legend { display: flex; gap: 8px; align-items: center; }

.sort-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.sort-label select {
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  outline: none;
}
.sort-label select:focus { border-color: var(--accent); }

.archived-desc { color: var(--text-muted); font-size: 14px; }

/* ── BUTTONS ── */
.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  box-shadow: 0 2px 12px var(--accent-glow);
  font-family: inherit;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border2);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); background: var(--surface2); }

.btn-danger {
  background: rgba(180,30,30,0.3);
  color: #ff8888;
  border: 1px solid rgba(180,30,30,0.4);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-danger:hover { background: rgba(200,40,40,0.45); color: #ffaaaa; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: var(--radius-xs);
  font-size: 15px;
  transition: all var(--transition);
  line-height: 1;
}
.btn-icon:hover { color: var(--text-muted); background: var(--surface2); }

/* ── MEMBER BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  flex-shrink: 0;
}
.badge.b { background: var(--b-dim); color: var(--b); border: 1px solid rgba(102,153,255,0.3); }
.badge.w { background: var(--w-dim); color: var(--w); border: 1px solid rgba(68,204,119,0.3); }
.badge.k { background: var(--k-dim); color: var(--k); border: 1px solid rgba(170,119,255,0.3); }
.badge.a { background: var(--a-dim); color: var(--a); border: 1px solid rgba(255,170,68,0.3); }

/* ── TABLE ── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.02);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th.b { color: var(--b); }
thead th.w { color: var(--w); }
thead th.k { color: var(--k); }
thead th.a { color: var(--a); }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), box-shadow var(--transition);
  animation: rowIn 0.3s ease both;
}
tbody tr:last-child { border-bottom: none; }

@keyframes rowIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

tbody tr:nth-child(odd) { background: rgba(255,255,255,0.012); }
tbody tr:hover {
  background: var(--surface2);
  box-shadow: inset 3px 0 0 var(--accent);
}

tbody td {
  padding: 13px 16px;
  vertical-align: middle;
}

.col-title  { min-width: 190px; }
.col-date   { min-width: 120px; white-space: nowrap; }
.col-added  { min-width: 80px; }
.col-rating { min-width: 64px; text-align: center; }
.col-avg    { min-width: 64px; text-align: center; }
.col-notes  { min-width: 160px; }
.col-actions { min-width: 72px; text-align: right; white-space: nowrap; }

.cell-title { font-weight: 600; font-size: 14px; }

.cell-rating { font-weight: 800; font-size: 15px; letter-spacing: -0.3px; }
.cell-rating.b { color: var(--b); text-shadow: 0 0 12px var(--b-glow); }
.cell-rating.w { color: var(--w); text-shadow: 0 0 12px var(--w-glow); }
.cell-rating.k { color: var(--k); text-shadow: 0 0 12px var(--k-glow); }
.cell-rating.a { color: var(--a); text-shadow: 0 0 12px var(--a-glow); }
.cell-rating.text { font-size: 11px; font-weight: 700; opacity: 0.85; letter-spacing: 0.5px; }
.cell-rating.empty { color: var(--text-dim); font-weight: 400; font-size: 13px; }

.cell-avg { font-weight: 800; font-size: 17px; letter-spacing: -0.5px; }
.avg-high { color: #44dd77; text-shadow: 0 0 14px rgba(68,221,119,0.4); }
.avg-mid  { color: #ddcc33; text-shadow: 0 0 14px rgba(221,204,51,0.35); }
.avg-low  { color: #ff8833; text-shadow: 0 0 14px rgba(255,136,51,0.35); }
.avg-bad  { color: #ff4444; text-shadow: 0 0 14px rgba(255,68,68,0.35); }

.cell-date { color: var(--text-muted); font-size: 13px; }
.added-by { font-size: 12px; color: var(--text-muted); }

.col-notes { color: var(--text-muted); font-size: 12px; font-style: italic; }

.loading {
  text-align: center;
  color: var(--text-dim);
  padding: 48px;
  font-style: italic;
  letter-spacing: 0.5px;
}

/* ── ARCHIVED LIST ── */
.archived-list {
  display: grid;
  gap: 3px;
}

.archived-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  transition: all var(--transition);
  animation: rowIn 0.25s ease both;
}
.archived-item:hover {
  background: var(--surface2);
  border-color: var(--border2);
  transform: translateX(3px);
}

.archived-rank {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  min-width: 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.archived-title {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  min-width: 0;
}

.archived-notes {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  flex: 1;
  min-width: 0;
}

.archived-rating {
  font-size: 20px;
  font-weight: 800;
  min-width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.archived-actions { display: flex; gap: 2px; }

.rating-bar {
  flex: 0 0 100px;
  height: 3px;
  background: var(--border2);
  border-radius: 2px;
  overflow: hidden;
}
.rating-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ── MODAL ── */
dialog {
  background: #0e0e1e;
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 560px;
  width: 90%;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.05);
}

dialog::backdrop {
  background: rgba(4,4,12,0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

dialog h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 22px;
  letter-spacing: -0.3px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.form-field { display: flex; flex-direction: column; gap: 7px; }
.form-field.span-2 { grid-column: span 2; }

.form-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.form-field input,
.form-field textarea,
.form-field select {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-field input::placeholder { color: var(--text-dim); }

.member-checks {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 0;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.check-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border2);
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.check-label input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check-label input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.confirm-modal p {
  margin-bottom: 24px;
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── INLINE RATING EDITOR (hover) ── */
td[data-member] { cursor: default; }
td[data-member]:hover { background: rgba(255,255,255,0.05); }

.inline-edit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  min-width: 88px;
}

.inline-val {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.inline-slider {
  width: 84px;
  height: 4px;
  cursor: pointer;
  border-radius: 2px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.15);
  outline: none;
}
.inline-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: currentColor;
  cursor: pointer;
  box-shadow: 0 0 8px currentColor;
}
.inline-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  main { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.span-2 { grid-column: span 1; }
  .toolbar { flex-direction: column; align-items: flex-start; }
  .col-notes { display: none; }
  .tabs { width: 100%; }
  .tab { flex: 1; text-align: center; }
}
