:root {
  --navy: #1c2c3f;       /* Graveney dark navy */
  --navy-2: #234772;     /* Graveney mid blue   */
  --gold: #c1a65b;       /* Graveney gold       */
  --gold-dark: #a39056;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1b2430;
  --muted: #5d6b7d;
  --border: #dfe3ea;
  --ok: #1f8a4c;
  --warn: #c7541c;
  --danger: #c0392b;
  --shadow: 0 1px 3px rgba(0,0,0,0.07);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--navy-2); }
h1, h2, h3 { color: var(--navy); }

/* ---- Top bar ---- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.topbar .brand img { height: 48px; display: block; }
.topbar .brand .sub {
  font-size: 16px; color: var(--gold); font-weight: 700; letter-spacing: .03em;
  border-left: 1px solid rgba(255,255,255,.25); padding-left: 12px;
}
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 14px;
}
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,0.12); }
.topbar nav a.on { color: var(--navy); background: var(--gold); }
.topbar .user { font-size: 13px; color: rgba(255,255,255,.8); display: flex; align-items: center; gap: 10px; }
.topbar .user a { color: var(--gold); }
.child-switch select {
  background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px; padding: 4px 8px; font-size: 13px; cursor: pointer;
}
.child-switch select option { color: var(--navy); background: #fff; }

/* hamburger (mobile) */
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }

.container { max-width: 1180px; margin: 0 auto; padding: 22px 20px 48px; }
/* Dashboard uses the full window width so the cards (and the Classroom table)
   have room to breathe on big screens instead of being capped narrow. */
.container--wide { max-width: min(2200px, 96vw); }
.page-head h1 { margin: 0 0 4px; font-size: 26px; }
.page-head p { margin: 0 0 22px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- Cards / sections ---- */
.grid {
  display: grid;
  /* auto-fit (not auto-fill) so a partly-filled row stretches its cards to
     fill the width instead of leaving narrow columns + empty space. */
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}
/* Wider cards on the dashboard so the per-class table fits on one line each. */
.container--wide .grid { grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card > header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card > header h2 { margin: 0; font-size: 17px; color: #fff; }
.card .body { padding: 16px; }

.section-tile { text-decoration: none; color: inherit; display: block; transition: transform .08s ease, box-shadow .08s ease; }
.section-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.1); }

/* ---- Homework list ---- */
.hw-list { list-style: none; margin: 0; padding: 0; }
.hw-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.hw-item:last-child { border-bottom: 0; }
.hw-item .title { font-weight: 600; }
.hw-item .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.due { background: #fde7e1; color: var(--warn); }
.badge.done { background: #e3f4ea; color: var(--ok); }
.badge.overdue { background: #fbe3e0; color: var(--danger); }
.badge.fyi { background: #eef2f8; color: var(--navy-2); }
.badge.stale { background: #fbe8cf; color: #8a6400; }

/* ---- Status banners ---- */
.status { border-radius: 9px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; }
.status.info { background: #eef2f8; color: var(--navy-2); border: 1px solid #d6e0ef; }
.status.warn { background: #fdf3ec; color: var(--warn); border: 1px solid #f3d9c6; }
.status.err  { background: #fbe9e7; color: var(--danger); border: 1px solid #f1c9c4; }
.status.ok   { background: #e9f6ef; color: var(--ok); border: 1px solid #c7e8d4; }

/* ---- Forms / buttons ---- */
.btn {
  display: inline-block; cursor: pointer; font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; text-decoration: none;
}
.btn.primary { background: var(--gold); color: var(--navy); }
.btn.primary:hover { background: var(--gold-dark); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--navy); }
.btn.ghost:hover { background: #eef1f5; }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
}
input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }

.auth-wrap { max-width: 380px; margin: 8vh auto 0; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 26px; }
.auth-card .logo { text-align: center; margin-bottom: 8px; }
.auth-card .logo img { height: 72px; }
.auth-card h1 { font-size: 20px; text-align: center; margin: 6px 0 18px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 13.5px; }

.cred-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Sparx % done progress bar */
.pct-row { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; }
.pct-bar { flex: 1; height: 8px; background: #e7ebf1; border-radius: 999px; overflow: hidden; max-width: 320px; }
.pct-fill { display: block; height: 100%; background: var(--gold); border-radius: 999px; transition: width .3s; }
.pct-fill.full { background: var(--ok); }
.pct-label { color: var(--muted); white-space: nowrap; }

/* Connection status panel */
.conn-card { margin-bottom: 18px; }
.conn-list { list-style: none; margin: 0; padding: 0; }
.conn-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.conn-row:last-child { border-bottom: 0; }
.conn-dot { font-size: 14px; line-height: 1; }
.conn-ok { color: var(--ok); }
.conn-attention { color: #d08700; }
.conn-off { color: var(--muted); }
.conn-label { font-weight: 600; min-width: 130px; }
.conn-detail { flex: 1; }
.conn-action { padding: 4px 10px; font-size: 13px; }
@media (max-width: 720px) {
  .conn-label { min-width: 0; }
  .conn-detail { flex-basis: 100%; order: 3; }
}

/* Connect-once streamed browser */
.remote-stage { display: flex; justify-content: center; background: #000; border-radius: 8px; overflow: hidden; }
.remote-stage #screen { width: 1000px; max-width: 100%; display: block; outline: none; cursor: default; image-rendering: auto; }

/* ---- Mobile ---- */
@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .topbar { flex-wrap: wrap; }
  .topbar nav { display: none; width: 100%; flex-direction: column; gap: 2px; margin-top: 8px; }
  .topbar nav.open { display: flex; }
  .topbar .user { width: 100%; margin-top: 6px; }
  .cred-row { grid-template-columns: 1fr; }
  .container { padding: 16px 14px 40px; }
}
