:root {
  --ed-green: #0b6e4f;
  --ed-green-dark: #08533b;
  --ed-gold: #f2a900;
  --ed-bg: #f4f6f8;
  --sidebar-w: 250px;
}
body.app { background: var(--ed-bg); }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--ed-green-dark), var(--ed-green));
  color: #fff; overflow-y: auto; z-index: 1030; transition: transform .2s;
}
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: 1rem; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar .brand-logo { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 6px; }
.sidebar .brand-name { font-weight: 700; letter-spacing: .3px; }
.sidebar .brand-school { font-size: .75rem; opacity: .85; line-height: 1.1; }
.sidebar .nav-link { color: rgba(255,255,255,.88); display: flex; align-items: center; gap: .55rem; padding: .48rem 1rem; font-size: .92rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.16); color: #fff; border-left: 3px solid var(--ed-gold); }
.sidebar .subnav .nav-link { padding-left: 2.6rem; font-size: .86rem; }
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.main .content { flex: 1; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid #e3e6ea; position: sticky; top: 0; z-index: 1020; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .main { margin-left: 0; }
}
.btn-primary { --bs-btn-bg: var(--ed-green); --bs-btn-border-color: var(--ed-green); --bs-btn-hover-bg: var(--ed-green-dark); --bs-btn-hover-border-color: var(--ed-green-dark); --bs-btn-active-bg: var(--ed-green-dark); }
.card { border: 1px solid #e3e6ea; border-radius: .6rem; }
.card-header { background: #fff; }
.stat .stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; }
.stat .stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.stat .stat-label { font-size: .8rem; color: #6c757d; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; color: #5b6570; white-space: nowrap; }
.filter-bar .form-select, .filter-bar .form-control { font-size: .875rem; }
.marks-grid input.form-control { width: 90px; }
.marks-grid .status-select { width: 120px; }
.cell-missing { background: #fff3cd !important; }
.cell-absent { background: #f8d7da !important; }
.cell-exempt, .cell-na { background: #e2e3e5 !important; }
body.guest { background: linear-gradient(135deg, var(--ed-green-dark), var(--ed-green)); min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.guest-card { width: 100%; max-width: 420px; }

/* Timetable */
.tt-grid { table-layout: fixed; }
.tt-grid th, .tt-grid td { text-align: center; vertical-align: middle; font-size: .78rem; padding: .25rem; }
.tt-grid td.tt-break { background: #f1f3f5; color: #868e96; font-style: italic; }
/* Traditional school layout: sideways break columns, merged doubles */
.tt-school { border: 2px solid #212529; }
.tt-school th, .tt-school td { border-color: #495057 !important; }
.tt-school .tt-dayhead, .tt-school .tt-day { font-weight: 800; font-size: .9rem; text-align: left; width: 70px; background: #fff; }
.tt-school .tt-time { font-weight: 700; font-size: .75rem; white-space: nowrap; }
.tt-school .tt-plabel { font-weight: 400; font-size: .65rem; color: #6c757d; }
.tt-school th.tt-breakhead { width: 46px; padding: .2rem .1rem; }
.tt-school th.tt-breakhead .tt-time { white-space: normal; font-size: .65rem; }
.tt-school td.tt-break-v { width: 46px; padding: .4rem .1rem; background: #fff; color: #212529; font-style: normal; border-left: 2px solid #212529 !important; border-right: 2px solid #212529 !important; vertical-align: middle; }
.tt-school td.tt-break-v span { display: inline-block; writing-mode: vertical-rl; white-space: nowrap; font-weight: 800; font-size: 1.35rem; letter-spacing: .12em; line-height: 1; font-family: Georgia, 'Times New Roman', serif; }
.tt-school td.tt-double-td { padding: .25rem; }
.tt-cell.double { min-height: 52px; display: flex; flex-direction: column; justify-content: center; }
.tt-cell.double .subj { font-size: .85rem; }
.tt-cell { min-height: 48px; border-radius: 6px; padding: 3px; cursor: default; }
.tt-cell.filled { background: #e7f5ef; border: 1px solid #b7e1cd; }
.tt-cell.locked { border: 2px solid var(--ed-gold); }
.tt-cell.conflict { background: #fde2e1 !important; border: 2px solid #dc2626 !important; }
.tt-chip { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; }
.tt-cell.drop-ok, .tt-chip.drop-ok { background: #dcfce7 !important; outline: 2px solid #16a34a; }
.tt-cell.drop-swap, .tt-chip.drop-swap { outline: 2px dashed #2563eb; }
.tt-chip.drop-swap { background: #dbeafe; }
.tt-cell.drop-bad, .tt-chip.drop-bad { background: #fee2e2 !important; outline: 2px solid #dc2626; }
.tt-cell.drop-bad { cursor: not-allowed; opacity: .85; }
.tt-cell.dragging { opacity: .4; }
.tt-grid, .tt-cell, .tt-chip { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.tt-cell.dragover { outline: 2px dashed var(--ed-green); }
.tt-cell .subj { font-weight: 600; }
.tt-cell .meta { color: #495057; font-size: .7rem; }
.tt-editable .tt-cell { cursor: pointer; }
.tt-editable .tt-cell.filled { cursor: grab; }

/* Print documents */
body.print-doc { background: #e9ecef; }
.print-doc .page { background: #fff; max-width: 210mm; margin: 1rem auto; padding: 14mm; box-shadow: 0 0 12px rgba(0,0,0,.08); }
.print-doc.landscape .page { max-width: 297mm; }
.letterhead { display: flex; align-items: center; gap: 1rem; border-bottom: 3px double var(--ed-green); padding-bottom: .5rem; margin-bottom: .6rem; }
.letterhead img { width: 70px; height: 70px; object-fit: contain; }
.lh-name { font-size: 1.35rem; font-weight: 700; color: var(--ed-green-dark); text-transform: uppercase; }
.lh-contact { font-size: .8rem; }
.lh-motto { font-size: .8rem; font-style: italic; color: #555; }
.doc-title { font-size: 1.05rem; text-align: center; text-transform: uppercase; margin: .4rem 0 .1rem; font-weight: 700; }
.doc-subtitle { text-align: center; font-size: .85rem; margin-bottom: .6rem; }
.print-doc table { font-size: .8rem; }
.print-doc .table td, .print-doc .table th { padding: .2rem .35rem; }
.print-footer { margin-top: 1rem; font-size: .7rem; color: #777; border-top: 1px solid #ddd; padding-top: .3rem; }
.sig-line { border-top: 1px solid #333; margin-top: 2.2rem; padding-top: .2rem; font-size: .8rem; }
.page-break { page-break-after: always; break-after: page; }
.report-card { page-break-after: always; break-after: page; }
.report-card:last-child { page-break-after: auto; }
@media print {
  .no-print, .sidebar, .topbar, footer, .page-actions, .filter-bar { display: none !important; }
  body.print-doc { background: #fff; }
  .print-doc .page { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .main { margin: 0; }
  @page { size: A4; margin: 12mm; }
  body.landscape { }
  .landscape-page { size: A4 landscape; }
  a[href]::after { content: none; }
}

/* Report card comments: long text wraps inside its cell */
.rc-comment { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.report-card table { table-layout: auto; }
.report-card th, .report-card td { white-space: normal; overflow-wrap: anywhere; }
@media print { .report-card table { width: 100%; max-width: 100%; } .report-card th { font-size: 7.5pt; } }

/* ---- Timetable: bold style (solid colours, abbreviations, thick lines) ---- */
.tt-bold { border: 2.5px solid #111 !important; border-collapse: collapse; }
.tt-bold th, .tt-bold td { border: 1.5px solid #111 !important; }
.tt-bold td { padding: 0 !important; height: 62px; background: #fff; }
.tt-bold .tt-cell { border: 0 !important; border-radius: 0; height: 100%; min-height: 62px; padding: 4px 3px; position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; line-height: 1.05; }
.tt-bold .tt-cell.filled { box-shadow: none; }
.tt-bold .tt-cell .subj { font-family: Arial, Helvetica, sans-serif; font-weight: 800; font-size: 1rem; letter-spacing: .02em; white-space: nowrap; }
.tt-bold .tt-cell .subj.long { font-size: .82rem; }
.tt-bold .tt-cell.double .subj { font-size: 1.2rem; }
.tt-bold .tt-cell.double .subj.long { font-size: 1rem; }
.tt-bold .tt-cell .tch { font-size: .7rem; font-weight: 700; margin-top: 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-bold .tt-cell .rm { font-size: .62rem; opacity: .85; }
.tt-bold .tt-cell .tt-n { position: absolute; right: 4px; bottom: 2px; font-size: .62rem; font-weight: 700; opacity: .8; }
.tt-bold .tt-cell.locked { outline: 3px solid var(--ed-gold); outline-offset: -3px; }
.tt-bold .tt-cell.conflict { outline: 3px solid #dc2626; outline-offset: -3px; }
.tt-bold.tt-school .tt-timehead, .tt-bold.tt-school .tt-breakhead { background: #fff; }
.tt-bold .tt-pno { font-family: Arial, Helvetica, sans-serif; font-size: 1.15rem; font-weight: 800; line-height: 1.1; }
.tt-bold th.tt-breakhead .tt-pno { font-size: .72rem; font-weight: 700; }
.tt-bold.tt-school td.tt-break-v { border-left: 2.5px solid #111 !important; border-right: 2.5px solid #111 !important; }
.tt-bold.tt-person td { height: 60px; }
.tt-bold.tt-person .tt-cell { min-height: 60px; padding-bottom: 4px; }
.tt-bold.tt-person .tt-cell .subj { font-size: .95rem; }
.tt-bold.tt-person .tt-cell .meta { color: inherit; font-weight: 700; }
.tt-key { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; font-size: .8rem; align-items: center; }
.tt-keyitem { white-space: nowrap; }
.tt-sw { display: inline-block; min-width: 3.4em; padding: .1rem .4rem; font-family: Arial, Helvetica, sans-serif; font-weight: 900; text-align: center; border: 1.5px solid #111; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.tt-classtitle { font-family: Arial, Helvetica, sans-serif; font-weight: 800; font-size: 1.2rem; margin: 1rem 0 .25rem; }
.tt-page:first-child .tt-classtitle { margin-top: 0; }
.print-doc .tt-classtitle { text-align: center; font-size: 2.3rem; margin: 0 0 .2rem; }
.print-doc .tt-page + .tt-page { page-break-before: always; break-before: page; }
.print-doc .tt-bold td { height: 70px; }
.print-doc .tt-bold .tt-cell { min-height: 70px; }
.print-doc .tt-bold.tt-person td { height: 58px; }
.print-doc .tt-bold.tt-person .tt-cell { height: 100%; min-height: 58px; }
.tt-print-only { display: none; }
.print-doc .tt-print-only { display: block; }
.tt-bold .tt-cell .tcode { font-family: Arial, Helvetica, sans-serif; font-size: .78rem; font-weight: 900; letter-spacing: .04em; }
.tt-sw-code { min-width: 2.8em; background: #fff; }
.tt-bold, .tt-bold * { box-sizing: border-box; }
.tt-bold .tt-cell .tch, .tt-bold .tt-cell .rm, .tt-bold .tt-cell .tt-n, .tt-key { font-family: Arial, Helvetica, sans-serif; }
.print-doc .d-print-none { display: none !important; }
.tt-personweek td.tt-free { background: #fff; }
.tt-bold.tt-personweek td { height: 62px; }
.tt-bold.tt-person .tt-cell .subj, .tt-bold.tt-person .tt-cell .meta { font-family: Arial, Helvetica, sans-serif; }
.tt-personweek td.tt-busy { background: repeating-linear-gradient(45deg, #eef0f2, #eef0f2 6px, #e2e5e9 6px, #e2e5e9 12px); color: #555; font-size: .66rem; text-align: center; vertical-align: middle; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.tt-sectiontitle { font-family: Arial, Helvetica, sans-serif; font-size: 1rem; font-weight: 800; margin: .9rem 0 .3rem; }
.tt-personweek:not(.tt-bold) td.tt-free, .tt-personweek:not(.tt-bold) td.tt-busy { height: 52px; }
/* The learning-area key is for the screen only; printed timetables show the grid alone. */
.print-doc .tt-legend { display: none !important; }
@media print { .tt-legend { display: none !important; } }
/* Report cards and result slips: text size, photo, signature images, QR code */
.report-card .rc-photo { width: 28mm; height: 34mm; object-fit: cover; border: 1px solid #999; }
.report-card.rc-size-small { font-size: 88%; }
.report-card.rc-size-small .table-sm > :not(caption) > * > * { padding: .15rem .3rem; }
.report-card.rc-size-compact { font-size: 76%; }
.report-card.rc-size-compact .table-sm > :not(caption) > * > * { padding: .08rem .25rem; }
.report-card.rc-size-compact .table { margin-bottom: .35rem; }
.report-card.rc-size-compact .rc-photo { width: 20mm; height: 24mm; }
.report-card.rc-size-compact .sig-line { margin-top: 1rem; }
.report-card.rc-size-large { font-size: 112%; }
.sig-img { position: relative; height: 44px; }
.sig-img .sig-sign { position: absolute; left: 0; bottom: -6px; max-height: 44px; max-width: 70%; }
.sig-img .sig-stamp { position: absolute; right: 8%; bottom: -14px; max-height: 64px; opacity: .85; }
.sig-img + .sig-line { margin-top: 0; }
.rc-qr svg { width: 22mm; height: 22mm; }
.report-card.rc-size-compact .rc-qr svg { width: 16mm; height: 16mm; }
.portal-slip .report-card { border: 0; padding: 0; margin: 0; }
