:root {
  /* Gray tones. District yellow is used only as an accent on dark gray (never as text on light),
     so every text/background pair meets WCAG AA contrast. */
  --gray-900: #232528;   /* top bar */
  --gray-800: #33363a;   /* sidebar, primary buttons */
  --gray-700: #484c52;   /* active nav, avatars */
  --gray-100: #e9eaec;   /* chips */
  --accent: #f2c318;     /* NLCSD yellow: thin accents on dark backgrounds only */
  --ink: #1f2124;
  --muted: #555a60;
  --line: #dcdde0;
  --page: #f4f4f5;
  --card: #ffffff;
  --ok: #1e6b3a;
  --red: #b3261e;
  --red-bg: #fbe9e7;
  --amber: #7a4f00;
  --amber-bg: #fbf1d9;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--page); }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--gray-900); color: #fff; padding: .7rem 1.2rem; border-bottom: 3px solid var(--accent); }
.brand { display: flex; align-items: center; gap: .7rem; color: #fff; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border: 2px solid var(--accent);
  border-radius: 8px; font: 700 15px Georgia, serif; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.brand-text strong { font-size: 18px; letter-spacing: .12em; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.who { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.who small { font-size: 11px; opacity: .8; }

/* Shell + sidebar */
.shell { display: flex; min-height: calc(100vh - 66px); }
.sidebar { width: 215px; flex: none; background: var(--gray-800); color: #fff; padding: 1.1rem .7rem; }
.nav-label { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; opacity: .6; margin: 0 .5rem .6rem; }
.nav-main { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-weight: 650;
  padding: .45rem .5rem; border-radius: 8px; }
.nav-main svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.nav-sub { display: block; color: rgba(255,255,255,.88); text-decoration: none; font-size: 13px; font-weight: 600;
  padding: .42rem .5rem .42rem 2.15rem; margin: .1rem 0; border-radius: 8px; border-left: 3px solid transparent; }
.nav-sub:hover, .nav-main:hover { background: rgba(255,255,255,.07); }
.nav-sub.active { background: var(--gray-700); border-left-color: var(--accent); color: #fff; }

/* Content */
.content { flex: 1; min-width: 0; padding: 1.4rem 1.8rem 2rem; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }
h1 { font-size: 30px; margin: .15rem 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 1.6rem 0 .6rem; }
.lead { font-size: 15px; color: #33433a; margin: 0 0 .4rem; max-width: 60ch; }
.note { font-size: 12.5px; color: var(--muted); max-width: 90ch; margin: 0 0 1rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.head-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-start; }
.page-foot { margin-top: 2rem; font-size: 12px; color: var(--muted); }

.chip { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: .25rem .6rem; border-radius: 999px; background: var(--gray-100); color: var(--ink); white-space: nowrap; }
.chip-dark { background: rgba(255,255,255,.14); color: #fff; }
.chip-red { background: var(--red-bg); color: var(--red); }
.chip-amber { background: var(--amber-bg); color: var(--amber); }

.flash { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gray-800); color: var(--ink); padding: .6rem .9rem;
  border-radius: 10px; margin-bottom: 1rem; }
.flash.err { background: var(--red-bg); border-color: #f0c2bd; color: var(--red); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.card h3 { margin: 0 0 .35rem; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.card .big { font-size: 20px; font-weight: 700; }
.card p { margin: .3rem 0; }
.ok { color: var(--ok); } .err { color: var(--red); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-word; }

/* Sync bar (Badge Printer) */
.syncbar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem; font-size: 13px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .5rem .35rem 1rem; width: fit-content; max-width: 100%; }
.syncbar strong { color: var(--ink); }
.syncform { display: inline-flex; align-items: center; gap: .5rem; }
.syncform label { display: inline-flex; align-items: center; gap: .25rem; cursor: pointer; }
.btn-small { padding: .25rem .7rem; font-size: 12.5px; }
.history { font-size: 12.5px; }

/* Multi-select (Badge Printer) */
.batchbar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem;
  background: var(--page); padding: .6rem 0; }
.batchbar .count { margin: 0; }
.pickcol { width: 1%; padding-right: 0; }
.pickcol input { width: 17px; height: 17px; accent-color: var(--gray-800); cursor: pointer; }
.linkbtn { font: inherit; font-size: 12.5px; background: none; border: 0; color: var(--ink); text-decoration: underline; cursor: pointer; padding: 0; }
.linkbtn:disabled { opacity: .45; cursor: default; }

/* Popup (e.g. badges skipped for no photo) */
dialog.popup { border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 14px; padding: 1.2rem 1.4rem;
  max-width: min(460px, 92vw); color: var(--ink); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
dialog.popup::backdrop { background: rgba(20,20,22,.45); }
dialog.popup h2 { margin: 0 0 .5rem; font-size: 18px; }
dialog.popup ul { margin: .3rem 0 .8rem; padding-left: 1.2rem; max-height: 40vh; overflow-y: auto; }
dialog.popup form { text-align: right; margin: 0; }

/* Printer supplies */
.supplies-msgs { list-style: none; padding: 0; margin: .3rem 0; }
.supplies-msgs li { margin: .2rem 0; }

/* Preview box */
dialog.preview { width: min(380px, 94vw); max-width: none; }
dialog.preview iframe { display: block; width: 100%; height: min(560px, 70vh); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
dialog.preview .preview-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .8rem; }

/* Collapsible change groups (sync run page) */
details.group { margin-bottom: .7rem; }
details.group > summary { cursor: pointer; font-weight: 650; padding: .45rem .2rem; list-style-position: inside; }
details.group > summary .chip { margin-left: .3rem; }
details.group[open] > summary { margin-bottom: .4rem; }

/* Students | Staff toggle */
.pills.who { margin-bottom: 0; }
.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 1.6rem; }
.pills.who a { padding: .4rem 1.1rem; }

/* Filters */
.filter-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 1rem 0 .4rem; }
.pills { display: inline-flex; flex-wrap: wrap; gap: .2rem; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .2rem; }
.pills a { text-decoration: none; color: var(--ink); font-weight: 650; font-size: 13px; padding: .35rem .8rem; border-radius: 999px; }
.pills a.on { background: var(--gray-800); color: #fff; }
.grades { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-weight: 650; font-size: 13px; }
.grades label { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.grades input { accent-color: var(--gray-800); width: 15px; height: 15px; }
input[type=search], input[type=text] { font: inherit; padding: .5rem .9rem; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; width: min(320px, 100%); }
.count { font-size: 12.5px; color: var(--muted); margin: .8rem 0 .5rem; }

/* Tables */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: #3c4a42; text-align: left;
  padding: .8rem .9rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .7rem .9rem; border-bottom: 1px solid #efeee7; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.student { display: flex; align-items: center; gap: .7rem; font-weight: 650; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%;
  background: var(--gray-800); color: #fff; font-size: 12px; font-weight: 700; }
.sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.actions { display: flex; gap: .4rem; align-items: center; white-space: nowrap; }

.btn { font: inherit; font-weight: 650; font-size: 13px; border: 1px solid var(--gray-800); background: var(--gray-800); color: #fff;
  padding: .4rem .85rem; border-radius: 999px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--gray-900); }
.btn-ghost { background: #fff; color: var(--gray-800); }
.btn-ghost:hover { background: var(--gray-100); }
.btn:disabled { opacity: .55; cursor: wait; }
form.inline { display: inline; }

/* Visible keyboard focus (dark ring on light areas, yellow ring on the dark bars). */
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.topbar :focus-visible, .sidebar :focus-visible { outline-color: var(--accent); }

/* Sign-in page, top bar sign out, Users page */
.btn-dark { background: transparent; border-color: rgba(255,255,255,.45); }
.btn-dark:hover { background: rgba(255,255,255,.1); }
.login { display: grid; place-items: start center; padding: 3rem 1rem; min-height: calc(100vh - 66px); }
.login-card { width: min(420px, 100%); padding: 1.6rem 1.8rem; border-top: 4px solid var(--accent); }
.login-card h1 { margin-top: 0; }
.login-google { margin: .4rem 0 1rem; padding: .6rem 1.2rem; font-size: 14px; }
.login-form { display: grid; gap: .7rem; margin: .4rem 0 1rem; }
.login-form label { display: grid; gap: .25rem; font-weight: 650; font-size: 13px; }
.login-form input { width: 100%; }
input[type=password] { font: inherit; padding: .5rem .9rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.addform { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
tr.muted td { opacity: .6; }
tr.warn td { background: #fff8e6; }

/* Screen time heat map. Colour steps (minutes): 0, <15, 15, 30, 60, 120, 180+ (ColorBrewer YlGnBu, colour-blind safe).
   Non-school days are striped; "no data" is a dot on white; today has a dashed outline. */
.st-estimate { border-left-color: var(--amber); background: var(--amber-bg); max-width: 110ch; }
.st-status { font-size: 13px; color: var(--muted); margin: 0 0 .4rem; }
.st-status strong { color: var(--ink); }
select { font: inherit; padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.st { display: inline-block; min-width: 2.1rem; padding: .2rem .25rem; border-radius: 5px; text-align: center; font-size: 12px;
  font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.3; }
.st.l0 { background: #f1f1f2; color: var(--muted); }
.st.l1 { background: #edf8b1; color: var(--ink); }
.st.l2 { background: #c7e9b4; color: var(--ink); }
.st.l3 { background: #7fcdbb; color: var(--ink); }
.st.l4 { background: #41b6c4; color: var(--ink); }
.st.l5 { background: #1d91c0; color: #fff; }
.st.l6 { background: #225ea8; color: #fff; }
.st.nodata { background: #fff; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.st.ns { background-image: repeating-linear-gradient(135deg, rgba(0,0,0,.13) 0 3px, transparent 3px 7px); }
.st.ns:not([class*=" l"]) { background-color: #fff; }
.st-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; font-size: 12px; margin: 1rem 0 0; }
.st-legend .note-inline { color: var(--muted); margin-right: .5rem; }
.st.today-key { background: #fff; outline: 2px dashed var(--gray-700); outline-offset: -2px; }
.st-wrap { max-height: 75vh; overflow: auto; }
table.st-map { width: auto; border-collapse: separate; border-spacing: 0; }
.st-map th, .st-map td { padding: .25rem .2rem; border-bottom: 1px solid #efeee7; }
.st-map thead th { position: sticky; top: 0; z-index: 2; background: var(--card); }
.st-map .st-name { position: sticky; left: 0; z-index: 1; background: var(--card); text-align: left; min-width: 11rem; padding-left: .8rem;
  font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--ink); white-space: nowrap; }
.st-map thead .st-name { z-index: 3; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: #3c4a42; }
.st-map .st-day { text-align: center; font-size: 11px; letter-spacing: 0; line-height: 1.15; padding: .5rem .15rem; }
.st-map .st-day span { display: block; font-weight: 400; color: var(--muted); text-transform: none; }
.st-map th.today, .st-map td.today { background: #fafaf6; }
.st-map td.today .st { outline: 2px dashed var(--gray-700); outline-offset: -2px; }
.st-map .st-avg { padding-right: .6rem; border-right: 1px solid var(--line); }
.st-map .st-avg .st { min-width: 2.6rem; font-size: 13px; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .5rem .8rem; }
  .nav-label { display: none; }
  .nav-section { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem; }
  .nav-sub { padding: .35rem .7rem; }
  .content { padding: 1rem; }
  .who small { display: none; }
  h1 { font-size: 24px; }
}

/* How to pull today's file */
.howto { max-width: 820px; }
.howto h2 { margin-top: 1.1rem; }
.howto h2:first-child { margin-top: 0; }
.howto ol, .howto ul { margin: .3rem 0 .6rem; padding-left: 1.3rem; }
.howto li { margin: .25rem 0; }
.howto table { margin: .3rem 0 .4rem; }

/* Measured (Chrome extension) cells: a small dark corner mark */
.st.meas { position: relative; }
.st.meas::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 7px 7px 0;
  border-color: transparent var(--gray-900) transparent transparent; border-top-right-radius: 5px; }
.variant { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; margin: .15rem 0; }
.variant select { padding: .15rem .5rem; font-size: 12px; }

/* "View as" banner (admins looking at the site as a teacher) */
.view-as-bar { background: #fde68a; color: #422006; padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: 14px; }
.view-as-bar form { margin-left: auto; }
.view-as-pick { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.view-as-pick .filter-label { margin: 0; }
.login-password { margin-top: 18px; }
.login-password summary { cursor: pointer; color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; list-style: none; font-size: 14px; }
.login-password summary::-webkit-details-marker { display: none; }
.login-password[open] summary { margin-bottom: 10px; }
.st-flag { display: inline-block; margin-top: 2px; padding: 0 6px; border-radius: 4px; background: #fef3c7; color: #78350f; font-size: 11px; font-weight: 600; }

/* CS / Tech time button (Screen time, one homeroom) */
.cs-time { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--line, #e5e7eb); border-radius: 8px; }
.cs-time.on { background: #ecfdf5; border-color: #6ee7b7; }
.cs-time form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.st.cs { box-shadow: inset 0 -3px 0 #059669; }

/* Users & permissions: one Save for the whole table */
.perm-save { position: sticky; top: 0; z-index: 2; display: flex; flex-direction: row-reverse; justify-content: flex-start; align-items: center; gap: 12px; padding: 8px 0; background: var(--page); }
#perm-dirty { color: #92400e; font-weight: 600; }

/* Screen time: fold the filters away */
.filters-toggle { margin: 0 0 0 auto; padding: 4px 10px; border: 1px solid var(--line, #d1d5db); border-radius: 6px; background: transparent; color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.filters-toggle:hover { background: rgba(0, 0, 0, .04); }
#filters[hidden] { display: none; }

/* Users page: search / school / with-access filters (left of Save) */
.user-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-right: auto; }
.user-filters input[type=search] { min-width: 14rem; }
#people tr[hidden] { display: none; }

/* No access page */
.bummer { max-width: 36rem; margin: 3rem auto; text-align: center; }
.bummer .big { font-size: 3rem; line-height: 1; margin-bottom: .5rem; }

/* Screen time: sort arrows in the table head */
.sort-arrow { color: #9a9ea4; text-decoration: none; font-size: 10px; padding: 0 2px; }
.sort-arrow:hover { color: var(--ink); }
.sort-arrow.on { color: var(--ink); font-size: 12px; }
.st-map .st-day .sort-arrow { display: block; }
