
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --black: #000; --white: #fff;
  --gray-50: #fafafa; --gray-100: #f4f4f5; --gray-200: #e4e4e7;
  --gray-300: #d4d4d8; --gray-400: #a1a1aa; --gray-500: #71717a;
  --gray-700: #3f3f46; --gray-900: #18181b;
  --green: #22c55e; --red: #ef4444;
  --radius: 8px;
}
html { scroll-behavior: smooth; }
body { background: var(--white); color: var(--gray-900); font-family: 'Inter', sans-serif; font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }

.page-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--gray-50); }

.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: 12px; padding: 36px 32px; width: 100%; max-width: 420px; }
.card-sm { max-width: 380px; }

.logo-link { display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; letter-spacing: -0.3px; color: var(--black); text-decoration: none; margin-bottom: 28px; }
.logo-link span { color: var(--gray-400); font-weight: 400; }

.card h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.card .subtitle { font-size: 13px; color: var(--gray-500); margin-bottom: 28px; }

.field { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }

input[type=text], input[type=email], input[type=password] {
  width: 100%; background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 10px 13px; color: var(--black);
  font-size: 14px; font-family: 'Inter', sans-serif; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--black); box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
input::placeholder { color: var(--gray-400); }
input.error { border-color: var(--red); }

.input-row { display: flex; background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.input-row:focus-within { border-color: var(--black); box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
.input-prefix { padding: 0 12px; background: var(--gray-50); border-right: 1px solid var(--gray-200); display: flex; align-items: center; font-size: 13px; color: var(--gray-500); white-space: nowrap; flex-shrink: 0; }
.input-row input { border: none; box-shadow: none; flex: 1; }
.input-row input:focus { border: none; box-shadow: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; border: none; font-family: 'Inter', sans-serif; text-decoration: none; transition: all .15s; letter-spacing: -0.1px; }
.btn-primary { background: var(--black); color: var(--white); width: 100%; }
.btn-primary:hover { background: var(--gray-900); }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--red); color: var(--white); }

.form-footer { text-align: center; margin-top: 18px; font-size: 13px; color: var(--gray-500); }
.form-footer a { color: var(--black); font-weight: 500; text-decoration: none; }
.form-footer a:hover { text-decoration: underline; }

.divider { height: 1px; background: var(--gray-200); margin: 20px 0; }

.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

.loading-spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: var(--white); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.dash-nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px;
}
.dash-nav-brand { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; color: var(--black); text-decoration: none; }
.dash-nav-brand span { color: var(--gray-400); font-weight: 400; }
.dash-nav-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dash-nav-user { color: var(--gray-500); }
.dash-nav-user strong { color: var(--black); }
.dash-btn-sm { padding: 5px 12px; font-size: 12px; font-weight: 600; border-radius: 6px; border: 1px solid var(--gray-200); background: var(--white); cursor: pointer; color: var(--gray-700); text-decoration: none; transition: all .15s; }
.dash-btn-sm:hover { background: var(--gray-100); }
.dash-btn-sm.logout { color: var(--red); border-color: #fecaca; }
.dash-btn-sm.logout:hover { background: #fef2f2; }

.dash-layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 52px); }
.dash-sidebar { border-right: 1px solid var(--gray-200); padding: 20px 12px; background: var(--gray-50); position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto; }
.dash-main { padding: 32px; background: var(--white); }

.sidebar-section { margin-bottom: 24px; }
.sidebar-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-400); padding: 0 10px; margin-bottom: 6px; }
.sidebar-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--gray-500); cursor: pointer; transition: all .15s; text-decoration: none; }
.sidebar-item:hover { background: var(--gray-200); color: var(--black); }
.sidebar-item.active { background: var(--white); color: var(--black); box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid var(--gray-200); }
.sidebar-item svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }

