:root {
  --bg: #f6f7f8;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --muted-2: #9aa1ac;
  --line: #e6e8eb;
  --soft: #f1f3f5;
  --accent: #16a34a;
  --accent-dark: #0f7a37;
  --accent-soft: #e7f6ec;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.1);
  --radius: 14px;
  --radius-lg: 20px;
  --sidebar-width: 248px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; max-width: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
h1, h2, h3 { margin: 0 0 6px; line-height: 1.15; }
h1 { font-size: 1.9rem; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.85rem; }

.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.stack { display: grid; gap: 14px; }
.compact { gap: 12px; margin-top: 14px; }

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { resize: vertical; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 650;
  background: var(--soft);
  color: var(--ink);
  transition: transform 0.1s ease, opacity 0.1s ease, background 0.15s ease;
}

.button:hover { background: var(--line); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button.primary { background: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-dark); }
.button.danger { background: var(--danger-soft); color: var(--danger); }
.button.danger:hover { background: #fecaca; }
.button.ghost { background: transparent; border: 1px solid var(--line); }
.button.ghost:hover { background: var(--soft); }
.button.small { padding: 7px 12px; font-size: 0.85rem; }

.message { min-height: 20px; color: var(--danger); font-weight: 600; font-size: 0.9rem; }
.message.success { color: var(--accent-dark); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 5px 11px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 650;
  font-size: 0.78rem;
  white-space: nowrap;
}

.pill.accent { background: var(--accent-soft); color: var(--accent-dark); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------------- */
/* Auth / login shell                                                     */
/* ---------------------------------------------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: min(100%, 400px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 22px;
  margin-bottom: 14px;
}

.brand-mark img { width: 28px; height: 28px; border-radius: 8px; }

.org-brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  margin-bottom: 14px;
}

.setup-help { margin-top: 16px; color: var(--muted); font-size: 0.85rem; }
.auth-links { margin-top: 18px; text-align: center; font-size: 0.86rem; color: var(--muted); }
.auth-links a { color: var(--accent-dark); font-weight: 650; text-decoration: none; }

.auth-back-link {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 650;
  font-size: 0.86rem;
}

.auth-back-link:hover { color: var(--ink); }

/* ---------------------------------------------------------------------- */
/* App shell: sidebar + main                                              */
/* ---------------------------------------------------------------------- */

.app-shell { display: flex; min-height: 100vh; align-items: flex-start; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 16px;
  font-weight: 800;
  font-size: 1.02rem;
}

.sidebar-brand .brand-dot {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 14px;
  overflow: hidden;
}

.sidebar-brand .brand-dot img { width: 100%; height: 100%; display: block; object-fit: cover; }

.workspace-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}

.workspace-card .avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.78rem;
  flex-shrink: 0;
  overflow: hidden;
}

.workspace-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.workspace-card div { min-width: 0; }
.workspace-card strong { display: block; font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-card small { display: block; color: var(--muted); font-size: 0.74rem; }

.nav-section-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 700;
  padding: 12px 10px 6px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 620;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.sidebar-nav button:hover { background: var(--soft); }
.sidebar-nav button.active { background: var(--accent-soft); color: var(--accent-dark); }
.sidebar-nav .nav-icon { width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-nav .nav-count {
  margin-left: auto;
  background: var(--soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.74rem;
  font-weight: 700;
}

.sidebar-nav button.active .nav-count { background: rgba(15, 122, 55, 0.14); color: var(--accent-dark); }

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-footer .avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--soft);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.sidebar-footer .who { flex: 1; min-width: 0; }
.sidebar-footer .who strong { display: block; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .who small { color: var(--muted); font-size: 0.74rem; text-transform: capitalize; }

.main { flex: 1; min-width: 0; padding: 26px clamp(18px, 4vw, 40px) 60px; }

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.main-header .date { color: var(--muted); font-weight: 600; font-size: 0.88rem; margin-bottom: 2px; }

/* Simple top bar used for the (single-page) learner portal */

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px clamp(16px, 5vw, 40px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 800; font-size: 1.02rem; }
.brand img { width: 26px; height: 26px; border-radius: 7px; object-fit: cover; }

.topbar nav, .row-actions, .inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.dashboard {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 4vw, 36px);
  display: grid;
  gap: 20px;
}

/* ---------------------------------------------------------------------- */
/* Cards / panels                                                         */
/* ---------------------------------------------------------------------- */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 26px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
}

.stat-tile .icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 18px;
}

.stat-tile strong { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat-tile span { color: var(--muted); font-size: 0.8rem; font-weight: 620; }

.stat-card, .progress-ring {
  flex: 0 0 auto;
  min-width: 150px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  color: var(--accent-dark);
}

.stat-card span, .progress-ring strong { display: block; font-size: 2.2rem; font-weight: 800; line-height: 1; margin: 0; }
.stat-card small, .progress-ring span { color: var(--muted); font-size: 0.82rem; font-weight: 620; margin: 0; }

.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.library-grid { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
.employee-layout { max-width: 960px; }

.section-heading { display: flex; justify-content: space-between; gap: 14px; align-items: start; margin-bottom: 4px; }

.app-section { display: none; flex-direction: column; gap: 20px; }
.app-section.active { display: flex; }

.list { display: grid; gap: 10px; margin-top: 14px; }

.list-item {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.list-item header { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.list-item p { margin: 0; color: var(--muted); }

.item-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-button {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  color: var(--ink);
  padding: 7px 11px;
  cursor: pointer;
  font-weight: 620;
  font-size: 0.85rem;
  text-decoration: none;
}

.icon-button:hover { background: var(--soft); }
.icon-button.danger { color: var(--danger); border-color: #f3c9c9; }
.icon-button.danger:hover { background: var(--danger-soft); }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.progress-bar { height: 8px; border-radius: 999px; overflow: hidden; background: var(--soft); }
.progress-bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.path-progress { margin-top: 14px; }

/* ---------------------------------------------------------------------- */
/* Tables                                                                  */
/* ---------------------------------------------------------------------- */

.data-toolbar {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 160px 160px;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

/* Wide enough (name+email+permission+progress+actions) that it can outgrow
   the viewport well before the single-column mobile layout below kicks in -
   scrolling horizontally here beats letting the Actions column silently run
   off the edge of the screen with no indication it's there. */
.data-table { overflow-x: auto; }
.data-table-inner { display: grid; gap: 8px; min-width: 880px; }

.data-table-header, .data-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.3fr) minmax(160px, 1fr) 110px minmax(150px, 1fr) 300px;
  gap: 12px;
  align-items: start;
}

.data-table-header {
  padding: 0 14px;
  color: var(--muted-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.data-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 14px;
}

.data-row strong { display: block; line-height: 1.2; }
.data-row small { color: var(--muted); display: block; margin-top: 2px; }

/* Grid items default to a min-width that ignores their own content, which
   is what let long emails bleed into the next column instead of truncating. */
.data-row > div { min-width: 0; }

.data-row > div:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A fixed 2-up grid (instead of flex-wrap) keeps every row's action column
   exactly two lines tall regardless of how long a given button's label is
   ("Make admin" vs "Make team member"), so row boundaries stay aligned
   across the whole table instead of drifting per row. */
.data-row .item-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.row-progress-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 0.82rem; font-weight: 650; margin-bottom: 6px; }

.row-detail {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 12px;
  display: grid;
  gap: 10px;
}

.row-detail header { display: flex; justify-content: space-between; gap: 10px; }
.row-detail p { margin: 0; color: var(--muted); }

/* ---------------------------------------------------------------------- */
/* Curriculum grid                                                        */
/* ---------------------------------------------------------------------- */

.curriculum-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.curriculum-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 480px;
}

.curriculum-table th, .curriculum-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

.curriculum-table thead th {
  position: sticky;
  top: 0;
  background: var(--soft);
  color: var(--muted-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: normal;
  min-width: 140px;
  z-index: 1;
}

.curriculum-table tbody th {
  position: sticky;
  left: 0;
  background: var(--card);
  text-align: left;
  font-weight: 650;
  white-space: nowrap;
  z-index: 1;
}

.curriculum-table thead th:first-child, .curriculum-table tbody th {
  left: 0;
  z-index: 2;
  box-shadow: 1px 0 0 var(--line);
}

.curriculum-table tbody tr:last-child th, .curriculum-table tbody tr:last-child td { border-bottom: none; }

.curriculum-table input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

.lesson-status-list { display: grid; gap: 8px; }

.lesson-status-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--soft);
}

/* ---------------------------------------------------------------------- */
/* Library / path cards                                                   */
/* ---------------------------------------------------------------------- */

.card-library, .lesson-path { display: grid; gap: 10px; margin-top: 14px; }

.entity-card, .lesson-path-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  text-align: left;
  cursor: pointer;
}

.entity-card:hover, .lesson-path-card:hover { border-color: var(--accent); }
.entity-card.active, .lesson-path-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lesson-path-card.locked { cursor: not-allowed; opacity: 0.6; }

.entity-card strong, .lesson-path-card strong { display: block; line-height: 1.2; }
.entity-card small, .lesson-path-card small { color: var(--muted); display: block; font-weight: 550; line-height: 1.35; margin-top: 3px; }

.entity-card-number, .lesson-card-number {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 0.86rem;
  flex-shrink: 0;
}

.section-gap { margin-top: 1.25rem; }

.review-file, .approval-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.question-review-list { display: grid; gap: 12px; }

.question-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 15px;
  display: grid;
  gap: 12px;
}

.question-card.approved { border-color: rgba(15, 122, 55, 0.4); box-shadow: 0 0 0 3px var(--accent-soft); }
.question-card.rejected { opacity: 0.55; }

.answer-list { display: grid; gap: 7px; }

.answer-choice { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; color: var(--muted); background: white; }
.answer-choice.correct { border-color: rgba(15, 122, 55, 0.4); background: var(--accent-soft); color: var(--ink); font-weight: 650; }

.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.approve-button { background: var(--accent); color: white; }
.reject-button { background: white; color: var(--danger); border: 1px solid var(--line); }
.replace-button { min-width: 50px; background: white; border: 1px solid var(--line); color: var(--ink); }

.nav-list .list-item { cursor: pointer; }
.nav-list .list-item.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.lesson-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 9px; border-radius: 10px; background: var(--soft); }

