:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e3e6ec;
  --brand: #1f4e9c;
  --brand-ink: #ffffff;
  --good: #1a7f4b;
  --bad: #b42318;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h2 { font-size: 1.15rem; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.25rem; background: var(--brand); color: var(--brand-ink);
}
.topbar .title { font-weight: 700; font-size: 1.1rem; }
.topbar .right { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.topbar button { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.5); }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea, button {
  font: inherit; color: inherit;
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9db6e4; border-color: var(--brand); }
button { cursor: pointer; background: #fff; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.danger { color: var(--bad); border-color: #f0c4bf; }
button.small { padding: .25rem .55rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.row > div { min-width: 120px; }
.grow { flex: 1; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card input { width: 100%; margin-bottom: .8rem; }
.login-card button { width: 100%; }

/* messages */
.msg { padding: .55rem .8rem; border-radius: 8px; margin: .6rem 0; font-size: .92rem; }
.msg.info { background: #eaf1fd; color: #1f3f7a; }
.msg.ok { background: #e7f6ee; color: var(--good); }
.msg.error { background: #fdecea; color: var(--bad); }
.muted { color: var(--muted); }
.small-text { font-size: .85rem; }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.tabs button { border-radius: 999px; }
.tabs button.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .k { font-size: .8rem; color: var(--muted); }
.stat .v { font-size: 1.6rem; font-weight: 700; }
.stat .s { font-size: .82rem; color: var(--muted); }
.up { color: var(--good); }
.down { color: var(--bad); }

.chart-box { position: relative; height: 320px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
td.num, th.num { text-align: right; }
tr.avg td { font-weight: 600; background: #fafbfc; }
td input[type=number] { width: 90px; text-align: right; padding: .3rem .45rem; }
.pill { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; background: #eef1f6; color: #3b4560; }
.ungraded { color: var(--muted); }

details summary { cursor: pointer; color: var(--brand); }
textarea { width: 100%; min-height: 110px; font-family: ui-monospace, monospace; font-size: .85rem; }
select[multiple] { min-width: 260px; }

@media (max-width: 600px) {
  main { padding: .75rem; }
  .topbar .who { display: none; }
}

/* language switch */
.lang-select { padding: .3rem .5rem; font-size: .85rem; border-radius: 8px; cursor: pointer; }
.topbar .lang-select { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.5); }
.topbar .lang-select option { color: var(--ink); }
.corner-lang { position: fixed; top: 1rem; right: 1rem; z-index: 10; }
.topbar a.title { color: inherit; text-decoration: none; }

/* student class list */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #eef3fc; }
a.class-link { font-weight: 600; text-decoration: none; }
tr.clickable:hover a.class-link { text-decoration: underline; }
.back-link { display: inline-block; margin-bottom: .5rem; text-decoration: none; font-weight: 600; }
.back-link:hover { text-decoration: underline; }
.topbar button, .topbar .who { white-space: nowrap; }
