:root {
  --ink: #1B1B2E;
  --ink-soft: #4A4A42;
  --muted: #6B6B63;
  --border: #E4E4DE;
  --bg: #F6F6F3;
  --card: #FFFFFF;
  --amber: #F0A63B;
  --amber-soft: #FCEBCB;
  --teal: #2F9E8F;
  --teal-soft: #D8F0EA;
  --danger: #D65B4A;
  --sidebar: #1B1B2E;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display {
  font-family: 'Space Grotesk', sans-serif;
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

#app { min-height: 100vh; }

/* ---------- Login screen ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #12121F;
  padding: 24px;
}
.login-card-wrap { width: 100%; max-width: 420px; }
.login-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(240,166,59,0.13);
  color: var(--amber);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.login-title { color: white; font-size: 30px; font-weight: 600; margin: 0; }
.login-sub { color: rgba(255,255,255,0.5); font-size: 14px; margin-top: 8px; }
.login-header { text-align: center; margin-bottom: 32px; }
.login-card {
  background: #1C1C2E;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 28px;
}
.field-label { display: block; font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.5); margin-bottom: 8px; }
.role-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.role-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 12px; font-size: 14px; font-weight: 500;
  background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.7);
  transition: background 0.15s, color 0.15s;
}
.role-btn.active { background: var(--amber); color: var(--ink); font-weight: 600; }
.login-input {
  width: 100%; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); color: white; outline: none;
}
.login-input::placeholder { color: rgba(255,255,255,0.35); }
.login-input:focus { border-color: var(--amber); }
.login-primary-btn {
  width: 100%; border: none; border-radius: 12px; padding: 13px; font-size: 14px; font-weight: 600;
  background: var(--amber); color: var(--ink);
}
.login-primary-btn:disabled { opacity: 0.4; cursor: default; }
.login-switch { text-align: center; margin-top: 16px; font-size: 13px; color: rgba(255,255,255,0.5); }
.login-switch button { background: none; border: none; color: var(--amber); font-weight: 600; padding: 0; margin-left: 4px; }
.login-error {
  background: rgba(214,91,74,0.15); color: #F09484; border-radius: 10px; padding: 10px 12px;
  font-size: 13px; margin-bottom: 16px;
}

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px; flex-shrink: 0; background: var(--sidebar); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-brand-row { display: flex; align-items: center; gap: 8px; }
.sidebar-brand-title { color: white; font-weight: 600; font-size: 14px; }
.sidebar-brand-sub { color: rgba(255,255,255,0.4); font-size: 12px; margin-top: 4px; }

.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px; border: none; background: none;
  border-radius: 10px; padding: 10px 12px; text-align: left; color: rgba(255,255,255,0.7); font-size: 14px;
  margin-bottom: 2px;
}
.nav-item.active { background: var(--amber); color: var(--ink); font-weight: 600; }
.nav-item:not(.active):hover { background: rgba(255,255,255,0.06); }

.phase-item {
  width: 100%; display: flex; align-items: center; gap: 12px; border: none; background: none;
  border-radius: 10px; padding: 10px 12px; text-align: left; margin-bottom: 2px;
}
.phase-item.active { background: rgba(255,255,255,0.08); }
.phase-dot {
  height: 24px; width: 24px; flex-shrink: 0; border-radius: 999px; display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 600; background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7);
}
.phase-dot.done { background: var(--teal); color: white; }

.nav-icon-badge {
  height: 24px; min-width: 34px; flex-shrink: 0; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  background: rgba(240,166,59,0.16); color: var(--amber); padding: 0 6px;
}
.phase-title { color: white; font-size: 13px; line-height: 1.3; }
.phase-subtitle { color: rgba(255,255,255,0.4); font-size: 11px; margin-top: 1px; }
.phase-text { min-width: 0; overflow: hidden; }
.phase-text > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.progress-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.progress-track { flex: 1; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.1); overflow: hidden; max-width: 150px; }
.progress-fill { height: 100%; background: var(--amber); border-radius: 999px; }
.progress-label { font-size: 12px; color: rgba(255,255,255,0.6); }

.user-row { display: flex; align-items: center; justify-content: space-between; }
.user-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar {
  height: 32px; width: 32px; border-radius: 999px; background: var(--amber); color: var(--ink);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.user-name { color: white; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,0.4); font-size: 11px; text-transform: capitalize; }
.logout-btn { background: none; border: none; color: rgba(255,255,255,0.4); padding: 4px; flex-shrink: 0; }
.logout-btn:hover { color: rgba(255,255,255,0.9); }

.main { flex: 1; padding: 32px; overflow-y: auto; min-width: 0; }
.content-max { max-width: 720px; }
.content-max-wide { max-width: 860px; }

.section-eyebrow { font-size: 12px; font-weight: 500; color: var(--amber); margin-bottom: 4px; }
.section-title { font-size: 26px; font-weight: 600; margin: 0; }
.section-desc { color: var(--muted); font-size: 14px; margin-top: 6px; max-width: 520px; }
.section-header { margin-bottom: 24px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.card + .card { margin-top: 20px; }
.card-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-title { font-size: 14px; font-weight: 600; }
.doc-image { width: 100%; max-width: 100%; height: auto; display: block; margin: 8px 0 16px; border-radius: 10px; border: 1px solid var(--border); background: #fff; }
.card-text { font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.card-hint { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.form-input, .form-textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; margin-bottom: 14px;
}
.form-textarea { resize: vertical; }
.form-input:focus, .form-textarea:focus { border-color: var(--amber); }
.form-row-inline { display: flex; align-items: center; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border: none; border-radius: 10px; padding: 10px 16px;
  font-size: 14px; font-weight: 600;
}
.btn-primary { background: var(--ink); color: white; }
.btn-accent { background: var(--amber); color: var(--ink); }
.btn-ghost { background: var(--bg); color: var(--ink); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.saved-flash { font-size: 12px; color: var(--teal); }

.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 500; }
.badge-neutral { background: #E9E9E3; color: #4A4A42; }
.badge-done { background: #DCEFE3; color: #2A7A4D; }

.chip { border: none; border-radius: 999px; padding: 7px 14px; font-size: 12px; font-weight: 500; background: #E9E9E3; color: #4A4A42; margin: 0 6px 6px 0; }
.chip.active { background: var(--ink); color: white; }
.chip-row { display: flex; flex-wrap: wrap; margin-bottom: 16px; }

.likert-item { margin-bottom: 18px; }
.likert-text { font-size: 14px; margin-bottom: 8px; }
.likert-options { display: flex; gap: 8px; }
.likert-btn {
  height: 32px; width: 32px; border-radius: 999px; border: none; font-size: 12px; font-weight: 600;
  background: var(--bg); color: var(--muted);
}
.likert-btn.active { background: var(--amber); color: var(--ink); }

.grade-box { background: var(--bg); border-radius: 10px; padding: 14px; margin-top: 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px; }
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 600; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-label { font-size: 12px; color: var(--muted); width: 190px; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; border-radius: 999px; background: #F0F0EA; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-value { font-size: 12px; color: var(--muted); width: 60px; text-align: right; flex-shrink: 0; }

.student-row { display: flex; align-items: center; justify-content: space-between; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; }
.student-name { font-size: 14px; font-weight: 600; }
.mini-dots { display: flex; gap: 4px; margin-top: 8px; }
.mini-dot { height: 8px; width: 24px; border-radius: 999px; background: var(--border); }
.mini-dot.done { background: var(--teal); }
.student-actions { display: flex; align-items: center; gap: 12px; }

.empty-state { color: var(--muted); font-size: 14px; }

/* Mobile top bar toggle */
.mobile-topbar { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .stat-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--sidebar); padding: 14px 16px; position: sticky; top: 0; z-index: 20;
  }
  .mobile-topbar-brand { color: white; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
  .mobile-menu-btn { background: rgba(255,255,255,0.08); border: none; color: white; border-radius: 8px; padding: 8px 10px; font-size: 13px; }

  .sidebar {
    width: 100%; height: auto; position: static; display: none; flex-direction: column;
  }
  .sidebar.open { display: flex; }
  .sidebar-nav { max-height: 50vh; }

  .main { padding: 20px 16px 90px; }
  .content-max, .content-max-wide { max-width: 100%; }

  .bar-label { width: 120px; font-size: 11px; }
  .student-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .student-actions { width: 100%; justify-content: space-between; }
}

@media (max-width: 480px) {
  .role-toggle { grid-template-columns: 1fr 1fr; }
  .likert-options { flex-wrap: wrap; }
  .form-row-inline { flex-wrap: wrap; }
}
