/* Shared light portal palette. Loaded after page styles; layouts remain page-owned. */
:root,
body {
  color-scheme: light;
  --bg-base: #fff !important;
  --bg-dark: #fff !important;
  --bg-body: #fff !important;
  --surface: #f8fafc !important;
  --surface-dark: #f8fafc !important;
  --surface-solid: #fff !important;
  --border: #dce3ed !important;
  --border-glass: #dce3ed !important;
  --primary: #244575 !important;
  --primary-hover: #172b4d !important;
  --accent: #0e7490 !important;
  --text-main: #172b4d !important;
  --text-muted: #526176 !important;
  --muted: #526176;
  --line: #dce3ed;
  --wr-bg: #fff;
  --wr-surface: #f8fafc;
  --wr-solid: #fff;
  --wr-border: #dce3ed;
  --wr-text: #172b4d;
  --wr-muted: #526176;
  --wr-primary: #244575;
  --wr-accent: #0e7490;
}

html body {
  background: #fff !important;
  color: #000000 !important;
  font-family: "Segoe UI", Arial, sans-serif !important;
}

body .ambient-glow {
  display: none !important;
}

/* Cards, Modals & Containers */
body :is(
  .card,
  .modal-content,
  .login-card,
  .login-box,
  .auth-card,
  .page-header-banner,
  .class-summary-card,
  .dashboard-count,
  .rating-intro,
  .marking-intro,
  .rating-assignment,
  .marking-assignment,
  .rating-summary > div,
  .marking-summary > div
) {
  background: #f8fafc !important;
  color: #172b4d !important;
  border-color: #dce3ed !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

body :is(.card-header, .modal-header, .modal-footer) {
  background: linear-gradient(140deg, #f8fafc, #f1f5f9 55%, #edf5f5) !important;
  color: #172b4d !important;
  border-color: #dce3ed !important;
}

/* Typography & Text Colors */
body :is(
  .card-title,
  .card-header small,
  .page-header-banner h3,
  .portfolio-page h1,
  .dashboard-title,
  .login-card h1,
  .login-box h1,
  .auth-card h1
) {
  color: #172b4d !important;
}

body :is(.text-white, .text-light, .form-label, label) {
  color: #172b4d !important;
}

body :is(.text-muted, .text-secondary, .muted) {
  color: #526176 !important;
}

body .text-info {
  color: #0e7490 !important;
}

/* Tables */
body :is(.table, .rater-table, .marker-table) {
  --bs-table-bg: #fff !important;
  --bs-table-color: #172b4d !important;
  --bs-table-striped-bg: #f8fafc !important;
  --bs-table-striped-color: #172b4d !important;
  --bs-table-hover-bg: #eaf2f5 !important;
  --bs-table-hover-color: #172b4d !important;
  --bs-table-border-color: #dce3ed !important;
  color: #172b4d !important;
  border-color: #dce3ed !important;
}

body .table > thead > tr > th {
  background: #edf2f7 !important;
  color: #172b4d !important;
  border-color: #dce3ed !important;
}

body .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: #f8fafc !important;
  color: #172b4d !important;
}

body .table-striped > tbody > tr:nth-of-type(even) > * {
  background-color: #fff !important;
  color: #172b4d !important;
}

body .table-hover > tbody > tr:hover > * {
  background-color: #eaf2f5 !important;
  color: #172b4d !important;
}

body .table :is(th, td) {
  border-color: #dce3ed;
}

/* Forms & Inputs */
body :is(
  .form-control,
  .form-select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="search"],
  textarea,
  select
) {
  background-color: #fff !important;
  color: #172b4d !important;
  border-color: #bdcbdc;
  color-scheme: light;
}

body :is(input, textarea)::placeholder {
  color: #64748b !important;
  opacity: 1;
}

body :is(input, textarea, select):focus {
  border-color: #0e7490;
}

