:root {
  --navy-900: #172c52;
  --navy-800: #1f3a68;
  --navy-700: #2a4a80;
  --blue-600: #2f6fdc;
  --blue-500: #3d7be8;
  --blue-100: #e3edfc;
  --blue-50: #f2f7fe;
  --bg: #eaf1fa;
  --surface: #ffffff;
  --border: #dbe6f4;
  --ink: #1b2b4a;
  --ink-2: #4a5b7a;
  --ink-3: #7b8aa6;
  --good: #2e9d5b;
  --good-bg: #e8f6ee;
  --warn-bg: #f3f6fd;
  --star: #f5b82e;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(31, 58, 104, 0.06);
  --font: "Noto Sans Thai", system-ui, sans-serif;
  --font-head: "Mali", "Noto Sans Thai", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
}
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-head); margin: 0; line-height: 1.3; }
.muted { color: var(--ink-3); }

/* ---------- logo ---------- */
.logo {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 40px;
  line-height: 0.9;
  color: #fff;
  text-decoration: none;
  -webkit-text-stroke: 2px #1d63c9;
  paint-order: stroke fill;
  text-shadow: 0 4px 0 #0f3d84;
  transform: rotate(-6deg);
}
.logo span:last-of-type { margin-left: 26px; }
.logo-star {
  position: absolute;
  right: -26px;
  top: -4px;
  font-style: normal;
  font-size: 30px;
  color: #ffd54a;
  -webkit-text-stroke: 1.5px #e09b12;
  text-shadow: none;
}

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 236px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 30px 14px 24px;
  background: linear-gradient(180deg, var(--navy-800), var(--navy-900));
  color: #dfe8f8;
}
.sidebar .logo { margin: 0 0 6px 18px; align-self: flex-start; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  color: #dfe8f8;
}
.nav a svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.nav a:hover { background: rgba(255, 255, 255, 0.08); }
.nav a.active { background: var(--blue-500); color: #fff; box-shadow: 0 4px 14px rgba(61, 123, 232, 0.4); }
.tagline {
  margin: auto 0 0;
  padding-left: 30px;
  font-family: var(--font-head);
  font-size: 15px;
  color: #fff;
  transform: rotate(-8deg);
}
.tagline::after { content: ""; display: block; width: 90px; height: 3px; margin-top: 6px; border-radius: 3px; background: #f5c33b; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: absolute;
  right: 24px;
  top: 18px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
}
.account { display: flex; align-items: center; gap: 10px; }
.account-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--navy-800); }
.account-icon svg { width: 24px; height: 24px; fill: #fff; }
.account-email { font-weight: 600; color: var(--navy-800); background: rgba(255, 255, 255, 0.85); padding: 4px 10px; border-radius: 10px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-badge { background: #fff4d6; color: #8a5a00; border: 1px solid #f1d58c; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; }
.view { padding: 0 24px 32px; outline: none; }

/* ---------- buttons / inputs ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 12px;
  padding: 10px 18px;
  cursor: pointer;
}
.btn-primary { background: var(--blue-500); color: #fff; }
.btn-primary:hover { background: var(--blue-600); }
.btn-dark { background: var(--navy-800); color: #fff; }
.btn-dark:hover { background: var(--navy-700); }
.btn-ghost { background: var(--blue-50); color: var(--navy-800); border: 1px solid var(--border); }
input {
  font: inherit;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
input:focus { outline: 2px solid var(--blue-500); outline-offset: 1px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  min-width: 0;
}
.card-title { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-size: 17px; margin-bottom: 12px; }
.card-title svg { width: 22px; height: 22px; fill: var(--blue-500); flex: none; }
.section-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 22px 0 14px; }
.section-head .grow { flex: 1; min-width: 200px; }
.section-head h2 { font-size: 22px; display: flex; align-items: center; gap: 10px; }
.section-head h2 svg { width: 30px; height: 30px; fill: var(--blue-500); }
.section-head p { margin: 2px 0 0; color: var(--ink-3); font-size: 14px; }
.search { position: relative; width: min(320px, 100%); }
.search input { padding-right: 40px; }
.search svg { position: absolute; right: 12px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); fill: var(--ink-3); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  margin: 0 -24px;
  min-height: 250px;
  padding: 40px 48px 36px;
  overflow: hidden;
  background: url("assets/hero.jpg") center 30% / cover no-repeat;
}
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(255, 255, 255, 0.94) 0%, rgba(255, 255, 255, 0.75) 45%, rgba(255, 255, 255, 0) 70%); }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 40px; background: linear-gradient(transparent, var(--bg)); }
.hero > * { position: relative; z-index: 1; }
.hero h1, .hero p { max-width: calc(100% - 230px); }
.hero h1 { font-size: 42px; color: var(--navy-900); }
.hero h1 small { display: block; font-size: 30px; }
.hero h1 .brand { font-family: "Fredoka", sans-serif; color: #fff; -webkit-text-stroke: 2px #1d63c9; paint-order: stroke fill; text-shadow: 0 3px 0 #0f3d84; }
.hero p { max-width: 520px; margin: 12px 0 0; color: var(--ink-2); font-weight: 500; }
.hero-mascot { position: absolute; right: 7%; bottom: -10px; width: 190px; z-index: 1; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.18)); }

/* ---------- player cards ---------- */
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.player-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.12s;
}
.player-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(31, 58, 104, 0.12); }
.player-card .name { font-family: var(--font-head); font-size: 17px; }
.player-card .sub { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-card .chev { margin-left: auto; color: var(--blue-500); font-size: 22px; }
.player-card > div { min-width: 0; }
.avatar {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--border);
  background: var(--avatar-bg, #dbe8fb) url("") center / cover no-repeat;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar--lg { width: 92px; height: 92px; }
.avatar--sm { width: 40px; height: 40px; border-width: 2px; }
.empty { padding: 30px; text-align: center; color: var(--ink-3); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--ink-3); font-weight: 600; font-size: 13px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--blue-50); }
tr.link { cursor: pointer; }
.cell-player { display: flex; align-items: center; gap: 10px; font-weight: 600; }

/* ---------- player detail ---------- */
.back { display: inline-flex; align-items: center; gap: 8px; margin: 70px 0 10px; font-weight: 600; text-decoration: none; color: var(--navy-800); }
.detail {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 0.95fr);
  gap: 16px;
  align-items: start;
}
.detail-left { display: grid; gap: 14px; }
.profile { display: flex; align-items: center; gap: 18px; }
.profile h1 { font-size: 30px; }
.profile .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.chip { display: inline-block; padding: 2px 10px; border-radius: 8px; background: var(--blue-100); color: var(--blue-600); font-weight: 600; font-size: 12.5px; }
.updated { display: flex; justify-content: flex-end; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); margin: -34px 0 12px; }
.kpis { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.kpi-label { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.kpi-value { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; }
.kpi-value b { font-size: 30px; font-family: var(--font-head); }
.kpi-value .of { color: var(--ink-3); }
.kpi-note { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.stars { color: #d9dfe9; font-size: 21px; letter-spacing: 1px; margin-left: auto; white-space: nowrap; }
.stars .on { color: var(--star); }
.trend { font-size: 26px; font-family: var(--font-head); color: var(--good); display: flex; gap: 6px; align-items: center; justify-content: center; }
.trend.down { color: #c2563f; }
.trend.flat { color: var(--ink-2); }
.center { text-align: center; }
.chart-box { position: relative; height: 210px; }
.chart-box--radar { height: 340px; }
.chart-box--sm { height: 230px; }
.highlights { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; }
.note b { display: block; }
.note--good { background: var(--good-bg); color: #1f6b40; border: 1px solid #cdebd9; }
.note--tip { background: var(--warn-bg); color: var(--ink-2); border: 1px solid var(--border); }
.note .ico { flex: none; font-size: 20px; line-height: 1.2; }
.map-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.map-card { border-radius: 12px; padding: 12px 14px; background: var(--blue-50); border: 1px solid var(--border); }
.map-card .t { font-weight: 700; font-size: 14px; }
.map-card .v { font-family: var(--font-head); font-size: 24px; }
.map-card .s { font-size: 12px; color: var(--ink-3); }

/* ---------- feedback list ---------- */
.fb-list { display: grid; gap: 12px; }
.fb-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.fb-item .who { font-weight: 700; font-size: 14px; }
.fb-item .who small { font-weight: 400; color: var(--ink-3); margin-left: 8px; }
.fb-item p { margin: 4px 0 0; font-size: 13.5px; color: var(--ink-2); }
.fb-face { width: 30px; height: 30px; }
.fb-item.mine { border-color: var(--blue-500); background: var(--blue-50); }

.answers td.q { max-width: 280px; }
.score-pill { display: inline-block; min-width: 54px; text-align: center; padding: 2px 8px; border-radius: 8px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-pill.hi { background: var(--good-bg); color: #1f6b40; }
.score-pill.mid { background: #fff4d6; color: #8a5a00; }
.score-pill.lo { background: #fde8e4; color: #a63b26; }
.missing { color: var(--ink-3); font-size: 12.5px; }

/* ---------- stats ---------- */
.page-title { margin: 76px 0 16px; font-size: 26px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.tile .label { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.tile .value { font-family: var(--font-head); font-size: 32px; }
.tile .value small { font-size: 15px; color: var(--ink-3); font-family: var(--font); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.settings { display: grid; gap: 16px; max-width: 760px; }
.settings dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.settings dt { color: var(--ink-3); }
.settings dd { margin: 0; word-break: break-all; }
.settings ol { margin: 0; padding-left: 20px; }
code { background: var(--blue-50); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 13px; }

/* ---------- login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: url("assets/hero.jpg") center / cover no-repeat;
  position: relative;
}
.login-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 22px;
  padding: 34px 30px 26px;
  box-shadow: 0 20px 50px rgba(15, 45, 90, 0.25);
  display: grid;
  gap: 10px;
}
.login-card .logo { justify-self: center; margin: 6px 26px 10px 0; }
.login-card h1 { text-align: center; font-size: 24px; }
.login-card p { text-align: center; margin: 0 0 8px; }
.login-card form { display: grid; gap: 12px; }
.login-card label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.form-error { color: #b3261e; min-height: 1.2em; margin: 0; font-size: 13.5px; text-align: left !important; }
.demo-link { text-align: center; font-size: 13px; color: var(--blue-600); }
.login-mascot { position: absolute; right: 6%; bottom: 4%; width: 200px; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2)); }
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); font-weight: 600; color: var(--navy-800); z-index: 10; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .detail { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .detail-left { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: sticky;
    z-index: 5;
    height: auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
  }
  .sidebar .logo { font-size: 24px; margin: 0 22px 0 4px; -webkit-text-stroke-width: 1.5px; text-shadow: 0 2px 0 #0f3d84; }
  .sidebar .logo span:last-of-type { margin-left: 14px; }
  .sidebar .logo-star { font-size: 18px; right: -16px; }
  .nav { flex-direction: row; gap: 2px; margin-left: auto; overflow-x: auto; }
  .nav a { padding: 8px 10px; gap: 6px; font-size: 13px; }
  .nav a svg { width: 18px; height: 18px; }
  .tagline { display: none; }
  .topbar { position: static; justify-content: flex-end; flex-wrap: wrap; padding: 10px 16px 0; }
  .view { padding: 0 16px 28px; }
  .hero { margin: 10px -16px 0; padding: 26px 20px 24px; min-height: 200px; }
  .hero h1 { font-size: 28px; }
  .hero h1 small { font-size: 20px; }
  .hero-mascot { width: 110px; right: 4%; opacity: 0.9; }
  .hero h1, .hero p { max-width: calc(100% - 110px); }
  .hero::before { background: linear-gradient(90deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7)); }
  .back, .page-title { margin-top: 16px; }
  .updated { margin: 0 0 10px; justify-content: flex-start; }
  .detail, .grid-2, .highlights { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: 1fr; }
  .login-mascot { width: 110px; }
}
@media (max-width: 560px) {
  .nav a span { display: none; }
  .map-cards { grid-template-columns: 1fr; }
  .account-email { display: none; }
  .profile h1 { font-size: 24px; }
}

/* ---------- login tabs / teacher application ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--blue-50); border: 1px solid var(--border); }
.tabs button { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 9px 10px; background: transparent; color: var(--ink-2); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--navy-800); box-shadow: 0 1px 4px rgba(31, 58, 104, 0.12); }
.pane { display: grid; gap: 10px; }
.switch { text-align: center; font-size: 14px; color: var(--ink-2); margin: 0; }
.linkish { font: inherit; font-weight: 600; color: var(--blue-600); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 4px; counter-reset: step; font-size: 12.5px; }
.steps li { flex: 1; counter-increment: step; text-align: center; color: var(--ink-3); border-top: 3px solid var(--border); padding-top: 6px; }
.steps li::before { content: counter(step) ". "; }
.steps li.on { color: var(--blue-600); border-color: var(--blue-500); font-weight: 600; }
.steps li.done { color: var(--good); border-color: var(--good); }
.form-ok { color: var(--good); font-size: 13.5px; margin: 0; }
.consent { display: flex !important; grid-template-columns: none !important; align-items: flex-start; gap: 8px !important; font-weight: 500 !important; font-size: 13px !important; color: var(--ink-2); }
.consent input { width: auto; margin-top: 3px; }
input[type="file"] { padding: 8px; background: var(--blue-50); }
.status-box { border-radius: 14px; padding: 14px 16px; background: var(--blue-50); border: 1px solid var(--border); font-size: 14px; }
.status-box.warn { background: #fff4d6; border-color: #f1d58c; color: #7a5200; }
.status-box b { display: block; font-size: 15px; margin-bottom: 4px; }
.status-box dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 8px 0 0; }
.status-box dt { color: var(--ink-3); }
.status-box dd { margin: 0; }
.nav-count { margin-left: auto; min-width: 22px; padding: 0 6px; border-radius: 999px; background: #f5c33b; color: #3d2b00; font-size: 12px; text-align: center; }
.req-list { display: grid; gap: 12px; }
.req { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.req h3 { font-family: var(--font); font-size: 16px; }
.req .info { font-size: 13.5px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; }
.req .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn-good { background: var(--good); color: #fff; }
.btn-bad { background: #fde8e4; color: #a63b26; }
.chip.pending { background: #fff4d6; color: #8a5a00; }
.chip.approved { background: var(--good-bg); color: #1f6b40; }
.chip.rejected { background: #fde8e4; color: #a63b26; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-row button.active { background: var(--navy-800); color: #fff; }
@media (max-width: 700px) { .req { grid-template-columns: 1fr; } .req .actions { justify-content: flex-start; } }