.lesson-reader-inner { display: grid; gap: 14px; }
.lesson-content { white-space: pre-wrap; color: var(--muted); line-height: 1.55; }

.material-card {
  display: block;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: var(--radius);
  padding: 14px;
  font-weight: 650;
  text-decoration: none;
  color: var(--accent-dark);
}

.status-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--muted-2); display: inline-block; }
.status-dot.complete { background: var(--accent); }
.status-dot.in-progress { background: var(--warn); }

.inline-form input, .inline-form select { flex: 1 1 200px; }

/* Quiz */

.quiz-form { margin-top: 1.2rem; }

.quiz-form fieldset {
  position: relative;
  margin: 1.2rem 0 1rem;
  padding: 3.6rem 1.2rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
}

.quiz-form legend {
  position: absolute;
  top: 1.1rem;
  left: 1.2rem;
  width: calc(100% - 2.4rem);
  padding: 0;
  margin: 0;
  font-weight: 650;
  color: var(--ink);
}

.check-row { display: flex; align-items: center; gap: 9px; margin-bottom: 0.6rem; }
.check-row input { width: auto; margin: 0; }
.quiz-form button { margin-top: 0.2rem; }
#quizMessage { margin-top: 0.8rem; }

/* Assignment builder */

.assignment-target-toggle { display: flex; gap: 8px; flex-wrap: wrap; }
.assignment-target-toggle button { flex: 1 1 auto; }
.assignment-target-toggle button.active { background: var(--accent); color: #fff; }

.credential-callout {
  border: 1px solid rgba(15, 122, 55, 0.35);
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--accent-dark);
  font-weight: 600;
  font-size: 0.9rem;
}

