:root {
  --green-900: #1f3d2b;
  --green-700: #2e6b43;
  --green-500: #3f8f5a;
  --green-100: #e3f1e7;
  --earth: #8a5a2b;
  --earth-bg: #f5ece2;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --text: #1e2a22;
  --muted: #5f6f65;
  --border: #d9e0db;
  --red: #b3261e;
  --red-bg: #fbe9e7;
  --amber: #8a5d00;
  --amber-bg: #fff4d6;
  --blue: #1f5fa6;
  --blue-bg: #e6eef9;
  --radius: 12px;
  --sidebar: 240px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 16px; color: var(--text); background: var(--bg); line-height: 1.5;
}
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; margin: 0 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.lead { margin: -.25rem 0 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.text-red { color: var(--red); font-weight: 600; }
.mt { margin-top: 14px; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- layout ---- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar);
  background: var(--green-900); color: #dfe9e2; display: flex; flex-direction: column; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; background: var(--green-500);
  color: #fff; font-weight: 700; font-size: 1.3rem; display: grid; place-items: center; flex: none;
}
a.brand-mark:hover { text-decoration: none; }
/* the NATI crest: a wide picture, so the small square shows the shield from its middle */
.brand-mark.has-logo { background: #23503a; overflow: hidden; padding: 0; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%; transform: scale(1.35); display: block; }
.brand-name { font-weight: 700; color: #fff; }
.brand-sub { font-size: .72rem; opacity: .75; line-height: 1.2; }
.nav { list-style: none; margin: 0; padding: 4px 10px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px; color: #dfe9e2; font-size: 1rem; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: var(--green-500); color: #fff; font-weight: 600; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: .875rem; }
.sidebar-footer a { color: #b9d3c2; }
.user-name { font-weight: 600; color: #fff; }
.user-role { opacity: .7; margin-bottom: 6px; }

.content { margin-left: var(--sidebar); padding: 28px 36px 56px; max-width: 1100px; }
/* signed-out pages (login): the page itself is the green background, edge to edge */
.content.no-nav { margin-left: 0; max-width: none; padding: 0; position: relative; }
.content.no-nav > .flash { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 2; width: min(360px, calc(100% - 32px)); }
.no-nav-body { background: var(--green-900); }

/* phone-only chrome; hidden on desktop */
.topbar, .drawer-backdrop { display: none; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.page-header .actions { margin-bottom: 0; }
.back { display: inline-block; margin-bottom: 10px; font-weight: 600; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.empty { color: var(--muted); text-align: center; padding: 28px 20px; }
.all-good { color: var(--green-700); font-weight: 600; }

/* ---- home tiles ---- */
.greeting { font-size: 1.9rem; margin-bottom: .25rem; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.tile {
  display: flex; flex-direction: column; gap: 14px; padding: 20px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tile:hover { text-decoration: none; border-color: var(--green-500); box-shadow: 0 4px 14px rgba(31,61,43,.12); transform: translateY(-1px); }
.tile-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; }
.tile-icon .ico { width: 28px; height: 28px; }
.t-green { background: var(--green-100); color: var(--green-700); }
.t-blue { background: var(--blue-bg); color: var(--blue); }
.t-amber { background: var(--amber-bg); color: var(--amber); }
.t-earth { background: var(--earth-bg); color: var(--earth); }
.tile-text { display: flex; flex-direction: column; }
.tile-text strong { font-size: 1.2rem; }
.tile-text > span { color: var(--muted); font-size: .95rem; }

.plain-list { list-style: none; margin: 0 0 8px; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }

/* ---- pills, scores ---- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eceff0; color: var(--muted); white-space: nowrap; }
.pill-red { background: var(--red-bg); color: var(--red); }
.pill-green { background: var(--green-100); color: var(--green-700); }
.pill-blue { background: var(--blue-bg); color: var(--blue); }
.pill-grey { background: #eceff0; color: var(--muted); }
.score { display: inline-block; min-width: 2.6em; text-align: center; padding: 3px 9px; border-radius: 8px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score.pass { background: var(--green-100); color: var(--green-700); }
.score.fail { background: var(--red-bg); color: var(--red); }
h2 .score { font-size: .85rem; margin-left: 6px; vertical-align: middle; }

/* ---- search + filter chips ---- */
.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search input { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 8px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; white-space: nowrap; }
.chip span { color: var(--muted); font-weight: 400; margin-left: 2px; }
.chip:hover { text-decoration: none; border-color: var(--green-500); }
.chip.active { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.chip.active span { color: #d4e8da; }

/* ---- tappable rows (students, graduates, stock) ---- */
.rows { list-style: none; margin: 0 0 10px; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rows li + li { border-top: 1px solid var(--border); }
.row-link { display: flex; align-items: center; gap: 14px; padding: 12px 16px; color: var(--text); min-height: 64px; }
.row-link:hover { background: #f7faf8; text-decoration: none; }
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-main strong { font-size: 1.02rem; }
.row-low { background: #fff8f7; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--green-100); color: var(--green-700); display: grid; place-items: center; font-weight: 700; font-size: .9rem; flex: none; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }
.qty { white-space: nowrap; font-size: 1.1rem; }

/* ---- student page ---- */
.profile { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.profile h1 { margin: 0 0 2px; }
.profile .pill { margin-top: 6px; }
.now-doing { font-size: 1.15rem; font-weight: 600; margin: 0 0 12px; }
.mark-list { list-style: none; margin: 0 0 8px; padding: 0; }
.mark-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 3px solid var(--green-100); }
.timeline li { padding: 4px 0 12px 10px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
details.add-box > summary { list-style: none; cursor: pointer; display: inline-block; }
details.add-box > summary::-webkit-details-marker { display: none; }
details.add-box[open] > summary.btn { display: none; }
details.add-box form { margin-top: 12px; }
.link-like { color: var(--green-700); font-weight: 600; }

/* ---- forms ---- */
.form-narrow { max-width: 620px; }
.form-wide { max-width: 900px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field.full > .field { margin-bottom: 0; }
fieldset { border: 0; margin: 0 0 18px; padding: 0; }
legend { font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; padding: 0; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label, .field .label, .label { font-size: .9rem; font-weight: 600; color: var(--muted); }
.hint { font-size: .85rem; color: var(--muted); }
input[type=text], input:not([type]), input[type=search], input[type=number], input[type=date], input[type=password],
input[type=email], input[type=tel], select, textarea {
  font: inherit; font-size: 16px; padding: 11px 12px; border: 1px solid #c5cfc8; border-radius: 8px; background: #fff; width: 100%; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(63,143,90,.35); outline-offset: 0; border-color: var(--green-500); }
textarea { min-height: 80px; resize: vertical; }
.choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.choice { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: #fff; font-weight: 500; color: var(--text); }
.choice:has(input:checked) { border-color: var(--green-500); background: var(--green-100); }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--green-700); }
.form-actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-fields { display: flex; gap: 12px; margin-top: 10px; }
.inline-fields .field { flex: 1; margin: 0; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  padding: 10px 18px; border-radius: 8px; cursor: pointer; line-height: 1.3; min-height: 44px;
  border: 1px solid var(--green-700); background: var(--green-700); color: #fff; text-decoration: none;
}
.btn:hover { background: var(--green-900); border-color: var(--green-900); text-decoration: none; }
.btn-big { font-size: 1.05rem; padding: 12px 22px; min-height: 50px; }
.btn-secondary { background: #fff; color: var(--green-700); }
.btn-secondary:hover { background: var(--green-100); color: var(--green-900); }
.btn-danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn-use { background: var(--earth); border-color: var(--earth); }
.btn-use:hover { background: #6d4520; border-color: #6d4520; }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: .875rem; }

/* ---- flash ---- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; font-weight: 500; }
.flash-success { background: var(--green-100); color: var(--green-900); border-color: #bcdcc6; }
.flash-error { background: var(--red-bg); color: var(--red); border-color: #efb8b3; }
.flash-info { background: var(--blue-bg); color: var(--blue); border-color: #b9cdea; }

/* ---- marks entry ---- */
.steps { padding: 0; }
.step { display: flex; gap: 14px; padding: 20px 22px; }
.step + .step { border-top: 1px solid var(--border); }
.step-num { width: 32px; height: 32px; border-radius: 50%; background: var(--green-700); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.step-body { flex: 1; min-width: 0; }
.step-body > label, .step-body > .label { display: block; margin-bottom: 6px; font-size: 1rem; color: var(--text); }
.step-body h2 { margin-top: 2px; }
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.subject {
  font: inherit; font-weight: 600; text-align: left; padding: 12px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--text); display: flex; flex-direction: column; gap: 2px;
}
.subject .small { font-weight: 400; color: var(--muted); }
.subject:hover { border-color: var(--green-500); }
.subject.complete .small { color: var(--green-700); }
.subject.active { border-color: var(--green-700); background: var(--green-700); color: #fff; }
.subject.active .small { color: #d4e8da; }
.result-entry { list-style: none; margin: 0; padding: 0; }
.result-entry li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.result-entry .who { flex: 1; min-width: 0; }
.result-choice { display: flex; gap: 6px; flex: none; }
.rc { position: relative; cursor: pointer; }
.rc input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rc span { display: grid; place-items: center; min-width: 52px; height: 44px; padding: 0 10px; border-radius: 8px; border: 1px solid #c5cfc8; background: #fff; font-weight: 700; color: var(--muted); }
.rc-none span { min-width: 40px; }
.rc input:focus-visible + span { outline: 3px solid rgba(63,143,90,.45); }
.rc-c input:checked + span { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.rc-nyc input:checked + span { background: var(--red); border-color: var(--red); color: #fff; }
.rc-none input:checked + span { background: #eceff0; color: var(--text); }
/* unit standards on the Results page: boxes, then a C / NYC / - for each standard per student */
.std-heading { font-size: 1rem; margin: 14px 0 8px; }
.std-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-bottom: 8px; }
.std-card { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.std-card .std-title { font-size: .9rem; line-height: 1.3; }
.std-card.std-now { border: 2px solid var(--green-700); background: #f1f8f3; }
.std-tag { align-self: flex-start; margin-top: 2px; font-size: .75rem; font-weight: 600; color: var(--green-700); }
.std-entry { width: 100%; border-collapse: collapse; }
.std-entry th, .std-entry td { padding: 6px 6px; border-bottom: 1px solid var(--border); text-align: center; vertical-align: middle; white-space: nowrap; }
.std-entry th:first-child, .std-entry td.who { text-align: left; white-space: normal; min-width: 150px;
  position: sticky; left: 0; z-index: 1; background: #fff; }      /* names stay in view when the table scrolls */
.std-cell-label, .std-all-phone, .std-select, .who-sum { display: none; }
/* phones: each student is a card - name, then one line per standard (code, C / NYC / -), then the unit result -
   instead of a table that scrolls sideways */
@media (max-width: 600px) {
  .std-scroll { overflow: visible; }
  .std-entry, .std-entry tbody, .std-entry tr, .std-entry td { display: block; width: auto; }
  .std-entry thead { display: none; }
  .std-entry tr { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
  .std-entry td, .std-entry td.who { position: static; min-width: 0; max-width: none; border: 0; padding: 0; text-align: left; white-space: normal; }
  .std-entry td.who { padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
  .std-entry td:not(.who) { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; }
  .std-cell-label { display: inline; font-weight: 600; font-size: .9rem; }
  .std-entry .std-unit .std-cell-label { font-weight: 400; color: var(--muted); }
  .std-entry .rc-sm { display: none; }                       /* the drop-down sets these */
  .std-select { display: block; flex: 0 0 auto; width: 120px; height: 44px; padding: 0 10px;
    border: 1px solid #c5cfc8; border-radius: 8px; background: #fff; font-size: 1rem; font-weight: 600; }
  .std-select.sel-c { background: var(--green-700); border-color: var(--green-700); color: #fff; }
  .std-select.sel-nyc { background: var(--red); border-color: var(--red); color: #fff; }
  .std-all-phone { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
  /* each student folded to one line (name, how many standards marked, unit result); tap to open */
  .std-entry tr { padding: 8px 12px; margin-bottom: 6px; }
  .std-entry td.who { position: relative; padding: 4px 96px 4px 0; margin: 0; border: 0; cursor: pointer; }
  .std-entry tr.open td.who { padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
  .std-entry tr:not(.open) td:not(.who) { display: none; }
  .who-sum { display: flex; align-items: center; gap: 6px; position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
  .who-count { font-size: .8rem; color: var(--muted); white-space: nowrap; }
  .chev { font-size: 1.1rem; color: var(--muted); transition: transform .15s; }
  .std-entry tr.open .chev { transform: rotate(180deg); }
}
.std-entry th .link-like { font-weight: 400; }
.rc-sm { justify-content: center; gap: 4px; }
.rc-sm .rc span { min-width: 40px; height: 38px; padding: 0 6px; font-size: .9rem; }
.rc-sm .rc-none span { min-width: 30px; }
.std-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.std-chip { font-size: .75rem; padding: 2px 7px; border-radius: 999px; background: #e7f3ea; color: var(--green-700); font-weight: 600; }
.std-chip-nyc { background: #fbe7e6; color: var(--red); }
.save-bar { position: sticky; bottom: 0; z-index: 3; background: linear-gradient(transparent, #fff 30%); padding: 18px 0 4px; }
.save-bar .btn { width: 100%; }

/* ---- stock page ---- */
.qty-card { text-align: center; }
.qty-card.low { border-color: #efb8b3; background: #fff8f7; }
.qty-big { font-size: 2.8rem; font-weight: 700; line-height: 1.1; margin: 4px 0 8px; }
.qty-big span { font-size: 1.2rem; color: var(--muted); font-weight: 500; }
.stock-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stock-form h2 { margin-bottom: 2px; }
.stock-form .btn { width: 100%; }
.stock-form.add { border-top: 4px solid var(--green-500); }
.stock-form.use { border-top: 4px solid var(--earth); }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; gap: 14px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.history-main { display: flex; flex-direction: column; }
.change { min-width: 64px; font-weight: 700; font-variant-numeric: tabular-nums; }
.change.in { color: var(--green-700); }
.change.out { color: var(--earth); }

/* ---- graduates bars + reports ---- */
.bars { list-style: none; margin: 0; padding: 0; }
.bars a { display: grid; grid-template-columns: minmax(0, 14em) 1fr 2.5em; gap: 12px; align-items: center; padding: 8px 6px; border-radius: 8px; color: var(--text); }
.bars a:hover { background: #f7faf8; text-decoration: none; }
.bars a.active { background: var(--green-100); }
.bar { height: 12px; background: #e6ebe7; border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green-500); border-radius: 6px; }
.bar-num { text-align: right; font-weight: 700; }
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.stat { flex: 1; min-width: 110px; background: var(--bg); border-radius: 10px; padding: 12px 14px; color: var(--muted); }
.stat-num { display: block; font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1.1; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ranking { margin: 0; padding-left: 1.6em; columns: 2; column-gap: 32px; }
.ranking li { padding: 5px 0; break-inside: avoid; }
.ranking li .score { margin-left: 6px; font-size: .85rem; }

/* ---- staff + leave ---- */
h2.dept { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
.leave-line { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.leave-chip { padding: 1px 8px; border-radius: 999px; background: #eceff0; color: var(--muted); white-space: nowrap; }
.leave-chip.used { background: var(--blue-bg); color: var(--blue); }
.leave-chip.over { background: var(--red-bg); color: var(--red); font-weight: 600; }
.leave-summary { list-style: none; margin: 4px 0 16px; padding: 0; }
.leave-summary li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.leave-summary .bar { grid-column: 1 / -1; }
.leave-summary li.over strong { color: var(--red); }
.leave-summary li.over .bar > span { background: var(--red); }

/* ---- activity log ---- */
.activity .row-link { align-items: flex-start; }
.act { flex: none; min-width: 72px; text-align: center; padding: 3px 8px; border-radius: 6px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.act-added { background: var(--green-100); color: var(--green-700); }
.act-edited { background: var(--blue-bg); color: var(--blue); }
.act-removed { background: var(--red-bg); color: var(--red); }
.search select { flex: 1; }

/* ---- settings ---- */
.settings-list { list-style: none; margin: 0; padding: 0; }
.settings-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--border); }
.settings-list li.inactive { opacity: .6; }
.inline-edit { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 220px; }
.unit-edit { display: flex; gap: 6px; align-items: center; flex: 1 1 100%; flex-wrap: wrap; }
.unit-edit input { padding: 8px 10px; }
.unit-edit .u-code { width: 130px; }
.unit-edit .u-name { flex: 1; min-width: 180px; }
.unit-edit .u-num { width: 84px; }
.inline-edit input { flex: 1; padding: 8px 10px; }
.user-cell { flex: 1; display: flex; flex-direction: column; min-width: 200px; }
.user-actions > summary { list-style: none; }
.user-actions > summary::-webkit-details-marker { display: none; }
.user-actions[open] { flex-basis: 100%; display: flex; flex-direction: column; gap: 8px; padding: 6px 0; }
.user-actions[open] > summary { align-self: flex-start; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--green-900), var(--green-700)); }
.login-card { background: #fff; padding: 32px; border-radius: 14px; width: min(380px, calc(100% - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .brand { padding: 0 0 18px; }
.login-card .brand-name, .login-card .brand-sub { color: var(--text); }
.login-card .btn { width: 100%; margin-top: 6px; min-height: 50px; font-size: 1.05rem; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 76px; }
.password-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%); min-width: 60px; min-height: 36px;
  font: inherit; font-size: .9rem; font-weight: 600; color: var(--green-700); background: var(--green-100);
  border: 0; border-radius: 6px; cursor: pointer;
}
.password-toggle:hover { background: #d3e9da; }
.password-toggle:focus-visible { outline: 3px solid rgba(63,143,90,.45); }
.pw-rules { list-style: none; margin: 6px 0 0; padding: 0; font-size: .9rem; color: var(--muted); }
.pw-rules li { padding: 2px 0 2px 26px; position: relative; }
.pw-rules li::before { content: "○"; position: absolute; left: 4px; }
.pw-rules li.met { color: var(--green-700); font-weight: 600; }
.pw-rules li.met::before { content: "✓"; }

/* ---- help pages ---- */
.section-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.section-tabs a { padding: 10px 14px; border-radius: 8px 8px 0 0; color: var(--muted); white-space: nowrap; }
.section-tabs a.active { background: var(--surface); border: 1px solid var(--border); border-bottom-color: var(--surface); color: var(--text); font-weight: 600; margin-bottom: -1px; }
.doc { max-width: 820px; }
.doc h1 { margin-top: 0; }
.doc h2 { border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-top: 1.6rem; }
.doc code { background: #eef2ef; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.doc pre { background: #1f2a22; color: #e8efe9; padding: 12px; border-radius: 6px; overflow-x: auto; }
.doc pre code { background: none; color: inherit; padding: 0; }
.doc table { margin: 10px 0; }
.doc img { max-width: 100%; }
.doc .toc { background: #fafbfa; border: 1px solid var(--border); padding: 10px 24px; border-radius: 6px; font-size: .9rem; }
.doc .toc ul { margin: 4px 0; padding-left: 18px; }

/* ---- Financials ---- */
/* Financials: the jobs (one row, wrapping - nothing hidden off the side), then the pages of the job you are in */
.fin-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: -8px 0 10px; }
.fin-nav a { padding: 9px 14px; border-radius: 10px; color: var(--green-900); background: #fff; border: 1px solid var(--border);
             font-weight: 700; font-size: .95rem; white-space: nowrap; }
.fin-nav a:hover { background: var(--green-100); text-decoration: none; }
.fin-nav a.active { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.fin-subnav { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0 0 18px; padding: 6px 8px; border-radius: 10px;
              background: var(--green-100); }
.fin-subnav a { padding: 7px 12px; border-radius: 8px; color: var(--green-900); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.fin-subnav a:hover { background: #fff; text-decoration: none; }
.fin-subnav a.active { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.12); color: var(--green-900); }
.tile-off { opacity: .45; cursor: default; }
.tile-off:hover { transform: none; box-shadow: none; border-color: var(--border); }
.fin-columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.attention .row-link { min-height: 52px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--blue); }
.dot-red { background: var(--red); }
.dot-amber { background: #d69e00; }
.plain-list .num, strong.num { font-variant-numeric: tabular-nums; }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.text-green { color: var(--green-700); font-weight: 700; }
.inline-form { display: inline; }
.unit-list { columns: 2; column-gap: 24px; margin: 0 0 12px; }
.fees-box { border-left: 4px solid var(--green-500); }
.fin-filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-bottom: 14px; }
.fin-filters label { display: flex; flex-direction: column; font-size: .8rem; font-weight: 600; color: var(--muted); gap: 3px; }
.fin-filters input, .fin-filters select { padding: 7px 9px; width: auto; min-width: 130px; }
.table-card { overflow-x: auto; }
.fin-table th, .fin-table td { padding: 8px 8px; }
.fin-table td input, .fin-table td select { padding: 6px 8px; min-width: 64px; }
.fin-table input[type=checkbox] { min-width: 0; width: 20px; height: 20px; accent-color: var(--green-700); }
.fin-table tfoot th { font-size: .9rem; text-transform: none; letter-spacing: 0; color: var(--text); border-top: 2px solid var(--border); }
.fin-table tr.void td { color: var(--muted); text-decoration: line-through; }
.fin-table tr.void td:last-child { text-decoration: none; }
.fin-table tr.reversed td { color: var(--muted); }
.fin-table tr.total-row td { font-weight: 700; border-top: 2px solid var(--border); }
.fin-table td.wrap { white-space: normal; }
.grid-entry td { padding: 3px 4px; }
.grid-entry td input { width: 100%; }
.grid-entry input.hours { width: 4.2em; min-width: 0; text-align: center; padding: 6px 4px; }
.grid-entry .mark { font-size: .7rem; font-weight: 700; color: var(--blue); display: block; text-align: center; }
.money-wrap { display: flex; align-items: center; border: 1px solid #c5cfc8; border-radius: 8px; background: #fff; }
.money-wrap > span { padding: 0 4px 0 12px; color: var(--muted); font-weight: 600; }
.money-wrap input { border: 0; padding-left: 4px; }
.money-wrap:focus-within { outline: 3px solid rgba(63,143,90,.35); border-color: var(--green-500); }
.money-wrap input:focus { outline: none; }
.upload-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.upload-row select { width: auto; }
.upload-row input[type=file] { flex: 1; min-width: 200px; }
.bank-wait { margin: 0; }
.bank-wait.late { border-color: #efb8b3; background: #fff8f7; }
.bank-wait .qty-big { font-size: 2rem; margin: 0 0 4px; }
.qty-big.small-big { font-size: 1.6rem; }
.count-check { font-weight: 700; margin: 10px 0 0; }
.count-check.ok { color: var(--green-700); }
.count-check.bad { color: var(--red); }
.count-table input { max-width: 120px; }
details.acct { border-bottom: 1px solid var(--border); padding: 10px 0; }
details.acct > summary { cursor: pointer; }
details.acct.inactive { opacity: .6; }
.finance-access select { width: auto; }
.item-grid .split-col { display: none; }
.item-grid.show-split .split-col { display: table-cell; }
.item-grid select { min-width: 7rem; }
.table-scroll { overflow-x: auto; }
.info-box {background: var(--blue-bg); color: var(--blue); border: 1px solid #c4d8ee; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.info-box a { color: inherit; text-decoration: underline; }
.bs-table td.indent { padding-left: 28px; }
.bs-table tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
.bs-table tr.head td { font-weight: 700; padding-top: 16px; text-transform: uppercase; font-size: .85rem; color: var(--muted); }
.warn-box { background: var(--amber-bg); color: var(--amber); border: 1px solid #f0d58a; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600; }
.bc-result .dl { grid-template-columns: 1fr max-content; }
.bc-result dd { text-align: right; font-variant-numeric: tabular-nums; }
.steps-line { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.steps-line span { padding: 6px 12px; border-radius: 999px; background: #eceff0; color: var(--muted); font-size: .85rem; font-weight: 600; }
.steps-line span.done { background: var(--green-100); color: var(--green-700); }
.steps-line span.now { background: var(--green-700); color: #fff; }
.steps-line span.no { background: var(--red-bg); color: var(--red); }
.side-by-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.side-by-side .card { margin: 0; }
.side-by-side .chosen { border: 2px solid var(--green-500); }

/* printed documents: receipts, invoices, vouchers, statements, payslips (A4) */
.print-doc { position: relative; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 32px; margin-bottom: 18px; max-width: 820px; }
.letterhead { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--green-900); padding-bottom: 10px; margin-bottom: 16px; }
.lh-name { font-size: 1.2rem; color: var(--green-900); }
.lh-title { text-align: right; }
.lh-title strong { font-size: 1.15rem; letter-spacing: .04em; }
.lh-no { font-size: 1.3rem; font-weight: 700; color: var(--red); }
.doc-dl { display: grid; grid-template-columns: 9em 1fr; gap: 8px 16px; margin: 0 0 14px; }
.doc-dl dt { color: var(--muted); }
.doc-dl dd { margin: 0; border-bottom: 1px dotted #c5cfc8; }
.doc-total { display: flex; justify-content: flex-end; align-items: center; gap: 14px; font-size: 1.1rem; margin: 10px 0; }
.doc-total strong { border: 2px solid var(--text); padding: 6px 18px; font-size: 1.4rem; }
.signs { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-top: 28px; font-size: .9rem; }
.stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 5rem; font-weight: 800; color: rgba(31,95,166,.18); letter-spacing: .1em; pointer-events: none; }
.stamp-red { color: rgba(179,38,30,.22); top: 60%; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.doc-note { font-size: .85rem; border-top: 1px solid var(--border); margin-top: 16px; padding-top: 8px; }
.page-break { break-after: page; }
.doc-programme { text-align: center; font-weight: 600; margin: 0 0 12px; }
.results-table td, .results-table th { padding: 6px 8px; }
.results-table td:first-child, .results-table th:last-child, .results-table th:nth-last-child(2) { white-space: nowrap; }
.doc-comment { margin: 14px 0 0; }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-columns { grid-template-columns: 1fr; }
}

/* ---- phones & small tablets ---- */
@media (max-width: 900px) {
  :root { --topbar: 56px; }

  /* top bar */
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30;
    height: calc(var(--topbar) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0;
    background: var(--green-900); color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2);
  }
  .topbar-title { flex: 1; font-weight: 600; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 8px; background: none; color: inherit; cursor: pointer; }
  .icon-btn:active { background: rgba(255,255,255,.12); }
  .brand-mark-sm { width: 34px; height: 34px; font-size: 1rem; margin-right: 6px; color: #fff; }

  /* sidebar becomes a slide-out drawer */
  .sidebar {
    width: min(300px, 85vw); z-index: 50; transform: translateX(-100%); transition: transform .22s ease;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  }
  body.drawer-open .sidebar { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.3); }
  .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .22s; }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }

  /* page content (everything is in the ☰ menu - no bar along the bottom) */
  .content { margin-left: 0; padding: 16px 14px calc(env(safe-area-inset-bottom) + 24px); }
  .content.no-nav { padding: 0; }
  h1 { font-size: 1.4rem; }
  .greeting { font-size: 1.5rem; }
  .page-header .btn-big { width: 100%; }
  .card { padding: 16px; overflow-x: auto; }
  .tiles { gap: 10px; margin-bottom: 22px; }
  .tile { padding: 16px; gap: 10px; }
  .tile-icon { width: 46px; height: 46px; }
  .tile-text strong { font-size: 1.1rem; }
  .tile-text > span { font-size: .875rem; }
  .row-link { padding: 12px 14px; }
  .stock-actions { grid-template-columns: 1fr; gap: 0; }
  .step { padding: 16px; gap: 12px; }
  .step-num { width: 28px; height: 28px; font-size: .9rem; }
  .subject-grid { grid-template-columns: 1fr 1fr; }
  .save-bar { bottom: env(safe-area-inset-bottom); }
  .card.steps { overflow: visible; }   /* a scrolling card would stop the Save button staying in view */
  .bars a { grid-template-columns: 1fr 2.5em; row-gap: 4px; }
  .bars .bar { grid-column: 1 / -1; grid-row: 2; }
  .ranking { columns: 1; }
  .dl { grid-template-columns: 1fr; gap: 0; }
  .dl dd { margin-bottom: 10px; }
  .form-actions .btn { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .drawer-backdrop, .actions, .chips, .btn, .flash, .no-print, .search, .fin-nav, .fin-subnav, .fin-filters { display: none !important; }
  .content { margin: 0; padding: 0; max-width: none; }
  .card { border: none; padding: 0; }
  body { background: #fff; font-size: 11pt; }
  @page { size: A4; margin: 14mm; }
  .print-doc { border: none; padding: 0; max-width: none; margin: 0; }
  .two-col { grid-template-columns: 1fr 1fr; }
  .fin-table th, .fin-table td { padding: 4px 6px; }
  a { color: inherit; }
}
@media screen and (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .print-doc { padding: 18px; }
  .doc-dl { grid-template-columns: 1fr; gap: 2px; }
  .letterhead { flex-direction: column; }
  .lh-title { text-align: left; }
}

/* Reports page: one section per reader */
.report-group { margin-bottom: 26px; }
.report-group h2 { margin-bottom: 10px; }
.report-group h2 .small { font-weight: 400; margin-left: 6px; }
@media (max-width: 600px) {
  .fin-nav { gap: 4px; }
  .fin-nav a { padding: 6px 10px; font-size: .86rem; }
  .fin-subnav a { padding: 5px 9px; font-size: .84rem; }
}

/* a group of fields inside a form section (e.g. 'If they have left' on the student form) */
.sub-box { border: 1px dashed var(--border); border-radius: var(--radius); padding: 12px 14px; }
.sub-box .form-grid { margin-top: 8px; }
/* unit standards under each unit (Settings) and on the Results page */
.std-box { flex-basis: 100%; margin-top: 4px; }
.std-box summary { cursor: pointer; color: var(--muted); }
.std-list { margin: 6px 0 0; padding-left: 0; list-style: none; }
.std-list li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.std-list li.inactive { opacity: .6; }
.std-list .u-title { flex: 1 1 260px; min-width: 0; }
.std-box .unit-edit { flex: 1 1 520px; }
.std-box .unit-edit select { width: auto; padding: 8px 10px; }
.std-box .unit-edit .u-title { flex: 1 1 240px; min-width: 0; }

/* the student page: the student at a glance, and detail cards folded until opened */
.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 14px 0 18px; }
.summary-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; min-width: 0; }
a.summary-item:hover { border-color: var(--green-500); }
.summary-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.summary-item strong { font-size: 1.15rem; overflow-wrap: anywhere; }
.summary-item span:last-child { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
details.fold > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; display: inline; }
details.fold > summary::after { content: "Show"; margin-left: auto; font-size: .85rem; color: var(--green-700); font-weight: 600; }
details.fold[open] > summary::after { content: "Hide"; }
details.fold[open] > summary { margin-bottom: 12px; }
details.older > summary { cursor: pointer; color: var(--green-700); font-weight: 600; margin: 12px 0 4px; }

/* Settings -> Attachment places: one row per place */
#places .unit-edit select { width: auto; padding: 8px 10px; }
#places .unit-edit .u-name { flex: 1 1 180px; }
#places .unit-edit .choice { padding: 6px 10px; }
