/*
  Hifz Diary — design tokens + Bootstrap overrides
*/

:root {
  --hd-brand-violet: #667eea;
  --hd-brand-plum: #764ba2;
  --hd-primary-solid: #5b4dc9;
  --hd-primary-solid-rgb: 91, 77, 201;
  --hd-gradient: linear-gradient(135deg, var(--hd-brand-violet) 0%, var(--hd-brand-plum) 100%);
  --hd-gradient-hover: linear-gradient(135deg, #5a6fd6 0%, #684292 100%);

  --hd-page-bg: #f3f2f9;
  --hd-text: #1c2133;
  --hd-muted: #5c6478;

  --bs-primary: var(--hd-primary-solid);
  --bs-primary-rgb: var(--hd-primary-solid-rgb);
  /*
    Bootstrap Reboot uses rgba(var(--bs-link-color-rgb)) for `a` color (not --bs-link-color alone)
    and hardcodes text-decoration: underline on `a`. Override both here.
  */
  --bs-link-color: #1c2133;
  --bs-link-hover-color: var(--hd-primary-solid);
  --bs-link-color-rgb: 28, 33, 51;
  --bs-link-hover-color-rgb: 91, 77, 201;
  --bs-focus-ring-color: rgba(var(--bs-primary-rgb), 0.35);

  --hd-rating-0: #7f1d1d;
  --hd-rating-1: #e53935;
  --hd-rating-2: #ef5a2e;
  --hd-rating-3: #f97316;
  --hd-rating-4: #7fb02a;
  --hd-rating-5: #15803d;
}

.hd-rating-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: help;
}

.hd-rating-num--0 {
  color: var(--hd-rating-0);
}

.hd-rating-num--1 {
  color: var(--hd-rating-1);
}

.hd-rating-num--2 {
  color: var(--hd-rating-2);
}

.hd-rating-num--3 {
  color: var(--hd-rating-3);
}

.hd-rating-num--4 {
  color: var(--hd-rating-4);
}

.hd-rating-num--5 {
  color: var(--hd-rating-5);
}

body.hd-app {
  color: var(--hd-text);
  background-color: var(--hd-page-bg);
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(var(--bs-primary-rgb), 0.12);
}

/*
  Reboot’s `a { text-decoration: underline }` is not tied to --bs-link-decoration in BS 5.3.3.
  Strip default underlines in main content; show on hover only (breadcrumbs, inline links).
 */
body.hd-app main a:not(.btn) {
  text-decoration: none;
}

body.hd-app main a:not(.btn):hover {
  text-decoration: underline;
}

/* Softer focus than browser default blue */
body.hd-app main a:focus-visible {
  outline: 2px solid rgba(var(--bs-primary-rgb), 0.4);
  outline-offset: 2px;
}

.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #4a3eb0;
  --bs-btn-hover-border-color: #4539a6;
  --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #40359a;
  --bs-btn-active-border-color: #3c3291;
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: #8b82d4;
  --bs-btn-disabled-border-color: #8b82d4;
}

.btn-outline-primary {
  --bs-btn-color: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--bs-primary);
  --bs-btn-hover-border-color: var(--bs-primary);
  --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #40359a;
  --bs-btn-active-border-color: #3c3291;
}

.btn-outline-secondary {
  --bs-btn-color: var(--hd-muted);
  --bs-btn-border-color: #c8cdd9;
  --bs-btn-hover-color: var(--hd-text);
  --bs-btn-hover-bg: rgba(var(--bs-primary-rgb), 0.08);
  --bs-btn-hover-border-color: #b4b9c8;
}

.btn-link {
  --bs-btn-color: var(--bs-link-color);
  --bs-btn-hover-color: var(--bs-link-hover-color);
}

.table-hover>tbody>tr:hover>* {
  --bs-table-hover-bg: rgba(var(--bs-primary-rgb), 0.07);
}

.list-group-item-action:hover,
.list-group-item-action:focus-visible {
  background-color: rgba(var(--bs-primary-rgb), 0.07);
  color: var(--hd-text);
}

.hd-gradient-nav {
  background: var(--hd-gradient);
  border-top: 3px solid #1e1b4b;
  box-shadow: 0 0.35rem 1.5rem rgba(91, 77, 201, 0.22);
}

