:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --surface2: #1e1e1e;
  --surface3: #252525;
  --border: #2a2a2a;
  --primary: #c9a227;
  --primary-dim: #a07f1a;
  --primary-glow: rgba(201,162,39,0.15);
  --blue: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --purple: #a855f7;
  --orange: #f97316;
  --text: #f0f0f0;
  --text-muted: #8a8a8a;
  --text-dim: #555;
  --radius: 10px;
  --radius-sm: 6px;
  --nav-h: 64px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ── NAV ── */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 8px;
}

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; color: var(--text);
  margin-right: 16px; white-space: nowrap;
}
.nav-brand .piano-icon {
  font-size: 22px;
}
.nav-brand span.accent { color: var(--primary); }

.nav-links { display: flex; gap: 2px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  transition: all .15s; cursor: pointer; border: none; background: none;
  text-decoration: none;
}
.nav-link:hover { color: var(--text); background: var(--surface3); text-decoration: none; }
.nav-link.active { color: var(--primary); background: var(--primary-glow); }
.nav-link svg { width: 15px; height: 15px; flex-shrink: 0; }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-user { font-size: 13px; color: var(--text-muted); }
.nav-user strong { color: var(--text); }

/* ── LAYOUT ── */
.page {
  margin-top: var(--nav-h);
  min-height: calc(100vh - var(--nav-h));
  padding: 32px 24px;
  max-width: 1280px;
  margin-left: auto; margin-right: auto;
  margin-top: calc(var(--nav-h) + 0px);
}
.page-wide { max-width: 1440px; }

/* ── AUTH ── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(201,162,39,0.08) 0%, transparent 60%);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center; margin-bottom: 28px;
}
.auth-logo .piano-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.auth-logo h1 { font-size: 22px; font-weight: 800; color: var(--text); }
.auth-logo h1 span { color: var(--primary); }
.auth-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.auth-tab {
  flex: 1; padding: 10px; text-align: center; cursor: pointer;
  color: var(--text-muted); font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all .15s;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; transition: all .15s; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #000; }
.btn-primary:hover { background: #e0b42f; }
.btn-secondary { background: var(--surface3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface2); border-color: #444; }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-ghost { background: none; color: var(--text-muted); padding: 6px 10px; }
.btn-ghost:hover { color: var(--text); background: var(--surface3); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }

/* ── CARDS ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.card-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; color: var(--text-muted); margin-bottom: 16px;
}

/* ── KPI GRID ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi-card.gold { border-color: rgba(201,162,39,0.4); background: linear-gradient(135deg, var(--surface) 0%, rgba(201,162,39,0.05) 100%); }
.kpi-card.gold .kpi-value { color: var(--primary); }
.kpi-card.blue .kpi-value { color: var(--blue); }
.kpi-card.green .kpi-value { color: var(--green); }
.kpi-card.purple .kpi-value { color: var(--purple); }
.kpi-card.orange .kpi-value { color: var(--orange); }

/* ── BADGE ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 700;
}
.badge-gold { background: rgba(201,162,39,0.2); color: var(--primary); border: 1px solid rgba(201,162,39,0.4); }
.badge-blue { background: rgba(59,130,246,0.15); color: var(--blue); border: 1px solid rgba(59,130,246,0.3); }
.badge-green { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.badge-purple { background: rgba(168,85,247,0.15); color: var(--purple); border: 1px solid rgba(168,85,247,0.3); }
.badge-orange { background: rgba(249,115,22,0.15); color: var(--orange); border: 1px solid rgba(249,115,22,0.3); }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 12px 14px; font-size: 13px; vertical-align: middle; }
.rank-1 td:first-child { color: var(--primary); font-weight: 800; }
.rank-2 td:first-child { color: #c0c0c0; font-weight: 700; }
.rank-3 td:first-child { color: #cd7f32; font-weight: 700; }

/* ── PROGRESS BAR ── */
.progress-bar {
  height: 6px; background: var(--surface3); border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--primary); border-radius: 99px;
  transition: width .4s ease;
}
.progress-fill.blue { background: var(--blue); }
.progress-fill.green { background: var(--green); }

/* ── DAILY LOG FORM ── */
.log-grid { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
.day-picker-list { display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 160px); overflow-y: auto; }
.day-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--text-muted);
  font-size: 13px; transition: all .1s; text-align: left; width: 100%;
}
.day-btn:hover { background: var(--surface2); color: var(--text); }
.day-btn.active { background: var(--primary-glow); border-color: rgba(201,162,39,0.4); color: var(--primary); font-weight: 600; }
.day-btn.logged { color: var(--text); }
.day-btn .dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.day-btn.logged .dot { background: var(--green); }
.day-btn:not(.logged) .dot { background: var(--surface3); border: 1px solid var(--border); }
.day-btn.future { opacity: .45; }

.entry-form-card { position: sticky; top: calc(var(--nav-h) + 20px); }

