:root {
  --bg1: #eef2ff;
  --bg2: #f5f3ff;
  --ink: #1e2438;
  --muted: #6b7280;
  --line: #e9ecf5;
  --card: #ffffff;
  --g1: #ec4899;   /* pink */
  --g2: #a855f7;   /* purple */
  --g3: #3b82f6;   /* blue */
  --green: #16a34a; --green-bg: #dcfce7;
  --amber: #d97706; --amber-bg: #fef3c7;
  --red: #e11d48;   --red-bg: #ffe4e6;
  --grey: #94a3b8;
  --shadow: 0 2px 8px rgba(30,41,59,.05), 0 12px 32px rgba(80,70,180,.09);
  --radius: 20px;
  --grad: linear-gradient(90deg, var(--g1), var(--g2), var(--g3));
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: "Poppins", ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2) 60%, #fdf2f8);
  min-height: 100vh;
  font-size: 15px;
  padding-bottom: 60px;
}

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 22px;
  background: linear-gradient(100deg, #6d28d9, #7c3aed 40%, #4f46e5);
  color: #fff;
  box-shadow: 0 6px 24px rgba(79,70,229,.28);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  font-size: 22px; width: 44px; height: 44px; border-radius: 14px;
  background: rgba(255,255,255,.16); display: grid; place-items: center;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.brand-sub { margin: 1px 0 0; font-size: 12px; color: rgba(255,255,255,.82); }
.topbar-actions { display: flex; gap: 8px; }

main { max-width: 1120px; margin: 0 auto; padding: 18px 16px 30px; }
.freshness { margin: 2px 4px 14px; font-size: 12.5px; color: var(--muted); }
.freshness b { color: var(--ink); }

/* tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; background: #fff; padding: 5px;
  border-radius: 14px; box-shadow: var(--shadow); width: fit-content; max-width: 100%; overflow-x: auto; }
.tab-btn {
  font-family: inherit; border: 0; background: none; padding: 9px 16px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab-btn.active { background: linear-gradient(90deg, #7c3aed, #4f46e5); color: #fff; }
.tab-btn .badge { margin-left: 6px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.tile {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.tile::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--grad);
}
.tile-label { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.tile-val { font-size: 30px; font-weight: 800; letter-spacing: -1px; margin-top: 3px; line-height: 1.1; }
.tile-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; font-weight: 500; }
.tv-green { color: var(--green); } .tv-amber { color: var(--amber); }
.tv-red { color: var(--red); } .tv-grey { color: var(--grey); }
.tv-grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* phase breakdown bar */
.phase-bar-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 22px; }
.phase-bar-wrap h2 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }
.phase-rows { display: flex; flex-direction: column; gap: 9px; }
.phase-row { display: grid; grid-template-columns: 200px 1fr 40px; align-items: center; gap: 10px; font-size: 12.5px; }
.phase-row .lbl { color: var(--muted); font-weight: 600; }
.phase-row .n { font-weight: 700; text-align: right; }
.pbar { height: 10px; border-radius: 6px; background: #eef0f7; overflow: hidden; }
.pbar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #f472b6, #a855f7 55%, #3b82f6); }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.toolbar select, .toolbar input[type=search] {
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; outline: none; box-shadow: var(--shadow);
}
.toolbar input[type=search] { flex: 1; min-width: 200px; }
.toolbar select:focus, .toolbar input:focus { border-color: var(--g2); }