.hd-weekly-shell {
  min-height: 100vh;
  background: linear-gradient(180deg, #f0eff7 0%, #ebe9f3 42%, #e6e8f0 100%);
}

.hd-weekly-hero.card {
  border-left: 4px solid rgb(var(--bs-primary-rgb));
  box-shadow: 0 0.4rem 1.35rem rgba(var(--bs-primary-rgb), 0.12), 0 0.15rem 0.4rem rgba(0, 0, 0, 0.04);
}

.hd-day-card-inner {
  background: rgba(var(--bs-primary-rgb), 0.05);
}

.hd-table-shell {
  box-shadow: 0 0.4rem 1.25rem rgba(var(--bs-primary-rgb), 0.09), 0 0.125rem 0.35rem rgba(0, 0, 0, 0.04);
  border-color: rgba(var(--bs-primary-rgb), 0.14) !important;
}

.hd-sign-in-card {
  max-width: 26rem;
}

.hd-auth-card {
  border-radius: 1.25rem;
  overflow: hidden;
  box-shadow: 0 0.75rem 2rem rgba(102, 126, 234, 0.18), 0 0.25rem 0.5rem rgba(0, 0, 0, 0.06);
}

.hd-auth-card .card-header {
  background: var(--hd-gradient);
  border: none;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.hd-password-field.input-group-lg > .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.hd-password-field .hd-password-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  padding-inline: 0.85rem;
  color: #6c757d;
  background-color: #fff;
  border-color: var(--bs-border-color);
}

.hd-password-field .hd-password-toggle-btn:hover,
.hd-password-field .hd-password-toggle-btn:focus-visible {
  color: var(--bs-primary);
  background-color: #fff;
  border-color: var(--bs-border-color);
}

.hd-password-field:focus-within .form-control,
.hd-password-field:focus-within .hd-password-toggle-btn {
  border-color: #86b7fe;
}

.hd-password-field:focus-within {
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
  border-radius: var(--bs-border-radius-lg);
}

.hd-password-field .hd-eye-icon {
  display: block;
}

.hd-password-field .hd-eye-icon--hide {
  display: none;
}

.hd-password-field .hd-password-toggle-btn[aria-pressed="true"] .hd-eye-icon--show {
  display: none;
}

.hd-password-field .hd-password-toggle-btn[aria-pressed="true"] .hd-eye-icon--hide {
  display: block;
}

.btn-hd-cta {
  color: #fff !important;
  border: none;
  background: var(--hd-gradient);
  font-weight: 600;
  box-shadow: 0 0.35rem 1rem rgba(118, 75, 162, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn-hd-cta:hover {
  color: #fff !important;
  background: var(--hd-gradient-hover);
  filter: brightness(1.02);
  box-shadow: 0 0.45rem 1.25rem rgba(118, 75, 162, 0.45);
}

.btn-hd-cta:active {
  transform: translateY(1px);
}

.hd-feature-card {
  border-radius: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
  box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.04);
}

.diary-week-main {
  max-width: 56rem;
}

.diary-week-main--table {
  max-width: 72rem;
}

.hd-breadcrumb-strip {
  background: #fff;
  border-color: rgba(var(--bs-primary-rgb), 0.12) !important;
}

.hd-breadcrumb {
  --bs-breadcrumb-divider: "›";
  --bs-breadcrumb-item-padding-x: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.hd-breadcrumb .breadcrumb-item a,
.hd-breadcrumb .breadcrumb-item a:visited {
  color: var(--hd-text);
  text-decoration: none;
  font-weight: 600;
}

.hd-breadcrumb .breadcrumb-item a:hover {
  color: var(--hd-primary-solid);
  text-decoration: underline;
}

.hd-breadcrumb .breadcrumb-item.active {
  color: var(--hd-muted);
  font-weight: 600;
}

/* Required / optional field markers (forms) */
.form-label.hd-required::after {
  content: " *";
  color: var(--bs-danger);
  font-weight: 700;
  margin-left: 0.125rem;
}

/* Diary: exempt entries — clearly greyed in card + table views */
.diary-band--exempt {
  border-color: #ced4da !important;
  background-color: #e9ecef;
  color: var(--hd-muted);
}

.diary-band--exempt .card-body {
  background-color: #e2e5ea !important;
  color: var(--hd-muted);
}

.diary-band--exempt .border-top {
  border-color: #ced4da !important;
}

.diary-band-head--exempt {
  background-color: #dee2e6 !important;
  color: var(--hd-muted) !important;
}

.diary-band--exempt .diary-stat-label,
.diary-band--exempt .small,
.diary-band--exempt .text-body {
  color: var(--hd-muted) !important;
}

.diary-tc--exempt {
  padding: 0.35rem 0.45rem;
  border-radius: 0.35rem;
  background-color: rgba(92, 100, 120, 0.1);
  border: 1px solid rgba(92, 100, 120, 0.18);
  color: var(--hd-muted);
}

.diary-tc--exempt .text-body,
.diary-tc--exempt .fw-semibold {
  color: var(--hd-muted) !important;
  font-weight: 600 !important;
}

.diary-week-table tbody tr>td.diary-week-td--exempt {
  background-color: #e9ecef !important;
  color: var(--hd-muted);
  box-shadow: inset 0 0 0 1px rgba(92, 100, 120, 0.12);
}

.diary-week-table.table-striped>tbody>tr:nth-of-type(odd)>td.diary-week-td--exempt {
  background-color: #e2e5ea !important;
}

.diary-week-table.table-hover tbody tr:hover>td.diary-week-td--exempt {
  background-color: #dde1e6 !important;
  color: var(--hd-muted);
}

/* Missed / absent labels — same red as fail rating (0/5), wins over exempt grey */
.diary-band--exempt .diary-slot-label--alert,
.diary-band-head--exempt .diary-slot-label--alert,
.diary-tc--exempt .diary-slot-label--alert,
.diary-slot-label--alert {
  color: var(--hd-rating-0) !important;
  font-weight: 600 !important;
}

/* =============================================================================
   Hifz Diary — student views design system (Profile + Strategy)
   Status: positive (green) | warning (amber) | critical (red) | neutral (grey)
   ============================================================================= */

.hd-ds-student-page.container {
  max-width: 58rem;
}

.hd-profile-section {
  scroll-margin-top: 1rem;
}

/* L4 — page / panel kickers */
.hd-profile-kicker,
.hd-ds-kicker {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hd-muted);
  font-weight: 600;
}

/* Hero panels (Qur’an %, strategy testing order) */
.hd-profile-hero,
.hd-ds-hero-panel {
  border-radius: 1rem;
  background: linear-gradient(145deg, #fff 0%, #f5f3ff 100%);
  border: 1px solid rgba(var(--bs-primary-rgb), 0.15);
}

/* L2 — section labels (muted caps) */
.hd-profile-section-label,
.hd-ds-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hd-muted);
  font-weight: 600;
}

/* L3 — supporting copy under metrics */
.hd-profile-sub,
.hd-ds-sub {
  font-size: 0.875rem;
  color: var(--hd-muted);
}

/* L1 — large headline numbers */
.hd-profile-metric,
.hd-ds-metric-value {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

/* Analytics: split Class | Home metric box (mirrors diary mistakes/hesitations pair) */
.hd-split-metric-box {
  min-height: 5rem;
}

.hd-split-metric-label {
  font-size: 0.65rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--hd-muted);
  margin-bottom: 0.4rem;
}

.hd-split-metric-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--bs-emphasis-color);
}

