:root {
  --bg: #f5f4f0;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #5d6677;
  --line: #e4e2dc;
  --brand: #1f2a44;
  --brand-2: #2d5bd7;
  --brand-soft: #eaf0fc;
  --ok: #1d7a4b;      --ok-bg: #e5f3eb;
  --info: #2457c5;    --info-bg: #e8effc;
  --bad: #b42318;     --bad-bg: #fdecea;
  --warn: #a8560a;    --warn-bg: #fcf1e1;
  --idle: #5b6473;    --idle-bg: #eef0f3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 33, .05), 0 4px 16px rgba(20, 24, 33, .05);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; line-height: 1.45; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
.muted { color: var(--muted); margin: .2rem 0 0; font-size: .9rem; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }

/* top bar */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: .7rem 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { font-weight: 700; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: .2rem; flex-wrap: wrap; justify-content: flex-end; }
.topbar .link-btn { color: #dfe6f5; }
.topbar .link-btn:hover { color: #fff; }

.link-btn {
  background: none; border: 0; padding: .35rem .5rem; color: var(--brand-2);
  font-size: .9rem; border-radius: 8px;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.back { padding-left: 0; margin-bottom: .2rem; }

/* buttons */
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: .65rem 1.1rem;
  font-weight: 600; font-size: .95rem; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand-2); color: #fff; }
.btn.primary:hover { background: #2350c4; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: .4rem .75rem; font-size: .85rem; }
.btn.outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.wide { width: 100%; margin-top: .4rem; }
.btn[disabled] { opacity: .6; cursor: default; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--card); border-radius: 18px;
  padding: 2rem 1.6rem; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.auth-title { font-size: 1.45rem; color: var(--brand); }
.auth-sub { color: var(--muted); margin: .35rem 0 1.4rem; }
.auth-help { color: var(--muted); font-size: .85rem; margin: 1.2rem 0 0; text-align: center; }
label { display: block; font-size: .88rem; font-weight: 600; margin: .9rem 0 .35rem; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=search], input:not([type]), select {
  width: 100%; padding: .7rem .8rem; border: 1px solid #cfd3db; border-radius: 10px;
  background: #fff; font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; border-color: transparent; }
.form-error { color: var(--bad); font-size: .9rem; min-height: 1.2em; margin: .7rem 0 .3rem; }

/* pages */
.page { max-width: 1120px; margin: 0 auto; padding: 20px 16px 48px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin: .4rem 0 1rem; flex-wrap: wrap;
}

.children { display: flex; gap: .5rem; margin-bottom: .6rem; overflow-x: auto; padding-bottom: 2px; }
.child-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: .45rem 1rem; font-weight: 600; white-space: nowrap; color: var(--ink);
}
.child-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.class-pills { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.class-pill {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 8px; padding: .35rem .75rem; font-size: .88rem;
}
.class-pill.active { background: var(--brand-soft); border-color: #c6d5f6; color: var(--brand-2); font-weight: 600; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.7rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat-note { font-size: .82rem; color: var(--muted); margin-top: .1rem; }
.stat.bad .stat-value { color: var(--bad); }
.stat.warn .stat-value { color: var(--warn); }
.stat.good .stat-value { color: var(--ok); }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0;
}
.card-sub { color: var(--muted); font-size: .86rem; margin: .25rem 0 .9rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 16px; }
.chart-wrap { position: relative; height: 240px; }
.empty { color: var(--muted); font-size: .92rem; padding: 1rem 0; text-align: center; }

/* topics */
.topic { margin-bottom: .8rem; }
.topic-top { display: flex; justify-content: space-between; gap: .5rem; font-size: .9rem; margin-bottom: .3rem; }
.topic-name { font-weight: 600; }
.topic-pct { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.bar { height: 9px; border-radius: 99px; background: #eceae4; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; }
.r-strong { background: var(--ok); }
.r-developing { background: #d38b1c; }
.r-needs { background: var(--bad); }

/* filters & chips */
.filters { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: .3rem .75rem; font-size: .84rem;
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* assignments */
.asg { border-top: 1px solid var(--line); padding: .9rem 0; }
.asg:first-child { border-top: 0; padding-top: .2rem; }
.asg-top { display: flex; justify-content: space-between; gap: .8rem; align-items: flex-start; }
.asg-title { font-weight: 650; }
.asg-due { color: var(--muted); font-size: .85rem; margin-top: .1rem; }
.badges { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }
.badge { font-size: .76rem; font-weight: 700; padding: .2rem .55rem; border-radius: 6px; white-space: nowrap; }
.b-graded { color: var(--ok); background: var(--ok-bg); }
.b-submitted { color: var(--info); background: var(--info-bg); }
.b-missing { color: var(--bad); background: var(--bad-bg); }
.b-upcoming, .b-not { color: var(--idle); background: var(--idle-bg); }
.b-late { color: var(--warn); background: var(--warn-bg); }
.asg-facts { display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; margin-top: .55rem; font-size: .9rem; }
.fact b { font-variant-numeric: tabular-nums; }
.fact .k { color: var(--muted); margin-right: .3rem; }
.comment {
  margin-top: .6rem; background: #f7f6f2; border-left: 3px solid var(--brand-2);
  padding: .55rem .75rem; border-radius: 0 8px 8px 0; font-size: .92rem;
}
.comment .k { display: block; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .15rem; }
.asg-link { display: inline-block; margin-top: .55rem; font-size: .9rem; font-weight: 600; color: var(--brand-2); text-decoration: none; }
.asg-link:hover { text-decoration: underline; }

/* admin */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tab { background: none; border: 0; padding: .6rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--brand-2); border-color: var(--brand-2); }
.toolbar { display: flex; gap: .6rem; margin-bottom: .9rem; flex-wrap: wrap; }
.toolbar input { flex: 2 1 220px; }
.toolbar select { flex: 1 1 180px; width: auto; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem 1rem; border-top: 1px solid var(--line); width: 100%;
  background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; color: inherit;
}
.row:first-child { border-top: 0; }
button.row:hover { background: #faf9f6; }
.row-main { min-width: 0; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.row-side { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.st-active { color: var(--ok); }
.st-invited { color: var(--warn); }
.st-none { color: var(--idle); }

/* misc */
.loading { position: fixed; inset: 0; background: rgba(245, 244, 240, .6); display: grid; place-items: center; z-index: 50; }
.spinner { width: 34px; height: 34px; border: 3px solid #d7dbe4; border-top-color: var(--brand-2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--brand); color: #fff; padding: .75rem 1.1rem; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 60; max-width: calc(100% - 32px); font-size: .92rem;
}

@media (max-width: 820px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  h1 { font-size: 1.3rem; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 1.45rem; }
  .asg-top { flex-direction: column; gap: .4rem; }
  .badges { justify-content: flex-start; }
  .page-head .btn { width: 100%; }
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: .2rem; }
  .topbar-actions { justify-content: flex-start; margin-left: -.5rem; }
  .row { flex-direction: column; align-items: flex-start; gap: .5rem; }
}
