:root {
  /* FourPL brand green: --brand is the WCAG-safe dark shade for text/borders/links;
     --brand-bright is the vivid lime used for filled surfaces (paired with dark text on top). */
  --brand: #5e7817;
  --brand-dark: #4a5f12;
  --brand-bright: #c1d82f;
  --brand-bright-dark: #a8be28;
  --ink: #231f20;
  --ink-soft: #595959;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e2e6f0;
  --danger: #d64545;
  --danger-bg: #fdecec;
  --success: #1f9d55;
  --success-bg: #e8f8ef;
  --warn: #b7791f;
  --warn-bg: #fdf3df;
  --hold: #6b7280;
  --hold-bg: #eceef1;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 26, 50, 0.06), 0 1px 2px rgba(20, 26, 50, 0.08);
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

body {
  margin: 0;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

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

.app-header {
  background: #fff;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header .brand {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.app-header .brand img.logo {
  height: 34px;
  width: auto;
  display: block;
}

.app-header .brand .tag {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--brand-bright);
  color: var(--ink);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.app-header nav {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.app-header nav a, .app-header nav button {
  color: var(--ink-soft);
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.app-header nav a:hover, .app-header nav button:hover {
  background: rgba(193, 216, 47, 0.15);
  color: var(--ink);
  text-decoration: none;
}

.app-header nav a.active {
  background: var(--brand-bright);
  color: var(--ink);
}

.app-header .user-chip {
  color: var(--ink-soft);
  font-size: 0.82rem;
  padding: 0 0.6rem;
}

main.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

main.page.admin-page {
  max-width: 1360px;
}

.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.page-title h1 { font-size: 1.4rem; margin: 0; }
.page-title p { color: var(--ink-soft); margin: 0.25rem 0 0; font-size: 0.9rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-size: 1.05rem;
  margin: 0 0 1rem;
}

.card h3 { font-size: 0.95rem; margin: 1rem 0 0.6rem; color: var(--ink); }

.grid {
  display: grid;
  gap: 1rem;
}

.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 960px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .app-header { flex-wrap: wrap; height: auto; padding: 0.6rem 1rem; }
  .app-header nav { width: 100%; justify-content: flex-start; }
  main.page { padding: 1rem 0.85rem 3rem; }
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(193, 216, 47, 0.3);
}

.field { margin-bottom: 0.9rem; }
.field .hint { font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.25rem; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
}
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; color: var(--ink); }

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary { background: var(--brand-bright); color: var(--ink); }
.btn-primary:hover { background: var(--brand-bright-dark); }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--ink); }
.btn-secondary:hover { background: #f1f3fa; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #fbdada; }
.btn-small { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge.status-not-started { background: var(--hold-bg); color: var(--hold); }
.badge.status-in-progress { background: var(--warn-bg); color: var(--warn); }
.badge.status-completed { background: var(--success-bg); color: var(--success); }
.badge.status-on-hold { background: var(--danger-bg); color: var(--danger); }

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress-bar .fill { height: 100%; background: var(--brand-bright); transition: width 0.25s ease; }

.module-tree { display: flex; flex-direction: column; gap: 0.4rem; }
.module-item { border: 1px solid var(--border); border-radius: 8px; padding: 0.65rem 0.8rem; background: #fbfcff; }

.toast-stack {
  position: fixed;
  top: 72px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 50;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  min-width: 220px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-soft); }

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #1c1c1c, #2b3010);
  padding: 1rem;
}
.auth-card {
  background: #fff;
  border-radius: 14px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.auth-card .brand-lockup { text-align: center; margin-bottom: 1.5rem; }
.auth-card .brand-lockup img.logo { height: 44px; width: auto; margin-bottom: 0.75rem; }
.auth-card .brand-lockup .tag {
  display: inline-block;
  background: var(--brand-bright);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}
.auth-card h1 { font-size: 1.3rem; margin: 0; }
.auth-card .error-box {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.6rem 0.8rem;
  border-radius: 7px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.auth-card .hint-creds {
  margin-top: 1.25rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
}

.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.stat-tile .label { font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.stat-tile .value { font-size: 1.6rem; font-weight: 700; margin-top: 0.15rem; }

.tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tabs button {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.65rem 0.9rem;
  color: var(--ink-soft);
  font-weight: 600;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

.landing-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #1c1c1c, #2b3010);
  padding: 1rem;
}
.landing-card img.logo { height: 48px; width: auto; margin-bottom: 1.25rem; }
.landing-card {
  background: #fff;
  border-radius: 14px;
  padding: 2.5rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.landing-card h1 { margin-top: 0; }
.landing-links { display: flex; gap: 0.75rem; margin-top: 1.5rem; justify-content: center; flex-wrap: wrap; }

.text-muted { color: var(--ink-soft); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.gap-sm { gap: 0.5rem; }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
