:root {
  --bg: #0b0f14;
  --card-bg: #131a22;
  --border: #212b36;
  --text: #f5f7fa;
  --muted: #8b98a5;
  --accent: #00babc;
  --accent-dim: #0a3a3a;
  --danger: #ff6b6b;
  --warn: #f0b429;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Segoe UI', Roboto, sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.85rem; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--muted);
}

/* ---- Login screen ---- */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 12px;
  padding: 24px;
  text-align: center;
}
.login-logo { width: 88px; height: 88px; border-radius: 20px; margin-bottom: 8px; }
.login-screen h1 { margin: 0; font-size: 1.5rem; }

.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #04211f;
  font-weight: 600;
  margin-top: 12px;
}

.points-badge {
  margin-left: auto;
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.profile { display: flex; align-items: center; gap: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--card-bg); object-fit: cover; }
.login-name { font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 1rem;
}

/* ---- Grid / Cards ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px;
  max-width: 980px;
  margin: 0 auto;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin: 0 0 10px; font-size: 0.95rem; color: var(--muted); font-weight: 600; }
.card-wide { grid-column: 1 / -1; }
.big-number { font-size: 2.2rem; font-weight: 700; line-height: 1.1; }

/* Hours */
.progress-bar { height: 10px; background: #1c2530; border-radius: 6px; overflow: hidden; margin: 6px 0 10px; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.4s ease; }
.hours-detail { font-size: 0.9rem; }
.daily-needed { margin-top: 6px; font-weight: 600; color: var(--accent); }
.hours-projection { margin-top: 8px; font-size: 0.82rem; color: var(--muted); }
.hours-projection.warn-text { color: var(--warn); }
.hint { margin-top: 8px; color: var(--warn); font-size: 0.8rem; }

/* Exams */
.exam-list { list-style: none; padding: 0; margin: 10px 0 0; font-size: 0.85rem; }
.exam-list li { padding: 4px 0; border-top: 1px solid var(--border); color: var(--muted); }
.exam-list li:first-child { border-top: none; }

/* Ranking */
.top-list { margin: 10px 0 0; padding-left: 18px; font-size: 0.85rem; color: var(--muted); }
.top-list li { padding: 2px 0; }
.top-list li.me { color: var(--accent); font-weight: 600; }
#coalition-detail { margin-top: 8px; }

/* Team status */
.team-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; }
.team-list li { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 0.85rem; }
.team-list .team-project { font-weight: 600; }
.team-list .team-members { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

/* Projects */
.card-header-row { display: flex; align-items: center; justify-content: space-between; }
.toggle { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.project-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.project-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
}
.project-name { font-size: 0.9rem; }
.badge { font-size: 0.72rem; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge.finished { color: var(--accent); border-color: var(--accent-dim); }
.badge.in_progress { color: var(--warn); border-color: #4a3a12; }
.project-check { margin-right: 10px; }
.project-item-left { display: flex; align-items: center; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 100;
}
.modal {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; width: 100%; max-width: 380px;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 0.85rem; color: var(--muted); }
.field input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 8px 10px; font-size: 0.9rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .card-wide { grid-column: 1 / -1; }
}