body :is(input, textarea, select):disabled {
  background-color: #edf2f7 !important;
  color: #526176 !important;
}

/* Override legacy dark focus rules as well as the closed field styling. */
body :is(.form-control, .form-select, select):is(:focus, :active, :focus-visible) {
  background-color: #fff !important;
  color: #172b4d !important;
  border-color: #0e7490 !important;
  box-shadow: 0 0 0 0.2rem rgba(14, 116, 144, 0.15) !important;
  color-scheme: light !important;
}

body select :is(option, optgroup) {
  background-color: #fff !important;
  color: #172b4d !important;
}

body select option:checked {
  background-color: #e3eef2 !important;
  color: #244575 !important;
}

/* Modals */
/* Modal-specific legacy selectors otherwise override the shared form colors. */
body .modal :is(.form-control, .form-select) {
  background-color: #fff !important;
  color: #172b4d !important;
  border-color: #bdcbdc !important;
  color-scheme: light !important;
}

body .modal :is(.form-control, .form-select):focus {
  background-color: #fff !important;
  border-color: #0e7490 !important;
  box-shadow: 0 0 0 0.2rem rgba(14, 116, 144, 0.15) !important;
}

body .modal .modal-body {
  background-color: #f8fafc !important;
  color: #172b4d !important;
}

body .modal .btn-close {
  filter: none !important;
}

body :is(#gradePercentagesModal, #portfolioSettingsModal) :is(
  .modal-title,
  .form-label,
  h6,
  .individual-weight-editor label,
  #portfolioTaskEditors label
) {
  color: #244575 !important;
  font-weight: 700 !important;
}

body :is(#gradePercentagesModal, #portfolioSettingsModal) .modal-title {
  color: #5145a5 !important;
}

/* Buttons & Badges */
body .btn-primary,
body .btn-class-report {
  --bs-btn-bg: #244575;
  --bs-btn-border-color: #244575;
  --bs-btn-hover-bg: #172b4d;
  --bs-btn-hover-border-color: #172b4d;
  background: #244575 !important;
  border-color: #244575 !important;
  color: #fff !important;
}

body .btn-primary:hover,
body .btn-class-report:hover {
  background: #172b4d !important;
}

body :is(.btn-outline-light, .btn-outline-primary) {
  color: #244575 !important;
  border-color: #b8c7db !important;
  background: #f1f5f9;
}

body :is(.btn-outline-light, .btn-outline-primary):hover {
  color: #172b4d !important;
  background: #e2e8f0 !important;
}

body .bg-primary,
body .table thead th.bg-primary {
  background: #244575 !important;
  color: #fff !important;
}

body :is(
  .btn-primary,
  .btn-success,
  .btn-danger,
  .btn-secondary,
  .bg-primary,
  .bg-success,
  .bg-danger,
  .bg-secondary
) .text-white,
body .badge.text-white {
  color: #fff !important;
}

body .bg-dark {
  background-color: #edf2f7 !important;
  color: #172b4d !important;
}

body .btn-close-white {
  filter: none;
}

body code {
  color: #0e7490;
  background: #e3eef2;
}

/* Shared navigation, including mobile dropdowns. */
body .app-header {
  background: #fff;
  border-color: #dce3ed;
}

body .app-header .logo,
body .wr-brand {
  color: #172b4d;
}

body .app-header :is(.mobile-menu-panel-inner, .training-dropdown, .user-dropdown) {
  background: #f8fafc;
  border-color: #dce3ed;
}

body .app-header :is(.nav-link-item, .training-option):hover {
  background: #e9eef6;
}

body .app-header .training-dropdown {
  box-shadow: 0 12px 32px rgba(23, 43, 77, 0.12);
}

/* Dashboard and marking/rating workspaces. */
body :is(.dashboard-classes, .academic-year) {
  background: #fff !important;
}