/* Checkboxes in form */
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  cursor: pointer; user-select: none; transition: all .1s;
}
.check-item:hover { border-color: #444; }
.check-item input[type=checkbox] { display: none; }
.check-item .check-box {
  width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0;
  border: 2px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center; transition: all .1s;
}
.check-item input:checked ~ .check-box {
  background: var(--primary); border-color: var(--primary);
}
.check-item input:checked ~ .check-box::after {
  content: '✓'; font-size: 11px; color: #000; font-weight: 800;
}
.check-item input:checked ~ .check-label { color: var(--text); }
.check-label { font-size: 13px; color: var(--text-muted); line-height: 1.3; }
.check-pts { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--primary); }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric-input { position: relative; }
.metric-input label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 5px; }
.metric-input input {
  width: 100%; padding: 9px 10px 9px 32px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
}
.metric-input input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.metric-icon { position: absolute; bottom: 9px; left: 10px; font-size: 13px; color: var(--text-dim); }
.pts-label { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

/* Score preview */
.score-preview {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  padding: 16px; background: var(--surface2); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.sp-item { text-align: center; }
.sp-val { font-size: 20px; font-weight: 800; color: var(--primary); }
.sp-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-top: 2px; }
.sp-item.total .sp-val { font-size: 26px; color: var(--green); }

/* ── WEEKLY HEATMAP ── */
.heatmap-wrap { overflow-x: auto; }
.heatmap-table { min-width: 900px; }
.heatmap-table td.heat-cell {
  text-align: center; font-size: 12px; font-weight: 600;
  border-radius: 4px; min-width: 58px;
}
.heat-0 { background: var(--surface2); color: var(--text-dim); }
.heat-1 { background: rgba(201,162,39,0.12); color: #a07f1a; }
.heat-2 { background: rgba(201,162,39,0.25); color: #c09020; }
.heat-3 { background: rgba(201,162,39,0.45); color: #d4a820; }
.heat-4 { background: rgba(201,162,39,0.7); color: #1a1200; }
.heat-5 { background: var(--primary); color: #000; }

/* ── CHART ── */
.chart-wrap { position: relative; height: 200px; }

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 800; }
.page-header p { color: var(--text-muted); margin-top: 4px; }

/* ── SECTION ── */
.section { margin-top: 24px; }
.section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-muted); margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── ALERT / TOAST ── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px;
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.alert-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.alert-info { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.25); color: #93c5fd; }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 20px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: none; } }

/* ── SPINNER ── */
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; padding: 48px; }

/* ── MISC ── */
.text-gold { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 960px;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-body { overflow-y: auto; flex: 1; }

/* ── ADMIN TABS ── */
.admin-tabs {
  display: flex; gap: 0; margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.admin-tab {
  padding: 10px 22px; border: none; background: none;
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all .15s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── NAV PROFILE DROPDOWN ── */
.nav-profile { position: relative; }
.nav-profile-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  transition: all .15s;
}
.nav-profile-btn:hover { background: var(--surface3); color: var(--text); }
.nav-profile-btn svg { width: 12px; height: 12px; transition: transform .2s; flex-shrink: 0; }
.nav-profile.open .nav-profile-btn svg { transform: rotate(180deg); }
.nav-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); min-width: 170px;
  box-shadow: var(--shadow); z-index: 200; overflow: hidden;
}
.nav-profile.open .nav-dropdown { display: block; }
.nav-dropdown-item {
  display: flex; align-items: center; width: 100%;
  padding: 10px 16px; font-size: 13px; color: var(--text-muted);
  background: none; border: none; cursor: pointer;
  text-align: left; text-decoration: none; transition: all .1s;
}
.nav-dropdown-item:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-dropdown-danger:hover { color: var(--red); }

/* ── WELCOME MODAL ── */
.welcome-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.welcome-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 580px;
  box-shadow: var(--shadow); overflow: hidden;
}
.welcome-box-header { padding: 32px 32px 0; text-align: center; }
.welcome-box-body { padding: 20px 32px 32px; }
.welcome-box-body video { width: 100%; border-radius: var(--radius-sm); margin-bottom: 16px; display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* ── MERCH ── */
.merch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.merch-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; transition: border-color .2s, transform .2s;
}
.merch-card:hover { border-color: rgba(201,162,39,0.4); transform: translateY(-3px); }
.merch-img-wrap { width: 100%; aspect-ratio: 1; overflow: hidden; background: var(--surface2); }
.merch-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.merch-img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 48px; color: var(--text-muted); }
.merch-body { padding: 16px; }
.merch-name { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.merch-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }
.merch-footer { display: flex; align-items: center; justify-content: space-between; }
.merch-price { font-size: 20px; font-weight: 900; color: var(--primary); }

/* ── CHAT BUBBLE ── */
#chat-unread-badge { display: flex; }

@media (max-width: 768px) {
  .log-grid { grid-template-columns: 1fr; }
  .entry-form-card { position: static; }
  .day-picker-list { max-height: 200px; flex-direction: row; flex-wrap: wrap; overflow-x: auto; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  nav { padding: 0 12px; }
  .nav-brand span:not(.accent):not(.piano-icon) { display: none; }
}