/* teacher cards */
.teacher-list { display: flex; flex-direction: column; gap: 10px; }
.teacher-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden;
  border-left: 5px solid var(--grey); display: block; width: 100%; text-align: left;
  border-top: 0; border-right: 0; border-bottom: 0; cursor: pointer; font-family: inherit; color: inherit;
}
.teacher-card.h-red { border-left-color: var(--red); }
.teacher-card.h-yellow { border-left-color: var(--amber); }
.teacher-card.h-green { border-left-color: var(--green); }
.tc-inner { display: grid; grid-template-columns: 1fr 220px 90px; align-items: center; gap: 14px; padding: 14px 18px; }
.tc-name { font-weight: 700; font-size: 15px; }
.tc-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tc-phase { font-size: 12.5px; }
.tc-phase .n { font-weight: 700; }
.tc-flagcount { font-size: 11px; color: var(--red); font-weight: 700; margin-top: 3px; }
.tc-right { text-align: right; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot-red { background: var(--red); } .dot-yellow { background: var(--amber); } .dot-green { background: var(--green); }

/* progress bar */
.bar { height: 10px; border-radius: 8px; background: #eef0f7; overflow: hidden; position: relative; }
.bar-fill {
  height: 100%; border-radius: 8px; min-width: 4px;
  background: linear-gradient(90deg, #f472b6, #a855f7 55%, #3b82f6);
  transition: width .4s cubic-bezier(.4,0,.2,1);
}
.bar.slim { height: 7px; }

/* detail / drilldown */
.detail-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.detail-head h2 { margin: 0; font-size: 19px; }
.detail-head .muted { font-size: 13px; }
.phase-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 16px 0; }
.phase-chip { border-radius: 12px; padding: 10px 8px; text-align: center; font-size: 11px; font-weight: 700; }
.phase-chip .pn { display: block; font-size: 10px; font-weight: 600; opacity: .75; margin-bottom: 3px; }
.pc-embedded { background: var(--green-bg); color: var(--green); }
.pc-inprogress { background: var(--amber-bg); color: var(--amber); }
.pc-notstarted { background: #eef0f5; color: var(--muted); }
.sec-title { font-size: 14px; font-weight: 700; margin: 22px 0 8px; }
.compliance-row { display: grid; grid-template-columns: 90px 60px 100px 1fr; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #f1f2f8; font-size: 12.5px; }
.compliance-row:last-child { border-bottom: 0; }
.back-link { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600;
  color: var(--g2); text-decoration: none; margin-bottom: 14px; cursor: pointer; background: none; border: 0;
  font-family: inherit; padding: 0; }

/* flags */
.flag-card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 10px; }
.flag-card.open { border-left: 4px solid var(--red); }
.flag-card.resolved { border-left: 4px solid var(--green); opacity: .75; }
.flag-top { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); }
.flag-issue { font-size: 14px; font-weight: 600; margin: 5px 0 2px; }
.flag-teacher { font-size: 12.5px; color: var(--muted); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.p-red { background: var(--red-bg); color: var(--red); }
.p-green { background: var(--green-bg); color: var(--green); }

/* misc */
.muted { color: var(--muted); } .sm { font-size: 12.5px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 36px 0; }

.btn {
  font-family: inherit; appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 13.5px; font-weight: 600; padding: 9px 14px; border-radius: 12px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 8px 13px; font-size: 12.5px; box-shadow: var(--shadow); }
.btn.ghost { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.28); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #1e2438; color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: 13.5px; z-index: 60; box-shadow: var(--shadow); max-width: 90%; text-align: center;
}

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px;
  background: linear-gradient(150deg, #6d28d9, #7c3aed 45%, #db2777); }
.login-card {
  background: #fff; border-radius: 22px; padding: 34px 28px; width: 100%; max-width: 340px;
  text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 13px;
  font-family: "Poppins", system-ui, sans-serif;
}
.login-logo { font-size: 42px; }
.login-card h1 { margin: 0; font-size: 21px; font-weight: 700; }
.login-card input { font-family: inherit; padding: 12px 14px; font-size: 16px; border: 1px solid var(--line); border-radius: 12px; letter-spacing: 4px; text-align: center; }
.login-card .btn-primary { background: linear-gradient(90deg, #7c3aed, #4f46e5); color: #fff; border: 0; padding: 13px; font-size: 15px; border-radius: 12px; font-weight: 600; }
.err { color: var(--red); font-size: 13px; margin: 0; }

@media (max-width: 920px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tc-inner { grid-template-columns: 1fr 96px; }
  .tc-phase { display: none; }
}
@media (max-width: 560px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .phase-grid { grid-template-columns: repeat(3, 1fr); }
  .phase-row { grid-template-columns: 1fr 30px; }
  .phase-row .lbl { grid-column: 1 / -1; }
}