body :is(
  .dashboard-count strong,
  .metric-chip > strong,
  .metric-chip > div .text-white,
  .metric-chip > div .text-success,
  .rating-summary strong,
  .marking-summary strong
) {
  color: #244575 !important;
}

body :is(.metric-chip, .academic-year > .card-header) {
  border-color: #dce3ed;
}

body .metric-chip:last-child {
  background: #edf2f7;
}

body :is(.period-heading, .evaluation-badge) {
  background: #244575;
  color: #fff;
  border-color: #244575;
}

body :is(
  .rating-intro p,
  .marking-intro p,
  .rater-actions span,
  .marker-actions span,
  .rating-summary span,
  .marking-summary span,
  .rating-assignment-period,
  .marking-assignment-period
) {
  color: #526176 !important;
}

body :is(
  .rating-back,
  .marking-back,
  .rating-assignment-heading h2,
  .marking-assignment-heading h2,
  .rating-card-link,
  .marking-card-link
) {
  color: #0e7490 !important;
  border-color: #dce3ed !important;
}

body :is(.rater-table, .marker-table) .student-col,
body :is(.rating-frozen-header, .marking-frozen-header),
body :is(.rating-frozen-header, .marking-frozen-header) th {
  background: #edf2f7 !important;
  color: #172b4d;
}

body :is(.rater-table, .marker-table) .criterion-issue {
  --bs-table-bg: #fff7ed !important;
}

/* Keep sticky student cells aligned with the striped row colors used in Existing Classes. */
body :is(.rater-table, .marker-table).table-striped > tbody > tr:nth-of-type(odd) > .student-col {
  background-color: #f8fafc !important;
}

body :is(.rater-table, .marker-table).table-striped > tbody > tr:nth-of-type(even) > .student-col {
  background-color: #fff !important;
}

body :is(.rater-table, .marker-table).table-hover > tbody > tr:hover > .student-col {
  background-color: #eaf2f5 !important;
}

body :is(.rater-table, .marker-table).table-striped > tbody > tr > .criterion-issue {
  background-color: #fff7ed !important;
}

body :is(.issue-message, .score-error) {
  color: #9a3412;
}

body input[aria-invalid="true"] {
  border-color: #b91c1c !important;
  background: #fff1f2 !important;
}

/* Writing standardization retains its dedicated workspace layout. */
body.wr-themed .wr-header {
  background: #fff;
}

body.wr-themed :is(a, legend) {
  color: #244575;
}

body.wr-themed a:hover {
  color: #0e7490;
}

body.wr-themed :is(main > p, label) {
  color: #526176;
}

body.wr-themed fieldset {
  background: #f8fafc;
  box-shadow: none;
}

body.wr-themed .wr-nav a[aria-current="page"] {
  background: #e3eef2;
  color: #244575;
  border-color: #cbd5e1;
}

body.wr-themed :is(button, .button) {
  background: #244575;
  color: #fff;
}

body.wr-themed :is(button, .button):hover {
  background: #172b4d;
  color: #fff;
}

body.wr-themed .secondary,
body.wr-themed .badge {
  background: #e3eef2;
  color: #0e7490;
}

body.wr-themed :is(.danger, .error) {
  background: #fff1f2;
  color: #991b1b;
}

body.wr-themed .success {
  background: #ecfdf5;
  color: #166534;
}

body.wr-themed :is(.bg-white, .bg-slate-50, .bg-slate-100, .bg-slate-200, [class~="bg-white/70"]) {
  background: #f8fafc;
}

body.wr-themed [class*="text-slate-"] {
  color: #526176;
}

body.wr-themed [class*="text-indigo-"] {
  color: #244575;
}

body.wr-themed [class*="text-emerald-"] {
  color: #166534;
}

body.wr-themed [class*="text-amber-"] {
  color: #92400e;
}

body.wr-themed [class*="text-red-"] {
  color: #991b1b;
}

/* Keep image cards and solid semantic badges readable. */
body.home-page .quick-link {
  color: #244575;
}

