:root {
  --navy: #123a5a; --navy-2: #1d5280; --ink: #1f2933; --muted: #67727e; --line: #e2e6ea; --bg: #f5f6f8; --card: #fff;
  --good: #1f9d55; --good-bg: #e6f6ec; --mid: #d68a00; --mid-bg: #fff3d6; --low: #d64545; --low-bg: #fde8e8;
  --free: #f0f2f4; --late: #8a4fd0; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 4px; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .lead { font-size: 1.05rem; margin: 4px 0 0; }
.center { text-align: center; } .right { text-align: right; } .nowrap { white-space: nowrap; } .b { font-weight: 700; }
.txt-low { color: var(--low); } .txt-late { color: var(--late); font-weight: 600; }

/* top bar */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1320px; margin: 0 auto; display: flex; align-items: center; gap: 22px; padding: 10px 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand strong { display: block; font-size: 1rem; line-height: 1.1; }
.brand small { display: block; opacity: .75; font-size: .75rem; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: #fff; position: relative; flex: none; }
.brand-mark::before { content: ""; position: absolute; left: 8px; top: 6px; width: 14px; height: 18px; border: 2px solid var(--navy); border-radius: 2px; }
.brand-mark::after { content: ""; position: absolute; left: 12px; top: 12px; width: 7px; height: 2px; background: var(--navy); box-shadow: 0 4px 0 var(--navy); }
.brand-mark.big { width: 52px; height: 52px; background: var(--navy); border-radius: 12px; display: inline-block; }
.brand-mark.big::before { left: 15px; top: 11px; width: 22px; height: 30px; border-color: #fff; }
.brand-mark.big::after { left: 20px; top: 21px; width: 12px; background: #fff; box-shadow: 0 6px 0 #fff; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: #d5e2ee; padding: 7px 12px; border-radius: 7px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav a.on { background: rgba(255,255,255,.16); color: #fff; }
.who { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.who form { margin: 0; }
.who-name { text-align: right; line-height: 1.15; font-size: .9rem; }
.who-name small { display: block; opacity: .7; font-size: .75rem; }
.topbar .btn-link { color: #d5e2ee; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }
.subnav { background: #0e2f49; display: flex; gap: 4px; padding: 6px 20px; overflow-x: auto; max-width: 100%; justify-content: center; }
.subnav a { color: #b8cadb; padding: 5px 11px; border-radius: 6px; font-size: .88rem; white-space: nowrap; }
.subnav a.on, .subnav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.badge-visitor { background: #ffd166; color: #3a2a00; padding: 4px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 22px 20px 40px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px; }

/* basic components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card.narrow { max-width: 520px; }
.card.narrow.center { margin: 40px auto; }
.card.notice { background: #fffaf0; border-color: #f3dfb0; }
details.card > summary { cursor: pointer; }
details.card[open] > summary { margin-bottom: 14px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.pagehead p { margin: 2px 0 0; }
.crumbs { margin-bottom: 8px; font-size: .9rem; }
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn-row form { margin: 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; line-height: 1.2; }
.btn:hover { background: #f3f5f7; text-decoration: none; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.btn-danger-ghost { color: var(--low); background: transparent; border-color: transparent; }
.btn-danger-ghost:hover { background: var(--low-bg); }
.btn-link { background: none; border: 0; padding: 0; color: var(--navy-2); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn[disabled] { opacity: .6; cursor: wait; }

input[type=text], input[type=email], input[type=search], input[type=number], input[type=date], input:not([type]), select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #cfd6dd; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3e6; outline-offset: 0; border-color: var(--navy-2); }
label { display: block; font-weight: 500; font-size: .9rem; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
label.check, label.radio { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; }
label.check input, label.radio input { width: auto; margin-top: 4px; }
label.inline { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 400; }
.stack > * + * { margin-top: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.form-grid.five { grid-template-columns: repeat(5, 1fr); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; min-width: 130px; }
.filters input[type=date] { width: auto; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash-ok { background: var(--good-bg); border-color: #b5e2c5; color: #14532d; }
.flash-err { background: var(--low-bg); border-color: #f5b8b8; color: #7f1d1d; }
.flash-warn { background: var(--mid-bg); border-color: #f2d48a; color: #6b4500; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; background: #eef1f4; font-size: .8rem; font-weight: 600; color: #3d4852; }
a.pill:hover { background: #dfe5ea; text-decoration: none; }
.pill-on { background: var(--navy); color: #fff; }
a.pill-on:hover { background: var(--navy-2); }
.pill-ok { background: var(--good-bg); color: var(--good); }
.pill-need { background: var(--low-bg); color: var(--low); }
.pill-now { background: #e1efff; color: var(--navy-2); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 5px; background: #eef1f4; font-size: .8rem; white-space: nowrap; }
.tag-lesson_plan { background: #e3edfb; } .tag-seating_plan { background: #f1e8fb; } .tag-data_sheet { background: #e4f6ef; }
.tag-presentation { background: #fff0dc; } .tag-activity_sheet { background: #fde7ef; }
.role-admin { background: #ffe4d1; } .role-leader { background: #e1efff; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table thead th { background: #f8f9fb; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.table tbody tr:hover { background: #fafbfc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.inactive td { color: #9aa5b1; }
.table form { margin: 0; display: inline; }
.table td.detail { max-width: 460px; word-break: break-word; font-family: ui-monospace, monospace; font-size: .78rem; }
.tablewrap { overflow-x: auto; }

/* login */
.login { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.login-card { width: 100%; max-width: 410px; background: #fff; border-radius: 14px; padding: 30px; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(18,58,90,.08); }
.login-head { text-align: center; margin-bottom: 18px; }
.login-head h1 { margin-top: 10px; }
.code-input { font-size: 1.7rem !important; letter-spacing: .45em; text-align: center; font-variant-numeric: tabular-nums; }
.resend { margin-top: 14px; text-align: center; font-size: .9rem; }

/* week nav */
.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.weeknav-label { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.weeknav-label strong { font-size: 1.05rem; }
.weeknav-pick { margin-left: auto; }
.weeknav-pick input { width: auto; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { display: block; font-size: .8rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.kpi strong { display: block; font-size: 1.7rem; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: .8rem; }
.kpi-good strong { color: var(--good); } .kpi-mid strong { color: var(--mid); } .kpi-low strong { color: var(--low); }
.kpi-big { grid-column: span 2; } .kpi-big strong { font-size: 2.3rem; }
.kpi-good .bar i { background: var(--good); } .kpi-mid .bar i { background: var(--mid); } .kpi-low .bar i { background: var(--low); }
.kpi-big.kpi-good { border-left: 4px solid var(--good); } .kpi-big.kpi-mid { border-left: 4px solid var(--mid); } .kpi-big.kpi-low { border-left: 4px solid var(--low); }
.bar { height: 8px; background: #edf0f3; border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.bar i { display: block; height: 100%; background: var(--navy-2); border-radius: 99px; }
.pc-good, .bar i.pc-good { background: var(--good); } .pc-mid { background: var(--mid); } .pc-low { background: var(--low); } .pc-na { background: #c9d1d9; }
.pctcell { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.pctcell .bar { flex: 1; margin: 0; }
.pctcell span { font-variant-numeric: tabular-nums; font-weight: 600; font-size: .9rem; width: 40px; text-align: right; }

/* legend + status colours */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.08); }
.st-complete { background: var(--good-bg); } .dot.st-complete { background: var(--good); }
.st-partial { background: var(--mid-bg); } .dot.st-partial { background: var(--mid); }
.st-missing { background: var(--low-bg); } .dot.st-missing { background: var(--low); }
.st-free { background: var(--free); } .dot.st-free { background: #d5dbe0; }
.st-holiday { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #e9ecef 6px, #e9ecef 12px); text-align: center; color: var(--muted); }
.dot.st-late { background: var(--late); }

/* weekly grid */
.gridwrap { overflow-x: auto; margin-bottom: 12px; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); }
.weekgrid { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 760px; table-layout: fixed; }
.weekgrid th { background: #f8f9fb; padding: 10px 8px; font-size: .9rem; border-bottom: 1px solid var(--line); text-align: center; }
.weekgrid th small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.weekgrid th.today { background: #e1efff; }
.weekgrid .pcol { width: 64px; text-align: center; color: var(--muted); font-size: .85rem; background: #f8f9fb; border-right: 1px solid var(--line); }
.weekgrid td { border-bottom: 1px solid #fff; border-right: 1px solid #fff; height: 76px; vertical-align: top; padding: 0; }
.weekgrid td.nocell { background: repeating-linear-gradient(-45deg, #fafbfc, #fafbfc 5px, #f2f4f6 5px, #f2f4f6 10px); }
.cell-link { display: block; height: 100%; padding: 8px 10px; color: inherit; position: relative; min-height: 76px; }
.cell-link:hover { text-decoration: none; box-shadow: inset 0 0 0 2px var(--navy-2); border-radius: 4px; }
.cell-class { display: block; font-weight: 700; font-size: .95rem; }
.cell-subj { display: block; font-size: .8rem; color: #4b5560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-free { color: #9aa5b1; font-size: .85rem; }
.chips { display: flex; gap: 3px; margin-top: 6px; }
.chip { width: 10px; height: 10px; border-radius: 3px; background: rgba(0,0,0,.08); }
.chip.req { box-shadow: 0 0 0 1.5px #56606a; }
.chip.on { background: var(--good); }
.flag-late { position: absolute; top: 6px; right: 8px; font-size: .68rem; font-weight: 700; color: #fff; background: var(--late); padding: 0 5px; border-radius: 4px; text-transform: uppercase; }
.flag-fb { position: absolute; bottom: 4px; right: 6px; font-size: .9rem; }
.flag-fb.dim { opacity: .45; }
.classgrid td { height: auto; padding: 6px 8px; }
.lesson + .lesson { border-top: 1px dashed rgba(0,0,0,.12); margin-top: 6px; padding-top: 6px; }
.lesson-head { line-height: 1.2; }
.lesson-head .muted { display: block; }
.doclink { display: block; font-size: .8rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* slot page */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; margin-bottom: 18px; }
.doc-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-top: 4px solid #d5dbe0; }
.doc-card.has { border-top-color: var(--good); }
.doc-card.need { border-top-color: var(--low); }
.doc-card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.file { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; background: #fbfcfd; }
.file-main { display: flex; flex-direction: column; }
.file-name { font-weight: 600; word-break: break-word; }
.file-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: flex-start; }
.file-actions form { margin: 0; }
.inline-details > summary { list-style: none; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] { flex-basis: 100%; order: 5; }
.inline-details[open] > summary { display: none; }
.upload-form { display: flex; flex-direction: column; gap: 8px; }
.upload-form > .btn { align-self: flex-start; }
.drop { border: 2px dashed #c4ccd4; border-radius: 9px; padding: 16px; text-align: center; cursor: pointer; background: #fafbfc; position: relative; font-weight: 400; }
.drop:hover, .drop.drag { border-color: var(--navy-2); background: #f1f7fd; }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop-text { color: var(--muted); font-size: .9rem; pointer-events: none; }
.drop.has-file .drop-text { color: var(--ink); font-weight: 600; }
.also summary { cursor: pointer; font-size: .85rem; color: var(--navy-2); }
.also-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin-top: 6px; font-size: .88rem; }
.progress { position: relative; height: 22px; background: #edf0f3; border-radius: 6px; overflow: hidden; }
.progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: #9cc3e6; transition: width .2s; }
.progress span { position: relative; font-size: .78rem; padding-left: 8px; line-height: 22px; }
.fb { border-left: 3px solid var(--navy-2); background: #f8fafc; padding: 8px 12px; margin-bottom: 10px; border-radius: 0 6px 6px 0; }
.fb p { margin: 4px 0 0; white-space: pre-wrap; }
.fb-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
ul.plain { list-style: none; padding: 0; margin: 8px 0 0; }
ul.plain li { padding: 3px 0; }

/* dashboard */
.dash-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.dash-row.two { grid-template-columns: 1fr 1fr; }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: 40px 1fr 44px; align-items: center; gap: 8px; font-size: .9rem; }
.hbar-v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.stack-bar { display: flex; height: 16px; border-radius: 5px; overflow: hidden; background: #edf0f3; }
.stack-bar i { display: block; height: 100%; }
.sb-good { background: var(--good); } .sb-mid { background: var(--mid); } .sb-low { background: var(--low); }
.vbars { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 18px; }
.vbar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; color: var(--ink); position: relative; }
.vbar:hover { text-decoration: none; }
.vbar i { display: block; width: 100%; max-width: 34px; border-radius: 5px 5px 0 0; min-height: 2px; }
.vbar.on i { outline: 2px solid var(--navy); outline-offset: 2px; }
.vbar-v { font-size: .72rem; font-weight: 600; margin-bottom: 2px; }
.vbar-l { font-size: .7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.typelist { list-style: none; padding: 0; margin: 0; }
.typelist li { display: grid; grid-template-columns: 165px 1fr 36px; gap: 8px; align-items: center; padding: 4px 0; font-size: .9rem; }
.typelist strong { text-align: right; font-variant-numeric: tabular-nums; }
.mini-bar { height: 8px; background: #edf0f3; border-radius: 99px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--navy-2); }
.remind { display: flex; gap: 10px; padding: 12px 18px; background: #f8f9fb; border-top: 1px solid var(--line); }
.remind input { flex: 1; }
.classtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.classtile { border-radius: 8px; padding: 8px 10px; color: var(--ink); border: 1px solid rgba(0,0,0,.05); }
.classtile:hover { text-decoration: none; box-shadow: inset 0 0 0 2px var(--navy-2); }
.classtile strong { display: block; font-size: .9rem; white-space: nowrap; }
.classtile span { font-size: .85rem; font-weight: 600; }
.pc-bg-good { background: var(--good-bg); } .pc-bg-mid { background: var(--mid-bg); } .pc-bg-low { background: var(--low-bg); } .pc-bg-na { background: var(--free); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 6px 0; border-bottom: 1px solid #f0f2f4; font-size: .9rem; }
.classpick { display: flex; flex-direction: column; gap: 8px; }
.classpick-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.classpick-row strong { min-width: 90px; font-size: .9rem; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; }
.copybox { display: flex; gap: 6px; min-width: 280px; }
.copybox input { font-family: ui-monospace, monospace; font-size: .78rem; }

/* PDF viewer overlay */
.viewer { position: fixed; inset: 0; background: rgba(15,23,32,.75); z-index: 50; display: flex; flex-direction: column; padding: 18px; }
.viewer[hidden] { display: none; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; background: #fff; padding: 8px 12px; border-radius: 10px 10px 0 0; gap: 10px; }
.viewer-bar span { display: flex; gap: 6px; }
.viewer iframe { flex: 1; border: 0; background: #525659; border-radius: 0 0 10px 10px; width: 100%; }

@media (max-width: 960px) {
  .dash-row, .dash-row.two { grid-template-columns: 1fr; }
  .kpi-big { grid-column: auto; }
  .form-grid.five { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; }
  .nav-toggle { display: block; margin-left: auto; }
  .nav { display: none; order: 5; flex-basis: 100%; flex-direction: column; }
  .nav.open { display: flex; }
  .who { order: 4; flex-basis: 100%; justify-content: space-between; }
  .who-name { text-align: left; }
  .wrap { padding: 16px 12px 30px; }
  .doc-grid { grid-template-columns: 1fr; }
  .weeknav-pick { margin-left: 0; }
  .viewer { padding: 0; }
}
