/* Teacher panel: sidebar on computers, bottom bar + slide-in menu on phones. */
#shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
#side { background: var(--hero); color: #dfe0ff; padding: 1.2rem .9rem; display: flex; flex-direction: column; gap: 1.2rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
#side .brand { color: #fff; }
#nav { display: flex; flex-direction: column; gap: .12rem; }
#nav a { color: #cfd0f7; text-decoration: none; padding: .55rem .75rem; border-radius: 10px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
#nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
#nav a.on { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 700; }
#side button.ghost { color: #cfd0f7; }
#side button.ghost:hover { background: rgba(255, 255, 255, .08); }
.badge { background: var(--accent); color: var(--night); font-size: .72rem; font-weight: 800; padding: .05rem .45rem; border-radius: 99px; }
.badge:empty { display: none; }
#top, #pbottom, #sideShade { display: none; }
#main { padding: 1.6rem 2rem 4rem; max-width: 1300px; width: 100%; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: .2rem; font-size: .92rem; }
.back { display: inline-block; margin-bottom: .5rem; text-decoration: none; font-weight: 600; font-size: .9rem; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.filters input, .filters select { width: auto; min-width: 180px; }
.seg { display: inline-flex; background: #e9e8f4; border-radius: 11px; padding: .22rem; gap: .2rem; flex-wrap: wrap; }
.seg button { background: transparent; color: var(--ink-2); border: 0; padding: .35rem .75rem; font-size: .88rem; min-height: 34px; }
.seg button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

.att-btns { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.att-btns button { padding: .3rem .6rem; font-size: .82rem; background: #fff; color: var(--ink-2); border: 1px solid #d6d4e8; min-height: 36px; }
.att-btns button.on.present { background: var(--ok); border-color: var(--ok); color: #fff; }
.att-btns button.on.late { background: #d98a00; border-color: #d98a00; color: #fff; }
.att-btns button.on.absent { background: var(--bad); border-color: var(--bad); color: #fff; }
.att-btns button.on.excused { background: #2a5ea8; border-color: #2a5ea8; color: #fff; }

.matrix td, .matrix th { padding: .35rem .4rem; text-align: center; font-size: .8rem; }
.matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; min-width: 140px; }
.cell { display: inline-block; width: 24px; height: 24px; line-height: 24px; border-radius: 6px; font-weight: 800; font-size: .72rem; }
.cell.present { background: var(--ok-bg); color: var(--ok); }
.cell.late { background: var(--warn-bg); color: var(--warn); }
.cell.absent { background: var(--bad-bg); color: var(--bad); }
.cell.excused { background: #e6f1fb; color: #2a5ea8; }

.qr-wrap { display: grid; grid-template-columns: minmax(240px, 1fr) 260px; gap: 1.5rem; align-items: start; }
.qr-box { background: #fff; border-radius: 14px; padding: 1rem; border: 1px solid var(--line); }
.qr-box svg { width: 100%; height: auto; display: block; }
.qr-full { position: fixed; inset: 0; background: #fff; z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 2rem; }
.qr-full .qr-box { width: min(80vh, 90vw); border: 0; }
.qr-full h1 { font-size: 2rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .5rem 0; border-bottom: 1px dashed var(--line); display: flex; gap: .8rem; font-size: .9rem; }
.timeline li time { color: var(--muted); min-width: 140px; font-size: .82rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; font-size: .92rem; align-items: center; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.key-box { font-family: ui-monospace, Consolas, monospace; min-height: 140px; }
.bar { height: 7px; border-radius: 99px; background: #e7e6f3; overflow: hidden; min-width: 70px; }
.bar > div { height: 100%; background: var(--ok); }
.bar.low > div { background: var(--bad); }
.bar.mid > div { background: var(--accent); }
video { width: 100%; max-height: 60vh; background: #000; border-radius: 10px; }
.money-hero { background: var(--hero); color: #fff; border: 0; }
.money-hero .stat span { color: #c9cafc; }
.book-thumb { width: 54px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); display: block; }

/* ---------- phones ---------- */
@media (max-width: 900px) {
  #shell { display: block; }
  #side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 950; transform: translateX(-105%); transition: transform .22s; padding-top: calc(1.2rem + env(safe-area-inset-top)); }
  #side.open { transform: none; box-shadow: 0 0 50px rgba(0, 0, 0, .45); }
  #sideShade.on { display: block; position: fixed; inset: 0; background: rgba(11, 10, 38, .45); z-index: 940; }
  #top { display: flex; align-items: center; gap: .6rem; padding: .65rem 1rem; padding-top: calc(.65rem + env(safe-area-inset-top)); background: var(--hero); color: #fff; position: sticky; top: 0; z-index: 700; }
  #main { padding: 1rem .85rem calc(5.8rem + env(safe-area-inset-bottom)); }
  #pbottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 800; background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(20, 18, 58, .07); }
  #pbottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .5rem 0 .45rem; font-size: .68rem; font-weight: 700; color: #8a88a8; text-decoration: none; position: relative; }
  #pbottom svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  #pbottom a.on { color: var(--brand); }
  #pbottom .dot { position: absolute; top: .35rem; left: calc(50% + 6px); width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; display: none; }
  #pbottom .dot.on { display: block; }
  .qr-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page-head { margin-bottom: .9rem; }
  .page-head > .row { width: 100%; }
  .page-head > .row > * { flex: 1; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters input, .filters select, .filters .seg { width: 100%; min-width: 0; }
  .seg { display: flex; }
  .seg button { flex: 1; }
  .timeline li { flex-direction: column; gap: .1rem; }
  .timeline li time { min-width: 0; }
  .kv { grid-template-columns: 1fr; gap: .1rem; }
  .kv dt { margin-top: .5rem; font-size: .8rem; }

  /* Tables turn into stacked cards: first cell is the title, the rest wrap underneath. */
  #main table:not(.matrix) thead { display: none; }
  #main table:not(.matrix), #main table:not(.matrix) tbody { display: block; }
  #main table:not(.matrix) tr { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; padding: .8rem .95rem; border-bottom: 1px solid var(--line); }
  #main table:not(.matrix) tr:last-child { border-bottom: 0; }
  #main table:not(.matrix) td { display: block; border: 0; padding: 0 !important; font-size: .88rem; }
  #main table:not(.matrix) td:first-child { flex-basis: 100%; font-size: .95rem; }
  #main table:not(.matrix) td.right { margin-left: auto; }
  #main table:not(.matrix) td:empty { display: none; }
  #main td[data-l]::before { content: attr(data-l) " "; color: var(--muted); font-size: .78rem; font-weight: 600; }
  .card > table tr { padding-left: 0 !important; padding-right: 0 !important; }
  .att-btns { width: 100%; }
  .att-btns button { flex: 1; min-height: 42px; font-size: .85rem; }
  .table-wrap { overflow: visible; }
}
