/* ── 520 Performance System ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #12141c;
  --surface: #1a1e2b;
  --surface2: #242a3d;
  --surface3: #2e364d;
  --border: rgba(255,255,255,0.1);
  --accent: #6aa3ff;
  --accent2: #9b8cff;
  --gold: #f5d742;
  --green: #5bdb9e;
  --red: #ff7a7a;
  --orange: #ffa766;
  --text: #ffffff;
  --text-muted: #b0b8cc;
  --text-dim: #7880a0;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
}

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

html { font-size: 15px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Typography ── */
h1, h2, h3 { font-family: var(--sans); font-weight: 400; line-height: 1.2; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.3rem; }
p { color: var(--text); }
a { color: var(--accent); text-decoration: none; }

/* ── Layout ── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .brand {
  font-family: var(--sans);
  font-size: 1.6rem;
  color: var(--text);
  letter-spacing: -0.5px;
}

.sidebar-logo .brand span { color: var(--accent); }
.sidebar-logo .sub { font-size: 0.72rem; color: var(--text-dim); letter-spacing: 2px; text-transform: uppercase; margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface3); color: var(--text); }
.nav-item svg { width: 17px; height: 17px; opacity: 0.7; flex-shrink: 0; }
.nav-item:hover svg, .nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 36px 40px;
  max-width: 1400px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card-sm { padding: 18px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Stat cards ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
}

.stat-card.gold::before { background: var(--gold); }
.stat-card.green::before { background: var(--green); }
.stat-card.purple::before { background: var(--accent2); }
.stat-card.red::before { background: var(--red); }

.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); margin-bottom: 8px; }
.stat-value { font-family: var(--sans); font-size: 2rem; color: var(--text); }
.stat-sub { font-size: 0.78rem; color: var(--text-dim); margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3a7de8; filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); border-color: var(--accent); }
.btn-danger { background: rgba(247,95,95,0.15); color: var(--red); border: 1px solid rgba(247,95,95,0.2); }
.btn-danger:hover { background: rgba(247,95,95,0.25); }
.btn-success { background: rgba(62,207,142,0.15); color: var(--green); border: 1px solid rgba(62,207,142,0.2); }
.btn-success:hover { background: rgba(62,207,142,0.25); }
.btn-gold { background: rgba(245,200,66,0.15); color: var(--gold); border: 1px solid rgba(245,200,66,0.2); }
.btn-gold:hover { background: rgba(245,200,66,0.25); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 6px; letter-spacing: 0.5px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--accent); }
.form-select { cursor: pointer; }
option { background: var(--surface2); }

/* ── Score inputs ── */
.score-input {
  width: 76px;
  text-align: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.score-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(106,163,255,0.25); }
.score-input[readonly] { opacity: 0.65; cursor: not-allowed; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th { padding: 12px 16px; text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 600; }
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr:hover td { background: var(--surface2); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.badge-green { background: rgba(62,207,142,0.15); color: var(--green); }
.badge-yellow { background: rgba(245,200,66,0.15); color: var(--gold); }
.badge-red { background: rgba(247,95,95,0.15); color: var(--red); }
.badge-blue { background: rgba(79,142,247,0.15); color: var(--accent); }
.badge-gray { background: rgba(122,130,153,0.15); color: var(--text-muted); }

/* ── Page header ── */
.page-header { margin-bottom: 28px; }
.page-header .breadcrumb { font-size: 0.78rem; color: var(--text-dim); margin-bottom: 8px; }
.page-header .breadcrumb a { color: var(--accent); }
.page-header h1 { margin-bottom: 6px; }
.page-header p { font-size: 0.88rem; }

/* ── Section header ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-family: var(--sans); font-size: 1.2rem; }

/* ── Question rows ── */
.question-row {
  display: grid;
  grid-template-columns: 1fr 86px 86px 86px;
  gap: 12px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.question-row:hover { background: var(--surface2); }
.question-row:last-child { border-bottom: none; }
.question-text { font-size: 0.88rem; color: var(--text); font-weight: 450; line-height: 1.5; }
.question-num { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); font-size: 0.75rem; font-weight: 600; color: #fff; margin-right: 12px; flex-shrink: 0; }
.col-header { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); text-align: center; font-weight: 600; }

.align-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 30px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  margin: auto;
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}
.modal-backdrop.open .modal { transform: scale(1); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.4rem; padding: 0; line-height: 1; }
.modal-close:hover { color: var(--text); }

/* ── Charts ── */
.chart-container { position: relative; width: 100%; }

/* ── Bonus result card ── */
.bonus-result {
  background: linear-gradient(135deg, rgba(79,142,247,0.08), rgba(124,106,245,0.08));
  border: 1px solid rgba(79,142,247,0.2);
  border-radius: var(--radius);
  padding: 28px;
  margin-top: 24px;
}

.bonus-amount {
  font-family: var(--sans);
  font-size: 2.8rem;
  color: var(--gold);
  margin: 8px 0;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.85rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-dim); font-size: 0.88rem; }
.detail-row .value { font-weight: 600; color: var(--text); font-size: 0.92rem; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
  max-width: 300px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-dim); }
.empty-state svg { opacity: 0.2; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* ── Print styles ── */
@media print {
  .sidebar, .btn, .modal-backdrop { display: none !important; }
  .main-content { margin-left: 0; padding: 20px; }
  body { background: white; color: black; }
  .card, .stat-card { border: 1px solid #ddd; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; padding: 20px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .question-row { grid-template-columns: 1fr; }
}

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

/* ── Misc ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.text-accent { color: var(--accent); }
.text-gold { color: var(--gold); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }

.text-sm { font-size: 0.82rem; }