.hd-split-metric-sub {
  font-size: 0.75rem;
  color: var(--hd-muted);
  margin-top: 0.35rem;
  line-height: 1.3;
}

/* L1 — primary headline line (strategy testing order) */
.hd-ds-reading-order {
  font-size: clamp(1.2rem, 2.8vw, 1.55rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--hd-text);
  font-variant-numeric: tabular-nums;
}

.hd-ds-hero-panel--reading {
  border-width: 2px;
  box-shadow: 0 6px 22px rgba(var(--bs-primary-rgb), 0.1);
}

.hd-ds-reading-order--lead {
  font-size: clamp(1.35rem, 3.2vw, 1.85rem);
  letter-spacing: -0.03em;
}

.hd-ds-hero-panel--plan {
  border-width: 1px;
  background: linear-gradient(145deg, #fff 0%, #f8fafc 100%);
  border-color: rgba(0, 0, 0, 0.08);
}

.hd-ds-plan-list {
  margin: 0;
  padding-left: 1.35rem;
  list-style: decimal outside;
}

.hd-ds-plan-list > li {
  padding-left: 0.35rem;
  margin-bottom: 0.65rem;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--hd-text);
}

.hd-ds-plan-list > li:last-child {
  margin-bottom: 0;
}

/* Strategy hero — dense focus callout (optional layout) */
.hd-ds-focus-brief {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.hd-ds-focus-brief--with-revision {
  border-left: 3px solid rgba(var(--bs-primary-rgb), 0.4);
  padding-left: 0.85rem;
  margin-left: 0.05rem;
}

.hd-ds-focus-brief-primary {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--hd-text);
  letter-spacing: -0.015em;
}

