:root {
  --bg: #070b16;
  --panel: rgba(17, 24, 45, 0.78);
  --panel-strong: #11182d;
  --panel-soft: #0d1428;
  --line: rgba(151, 172, 220, 0.13);
  --text: #f4f7ff;
  --muted: #8e9ab7;
  --accent: #7c5cff;
  --accent-2: #a78bfa;
  --green: #36d399;
  --green-soft: rgba(54, 211, 153, 0.13);
  --red: #ff6b81;
  --red-soft: rgba(255, 107, 129, 0.12);
  --yellow: #f6c453;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% -10%, rgba(124, 92, 255, 0.18), transparent 32rem),
    radial-gradient(circle at 95% 20%, rgba(71, 100, 255, 0.11), transparent 28rem),
    linear-gradient(180deg, #090e1d 0%, var(--bg) 58%, #060913 100%);
}

button, input, select { font: inherit; }
button { color: inherit; }

.page-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }
.topbar {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--accent), #4f7cff);
  box-shadow: 0 10px 30px rgba(124, 92, 255, 0.28);
}
.brand strong { display: block; font-size: 15px; letter-spacing: 0.08em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: 10px; }
.ghost-button, .admin-button, .primary-button, .text-button, .icon-button {
  border: 0;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.ghost-button, .admin-button {
  height: 40px;
  padding: 0 15px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.035);
}
.ghost-button:hover, .admin-button:hover { transform: translateY(-1px); border-color: rgba(167,139,250,.35); }
.admin-button { background: linear-gradient(135deg, rgba(124,92,255,.96), rgba(86,104,255,.96)); border-color: transparent; font-weight: 700; }
.admin-button.logged-in { background: var(--green-soft); color: #8ef2ca; border-color: rgba(54,211,153,.22); }
.refresh-icon { display: inline-block; margin-right: 4px; font-size: 16px; }
.ghost-button.loading .refresh-icon { animation: spin .8s linear infinite; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 26px 0 18px; }
.stat-card { padding: 21px 22px; border: 1px solid var(--line); border-radius: 16px; background: rgba(14,21,40,.68); backdrop-filter: blur(12px); }
.stat-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.stat-card strong { display: block; margin-top: 9px; font-size: 27px; letter-spacing: -.035em; }
.stat-card small { display: block; margin-top: 7px; color: #71809f; font-size: 12px; }

.requirement-grid-card { margin-bottom: 18px; }
.requirement-toolbar { min-height: 76px; }
.requirement-summary { flex: 0 0 auto; color: #71809f; font-size: 11px; font-weight: 700; }
.requirement-table { min-width: 760px; }
.requirement-table th:nth-child(1) { width: 38%; }
.requirement-table th:nth-child(2) { width: 20%; }
.requirement-table th:nth-child(3) { width: 24%; }
.requirement-table th:nth-child(4) { width: 18%; }
.requirement-table td { vertical-align: middle; }
.requirement-edit-col { width: 210px; }
.requirement-member-input { max-width: 190px; }
.requirement-readonly { font-size: 13px; font-variant-numeric: tabular-nums; }
.compact-member-cell { min-width: 190px; }
.small-avatar { width: 32px; height: 32px; border-radius: 10px; }
.dashboard-card { overflow: hidden; margin: 0 0 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); backdrop-filter: blur(16px); box-shadow: var(--shadow); }
.table-toolbar { min-height: 88px; padding: 19px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.table-toolbar h2 { margin: 0; font-size: 18px; }
.table-toolbar p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.search-box { width: min(330px, 40vw); height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(5,10,21,.48); color: #6f7b98; }
.search-box:focus-within { border-color: rgba(124,92,255,.45); box-shadow: 0 0 0 3px rgba(124,92,255,.08); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-box input::placeholder { color: #64708c; }

.warning-banner { margin: 14px 18px 0; padding: 12px 14px; border-radius: 11px; font-size: 13px; }
.warning-banner { color: #ffd98b; background: rgba(246,196,83,.08); border: 1px solid rgba(246,196,83,.18); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 15px 20px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: #6f7d9e; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: rgba(7,11,22,.28); }
td { font-size: 14px; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: rgba(255,255,255,.018); }
tbody tr:last-child td { border-bottom: 0; }
.rank-col { width: 58px; color: #5f6a84; }
.points-col { width: 180px; }
.status-col { width: 190px; }
.member-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.avatar { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #c8bcff; font-weight: 800; font-size: 12px; background: linear-gradient(145deg, rgba(124,92,255,.18), rgba(78,105,255,.09)); border: 1px solid rgba(124,92,255,.14); }
.member-meta strong { display: block; font-size: 13.5px; }
.member-meta small { display: block; margin-top: 3px; color: #66728d; font-size: 11px; }
.discord-value { color: #b5c0d9; }
.empty-value { color: #56617a; font-style: italic; }
.points-value { font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: -.015em; }
.points-exact { margin-left: 7px; color: #58637b; font-size: 11px; font-weight: 500; }
.status-badge { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 800; }
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.status-badge.met { color: #8fe9c4; background: var(--green-soft); border: 1px solid rgba(54,211,153,.13); }
.status-badge.met::before { background: var(--green); }
.status-badge.not-met { color: #ff9cad; background: var(--red-soft); border: 1px solid rgba(255,107,129,.13); }
.status-badge.not-met::before { background: var(--red); }
.status-badge.not-set { color: #a9b4cc; background: rgba(151,172,220,.08); border: 1px solid rgba(151,172,220,.12); }
.status-badge.not-set::before { background: #71809f; }
.admin-input, .admin-select { width: 100%; min-width: 130px; height: 36px; border: 1px solid rgba(151,172,220,.16); border-radius: 9px; outline: none; background: #0b1224; color: var(--text); padding: 0 10px; }
.admin-input:focus, .admin-select:focus { border-color: rgba(124,92,255,.55); box-shadow: 0 0 0 3px rgba(124,92,255,.08); }
.admin-input.saving, .admin-select.saving { opacity: .55; }
.loading-row td { height: 180px; text-align: center; color: var(--muted); }
.loading-row td > * { display: inline-block; vertical-align: middle; }
.loader { width: 20px; height: 20px; margin-right: 9px; border: 2px solid rgba(255,255,255,.12); border-top-color: #9a84ff; border-radius: 50%; animation: spin .8s linear infinite; }
.empty-row td { padding: 42px 20px; text-align: center; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

.table-footer { min-height: 49px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: #66728e; border-top: 1px solid var(--line); font-size: 11px; }
footer { min-height: 82px; display: flex; align-items: flex-start; justify-content: space-between; padding-top: 18px; color: #4d5871; font-size: 11px; }

.modal { width: min(430px, calc(100% - 28px)); padding: 0; border: 1px solid rgba(151,172,220,.15); border-radius: 18px; background: #10172a; color: var(--text); box-shadow: 0 35px 100px rgba(0,0,0,.55); }
.modal::backdrop { background: rgba(3,6,14,.72); backdrop-filter: blur(8px); }
.modal form { padding: 24px; }
.modal-header { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.modal-kicker { display: block; margin-bottom: 5px; color: #9e8af7; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.modal h2 { margin: 0; font-size: 22px; }
.modal p { margin: 7px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.icon-button { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.05); font-size: 22px; }
.icon-button:hover { background: rgba(255,255,255,.09); }
.modal label { display: block; margin-top: 14px; }
.modal label > span { display: block; margin-bottom: 7px; color: #91a0be; font-size: 11px; font-weight: 700; }
.modal input { width: 100%; height: 44px; border: 1px solid rgba(151,172,220,.16); border-radius: 11px; outline: 0; padding: 0 12px; color: white; background: #0a1122; }
.modal input:focus { border-color: rgba(124,92,255,.58); box-shadow: 0 0 0 3px rgba(124,92,255,.08); }
.form-error { margin-top: 14px; padding: 10px 11px; border-radius: 9px; color: #ff9dac; background: rgba(255,107,129,.08); font-size: 12px; }
.primary-button { width: 100%; height: 44px; margin-top: 18px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), #5b72ff); font-weight: 800; }
.primary-button:hover { transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .6; transform: none; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: min(360px, calc(100% - 44px)); padding: 12px 15px; border: 1px solid var(--line); border-radius: 11px; background: #151d33; color: #dce4f6; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { color: #ffb2bf; border-color: rgba(255,107,129,.18); }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 22px, 1240px); }
  .topbar { height: 72px; }
  .brand small, .ghost-button { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 16px; }
  .stat-card strong { font-size: 22px; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .table-footer { align-items: flex-start; flex-direction: column; justify-content: center; padding: 11px 18px; }
  footer { flex-direction: column; gap: 7px; }
}
