:root {
  --red: #BC0202;
  --red-dark: #8f0101;
  --cream: #FEF2A0;
  --paper: #fffdf0;
  --line: #eadf9c;
  --text: #2a1b1b;
  --muted: #6b5a5a;
  --bs-body-font-family: 'Public Sans', system-ui, sans-serif;
  --bs-body-bg: var(--paper);
  --bs-body-color: var(--text);
  --bs-primary: var(--red);
  --bs-primary-rgb: 188, 2, 2;
  --bs-link-color-rgb: 188, 2, 2;
  --bs-link-hover-color-rgb: 143, 1, 1;
  --bs-secondary-color: var(--muted);
}
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
.text-muted { color: var(--muted) !important; }
h1, h2, h3, h4 { font-family: 'Literata', Georgia, serif; font-weight: 700; color: var(--red); }
h1 { font-size: 1.75rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.15rem; }

.btn-primary { --bs-btn-color: #fff; --bs-btn-bg: var(--red); --bs-btn-border-color: var(--red);
  --bs-btn-hover-color: var(--cream); --bs-btn-hover-bg: var(--red-dark); --bs-btn-hover-border-color: var(--red-dark);
  --bs-btn-active-bg: var(--red-dark); --bs-btn-active-border-color: var(--red-dark);
  --bs-btn-disabled-bg: var(--red); --bs-btn-disabled-border-color: var(--red); }
.btn-outline-primary { --bs-btn-color: var(--red); --bs-btn-border-color: var(--red);
  --bs-btn-hover-bg: var(--red); --bs-btn-hover-border-color: var(--red); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--red-dark); --bs-btn-active-border-color: var(--red-dark); }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: 0 0 0 .2rem rgba(188, 2, 2, .25); border-color: var(--red); }