body :is(a, button, input, select, textarea):focus-visible {
  outline-color: #0e7490;
}

@media print {
  body .app-header {
    display: none !important;
  }
}

/* Older page-specific panels use fixed colors instead of theme variables. */
body :is(
  .stat-card,
  .training-card,
  .content-card,
  .entry-form,
  .entry-card,
  .empty-box,
  .summary-item,
  .result-card,
  .dashboard-filter-bar,
  .period-box,
  .section-heading,
  .list-plain li,
  .multi-select-dropdown summary,
  .rich-text-editor
) {
  background: #f8fafc !important;
  color: #172b4d !important;
  border-color: #dce3ed !important;
  box-shadow: none !important;
}

body :is(.security-table, .class-table, .analysis-table) thead th {
  background: #edf2f7;
  color: #526176;
}

/* Sidebar & Misc Components */
body .sidebar-menu {
  gap: 4px;
}

body .sidebar-menu a {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 11px 12px;
  gap: 12px;
  color: #526176;
  font-weight: 600;
  font-size: 14px;
  box-shadow: none;
  transition: background 0.15s, color 0.15s;
}

body .sidebar-menu a:hover {
  background: #f1f5f9;
  border-color: transparent;
  color: #244575;
  box-shadow: none;
}

body .sidebar-menu a.active {
  background: #e8eef6;
  border-color: transparent;
  color: #244575;
  font-weight: 700;
  box-shadow: none;
}

body .sidebar-menu .menu-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  background: none;
  border: 0;
  border-radius: 0;
  color: #244575;
}

body.admin-typography-page .sidebar-menu a {
  color: #000 !important;
}

body.admin-typography-page .sidebar-menu a:hover,
body.admin-typography-page .sidebar-menu a:focus-visible,
body.admin-typography-page .sidebar-menu a.active {
  background: #244575 !important;
  border-color: #244575 !important;
  color: #fff !important;
}

body.admin-typography-page .sidebar-menu a.active {
  border-bottom: 3px solid #e99d10 !important;
}

body.admin-typography-page .sidebar-menu .menu-icon {
  color: #000 !important;
  stroke: #000;
}

body.admin-typography-page .sidebar-menu a:hover .menu-icon,
body.admin-typography-page .sidebar-menu a:focus-visible .menu-icon,
body.admin-typography-page .sidebar-menu a.active .menu-icon {
  color: #fff !important;
  stroke: #fff;
}

body .sidebar-panel .card-header h5 {
  color: #244575;
  font-weight: 700;
}

body .training-icon {
  color: #5145a5;
}

body .class-name-link,
body .class-name-link:hover {
  color: #0e7490;
}

body .nav-tabs .nav-link.active {
  background: #edf2f7 !important;
  color: #244575 !important;
  border-color: #dce3ed !important;
}

body .input-group-text {
  background: #edf2f7 !important;
  color: #526176 !important;
  border-color: #dce3ed !important;
}

/* Portfolio Matrix */
body .portfolio-matrix .total-cell {
  color: #244575 !important;
  background: #e3eef2 !important;
}

body .portfolio-page .portfolio-matrix thead .task-writing {
  background: #ede9fe !important;
  color: #5b21b6 !important;
}

body .portfolio-page .portfolio-matrix thead .task-speaking {
  background: #e0f2fe !important;
  color: #075985 !important;
}

body .portfolio-page .portfolio-matrix thead .task-moodle {
  background: #dcfce7 !important;
  color: #166534 !important;
}

body .portfolio-page .portfolio-matrix thead small {
  color: inherit;
}

body .portfolio-page .portfolio-matrix .total-heading {
  background: #244575 !important;
  color: #fff !important;
}

body > header .logo {
  color: #172b4d;
}

body .btn-outline-info:hover {
  color: #fff !important;
}

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

