:root {
  --ink: #1d2a36;
  --muted: #5b6770;
  --paper: #f3f5f4;
  --card: #ffffff;
  --line: #d8dedb;
  --in: #16875a;
  --in-soft: #e3f3eb;
  --out: #2656c9;
  --out-soft: #e6ecfa;
  --warn: #a86b00;
  --warn-soft: #fcf1d9;
  --bad: #b3372d;
  --bad-soft: #fbe7e5;
  --radius: 6px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.45; }
a { color: var(--out); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
p { margin: .4rem 0 .8rem; max-width: 72ch; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 30; height: 56px; background: var(--ink); color: #fff; display: flex; align-items: center; gap: .75rem; padding: 0 1rem; }
.brand { font-weight: 700; font-size: 1.05rem; color: #fff; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { margin-left: auto; display: flex; align-items: center; gap: .8rem; font-size: .875rem; }
.who a { color: #c3ceda; }
.who form { margin: 0; }
.linkbtn { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; white-space: nowrap; }
.nav-toggle { flex: none; width: 40px; height: 40px; margin-left: -.4rem; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; }
.nav-toggle:hover { background: rgba(255,255,255,.1); }
.nav-toggle span { display: block; width: 18px; height: 2px; background: #fff; border-radius: 1px; }

/* Page layout: menu on the left, page content beside it */
.layout { display: flex; align-items: flex-start; min-height: calc(100vh - 56px); }
body:not(.has-topbar) .layout { min-height: 100vh; }
.sidenav { flex: none; width: 210px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; background: #fff; border-right: 1px solid var(--line); padding: .75rem .6rem; }
.navgroup { display: flex; flex-direction: column; gap: 2px; padding: .4rem 0; }
.navgroup + .navgroup { border-top: 1px solid var(--line); }
.sidenav a { display: block; padding: .5rem .75rem; border-radius: var(--radius); color: var(--ink); text-decoration: none; font-size: .95rem; }
.sidenav a:hover { background: var(--paper); }
.sidenav a.on { background: var(--ink); color: #fff; font-weight: 600; }
.nav-scrim { display: none; }
body.nav-collapsed .sidenav { display: none; }

main { flex: 1; min-width: 0; max-width: 1180px; padding: 1.5rem 1.5rem 4rem; }
body:not(.has-nav) main { margin: 0 auto; }

/* Small screens: the menu slides over the page instead of sitting beside it */
@media (max-width: 800px) {
  .sidenav { display: none; position: fixed; left: 0; top: 56px; z-index: 25; box-shadow: 0 6px 24px rgba(29,42,54,.18); }
  body.nav-open .sidenav { display: block; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 56px 0 0 0; z-index: 20; background: rgba(29,42,54,.35); }
  main { padding: 1.25rem 1rem 3rem; }
  .who a { display: none; }
}
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Flash messages */
.flash { padding: .7rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; border-left: 4px solid; }
.flash.ok { background: var(--in-soft); border-color: var(--in); }
.flash.error { background: var(--bad-soft); border-color: var(--bad); }
.flash.warn { background: var(--warn-soft); border-color: var(--warn); }

/* Panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

/* Stats strip */
.stats { display: flex; gap: 2rem; flex-wrap: wrap; margin: .25rem 0 1.25rem; }
.stat b { display: block; font-size: 1.9rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .875rem; }

/* Tables */
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; background: #fafbfa; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.voided td:last-child { text-decoration: none; }

/* Badges */
.tag { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef1ef; color: var(--ink); margin: 0 .2rem .1rem 0; white-space: nowrap; }
.tag.in { background: var(--in-soft); color: var(--in); }
.tag.out { background: var(--out-soft); color: var(--out); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }

/* Forms */
label { display: block; font-weight: 600; font-size: .92rem; margin: .8rem 0 .3rem; }
label.inline { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; margin: .2rem 1rem .2rem 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], input[type=date],
input[type=datetime-local], input[type=search], select, textarea {
  font: inherit; padding: .5rem .6rem; border: 1px solid #b9c3c0; border-radius: var(--radius); background: #fff; color: var(--ink); max-width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #8fb0f0; outline-offset: 1px; }
input.wide, select.wide { width: 100%; }
.help { color: var(--muted); font-size: .85rem; margin: .2rem 0 0; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > label { margin: 0; }

.btn { display: inline-block; font: inherit; font-weight: 600; font-size: .95rem; padding: .5rem .95rem; border-radius: var(--radius);
  border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover { filter: brightness(1.15); }
.btn.secondary { background: #fff; color: var(--ink); border-color: #b9c3c0; }
.btn.in { background: var(--in); border-color: var(--in); }
.btn.out { background: var(--out); border-color: var(--out); }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
form.inline { display: inline; margin: 0; }

/* Hours editor */
.hours-grid { display: grid; grid-template-columns: 7.5rem 1fr; gap: .45rem 1rem; align-items: center; }
.hours-grid .day { font-weight: 600; }
.hours-grid .blocks { display: flex; gap: 1rem; flex-wrap: wrap; }
.hours-grid .block { display: flex; gap: .35rem; align-items: center; }

.namelist .item { display: flex; gap: .6rem; align-items: center; margin-bottom: .35rem; }

/* Sections within long forms */
.section { border-top: 1px solid var(--line); padding-top: .25rem; margin-top: 1.5rem; }
.section:first-of-type { border-top: 0; margin-top: 0; }

/* Present-now list */
.present-group h3 { display: flex; align-items: baseline; gap: .5rem; }
.present-group h3 small { color: var(--muted); font-weight: 400; }

.codebox { font-size: 2.2rem; font-weight: 700; letter-spacing: .3rem; background: var(--in-soft); color: var(--in); padding: .4rem 1rem; border-radius: var(--radius); display: inline-block; font-variant-numeric: tabular-nums; }
.secret { font-family: ui-monospace, Consolas, monospace; background: #eef1ef; padding: .1rem .4rem; border-radius: 4px; }

.auth { max-width: 420px; margin: 8vh auto; }
.auth .panel { padding: 1.5rem; }

.checklist li { margin-bottom: .6rem; }
.done { color: var(--in); font-weight: 700; }

@media (max-width: 640px) {
  .hours-grid { grid-template-columns: 1fr; }
  .stats { gap: 1.25rem; }
}
@media print {
  .topbar, .noprint { display: none !important; }
}

/* Student unique IDs (the value inside their QR code) */
.uid { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9rem; letter-spacing: .02em; white-space: nowrap; }
.uid-head { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 500; font-size: 1.1rem; color: var(--muted); white-space: nowrap; }

/* Label size picker */
.layout-info { margin-top: .75rem; }
.label-sample-wrap { margin: .5rem 0 0; }
.label-sample { width: var(--w); height: var(--h); background: #fff; border: 1px dashed #9aa6ad; border-radius: 4px; display: flex; overflow: hidden; }
.label-sample .qr { width: var(--qr); height: var(--qr); flex: none; }
.label-sample .qr svg { width: 100%; height: 100%; display: block; }
.label-sample .text { min-width: 0; flex: 1; line-height: 1.12; }
.label-sample .name { font-weight: 700; font-size: var(--name); }
.label-sample .name span { display: block; white-space: nowrap; overflow: hidden; }
.label-sample .subject { font-size: var(--subject); }
.label-sample.side { align-items: center; gap: .05in; padding: 0 .06in; }
.label-sample.stack { flex-direction: column; align-items: center; justify-content: center; padding: .04in; text-align: center; }
.label-sample.stack .text { width: 100%; flex: none; }
.size-compare { display: flex; align-items: flex-end; gap: 1.25rem; flex-wrap: wrap; padding: .75rem 0; }
.size-item { display: flex; flex-direction: column; align-items: center; gap: .35rem; font-size: .8rem; color: var(--muted); }
.size-box { border: 2px solid #b9c3c0; background: #fff; border-radius: 3px; }
.size-item.on .size-box { border-color: var(--in); background: var(--in-soft); }
.size-item.on span { color: var(--in); font-weight: 700; }
.size-box.coin { border-radius: 50%; background: #e4e7e5; border-style: dashed; }

/* Explanations and how-to boxes in Settings */
.note { background: var(--paper); border-left: 3px solid var(--line); padding: .6rem .9rem; margin: .8rem 0; font-size: .92rem; }
.note p, .note ul { margin: .3rem 0; }
.note li { margin-bottom: .25rem; }
details.howto { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; margin: .8rem 0; font-size: .92rem; }
details.howto summary { cursor: pointer; font-weight: 600; }
details.howto h4 { margin: 1rem 0 .3rem; font-size: .95rem; }
details.howto ol { margin: .2rem 0; padding-left: 1.3rem; }
details.howto li { margin-bottom: .2rem; }