.hd-ds-focus-brief-secondary {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--hd-text);
  letter-spacing: -0.01em;
}

.hd-ds-focus-brief-secondary-lead {
  font-weight: 600;
  color: var(--hd-text);
}

.hd-ds-focus-brief-secondary-sep {
  font-weight: 600;
  margin: 0 0.12em 0 0;
}

.hd-ds-focus-brief-secondary-target {
  font-weight: 600;
}

.hd-ds-focus-brief-escalation {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--hd-muted);
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Shared data tables — Profile revision strength + Strategy revision recency */
.hd-juz-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hd-muted);
  font-weight: 600;
  text-align: center !important;
}

/* Bootstrap .table sets cell alignment; force centre for headers and data */
table.hd-juz-grid > thead > tr > th,
table.hd-juz-grid > tbody > tr > td,
.hd-juz-grid th,
.hd-juz-grid td {
  padding: 0.72rem 0.9rem;
  vertical-align: middle;
  text-align: center !important;
}

.hd-juz-grid th:first-child,
.hd-juz-grid td:first-child {
  padding-left: 1.1rem;
}

.hd-juz-grid th:last-child,
.hd-juz-grid td:last-child {
  padding-right: 1.1rem;
}

/* Revision strength — recency (blue), strongest (green), weakest (red) */
.hd-juz-grid tbody tr.hd-juz-row-latest > td {
  background-color: rgba(var(--bs-primary-rgb), 0.09);
}
.hd-juz-grid tbody tr.hd-juz-row-latest > td:first-child {
  box-shadow: inset 3px 0 0 0 rgba(var(--bs-primary-rgb), 0.55);
}
.table.hd-juz-grid.table-hover tbody tr.hd-juz-row-latest:hover > td {
  background-color: rgba(var(--bs-primary-rgb), 0.14);
}

.hd-juz-grid tbody tr.hd-juz-row-strongest > td {
  background-color: rgba(34, 197, 94, 0.14) !important;
}
.hd-juz-grid tbody tr.hd-juz-row-strongest > td:first-child {
  box-shadow: inset 3px 0 0 0 #22c55e;
}
.table.hd-juz-grid.table-hover tbody tr.hd-juz-row-strongest:hover > td {
  background-color: rgba(34, 197, 94, 0.2) !important;
}

.hd-juz-grid tbody tr.hd-juz-row-weakest > td {
  background-color: rgba(248, 113, 113, 0.16) !important;
}
.hd-juz-grid tbody tr.hd-juz-row-weakest > td:first-child {
  box-shadow: inset 3px 0 0 0 #ef4444;
}
.table.hd-juz-grid.table-hover tbody tr.hd-juz-row-weakest:hover > td {
  background-color: rgba(248, 113, 113, 0.22) !important;
}

/* Revision table — strength labels (plain text, no chip) */
.hd-state-strong {
  color: #15803d;
  font-weight: 700;
}

.hd-state-good {
  color: #16a34a;
  font-weight: 600;
}

.hd-state-medium {
  color: #0f766e;
  font-weight: 600;
}

.hd-state-weak {
  color: #a16207;
  font-weight: 600;
}

.hd-state-atrisk {
  color: #c2410c;
  font-weight: 700;
}

.hd-state-neutral {
  color: var(--hd-muted);
  font-weight: 500;
}

.hd-state-urgent {
  color: #dc2626;
  font-weight: 700;
}

/* Unified status pills — use everywhere (cards, tables, flags) */
.hd-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
  border: 1px solid transparent;
  white-space: nowrap;
}

.hd-status-pill--sm {
  font-size: 0.75rem;
  padding: 0.26rem 0.62rem;
}

.hd-status-pill--md {
  font-size: 0.8125rem;
  padding: 0.38rem 0.78rem;
}

.hd-status-pill--lg {
  font-size: 0.95rem;
  padding: 0.55rem 1.1rem;
}

.hd-status-pill--positive {
  background-color: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
  border-color: rgba(25, 135, 84, 0.32);
}

.hd-status-pill--warning {
  background-color: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
  border-color: rgba(234, 179, 8, 0.45);
}

.hd-status-pill--critical {
  background-color: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
  border-color: rgba(220, 53, 69, 0.35);
}

.hd-status-pill--neutral {
  background-color: var(--bs-light);
  color: var(--bs-secondary-color);
  border-color: rgba(0, 0, 0, 0.12);
}