@media (max-width: 480px) {
  body .stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

body .app-header .dropdown-inner-box {
  box-shadow: 0 12px 32px rgba(23, 43, 77, 0.12);
}

body .duty-navigation a {
  background: #f8fafc;
  color: #244575;
  border-color: #dce3ed;
}

body .duty-navigation span {
  background: #e3eef2;
  color: #0e7490;
}

body .marker-table .marking-attendance {
  color: #526176;
}

body .header-badge {
  color: #5145a5;
}

body .new-badge {
  color: #166534;
}

body .rich-text-toolbar .btn:hover {
  background: #e2e8f0;
}

body .rich-text-toolbar .btn[aria-pressed="true"] {
  background: #244575;
  color: #fff;
}

body .instructors-panel .text-success {
  color: #166534 !important;
}

/* Matching light badges across marking and speaking workspaces/admin panels. */
body :is(.markings-admin, .ratings-admin) :is(.marking-status, .rating-status) {
  background: #edf2f7;
  color: #526176;
  border: 1px solid #dce3ed;
}

body :is(.markings-admin, .ratings-admin) :is(.status-ready, .status-published) {
  background: #e7f4ec;
  color: #21633e;
  border-color: #c8e3d2;
}

body :is(.markings-admin, .ratings-admin) .status-open {
  background: #e3eef2;
  color: #286678;
  border-color: #cbdde5;
}

body :is(.markings-admin, .ratings-admin) .status-discrepancy,
body :is(.marking-assignment, .rating-assignment, .marker-table, .rater-table)
  :is(.marking-discrepancy-tag, .rating-discrepancy-tag, .marking-not-attended-tag, .rating-not-attended-tag) {
  background: #fff3dc;
  color: #855618;
  border: 1px solid #efdbb6;
}

body :is(.marking-assignment, .rating-assignment) :is(.marking-role-first, .rating-role-first) {
  background: #fff3dc;
  color: #855618;
  border-color: #efdbb6;
}

body :is(.marking-assignment, .rating-assignment) :is(.marking-role-second, .rating-role-second) {
  background: #eeeafa;
  color: #655097;
  border-color: #dcd3ef;
}

body .marking-assignment .marking-role-interlocutor {
  background: #e3eef2;
  color: #286678;
  border-color: #cbdde5;
}

body :is(.marking-assignment, .rating-assignment) :is(.marking-card-tag, .rating-card-tag) {
  color: #526176;
}

/* Admin Action Buttons */
body :is(.markings-admin, .ratings-admin) .btn[value="close"] {
  --bs-btn-color: #000;
  --bs-btn-bg: #ffc107;
  --bs-btn-border-color: #ffc107;
  --bs-btn-hover-color: #000;
  --bs-btn-hover-bg: #e0a800;
  --bs-btn-hover-border-color: #d39e00;
  --bs-btn-active-color: #000;
  --bs-btn-active-bg: #d39e00;
  --bs-btn-active-border-color: #c69500;
  --bs-btn-disabled-color: #000;
  --bs-btn-disabled-bg: #ffc107;
  --bs-btn-disabled-border-color: #ffc107;
}

body :is(.markings-admin, .ratings-admin) .btn:is([value="unpublish"], [form^="markingUnpublish"], [form^="ratingUnpublish"]) {
  --bs-btn-color: #5b438c;
  --bs-btn-bg: #eeeafa;
  --bs-btn-border-color: #d4c8ec;
  --bs-btn-hover-color: #493475;
  --bs-btn-hover-bg: #ddd4f2;
  --bs-btn-hover-border-color: #baa7dd;
  --bs-btn-active-color: #493475;
  --bs-btn-active-bg: #cfc0e9;
  --bs-btn-active-border-color: #aa92d3;
  --bs-btn-disabled-color: #5b438c;
  --bs-btn-disabled-bg: #eeeafa;
  --bs-btn-disabled-border-color: #d4c8ec;
  --bs-btn-focus-shadow-rgb: 101, 80, 151;
}