.credential-callout code {
  background: rgba(255, 255, 255, 0.65);
  border-radius: 6px;
  padding: 2px 6px;
  font-weight: 700;
}

.color-swatch-row { display: flex; gap: 10px; align-items: center; }
.color-swatch-row input[type="color"] { width: 44px; height: 38px; padding: 3px; }

@media (max-width: 980px) {
  .app-shell { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px 12px;
  }

  .sidebar-brand, .workspace-card, .nav-section-label { display: none; }
  .sidebar-nav { flex-direction: row; order: 1; }
  .sidebar-nav .nav-count { display: none; }
  .sidebar-footer { order: 2; margin-left: auto; margin-bottom: 0; border-top: 0; padding-top: 0; }
  .sidebar-footer .who { display: none; }

  .library-grid, .grid.two { grid-template-columns: 1fr; }
  .data-toolbar { grid-template-columns: 1fr; }
  .data-table-header { display: none; }
  .data-table-inner { min-width: 0; }
  .data-row { grid-template-columns: 1fr; }
  .hero-card { align-items: stretch; flex-direction: column; }
  .stat-card, .progress-ring { min-width: 100%; }
  .topbar { align-items: flex-start; gap: 10px; flex-direction: column; }
  .topbar nav { width: 100%; justify-content: space-between; }
  .auth-card { padding: 24px; }
}