/* Strategy — structured metric tiles */
.hd-ds-tile {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0.75rem;
  padding: 0.9rem 1rem;
  height: 100%;
  background: rgba(var(--bs-primary-rgb), 0.04);
}

.hd-ds-tile-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hd-muted);
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.hd-ds-tile-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--hd-text);
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.hd-ds-tile-note {
  font-size: 0.8125rem;
  color: var(--hd-muted);
  margin-top: 0.3rem;
  font-weight: 500;
}

/* Tile on grey footer bands (Strategy revision summary) */
.hd-ds-tile--on-light {
  background: #fff !important;
  border-color: rgba(0, 0, 0, 0.07);
}

/* Strategy — New Lesson summary: narrative groups */
.hd-ds-nl-brief-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--hd-muted);
  font-weight: 700;
  margin-bottom: 0.65rem;
}

.hd-ds-tile--lead .hd-ds-tile-value {
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.hd-ds-tile--outcomes .hd-ds-tile-label {
  margin-bottom: 0.45rem;
}

.hd-ds-nl-outcomes-line {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--hd-text);
  font-variant-numeric: tabular-nums;
}

.hd-ds-nl-outcomes-sub {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 0.35rem;
  color: #15803d;
}

.hd-ds-tile--outcomes-risk .hd-ds-nl-outcomes-line {
  color: var(--bs-danger-text-emphasis);
}

.hd-ds-tile--outcomes-risk .hd-ds-nl-outcomes-sub {
  color: var(--hd-muted);
  font-weight: 500;
}

.hd-ds-tile--pattern {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.hd-ds-nl-pattern-line {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--hd-text);
}

/* Strategy — key alerts (warning lane) */
.hd-ds-alert-list {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.hd-ds-alert-list > li {
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 0.5rem;
  border-left: 4px solid var(--bs-warning);
  background-color: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
  font-size: 0.875rem;
  font-weight: 600;
}

.hd-ds-alert-list > li:last-child {
  margin-bottom: 0;
}

/* Flags / secondary callouts */
.hd-ds-flags-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* Card body rhythm (Profile + Strategy) */
.hd-ds-card-body {
  padding: 1rem 1.25rem;
}

@media (min-width: 768px) {
  .hd-ds-card-body {
    padding: 1.25rem 1.5rem;
  }
}

/* Performance summary rows (Strategy hero) */
.hd-ds-perf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.hd-ds-perf-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.hd-ds-perf-row:first-child {
  padding-top: 0;
}

/* School org / platform — weekday list (wrapper must NOT use .form-check-input; see forms.py) */
.hd-class-weekday-checkboxes .hd-weekday-multiple,
.hd-class-weekday-checkboxes > div[id^="id_class_weekdays"],
.hd-class-weekday-checkboxes #id_class_weekdays {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.hd-class-weekday-checkboxes .hd-weekday-multiple > div > label,
.hd-class-weekday-checkboxes > div[id^="id_class_weekdays"] > div > label,
.hd-class-weekday-checkboxes #id_class_weekdays > div > label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-weight: 500;
}

.hd-class-weekday-checkboxes .hd-weekday-multiple input[type="checkbox"],
.hd-class-weekday-checkboxes input[type="checkbox"] {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  margin: 0;
}

.hd-class-weekday-checkboxes ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.hd-class-weekday-checkboxes .form-check {
  margin-bottom: 0;
}

.hd-institution-form-actions {
  /* Keep in normal flow — do not raise z-index or the Save button can paint over fields above */
  width: 100%;
}

/*
 * Bootstrap’s .card is `display: flex; flex-direction: column`. Putting that class on <form>
 * makes the form a flex container and can clip or stack children oddly with long checkbox lists.
 * Use: div.card > div.card-body > form.hd-plain-form
 */
.hd-card-with-form.card {
  overflow: visible;
}

.hd-card-with-form > .card-body {
  overflow: visible;
  /* Avoid flex-grow filling parent viewport (can clip long checkbox lists inside the card) */
  flex: 0 0 auto;
}

.hd-plain-form {
  display: block;
}