.form-check-input:checked { background-color: var(--red); border-color: var(--red); }
.form-control, .form-select { border-color: #d9cf8e; }

/* Top bar */
.app-nav { background: var(--red); border-bottom: 3px solid var(--cream); }
.app-nav .navbar-brand { color: var(--cream); font-family: 'Literata', Georgia, serif; font-weight: 700; display: flex; align-items: center; gap: .6rem; }
.brand-logo { height: 46px; width: 46px; object-fit: contain; }
.app-nav .nav-link { color: rgba(254, 242, 160, .85); }
.app-nav .nav-link:hover, .app-nav .nav-link.active { color: #fff; box-shadow: inset 0 -3px 0 var(--cream); }
.app-nav .navbar-toggler { border-color: rgba(254, 242, 160, .6); }
.app-nav .navbar-toggler-icon { filter: invert(1); }
.nav-user { color: var(--cream); font-size: .9rem; }
.nav-user small { opacity: .8; }
.nav-user .btn-outline-light { --bs-btn-color: var(--cream); --bs-btn-border-color: var(--cream);
  --bs-btn-hover-bg: var(--cream); --bs-btn-hover-color: var(--red); --bs-btn-hover-border-color: var(--cream); }
.nav-user .btn-light { --bs-btn-bg: var(--cream); --bs-btn-color: var(--red); --bs-btn-border-color: var(--cream);
  --bs-btn-hover-bg: #fff; --bs-btn-hover-color: var(--red-dark); --bs-btn-hover-border-color: #fff; }

/* Content */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 1.25rem; }
.panel + .panel { margin-top: 1.25rem; }
.stat { border-left: 4px solid var(--red); padding-left: .9rem; }
.stat .num { font-family: 'Literata', serif; font-size: 1.9rem; font-weight: 700; color: var(--red); line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .88rem; }

.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table thead th { background: var(--cream); color: var(--red-dark); font-weight: 600; border-bottom: 1px solid var(--line); }
.app-footer { padding: 1rem 0; color: var(--muted); font-size: .85rem; border-top: 3px solid var(--cream); background: #fff; }

/* Rating scale control */
.scale-row { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center;
  padding: .8rem 0; border-bottom: 1px solid var(--line); }
.scale-row:last-child { border-bottom: 0; }
.scale-opts { display: flex; gap: .4rem; }
.scale-opts input { position: absolute; opacity: 0; pointer-events: none; }
.scale-opts label { width: 2.6rem; height: 2.6rem; display: grid; place-items: center; cursor: pointer;
  border: 1px solid #d9cf8e; border-radius: 4px; background: #fff; font-weight: 600; color: var(--red); }
.scale-opts label:hover { background: var(--cream); border-color: var(--red); }
.scale-opts input:checked + label { background: var(--red); color: #fff; border-color: var(--red); }
.scale-opts input:focus-visible + label { box-shadow: 0 0 0 .2rem rgba(188, 2, 2, .35); }
.rating-scale .prf-title { font-size: 1.5rem; letter-spacing: .04em; margin-bottom: .75rem; }
.rating-scale-table td, .rating-scale-table th { padding: .6rem .75rem; }
.rating-scale-table tbody tr:last-child td { border-bottom: 0; }
@media print { .rating-scale { break-inside: avoid; } }
.scale-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: .85rem; color: var(--muted); }
.scale-legend b { color: var(--red); }
@media (max-width: 575px) { .scale-row { grid-template-columns: 1fr; } }

.bar { height: .55rem; background: #f4ecb8; border-radius: 3px; overflow: hidden; min-width: 90px; }
.bar > span { display: block; height: 100%; background: var(--red); }
.comment { border-left: 3px solid #e3d370; padding: .2rem 0 .2rem .8rem; margin-bottom: .8rem; }

/* Login / register */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr;
  /* one cream surface behind both halves, with the building photo showing faintly through */
  background: linear-gradient(#db3b1bed, rgba(254, 242, 160, .93)), url('../img/bg-login.jpg') center / cover no-repeat; }
.login-side { color: var(--red-dark); padding: 4rem; display: flex; flex-direction: column; justify-content: center; }
.side-logo { width: 170px; height: 170px; object-fit: contain; margin-bottom: 1.5rem; }
.login-side h1 { color: var(--red); font-size: 2.4rem; line-height: 1.15; max-width: 16ch; }
.login-side p { color: #5a3a3a; max-width: 44ch; }
.login-side .scale { margin-top: 2rem; display: flex; gap: .5rem; }
.login-side .scale span { width: 2.6rem; height: 2.6rem; display: grid; place-items: center; border: 1px solid var(--red); color: var(--red); border-radius: 4px; font-weight: 600; }
.login-side .scale span:last-child { background: var(--red); color: var(--cream); }
.login-form { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.login-form form { width: 100%; max-width: 400px; }
.login-form .form-control, .login-form .form-select { background-color: #fff; }
@media (max-width: 800px) {
  .login-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-side { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: .85rem; padding: 1.25rem 1.25rem .25rem; }
  .side-logo { width: 64px; height: 64px; margin: 0; }
  .login-side h1 { font-size: 1.3rem; max-width: none; margin: 0; flex: 1 1 11rem; }
  .login-side p { flex-basis: 100%; margin: 0; font-size: .92rem; }
  .login-side .scale { display: none; }
  .login-form { align-items: flex-start; padding: 1rem 1.25rem 2rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Accordion (criteria) */
.accordion { --bs-accordion-border-color: var(--line); --bs-accordion-active-bg: var(--cream); --bs-accordion-active-color: var(--red-dark);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 .2rem rgba(188, 2, 2, .25); }
.accordion-header { font-size: 1rem; margin: 0; }
.accordion-button { font-family: 'Literata', Georgia, serif; font-weight: 700; color: var(--red); }
.accordion-button:not(.collapsed) { box-shadow: none; }

/* Sidebar layout */
.app-shell { display: flex; flex: 1; min-height: 100vh; }
.sidebar { width: 264px; flex: 0 0 264px; position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--red); border-right: 4px solid var(--cream); }
.offcanvas-sidebar { background: var(--red); width: 280px; }
.sidebar-inner { display: flex; flex-direction: column; min-height: 100%; }
.side-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; color: var(--cream); text-decoration: none;
  font-family: 'Literata', Georgia, serif; font-weight: 700; line-height: 1.15; border-bottom: 1px solid rgba(254, 242, 160, .25); }
.side-brand small { display: block; font-family: 'Public Sans', sans-serif; font-weight: 500; opacity: .8; letter-spacing: .08em; margin-top: .15rem; }
.side-brand:hover { color: #fff; }
.side-nav { padding: .75rem 0; display: flex; flex-direction: column; }
.side-link { display: block; padding: .62rem 1.25rem; color: rgba(254, 242, 160, .9); text-decoration: none; font-weight: 500;
  border-left: 4px solid transparent; }
.side-link:hover { background: rgba(254, 242, 160, .14); color: #fff; }
.side-link.active { background: var(--cream); color: var(--red); font-weight: 600; border-left-color: var(--red-dark); }
.side-link:focus-visible { outline: 2px solid var(--cream); outline-offset: -2px; }
.side-user { margin-top: auto; padding: 1.1rem 1.25rem 1.4rem; border-top: 1px solid rgba(254, 242, 160, .25); color: var(--cream); }
.side-user-name { font-weight: 600; }
.side-user-role { font-size: .85rem; opacity: .8; }
.side-user .btn-outline-light { --bs-btn-color: var(--cream); --bs-btn-border-color: var(--cream);
  --bs-btn-hover-bg: var(--cream); --bs-btn-hover-color: var(--red); --bs-btn-hover-border-color: var(--cream); }
.side-user .btn-light { --bs-btn-bg: var(--cream); --bs-btn-color: var(--red); --bs-btn-border-color: var(--cream);
  --bs-btn-hover-bg: #fff; --bs-btn-hover-color: var(--red-dark); --bs-btn-hover-border-color: #fff; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content { flex: 1; width: 100%; max-width: 1280px; padding: 1.75rem 2rem; }
.topbar { background: var(--red); color: var(--cream); display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; border-bottom: 3px solid var(--cream); position: sticky; top: 0; z-index: 1020; }
.topbar .btn-outline-light { --bs-btn-color: var(--cream); --bs-btn-border-color: var(--cream); --bs-btn-hover-bg: var(--cream); --bs-btn-hover-color: var(--red); }
.brand-logo-sm { height: 34px; width: 34px; object-fit: contain; }
.topbar-title { font-family: 'Literata', Georgia, serif; font-weight: 700; }
.brand-logo { height: 46px; width: 46px; object-fit: contain; flex: none; }
@media (max-width: 991px) { .app-content { padding: 1.25rem 1rem; } }

/* Add / edit subject form */
.subject-form { max-width: 760px; padding: 1.75rem; }
.subject-form .form-control, .subject-form .form-select { padding: .65rem .85rem; }

.side-badge { background: var(--cream); color: var(--red); font-weight: 700; margin-left: .4rem; }
.side-link.active .side-badge { background: var(--red); color: var(--cream); }


/* ---------- Responsive: phones, tablets, laptops, large screens ---------- */
html { -webkit-text-size-adjust: 100%; }
.app-content { margin-inline: auto; }
.offcanvas-sidebar { width: min(300px, 86vw); height: 100vh; height: 100dvh; max-height: 100dvh; overflow-y: auto; overscroll-behavior: contain; }
.offcanvas-sidebar > .btn-close { flex: 0 0 auto; margin: .75rem .9rem .25rem auto; }
.offcanvas-sidebar > .sidebar-inner { flex: 1 0 auto; min-height: 0; }
.offcanvas-sidebar .side-brand { padding-top: .25rem; }
.offcanvas-sidebar .side-user { padding-bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 992px) and (max-width: 1199px) {
  .sidebar { width: 224px; flex-basis: 224px; }
  .app-content { padding: 1.5rem 1.5rem; }
}
@media (max-width: 575px) {
  h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
  .app-content { padding: 1rem .85rem; }
  .panel { padding: 1rem; }
  .stat .num { font-size: 1.6rem; }
  .table > :not(caption) > * > * { padding: .5rem .55rem; font-size: .92rem; }
  .scale-opts { width: 100%; }
  .scale-opts label { flex: 1; width: auto; height: 2.9rem; }
  .accordion-button { flex-wrap: wrap; row-gap: .15rem; }
  .subject-form { padding: 1.1rem; }
  .app-footer { font-size: .8rem; }
}
/* touch screens: bigger tap targets, and 16px fields so iPhones do not zoom in on focus */
@media (pointer: coarse) {
  .btn-sm { --bs-btn-padding-y: .45rem; --bs-btn-padding-x: .85rem; min-height: 2.4rem; }
  .form-select-sm, .form-control-sm { min-height: 2.4rem; font-size: 1rem; }
  .side-link { padding-top: .8rem; padding-bottom: .8rem; }
  .topbar .btn { min-height: 2.4rem; }
}

/* ---------- Card layout (one card per course, department, or category) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 1.1rem; align-items: start; }
.cards.wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); }
.cardx { background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--red); border-radius: 6px; }
.cardx-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: .85rem 1rem; background: #fffbe6; border-bottom: 1px solid var(--line); }
.cardx-title { font-family: 'Literata', Georgia, serif; font-weight: 700; color: var(--red); font-size: 1.1rem; line-height: 1.2; margin: 0; }
.cardx-sub { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.cardx-tools { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; justify-content: flex-end; }
.cardx-tools form { margin: 0; }
.cardx-count { background: var(--cream); color: var(--red-dark); font-weight: 600; font-size: .8rem; border-radius: 999px; padding: .15rem .6rem; white-space: nowrap; }
.cardx-group { padding: .35rem 1rem; background: #f7f3d0; color: var(--red-dark); font-weight: 600; font-size: .8rem; border-bottom: 1px solid var(--line); }
.cardx-row { padding: .65rem 1rem; border-bottom: 1px solid var(--line); }
.cardx-row:last-child { border-bottom: 0; }
.cardx-row .name { font-weight: 600; }
.cardx-row .meta { color: var(--muted); font-size: .85rem; word-break: break-word; }
.cardx-row .acts { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.cardx-row .acts form { margin: 0; }
.cardx-line { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.cardx-empty { padding: 1rem; color: var(--muted); }
.cards-title { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }

/* ---------- Clickable tiles (departments, criteria categories) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 1.1rem; }
.tile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; padding: 1.4rem 1rem 1.1rem;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; font: inherit; color: var(--text);
  box-shadow: 0 1px 2px rgba(143,1,1,.06); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.tile:hover, .tile:focus-visible { transform: translateY(-3px); border-color: var(--red); box-shadow: 0 8px 20px rgba(143,1,1,.15); outline: 0; }
.tile-title { font-family: 'Literata', Georgia, serif; font-weight: 700; color: var(--red); font-size: 1.15rem; line-height: 1.2; }
.tile-sub { color: var(--muted); font-size: .85rem; min-height: 2.4em; }
.tile-cat { min-height: 96px; justify-content: center; border-left: 5px solid var(--red); }
.dept-logo { width: 84px; height: 84px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  background: radial-gradient(circle at 30% 25%, #d41414, var(--red-dark)); color: var(--cream); border: 3px solid var(--cream);
  box-shadow: 0 0 0 2px var(--red); flex: none; }
.dept-logo b { font-family: 'Literata', Georgia, serif; font-size: 1.25rem; letter-spacing: .02em; }
.dept-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.dept-logo.sm { width: 48px; height: 48px; border-width: 2px; }
.dept-logo.sm b { font-size: .85rem; }
.modal-header { background: #fffbe6; border-bottom: 1px solid var(--line); }
.cardx.in-modal { border: 0; border-radius: 0; }
.cardx.in-modal .cardx-head { justify-content: flex-end; background: #fff; }
.modal-header .cardx-title { font-size: 1.25rem; }
.dept-logo.has-img { width: 104px; height: 104px; background: none; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
.dept-logo.has-img img { background: transparent; object-fit: contain; }
.dept-logo.has-img.sm { width: 52px; height: 52px; }
.tile-cat .cardx-count { margin-top: .3rem; }

/* ---------- Subjects: full-page program view with a dropdown per year level ---------- */
.year-acc .accordion-item { border: 1px solid var(--line); border-top: 4px solid var(--red); border-radius: 6px; margin-bottom: .8rem; overflow: hidden; background: #fff; }
.year-acc .accordion-button { background: #fffbe6; color: var(--red); font-family: 'Literata', Georgia, serif; font-weight: 700; font-size: 1.1rem; box-shadow: none; }
.year-acc .accordion-button:not(.collapsed) { background: #fffbe6; color: var(--red-dark); border-bottom: 1px solid var(--line); }
.year-acc .accordion-button:focus { box-shadow: 0 0 0 .2rem rgba(188,2,2,.2); }
a.tile-cat { color: var(--text); }

/* Confirmation box */
.confirm-overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.confirm-overlay[hidden] { display: none; }
.confirm-box { background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.3); width: min(92vw, 420px); padding: 20px 22px; }
.confirm-title { font-weight: 600; font-size: 1.1rem; margin-bottom: 8px; }
.confirm-msg { font-size: .95rem; color: #333; margin-bottom: 18px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.confirm-actions button { border: 0; border-radius: 8px; padding: 7px 20px; font-weight: 600; cursor: pointer; }
.confirm-ok { background: #b00000; color: #fff; }
.confirm-ok:focus-visible { outline: 3px solid #f5c400; outline-offset: 2px; }
.confirm-cancel { background: #e6e6e6; color: #222; }

/* Reports: top-faculty pagination uses the school colours */
.pagination .page-link { color: var(--red); }
.pagination .page-item.active .page-link { background: var(--red); border-color: var(--red); color: #fff; }
.pagination .page-link:focus { box-shadow: 0 0 0 .2rem rgba(188,2,2,.2); }

/* =====================================================================
   UI / UX polish (all roles)
   ===================================================================== */
html { scroll-behavior: smooth; }
body { line-height: 1.55; -webkit-font-smoothing: antialiased; }
main:focus { outline: 0; }
.skip-link { position: absolute; left: .75rem; top: -4rem; z-index: 3000; background: var(--cream); color: var(--red-dark); font-weight: 600;
  padding: .55rem 1rem; border-radius: 0 0 8px 8px; text-decoration: none; transition: top .15s; }
.skip-link:focus { top: 0; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid rgba(188, 2, 2, .45); outline-offset: 2px; border-radius: 4px; }

/* Sidebar: groups, icons, avatar */
.side-nav { padding: .5rem 0 1rem; }
.side-group { padding: 1rem 1.25rem .3rem; font-size: .7rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: rgba(254, 242, 160, .6); }
.side-link { display: flex; align-items: center; gap: .75rem; transition: background .15s, color .15s, padding-left .15s; }
.side-link .bi { font-size: 1.05rem; width: 1.25rem; text-align: center; flex: none; opacity: .9; }
.side-link:hover { padding-left: 1.4rem; }
.side-link.active:hover { padding-left: 1.25rem; }
.side-user-row { display: flex; align-items: center; gap: .7rem; }
.side-avatar { width: 2.4rem; height: 2.4rem; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--cream); color: var(--red);
  font-family: 'Literata', Georgia, serif; font-weight: 700; font-size: 1.1rem; }
.side-user-name { line-height: 1.2; word-break: break-word; }
.sidebar::-webkit-scrollbar { width: 8px; } .sidebar::-webkit-scrollbar-thumb { background: rgba(254, 242, 160, .3); border-radius: 8px; }

/* Page header: title row stays tidy on any width */
.app-content > h1:first-of-type { margin-bottom: .25rem; }
.app-content > h1 + p.text-muted, .app-content > div > h1 + p.text-muted { max-width: 70ch; }

/* Panels, stats and tiles feel interactive */
.panel { box-shadow: 0 1px 2px rgba(143, 1, 1, .05); }
.stat { transition: transform .15s ease; }
a .stat:hover, a.stat:hover { transform: translateY(-2px); }
.tile .tile-title::after { content: ''; }
a.tile:hover .tile-title, button.tile:hover .tile-title { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.tile:active { transform: translateY(-1px); }
.cardx { box-shadow: 0 1px 2px rgba(143, 1, 1, .05); }

/* Buttons */
.btn { transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s; font-weight: 500; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .6; cursor: not-allowed; }
.btn-outline-danger { --bs-btn-color: #b00000; --bs-btn-border-color: #b00000; --bs-btn-hover-bg: #b00000; --bs-btn-hover-border-color: #b00000; }

/* Forms */
.form-label { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.form-control, .form-select { transition: border-color .15s, box-shadow .15s; }
.form-control::placeholder { color: #a79b84; }
.was-validated .form-control:invalid, .was-validated .form-select:invalid { border-color: #b00000; }
.form-error { border-left: 4px solid #b00000; }
.form-text { color: var(--muted); }

/* Tables */
.table { --bs-table-hover-bg: #fffbe6; margin-bottom: 0; }
.table > tbody > tr { transition: background-color .12s; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #fffbe6; }
.table-responsive, .panel > .table, .panel > table { border-radius: 6px; }
.table thead th { position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.badge { font-weight: 600; letter-spacing: .01em; }

/* Alerts / flash messages */
.alert { border-radius: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.alert-dismissible { display: flex; align-items: center; gap: .6rem; }   /* flash messages only: single line + icon */
.alert.fade-out { opacity: 0; transform: translateY(-4px); transition: opacity .35s, transform .35s; }
.alert .btn-close { margin-left: auto; }
.alert-dismissible.alert-success::before, .alert-dismissible.alert-danger::before, .alert-dismissible.alert-warning::before, .alert-dismissible.alert-info::before { font-family: 'bootstrap-icons'; font-size: 1.15rem; flex: none; }
.alert-dismissible.alert-success::before { content: '\f26a'; } .alert-dismissible.alert-danger::before { content: '\f33a'; }
.alert-dismissible.alert-warning::before { content: '\f33a'; } .alert-dismissible.alert-info::before { content: '\f431'; }

/* Empty states */
.empty-state, .panel.text-center.text-muted { padding: 2rem 1rem; }
.empty-state { text-align: center; color: var(--muted); }
.empty-state .bi { font-size: 2.2rem; color: #d8cc7a; display: block; margin-bottom: .4rem; }

/* Modals and confirm box: smoother entrance */
.modal-content { border: 0; border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); overflow: hidden; }
.confirm-box { animation: confirmIn .16s ease-out; border-top: 5px solid #b00000; }
@keyframes confirmIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
.confirm-ok:hover { background: #8f0101; } .confirm-cancel:hover { background: #d8d8d8; }

/* Rating colours used for scores */
.rate-pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-weight: 600; font-size: .8rem; background: var(--cream); color: var(--red-dark); }
.bar > span { transition: width .6s ease; }

/* Back to top */
.to-top { position: fixed; right: 1rem; bottom: 1rem; z-index: 1030; width: 2.6rem; height: 2.6rem; border: 0; border-radius: 50%; background: var(--red); color: var(--cream);
  display: none; place-items: center; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); cursor: pointer; }
.to-top.show { display: grid; } .to-top:hover { background: var(--red-dark); }

/* Print: clean pages without chrome */
@media print {
  .sidebar, .offcanvas, .topbar, .app-footer, .to-top, .skip-link, .btn, form[data-confirm] { display: none !important; }
  .app-content { max-width: none; padding: 0; } body { background: #fff; }
}

/* Phones: tables turn into stacked cards (labels are filled in by app.js) */
@media (max-width: 575px) {
  table.stack-sm, table.stack-sm tbody, table.stack-sm tr, table.stack-sm td { display: block; width: 100%; }
  table.stack-sm thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack-sm tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: .75rem; background: #fff; overflow: hidden; }
  table.stack-sm td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-align: right; border: 0; border-bottom: 1px solid #f3edc4; padding: .5rem .8rem !important; }
  table.stack-sm td:last-child { border-bottom: 0; }
  table.stack-sm td::before { content: attr(data-label); font-weight: 600; color: var(--red-dark); text-align: left; flex: 0 0 38%; font-size: .82rem; }
  table.stack-sm td:not([data-label])::before, table.stack-sm td[data-label=""]::before { display: none; }
  table.stack-sm td.text-end { justify-content: flex-end; flex-wrap: wrap; }
  .to-top { bottom: .75rem; right: .75rem; }
}

/* Admin dashboard: linked stat cards and quick actions */
.stat-link { display: block; color: inherit; text-decoration: none; height: 100%; }
.stat-link .panel.stat { position: relative; height: 100%; margin-top: 0; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.stat-link:hover .panel.stat, .stat-link:focus-visible .panel.stat { transform: translateY(-3px); border-color: var(--red); box-shadow: 0 8px 20px rgba(143, 1, 1, .14); }
.stat-ic { position: absolute; right: .9rem; top: .8rem; font-size: 1.5rem; color: #e4d98a; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; }
.quick-actions a { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: #fffbe6;
  color: var(--red-dark); font-weight: 600; text-decoration: none; transition: background .15s, border-color .15s, transform .15s; }
.quick-actions a:hover, .quick-actions a:focus-visible { background: var(--cream); border-color: var(--red); transform: translateY(-2px); }
.quick-actions .bi { font-size: 1.2rem; }

/* Student: progress */
.progress-line { display: flex; align-items: center; gap: .9rem; max-width: 560px; }
.progress-line .bar { height: .7rem; }
.progress-text { font-weight: 600; color: var(--red-dark); white-space: nowrap; font-size: .9rem; }

/* Sidebar: tighter spacing, and the account block stays visible at the bottom on short screens */
.side-group { padding: .75rem 1.25rem .2rem; }
.side-link { padding-top: .5rem; padding-bottom: .5rem; }
.side-user { position: sticky; bottom: 0; background: var(--red); }

/* ---------- Every link is shown as a button ---------- */
.skip-link.btn { border-radius: 0 0 8px 8px; }
.quick-actions a.btn { justify-content: flex-start; text-align: left; }
.stat-link .btn, a.tile .btn { pointer-events: none; }
.tile-cat .btn { min-width: 6rem; }
.btn.disabled[aria-disabled="true"] { pointer-events: none; }


/* ---------- Sidebar dropdown (Users) ---------- */
button.side-toggle { width: 100%; background: none; border-top: 0; border-right: 0; border-bottom: 0; font: inherit; text-align: left; cursor: pointer; }
.side-toggle > span { flex: 1; }
.side-caret { margin-left: auto; transition: transform .2s ease; font-size: .8rem !important; width: auto !important; }
.side-dropdown.open .side-caret { transform: rotate(180deg); }
.side-toggle.has-active { color: #fff; }
.side-sub { display: none; background: rgba(0, 0, 0, .12); }
.side-dropdown.open .side-sub { display: block; }
.side-sublink { display: flex; align-items: center; gap: .7rem; padding: .45rem 1.25rem .45rem 2.6rem; color: rgba(254, 242, 160, .9); text-decoration: none; font-weight: 500;
  border-left: 4px solid transparent; }
.side-sublink .bi { width: 1.1rem; text-align: center; opacity: .9; }
.side-sublink:hover { background: rgba(254, 242, 160, .14); color: #fff; }
.side-sublink.active { background: var(--cream); color: var(--red); font-weight: 600; border-left-color: var(--red-dark); }

/* ---------- Page header card: every page title sits in a card header ---------- */
.app-content h1 { background: #fffbe6; border: 1px solid var(--line); border-top: 4px solid var(--red); border-radius: 6px;
  padding: .75rem 1.1rem; box-shadow: 0 1px 2px rgba(143, 1, 1, .05); }
.app-content h1 .text-muted { color: var(--muted) !important; }
.app-content .modal h1, .app-content .confirm-box h1 { background: none; border: 0; box-shadow: none; padding: 0; }


/* ---------- Page header card is responsive: fills the row, the action button wraps below on small screens ---------- */
.app-content h1 { display: block; width: 100%; overflow-wrap: anywhere; }
.app-content .d-flex > h1, .app-content .d-flex > div:has(> h1) { flex: 1 1 16rem; min-width: 0; }
.app-content .d-flex > div:has(> h1) > p { margin-top: .4rem; }
@media (max-width: 575px) {
  .app-content h1 { padding: .6rem .8rem; font-size: 1.25rem; }
  .app-content .d-flex > .btn { width: 100%; }
}

/* ---------- Pages shown inside a window (dashboard buttons): hide the menu and footer ---------- */
.embedded .sidebar, .embedded .topbar, .embedded .app-footer, .embedded .skip-link, .embedded .offcanvas-sidebar { display: none !important; }
.embedded .app-shell { min-height: 0; }
.embedded .app-content { max-width: none; padding: 1rem 1.25rem; }
.dash-frame { width: 100%; height: min(78vh, 760px); border: 0; display: block; background: var(--cream); }


/* ---------- Title row (title + action button) is ONE card header ---------- */
.app-content .d-flex:has(> h1), .app-content .d-flex:has(> div > h1) {
  background: #fffbe6; border: 1px solid var(--line); border-top: 4px solid var(--red); border-radius: 6px;
  padding: .75rem 1.1rem; box-shadow: 0 1px 2px rgba(143, 1, 1, .05); align-items: center !important; }
.app-content .d-flex:has(> h1) h1, .app-content .d-flex:has(> div > h1) h1 {
  background: none; border: 0; box-shadow: none; padding: 0; border-radius: 0; width: auto; }
.app-content .d-flex:has(> div > h1) > div > p { margin-bottom: 0 !important; }
.app-content .d-flex:has(> h1) > .btn, .app-content .d-flex:has(> div > h1) > .btn { flex: none; }
@media (max-width: 575px) { .app-content .d-flex:has(> h1), .app-content .d-flex:has(> div > h1) { padding: .6rem .8rem; } }


/* ---------- Title + description are one card header ---------- */
.app-content .page-head { background: #fffbe6; border: 1px solid var(--line); border-top: 4px solid var(--red); border-radius: 6px;
  padding: .75rem 1.1rem; box-shadow: 0 1px 2px rgba(143, 1, 1, .05); margin-bottom: 1rem; }
.app-content .page-head h1 { background: none; border: 0; box-shadow: none; padding: 0; border-radius: 0; margin-bottom: .2rem !important; }
.app-content .page-head > p { margin: 0 !important; max-width: none; }
.app-content .page-head > p + p { margin-top: .35rem !important; }
@media (max-width: 575px) { .app-content .page-head { padding: .6rem .8rem; } }

#qFormEl { display: contents; }

/* Dashboard: today's evaluation activity */
.today-num { font-family: 'Literata', serif; font-size: 2.6rem; font-weight: 700; color: var(--red); line-height: 1; }
.hour-chart { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding-top: 1rem; border-bottom: 1px solid var(--line); }
.hour-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; min-width: 0; }
.hour-bar { display: block; width: 100%; max-width: 26px; background: var(--red); border-radius: 3px 3px 0 0; min-height: 2px; }
.hour-n { font-size: .72rem; color: var(--muted); line-height: 1; margin-bottom: 2px; }
.hour-l { position: absolute; bottom: -1.3rem; font-size: .7rem; color: var(--muted); white-space: nowrap; }
.hour-chart { margin-bottom: 1.5rem; }
.week-chart { gap: 10px; }
.week-chart .hour-bar { max-width: 56px; }
.week-chart .hour-n { font-size: .8rem; }
.week-chart .hour-l { font-size: .8rem; }
.week-chart .is-future .hour-bar { opacity: .35; }
.week-chart .is-today .hour-l { color: var(--red); font-weight: 700; }
/* Users/faculty table: actions sit right beside the name */
.user-actions { display: flex; flex-wrap: nowrap; gap: .35rem; align-items: center; }
.user-actions form { margin: 0; }

/* ---------- Cards are not links: only the View button is clickable ---------- */
.stat-link .btn, .tile-static .btn { pointer-events: auto; }
.stat-link:hover .panel.stat { transform: none; border-color: var(--line); box-shadow: 0 1px 2px rgba(143, 1, 1, .05); }
.stat-link .panel.stat { border-left: 4px solid var(--red); }
.tile-static, .tile-static:hover { cursor: default; transform: none; border-color: var(--line); box-shadow: 0 1px 2px rgba(143, 1, 1, .06); }
.tile-static { border-left: 5px solid var(--red); }
.tile-static:hover .tile-title { text-decoration: none; }
.stat-link .btn, .tile-static .btn { cursor: pointer; padding-left: 1rem; padding-right: 1rem; }

/* ---------- More room around buttons ---------- */
.quick-actions { gap: 1rem; }
.quick-actions a.btn { padding: .95rem 1.15rem; }
.panel ol > li { margin-bottom: .7rem; padding-left: .35rem; }
.panel ol > li:last-child { margin-bottom: 0; }
.tiles { gap: 1.25rem; }

/* ---------- Quick actions: calm hover (text stays dark red and readable) ---------- */
.quick-actions a.btn, .quick-actions a.btn:hover, .quick-actions a.btn:focus-visible, .quick-actions a.btn:active {
  color: var(--red-dark); transform: none; }
.quick-actions a.btn:hover, .quick-actions a.btn:focus-visible {
  background: #fff; border-color: var(--red); box-shadow: 0 2px 8px rgba(143, 1, 1, .12); }
.quick-actions a.btn:active { background: #fffbe6; }

/* ---------- Actions column: always the last column, same place on every row ---------- */
th.col-actions, td.col-actions { width: 1%; white-space: nowrap; }
.col-actions .user-actions { justify-content: flex-start; }
.user-actions > .btn, .user-actions > form > .btn { min-width: 4.25rem; text-align: center; }     /* View, Edit, Delete */
.user-actions > form:nth-child(3) > .btn.btn-outline-secondary { min-width: 6.5rem; }             /* Activate / Deactivate share one width */