.dash-title { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.dash-subtitle { font-size: 13px; color: var(--gray-400); margin-bottom: 28px; }

.stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 28px; }
.stat-card { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 9px; padding: 18px 16px; }
.stat-card-val { font-size: 28px; font-weight: 700; letter-spacing: -1px; }
.stat-card-label { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.stat-card-change { font-size: 11px; margin-top: 6px; }
.stat-card-change.up { color: var(--green); }
.stat-card-change.down { color: var(--red); }

.chart-card { border: 1px solid var(--gray-200); border-radius: 9px; padding: 20px; margin-bottom: 24px; }
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.chart-bar { flex: 1; background: var(--black); border-radius: 2px 2px 0 0; min-height: 2px; transition: opacity .15s; }
.chart-bar:hover { opacity: .7; }

.links-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.link-item { display: flex; align-items: center; gap: 10px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 10px 12px; }
.link-item-drag { cursor: grab; color: var(--gray-300); font-size: 18px; line-height: 1; }
.link-item-info { flex: 1; min-width: 0; }
.link-item-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-item-url { font-size: 11px; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.link-action-btn { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 5px; cursor: pointer; border: none; background: none; transition: background .15s; }
.link-action-btn:hover { background: var(--gray-200); }
.link-action-btn svg { width: 14px; height: 14px; stroke: var(--gray-500); fill: none; stroke-width: 2; }
.link-action-btn.delete:hover { background: #fef2f2; }
.link-action-btn.delete:hover svg { stroke: var(--red); }

.profile-preview { border: 1px solid var(--gray-200); border-radius: 10px; overflow: hidden; }
.preview-header { padding: 24px; text-align: center; border-bottom: 1px solid var(--gray-200); background: var(--gray-50); }
.preview-avatar { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 700; color: var(--white); }
.preview-name { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.preview-bio { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.preview-links { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.preview-link { display: flex; align-items: center; gap: 10px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 12px 14px; font-size: 13px; font-weight: 500; color: var(--black); text-decoration: none; transition: background .15s; }
.preview-link:hover { background: var(--gray-100); }
.preview-link-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--black); flex-shrink: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-400); padding: 0 0 10px; border-bottom: 1px solid var(--gray-200); }
.table td { padding: 10px 0; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
.table tr:last-child td { border-bottom: none; }

@media (max-width: 860px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-sidebar { display: none; }
  .stats-row { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .dash-main { padding: 16px; }
  .card { padding: 24px 20px; }
}
@media (max-width: 360px) {
  .card { padding: 20px 16px; max-width: 100%; }
  .page-shell { padding: 16px; }
  .logo-link { font-size: 16px; margin-bottom: 20px; }
  .btn { font-size: 13px; }
}

[data-theme="dark"] {
  --black: #fff;
  --white: #0a0a0a;
  --gray-50: #111113;
  --gray-100: #1a1a1e;
  --gray-200: #2a2a2f;
  --gray-300: #3a3a40;
  --gray-400: #71717a;
  --gray-500: #a1a1aa;
  --gray-700: #d4d4d8;
  --gray-900: #fafafa;
}
[data-theme="dark"] .dash-nav {
  background: rgba(10,10,10,.92);
}
[data-theme="dark"] .alert-error { background: #2a1010; border-color: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .alert-success { background: #0f2a1a; border-color: #14532d; color: #86efac; }
[data-theme="dark"] input[type=text],
[data-theme="dark"] input[type=email],
[data-theme="dark"] input[type=password] {
  background: var(--gray-100);
  color: var(--gray-900);
}
[data-theme="dark"] .input-row { background: var(--gray-100); }
[data-theme="dark"] .input-prefix { background: var(--gray-200); }
[data-theme="dark"] .page-shell { background: var(--gray-100); }

.theme-pill-toggle {
  display: flex; align-items: center; gap: 6px;
  background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: 999px; padding: 4px 8px;
  cursor: pointer; transition: background .2s, border-color .2s;
  flex-shrink: 0;
}
.theme-pill-toggle:hover { background: var(--gray-200); }
.tpt-icon { font-size: 13px; line-height: 1; transition: opacity .2s; }
.tpt-track {
  width: 28px; height: 16px; background: var(--gray-300);
  border-radius: 999px; position: relative;
  transition: background .2s; flex-shrink: 0;
}
.tpt-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; background: var(--white);
  border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s, background .2s;
}

.theme-pill-toggle[data-active="light"] .tpt-sun  { opacity: 1; }
.theme-pill-toggle[data-active="light"] .tpt-moon { opacity: 0.35; }
.theme-pill-toggle[data-active="light"] .tpt-track { background: #e4e4e7; }
.theme-pill-toggle[data-active="light"] .tpt-thumb { transform: translateX(0); }

.theme-pill-toggle[data-active="dark"] .tpt-sun  { opacity: 0.35; }
.theme-pill-toggle[data-active="dark"] .tpt-moon { opacity: 1; }
.theme-pill-toggle[data-active="dark"] .tpt-track { background: #3f3f46; }
.theme-pill-toggle[data-active="dark"] .tpt-thumb { transform: translateX(12px); background: #fafafa; }

#globalThemeBtn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-900);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.10);
  transition: transform .15s, box-shadow .15s, background .2s;
  line-height: 1;
}
#globalThemeBtn:hover {
  transform: scale(1.12);
  box-shadow: 0 4px 18px rgba(0,0,0,.16);
}
[data-theme="dark"] #globalThemeBtn {
  background: var(--gray-100);
  border-color: var(--gray-200);
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
}

.discord-invite-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  background: #5865F2;
  color: #fff !important;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, transform .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(88,101,242,.35);
  white-space: nowrap;
}
.discord-invite-btn:hover {
  background: #4752C4;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(88,101,242,.45);
}
.discord-invite-btn svg { flex-shrink: 0; }

[data-theme="dark"] { --logo-filter: invert(1); }
[data-theme="light"] { --logo-filter: none; }