/* Class analytics — coloured summary + metric tiles */
.hd-analytics-points-card {
  border-radius: 0.85rem;
  padding: 1rem 1.1rem;
  height: 100%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.hd-analytics-points-card--positive {
  background: linear-gradient(145deg, #fff 0%, var(--bs-success-bg-subtle) 100%);
  border-color: rgba(25, 135, 84, 0.28);
}

.hd-analytics-points-card--warning {
  background: linear-gradient(145deg, #fff 0%, var(--bs-warning-bg-subtle) 100%);
  border-color: rgba(234, 179, 8, 0.35);
}

.hd-analytics-points-card--critical {
  background: linear-gradient(145deg, #fff 0%, var(--bs-danger-bg-subtle) 100%);
  border-color: rgba(220, 53, 69, 0.28);
}

.hd-analytics-points-card--neutral {
  background: linear-gradient(145deg, #fff 0%, #f4f5f8 100%);
}

.hd-analytics-points-card__class {
  font-weight: 700;
  font-size: 0.95rem;
}

.hd-analytics-points-card__teacher {
  font-size: 0.8rem;
  color: var(--hd-muted);
}

.hd-analytics-points-card__rank {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--hd-muted);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.hd-analytics-points-card__total {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
  margin: 0.65rem 0 0.35rem;
  font-variant-numeric: tabular-nums;
}

.hd-analytics-points-card__pts-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--hd-muted);
}

.hd-analytics-points-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--hd-muted);
}

.hd-analytics-class-card {
  border-left: 4px solid transparent;
}

.hd-analytics-class-card--positive {
  border-left-color: var(--bs-success);
}

.hd-analytics-class-card--warning {
  border-left-color: var(--bs-warning);
}

.hd-analytics-class-card--critical {
  border-left-color: var(--bs-danger);
}

.hd-analytics-class-card--neutral {
  border-left-color: var(--bs-secondary);
}

.hd-analytics-class-points-badge {
  border-radius: 0.85rem;
  padding: 0.75rem 1rem;
  min-width: 9.5rem;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.hd-analytics-class-points-badge--positive {
  background: var(--bs-success-bg-subtle);
  border-color: rgba(25, 135, 84, 0.3);
}

.hd-analytics-class-points-badge--warning {
  background: var(--bs-warning-bg-subtle);
  border-color: rgba(234, 179, 8, 0.35);
}

.hd-analytics-class-points-badge--critical {
  background: var(--bs-danger-bg-subtle);
  border-color: rgba(220, 53, 69, 0.3);
}

.hd-analytics-class-points-badge--neutral {
  background: var(--bs-light);
}

.hd-analytics-class-points-badge__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--hd-muted);
}

.hd-analytics-class-points-badge__value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.hd-analytics-class-points-badge__sub {
  font-size: 0.75rem;
  color: var(--hd-muted);
}

.hd-analytics-metric {
  border-radius: 0.75rem;
  padding: 0.9rem 1rem;
  height: 100%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.hd-analytics-metric--positive {
  background: rgba(var(--bs-success-rgb), 0.07);
  border-color: rgba(25, 135, 84, 0.22);
}

.hd-analytics-metric--warning {
  background: rgba(var(--bs-warning-rgb), 0.1);
  border-color: rgba(234, 179, 8, 0.28);
}

.hd-analytics-metric--critical {
  background: rgba(var(--bs-danger-rgb), 0.07);
  border-color: rgba(220, 53, 69, 0.22);
}

.hd-analytics-metric--neutral {
  background: rgba(var(--bs-secondary-rgb), 0.05);
}

.hd-analytics-metric__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--hd-muted);
  margin-bottom: 0.45rem;
}

.hd-analytics-metric__value {
  min-height: 2rem;
  margin-bottom: 0.35rem;
}

.hd-analytics-metric__detail {
  font-size: 0.8125rem;
  color: var(--hd-muted);
  line-height: 1.35;
}

/* Diary — school holiday / closure days */
.diary-day-card--closure,
.diary-day-head--closure {
  background: linear-gradient(180deg, #fff9eb 0%, #fff 100%) !important;
}

.diary-day-col--closure {
  background: #fff9eb !important;
}

.diary-closure-badge .badge {
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Points earned/lost flash */
.hd-points-flash {
  position: fixed;
  top: 5.25rem;
  right: 1.25rem;
  z-index: 1080;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  pointer-events: none;
  animation: hd-points-float 2.4s ease-out forwards;
}

.hd-points-flash--gain {
  background: #ecfdf3;
  color: #15803d;
  border: 1px solid rgba(21, 128, 61, 0.25);
}

.hd-points-flash--loss {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid rgba(185, 28, 28, 0.22);
}

@keyframes hd-points-float {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.92);
  }
  12% {
    opacity: 1;
    transform: translateY(0) scale(1.04);
  }
  70% {
    opacity: 1;
    transform: translateY(-10px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-28px) scale(0.98);
  }
}