/* ==========================================================================
   Mayakids dashboard design system
   One stylesheet shared by the Super Admin, Branch Admin, Teacher, Student and
   Guardian workspaces.  Mobile first; breakpoints: 640px, 1024px, 1280px.

   Colour notes (WCAG 2.2 AA): the brand palette is used as specified, with two
   text-safe companions because the raw values fail 4.5:1 on white:
     --mk-muted  #5A6678 (5.8:1)  replaces #718096 (4.0:1) for body text
     --mk-accent-strong #0E7C69 (5.1:1) replaces #36B8A0 (2.5:1) for text/links
   The original values remain available as decorative tokens.
   ========================================================================== */

:root {
  --mk-primary: #243B70;
  --mk-primary-700: #1b2d57;
  --mk-primary-50: #eaeff9;
  --mk-secondary: #4867A8;
  --mk-accent: #36B8A0;
  --mk-accent-strong: #0E7C69;
  --mk-accent-50: #e6f6f3;
  --mk-bg: #F5F7FB;
  --mk-surface: #FFFFFF;
  --mk-text: #1F2937;
  --mk-muted: #5A6678;
  --mk-muted-soft: #718096;
  --mk-border: #E5EAF1;
  --mk-border-strong: #cfd7e3;

  --mk-success: #067647;  --mk-success-bg: #e7f6ee;
  --mk-warning: #93510a;  --mk-warning-bg: #fdf2dc;
  --mk-danger: #b42318;   --mk-danger-bg: #fdecea;
  --mk-info: #175cd3;     --mk-info-bg: #e8f0fd;

  --mk-radius-sm: 8px;
  --mk-radius: 12px;
  --mk-radius-lg: 16px;
  --mk-shadow-sm: 0 1px 2px rgba(31, 41, 55, .06);
  --mk-shadow: 0 4px 14px rgba(36, 59, 112, .08);
  --mk-shadow-lg: 0 16px 40px rgba(31, 41, 55, .18);

  --mk-sidebar-w: 264px;
  --mk-topbar-h: 60px;
  --mk-font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", sans-serif;

  --mk-chart-1: #243B70; --mk-chart-2: #36B8A0; --mk-chart-3: #4867A8;
  --mk-chart-4: #E0A030; --mk-chart-5: #C8553D; --mk-chart-6: #7A5AA6;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.mk-body {
  margin: 0; font-family: var(--mk-font); font-size: 15px; line-height: 1.55;
  color: var(--mk-text); background: var(--mk-bg);
  -webkit-font-smoothing: antialiased;
}
.mk-body h1, .mk-body h2, .mk-body h3, .mk-body h4 { margin: 0; line-height: 1.25; color: var(--mk-text); }
.mk-body p { margin: 0 0 .75rem; }
.mk-body a { color: var(--mk-secondary); text-decoration: none; }
.mk-body a:hover { text-decoration: underline; }
.mk-body img { max-width: 100%; height: auto; }
.mk-body small, .muted, .ops-muted { color: var(--mk-muted); }
.mk-body ul { padding-left: 1.2rem; }

/* ---- Focus: always visible, 3:1 against any background -------------------- */
.mk-body :focus-visible {
  outline: 3px solid var(--mk-secondary); outline-offset: 2px;
  box-shadow: 0 0 0 5px #fff;
}
.mk-skip {
  position: absolute; left: .75rem; top: -4rem; z-index: 1000; background: var(--mk-primary); color: #fff !important;
  padding: .6rem 1rem; border-radius: var(--mk-radius-sm); font-weight: 600;
}
.mk-skip:focus { top: .75rem; }
.mk-sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- App frame ------------------------------------------------------------ */
.mk-app { min-height: 100vh; display: block; }
.mk-sidebar {
  position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 60;
  background: var(--mk-primary); color: #dfe6f5; display: flex; flex-direction: column;
  transform: translateX(-102%); transition: transform .22s ease; overflow-y: auto; overscroll-behavior: contain;
}
.mk-nav-open .mk-sidebar { transform: none; box-shadow: var(--mk-shadow-lg); }
.mk-scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 55; opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.mk-nav-open .mk-scrim { opacity: 1; pointer-events: auto; }
.mk-brand { display: flex; align-items: center; gap: .65rem; padding: 1rem 1.1rem; color: #fff !important; font-weight: 800; font-size: 1.05rem; }
.mk-brand:hover { text-decoration: none !important; }
.mk-brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--mk-accent); color: var(--mk-primary);
  display: grid; place-items: center; font-weight: 900; font-size: 1.1rem; flex: none;
}
.mk-brand small { display: block; font-weight: 500; font-size: .72rem; color: #b8c4de; }
.mk-workspace { padding: 0 1rem .75rem; }
.mk-workspace label { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #b8c4de; margin-bottom: .25rem; }
.mk-workspace select {
  width: 100%; padding: .5rem .6rem; border-radius: var(--mk-radius-sm); border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08); color: #fff; font: inherit; font-size: .85rem;
}
.mk-workspace select option { color: var(--mk-text); }
.mk-nav { padding: .25rem .6rem 1.5rem; flex: 1; }
.mk-nav-title {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #aebbd9; padding: .9rem .6rem .35rem; margin: 0;
}
.mk-nav a {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .65rem; border-radius: var(--mk-radius-sm);
  color: #e6ecf8; font-size: .9rem; font-weight: 500; min-height: 40px;
}
.mk-nav a i { font-size: 1.15rem; opacity: .9; flex: none; }
.mk-nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.mk-nav a[aria-current="page"] { background: #fff; color: var(--mk-primary); font-weight: 700; }
.mk-nav-count {
  margin-left: auto; background: var(--mk-accent); color: #0b2a24; border-radius: 999px; padding: 0 .5rem;
  font-size: .72rem; font-weight: 700; min-width: 1.4rem; text-align: center;
}
.mk-nav a[aria-current="page"] .mk-nav-count { background: var(--mk-primary); color: #fff; }

.mk-main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.mk-topbar {
  position: sticky; top: 0; z-index: 40; height: var(--mk-topbar-h); display: flex; align-items: center; gap: .6rem;
  padding: 0 .9rem; background: var(--mk-surface); border-bottom: 1px solid var(--mk-border);
}
.mk-topbar-title { font-weight: 700; font-size: 1rem; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mk-icon-btn {
  position: relative; display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: transparent; color: var(--mk-text); cursor: pointer; font-size: 1.3rem;
}
.mk-icon-btn:hover { background: var(--mk-primary-50); text-decoration: none; }
.mk-badge-dot {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
  background: var(--mk-danger); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center;
}
.mk-user { position: relative; }
.mk-user-btn {
  display: flex; align-items: center; gap: .5rem; padding: .25rem .5rem .25rem .25rem; border-radius: 999px;
  border: 1px solid var(--mk-border); background: var(--mk-surface); cursor: pointer; font: inherit; color: inherit; min-height: 44px;
}
.mk-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--mk-primary); color: #fff; display: grid; place-items: center;
  font-size: .78rem; font-weight: 700; flex: none; overflow: hidden;
}
/* On phones the name is hidden visually but stays in the button's accessible name. */
.mk-user-name {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0);
  font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.mk-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--mk-surface);
  border: 1px solid var(--mk-border); border-radius: var(--mk-radius); box-shadow: var(--mk-shadow-lg); padding: .4rem; z-index: 70;
}
.mk-menu[hidden] { display: none; }
.mk-menu a, .mk-menu button {
  display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .7rem; border-radius: var(--mk-radius-sm);
  color: var(--mk-text); background: none; border: 0; font: inherit; font-size: .9rem; cursor: pointer; text-align: left;
}
.mk-menu a:hover, .mk-menu button:hover { background: var(--mk-primary-50); text-decoration: none; }
.mk-menu hr { border: 0; border-top: 1px solid var(--mk-border); margin: .35rem 0; }
.mk-menu .mk-menu-head { padding: .5rem .7rem; font-size: .8rem; color: var(--mk-muted); }

.mk-content { flex: 1; padding: 1rem .9rem 2.5rem; width: 100%; max-width: 1400px; margin: 0 auto; outline: none; }
.mk-footer { padding: 1rem; text-align: center; font-size: .8rem; color: var(--mk-muted); border-top: 1px solid var(--mk-border); background: var(--mk-surface); }

@media (min-width: 640px) {
  .mk-content { padding: 1.25rem 1.5rem 3rem; }
  .mk-user-name { position: static; display: inline; width: auto; height: auto; margin: 0; clip: auto; max-width: 150px; text-overflow: ellipsis; }
}
@media (min-width: 1024px) {
  .mk-app { display: grid; grid-template-columns: var(--mk-sidebar-w) minmax(0, 1fr); }
  .mk-sidebar { position: sticky; top: 0; height: 100vh; width: auto; transform: none; z-index: 30; }
  .mk-scrim { display: none; }
  .mk-menu-toggle { display: none !important; }
  .mk-content { padding: 1.5rem 2rem 3rem; }
}

/* ---- Breadcrumbs, page header -------------------------------------------- */
.mk-crumbs { font-size: .82rem; color: var(--mk-muted); margin-bottom: .6rem; }
.mk-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; padding: 0; margin: 0; }
.mk-crumbs li + li::before { content: "/"; margin-right: .25rem; color: var(--mk-border-strong); }
.mk-crumbs a { color: var(--mk-muted); }
.mk-crumbs [aria-current] { color: var(--mk-text); font-weight: 600; }
.mk-page-head, .ops-head {
  display: flex; flex-direction: column; gap: .75rem; margin: 0 0 1.1rem;
}
.mk-page-head h1, .ops-head h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -.01em; }
.mk-page-head p, .ops-head p { margin: .2rem 0 0; color: var(--mk-muted); font-size: .92rem; }
.mk-actions, .ops-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.ops-head h2 { font-size: 1.1rem; }
@media (min-width: 720px) {
  .mk-page-head, .ops-head { flex-direction: row; align-items: center; justify-content: space-between; }
}

/* ---- Cards, grids --------------------------------------------------------- */
.mk-card, .ops-card {
  background: var(--mk-surface); border: 1px solid var(--mk-border); border-radius: var(--mk-radius);
  padding: 1rem; min-width: 0; box-shadow: var(--mk-shadow-sm);
}
.mk-card > h2, .mk-card-head h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: .6rem; }
.mk-card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.mk-card-head h2 { margin: 0; }
.mk-grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.mk-grid-2, .ops-two { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.mk-grid-3 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.mk-stats, .ops-grid { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
@media (min-width: 720px) {
  .mk-grid-2, .ops-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mk-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mk-stats, .ops-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1280px) { .mk-stats.mk-stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.mk-stat, .ops-stat {
  background: var(--mk-surface); border: 1px solid var(--mk-border); border-radius: var(--mk-radius); padding: .9rem 1rem;
  display: flex; flex-direction: column; gap: .15rem; min-width: 0; box-shadow: var(--mk-shadow-sm);
}
.mk-stat strong, .ops-stat strong { font-size: 1.7rem; line-height: 1.1; color: var(--mk-primary); font-weight: 800; }
.mk-stat span, .ops-stat span { font-size: .82rem; color: var(--mk-muted); font-weight: 600; }
.mk-stat small, .ops-stat small { font-size: .76rem; color: var(--mk-muted); }
.mk-stat .mk-stat-icon { align-self: flex-start; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--mk-primary-50); color: var(--mk-primary); font-size: 1.2rem; margin-bottom: .35rem; }
.mk-stat.is-accent .mk-stat-icon { background: var(--mk-accent-50); color: var(--mk-accent-strong); }
.mk-stat.is-warn .mk-stat-icon { background: var(--mk-warning-bg); color: var(--mk-warning); }
.mk-stat.is-danger .mk-stat-icon { background: var(--mk-danger-bg); color: var(--mk-danger); }
.mk-stat a.mk-stat-link { margin-top: .25rem; font-size: .8rem; font-weight: 600; }
.worksheet-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* ---- Buttons -------------------------------------------------------------- */
.btn, .mk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: .5rem 1rem;
  border-radius: var(--mk-radius-sm); border: 1px solid transparent; font: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; text-decoration: none !important; line-height: 1.2; transition: background .15s, border-color .15s, box-shadow .15s;
  background: var(--mk-surface); color: var(--mk-primary); border-color: var(--mk-border-strong); touch-action: manipulation;
}
.btn:hover, .mk-btn:hover { background: var(--mk-primary-50); }
.btn-brand, .btn-primary, .mk-btn-primary { background: var(--mk-primary); border-color: var(--mk-primary); color: #fff !important; }
.btn-brand:hover, .btn-primary:hover, .mk-btn-primary:hover { background: var(--mk-primary-700); }
.btn-accent { background: var(--mk-accent-strong); border-color: var(--mk-accent-strong); color: #fff !important; }
.btn-accent:hover { background: #0b6354; }
.btn-outline { background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--mk-secondary); }
.btn-ghost:hover { background: var(--mk-primary-50); }
.btn-danger, .mk-btn-danger { background: var(--mk-danger); border-color: var(--mk-danger); color: #fff !important; }
.btn-danger:hover { background: #8f1b11; }
.btn-sm { min-height: 34px; padding: .3rem .7rem; font-size: .82rem; }
.btn-lg { min-height: 48px; padding: .7rem 1.4rem; font-size: 1rem; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .65; cursor: not-allowed; }
.btn[aria-busy="true"]::after {
  content: ""; width: .9em; height: .9em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: mk-spin .7s linear infinite;
}
@keyframes mk-spin { to { transform: rotate(360deg); } }
.mk-btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

/* ---- Badges / status ------------------------------------------------------ */
.badge, .mk-badge {
  display: inline-flex; align-items: center; gap: .25rem; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem;
  font-weight: 700; line-height: 1.5; background: var(--mk-primary-50); color: var(--mk-primary); white-space: nowrap;
}
.badge-purple, .badge-blue { background: var(--mk-primary-50); color: var(--mk-primary); }
.badge-green, .badge-success { background: var(--mk-success-bg); color: var(--mk-success); }
.badge-gray, .badge-muted { background: #eef1f5; color: #4a5568; }
.badge-outline { background: transparent; border: 1px solid var(--mk-border-strong); color: var(--mk-muted); }
.badge-amber, .badge-warning { background: var(--mk-warning-bg); color: var(--mk-warning); }
.badge-red, .badge-danger { background: var(--mk-danger-bg); color: var(--mk-danger); }
.badge-teal { background: var(--mk-accent-50); color: var(--mk-accent-strong); }
.badge-info { background: var(--mk-info-bg); color: var(--mk-info); }

/* ---- Alerts / toasts ------------------------------------------------------ */
.alert, .mk-alert {
  padding: .75rem 1rem; border-radius: var(--mk-radius-sm); border: 1px solid var(--mk-border); margin-bottom: 1rem;
  background: var(--mk-info-bg); color: #123b82; border-color: #c4d7f8; font-size: .92rem;
}
.alert-success { background: var(--mk-success-bg); color: var(--mk-success); border-color: #b4e2c8; }
.alert-error, .alert-danger { background: var(--mk-danger-bg); color: var(--mk-danger); border-color: #f4c0ba; }
.alert-warning { background: var(--mk-warning-bg); color: var(--mk-warning); border-color: #f0d49b; }
.mk-toasts { position: fixed; right: .75rem; left: .75rem; bottom: .75rem; z-index: 90; display: grid; gap: .5rem; pointer-events: none; }
@media (min-width: 640px) { .mk-toasts { left: auto; width: 380px; } }
.mk-toast {
  pointer-events: auto; display: flex; gap: .6rem; align-items: flex-start; padding: .75rem .9rem; border-radius: var(--mk-radius-sm);
  background: var(--mk-text); color: #fff; box-shadow: var(--mk-shadow-lg); font-size: .9rem; border-left: 5px solid var(--mk-info);
}
.mk-toast.is-success { border-left-color: var(--mk-accent); }
.mk-toast.is-error { border-left-color: #ff7b6e; }
.mk-toast.is-warning { border-left-color: #f1b24a; }
.mk-toast button { margin-left: auto; background: none; border: 0; color: #fff; cursor: pointer; font-size: 1.1rem; padding: 0 .25rem; min-width: 32px; min-height: 32px; }

/* ---- Forms ---------------------------------------------------------------- */
.mk-form, .ops-form { display: grid; gap: 1rem; }
.mk-form-grid, .form-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .mk-form-grid, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mk-field { min-width: 0; }
.mk-field.is-wide, .mk-form-grid > .alert { grid-column: 1 / -1; }
.mk-field label, .ops-form label, .ops-toolbar label {
  display: block; font-size: .85rem; font-weight: 700; color: var(--mk-text); margin-bottom: .3rem;
}
.mk-req { color: var(--mk-danger); margin-left: .15rem; }
.form-control, .field-control, .mk-input, .mk-form select, .mk-form textarea, .mk-form input[type=text], .mk-form input[type=number],
.mk-form input[type=email], .mk-form input[type=password], .mk-form input[type=date], .mk-form input[type=time],
.mk-form input[type=datetime-local], .mk-form input[type=url], .mk-form input[type=search], .mk-form input[type=file], .mk-form input[type=tel] {
  width: 100%; min-height: 44px; padding: .55rem .75rem; border: 1px solid var(--mk-border-strong); border-radius: var(--mk-radius-sm);
  background: #fff; color: var(--mk-text); font: inherit; font-size: 1rem;
}
textarea.form-control, textarea.field-control, .mk-form textarea { min-height: 100px; resize: vertical; }
.form-control:focus, .field-control:focus, .mk-form input:focus, .mk-form select:focus, .mk-form textarea:focus { border-color: var(--mk-secondary); }
.mk-form input[type=checkbox], .mk-form input[type=radio], .ops-form input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--mk-primary); flex: none; }
input.field-control[type=checkbox], input.field-control[type=radio], input.form-control[type=checkbox], input.form-control[type=radio] {
  width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--mk-primary); flex: none;
}
.ops-form input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--mk-primary); }
.helptext, .mk-help { display: block; color: var(--mk-muted); font-size: .8rem; margin-top: .25rem; }
.field-error, .form-error, .mk-error, ul.errorlist { color: var(--mk-danger); font-size: .82rem; margin-top: .25rem; list-style: none; padding: 0; font-weight: 600; }
.mk-field.has-error input, .mk-field.has-error select, .mk-field.has-error textarea { border-color: var(--mk-danger); }
.ops-checks ul, .mk-checks ul, .mk-checks { list-style: none; display: grid; gap: .1rem; grid-template-columns: 1fr; padding: 0; margin: 0; }
@media (min-width: 720px) { .ops-checks ul, .mk-checks ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ops-checks li label, .mk-checks label, .mk-check { display: flex; align-items: center; gap: .55rem; font-weight: 500 !important; min-height: 36px; margin: 0; cursor: pointer; }
.mk-fieldset { border: 1px solid var(--mk-border); border-radius: var(--mk-radius-sm); padding: .8rem 1rem 1rem; margin: 0; min-width: 0; }
.mk-fieldset legend { font-weight: 700; font-size: .9rem; padding: 0 .4rem; }
.mk-perm-group { margin-bottom: 1rem; }
.mk-perm-group h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mk-muted); margin-bottom: .35rem; }

/* ---- Filter bar ----------------------------------------------------------- */
.ops-toolbar, .mk-filters {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; padding: .85rem;
  background: var(--mk-surface); border: 1px solid var(--mk-border); border-radius: var(--mk-radius);
}
.ops-toolbar .field, .mk-filters .field { flex: 1 1 160px; min-width: 0; }
.ops-toolbar .field.is-search, .mk-filters .field.is-search { flex: 2 1 240px; }

/* ---- Tables --------------------------------------------------------------- */
/* `position: relative` makes the wrapper the containing block of visually-hidden text inside the
   table (e.g. the "Actions" header), so that text is clipped with the table instead of widening the page. */
.ops-table-wrap, .mk-table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ops-table, .mk-table { width: 100%; border-collapse: collapse; }
.ops-table th, .ops-table td, .mk-table th, .mk-table td {
  text-align: left; padding: .7rem .65rem; border-bottom: 1px solid var(--mk-border); font-size: .88rem; vertical-align: middle;
}
.ops-table th, .mk-table th {
  color: var(--mk-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; background: #fafbfd;
}
.ops-table tbody tr:hover, .mk-table tbody tr:hover { background: #fafcff; }
.ops-table td strong, .mk-table td strong { color: var(--mk-text); }
.mk-table a.mk-sort { color: inherit; }
.mk-table td.num, .mk-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* On phones every row becomes a labelled card (labels are added by mk.js). */
@media (max-width: 719px) {
  table.mk-stack { min-width: 0 !important; }
  table.mk-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.mk-stack, table.mk-stack tbody, table.mk-stack tr, table.mk-stack td { display: block; width: 100%; }
  table.mk-stack tr { border: 1px solid var(--mk-border); border-radius: var(--mk-radius-sm); margin-bottom: .75rem; padding: .35rem .25rem; background: #fff; }
  table.mk-stack td { border: 0; padding: .35rem .6rem; display: flex; gap: .75rem; justify-content: space-between; align-items: center; text-align: right; }
  table.mk-stack td::before { content: attr(data-label); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--mk-muted); font-weight: 700; text-align: left; flex: none; max-width: 42%; }
  table.mk-stack td[data-label=""]::before { content: none; }
  table.mk-stack td > * { min-width: 0; }
  table.mk-stack td[colspan] { display: block; text-align: left; }
}
.ops-pagination, .mk-pagination { display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: 1rem; flex-wrap: wrap; font-size: .88rem; }

/* ---- Detail lists, empty states, misc ------------------------------------- */
.ops-detail, .mk-detail { display: grid; gap: .75rem; grid-template-columns: 1fr; margin: 0; }
@media (min-width: 640px) { .ops-detail, .mk-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ops-detail div, .mk-detail div { padding: .7rem .85rem; background: #f8f9fc; border-radius: var(--mk-radius-sm); min-width: 0; }
.ops-detail dt, .mk-detail dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mk-muted); font-weight: 700; }
.ops-detail dd, .mk-detail dd { margin: .2rem 0 0; font-weight: 600; overflow-wrap: anywhere; }
.ops-empty, .mk-empty {
  padding: 2rem 1rem; text-align: center; color: var(--mk-muted); background: var(--mk-surface);
  border: 1px dashed var(--mk-border-strong); border-radius: var(--mk-radius);
}
.mk-empty i { font-size: 2rem; color: var(--mk-muted-soft); display: block; margin-bottom: .35rem; }
.mk-empty strong { display: block; color: var(--mk-text); margin-bottom: .25rem; }
.mk-list { list-style: none; padding: 0 !important; margin: 0; }
.mk-list li { padding: .7rem 0; border-bottom: 1px solid var(--mk-border); display: flex; gap: .75rem; align-items: flex-start; justify-content: space-between; }
.mk-list li:last-child { border-bottom: 0; }
.mk-list .mk-list-main { min-width: 0; }
.mk-list .mk-list-main strong { display: block; overflow-wrap: anywhere; }
.mk-tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--mk-border); margin-bottom: 1rem; }
.mk-tabs a { padding: .6rem .9rem; color: var(--mk-muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.mk-tabs a[aria-current="page"] { color: var(--mk-primary); border-bottom-color: var(--mk-primary); }
.mk-progress { height: 10px; background: #e8edf5; border-radius: 999px; overflow: hidden; }
.mk-progress > span { display: block; height: 100%; background: var(--mk-accent-strong); border-radius: 999px; }
.mk-progress.is-warn > span { background: #d98a1c; }
.mk-progress.is-danger > span { background: var(--mk-danger); }
.mk-chip-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.mk-kv { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px dashed var(--mk-border); font-size: .9rem; }
.mk-kv:last-child { border-bottom: 0; }
.mk-kv span:first-child { color: var(--mk-muted); }
.mk-callout { border-left: 4px solid var(--mk-accent); background: var(--mk-accent-50); padding: .75rem 1rem; border-radius: 0 var(--mk-radius-sm) var(--mk-radius-sm) 0; margin-bottom: 1rem; font-size: .9rem; }
.mk-callout.is-warn { border-left-color: #d98a1c; background: var(--mk-warning-bg); }
.mk-callout.is-danger { border-left-color: var(--mk-danger); background: var(--mk-danger-bg); }
.mk-credential { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.15rem; background: #f2f4f8; padding: .6rem .8rem; border-radius: var(--mk-radius-sm); letter-spacing: .03em; overflow-wrap: anywhere; }

/* ---- Segmented radio group (attendance), checklists, schedule ------------- */
.mk-seg { display: flex; flex-wrap: wrap; gap: .35rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.mk-seg-item { position: relative; }
.mk-seg-item input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.mk-seg-item span {
  display: inline-flex; align-items: center; min-height: 40px; padding: .3rem .75rem; border: 1px solid var(--mk-border-strong);
  border-radius: var(--mk-radius-sm); font-size: .85rem; font-weight: 600; background: #fff; color: var(--mk-text);
}
.mk-seg-item input:checked + span { background: var(--mk-primary); border-color: var(--mk-primary); color: #fff; }
.mk-seg-item input:focus-visible + span { outline: 3px solid var(--mk-secondary); outline-offset: 2px; }
.mk-seg[disabled] .mk-seg-item span { opacity: .7; }
.mk-checklist { max-height: 300px; overflow: auto; border: 1px solid var(--mk-border-strong); border-radius: var(--mk-radius-sm); padding: .4rem .6rem; background: #fff; }
.mk-checklist ul { list-style: none; padding: 0; margin: 0; display: block; }
.mk-checklist li label { display: flex; align-items: center; gap: .55rem; min-height: 40px; margin: 0; font-weight: 500; cursor: pointer; }
.mk-schedule { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .mk-schedule { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .mk-schedule { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.mk-today { border-color: var(--mk-accent-strong); box-shadow: 0 0 0 2px var(--mk-accent-50); }
details > summary { cursor: pointer; list-style: none; display: inline-flex; }
details > summary::-webkit-details-marker { display: none; }

/* ---- Charts --------------------------------------------------------------- */
.mk-chart { width: 100%; min-height: 0; }
.mk-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.mk-chart text { font-family: var(--mk-font); fill: var(--mk-muted); font-size: 11px; }
.mk-chart .mk-axis { stroke: var(--mk-border-strong); stroke-width: 1; }
.mk-chart .mk-grid-line { stroke: var(--mk-border); stroke-width: 1; stroke-dasharray: 3 3; }
.mk-chart .mk-value { fill: var(--mk-text); font-weight: 700; }
.mk-chart-legend { display: flex; flex-wrap: wrap; gap: .75rem; font-size: .8rem; color: var(--mk-muted); margin-top: .5rem; }
.mk-chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .3rem; }
.mk-chart-empty { color: var(--mk-muted); text-align: center; padding: 2rem 0; font-size: .9rem; }
.mk-ring { position: relative; width: 120px; height: 120px; margin: 0 auto; }
.mk-ring .mk-ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 1.4rem; color: var(--mk-primary); }

/* ---- Dialogs -------------------------------------------------------------- */
dialog.mk-dialog {
  border: 0; border-radius: var(--mk-radius); padding: 0; width: min(92vw, 460px); box-shadow: var(--mk-shadow-lg); color: var(--mk-text);
}
dialog.mk-dialog::backdrop { background: rgba(15, 23, 42, .55); }
.mk-dialog-body { padding: 1.25rem 1.25rem .75rem; }
.mk-dialog-body h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.mk-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; padding: .75rem 1.25rem 1.25rem; }

/* ---- Skeleton loading ----------------------------------------------------- */
.mk-skeleton { background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 37%, #eef1f6 63%); background-size: 400% 100%; animation: mk-shimmer 1.4s ease infinite; border-radius: var(--mk-radius-sm); min-height: 1rem; }
@keyframes mk-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---- Student-roster avatars (legacy markup) ------------------------------- */
.student-roster-person { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.student-roster-avatar { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--mk-primary-50); color: var(--mk-primary); font-size: .75rem; font-weight: 800; }
.student-roster-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Utilities kept for the legacy templates ------------------------------ */
.d-flex { display: flex; } .flex { display: flex; } .flex-wrap { flex-wrap: wrap; }
.align-items-start { align-items: flex-start; } .justify-content-between { justify-content: space-between; }
.gap-3 { gap: 1rem; } .gap-sm { gap: .5rem; } .text-center { text-align: center; }
.mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-3 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; } .mb-3 { margin-bottom: 1rem; } .my-3 { margin: 1rem 0; }
.mk-hide-mobile { display: none; } @media (min-width: 720px) { .mk-hide-mobile { display: initial; } }
.mk-nowrap { white-space: nowrap; }

/* ---- Print: clean reports ------------------------------------------------- */
@media print {
  .mk-sidebar, .mk-topbar, .mk-scrim, .mk-footer, .mk-toasts, .mk-actions, .ops-actions, .ops-toolbar, .mk-filters,
  .ops-pagination, .no-print, .mk-crumbs, .mk-tabs { display: none !important; }
  .mk-app { display: block; }
  body.mk-body { background: #fff; font-size: 12px; }
  .mk-content { padding: 0; max-width: none; }
  .mk-card, .ops-card, .mk-stat, .ops-stat { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  a { color: inherit !important; text-decoration: none !important; }
  .mk-print-only { display: block !important; }
}
.mk-print-only { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .btn, .mk-btn, .badge { border: 1px solid CanvasText; }
  .mk-nav a[aria-current="page"] { outline: 2px solid Highlight; }
}

/* ---- Fixes found by the real-browser audit -------------------------------- */
/* An author `display` rule must never defeat the hidden attribute. */
[hidden] { display: none !important; }
/* Values such as file-system paths have no break points: wrap instead of overflowing. */
.mk-kv span:last-child { min-width: 0; overflow-wrap: anywhere; text-align: right; }
/* Links inside list rows sit next to body text: underline them (not colour alone). */
.mk-list .mk-list-main a { text-decoration: underline; text-underline-offset: 2px; }
/* Picture picker preview (student form). */
.mk-photo-preview {
  display: flex; align-items: center; gap: .8rem; padding: .8rem; border: 1px solid var(--mk-border);
  border-radius: var(--mk-radius-sm); background: #f8f9fc; margin-top: 1rem;
}
.mk-photo-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; }
/* Close button inside the phone drawer (the scrim and Escape also close it). */
.mk-nav-close {
  position: absolute; top: .55rem; right: .55rem; z-index: 2; background: rgba(255, 255, 255, .12);
  color: #fff; border-color: rgba(255, 255, 255, .3);
}
.mk-nav-close:hover { background: rgba(255, 255, 255, .22); }
@media (min-width: 1024px) { .mk-nav-close { display: none; } }
/* Stacked (phone) tables: a bold name in the first cell acts as the card heading, without its caption. */
@media (max-width: 719px) {
  table.mk-stack td:first-child:has(> strong, > a) { justify-content: flex-start; text-align: left; }
  table.mk-stack td:first-child:has(> strong, > a)::before { content: none; }
}
/* Form controls never outgrow their column (a textarea's `cols` width used to push 320px screens sideways). */
.mk-body :is(input, select, textarea):not([type=checkbox]):not([type=radio]) { max-width: 100%; box-sizing: border-box; }
/* A link that sits inside a sentence must not rely on colour alone (WCAG 1.4.1). */
.mk-content :is(p, li, dd, .alert, .mk-callout, small) a:not(.btn):not(.badge) { text-decoration: underline; text-underline-offset: 2px; }
/* Side-by-side cards of different heights keep their own height instead of stretching to the taller one. */
.mk-align-start { align-items: start; }
/* A linked title above a caption (deadline lists, group pages) sits on its own line like <strong> does. */
.mk-list .mk-list-main > a { display: block; overflow-wrap: anywhere; }
/* A small caption (date, score, room) under a list title is its own line, not run into the text after it. */
.mk-list .mk-list-main small { display: block; }

/* Quick links to the public-website work (Super Admin dashboard): count + label tiles. */
.mk-quick { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; }
.mk-quick a {
  display: grid; grid-template-columns: auto 1fr; column-gap: .75rem; align-items: center; padding: .8rem 1rem; text-decoration: none;
  color: var(--mk-text); background: var(--mk-bg); border: 1px solid var(--mk-border); border-radius: var(--mk-radius);
}
.mk-quick a:hover { border-color: var(--mk-secondary); background: var(--mk-primary-50); }
.mk-quick i { grid-row: span 2; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--mk-primary-50); color: var(--mk-primary); font-size: 1.2rem; }
.mk-quick strong { font-size: 1.3rem; line-height: 1.1; }
.mk-quick span { font-size: .8rem; color: var(--mk-muted); }
.mk-todo-row { margin-bottom: 1rem; }
.mk-todo-row .mk-list a { text-decoration: none; display: flex; gap: .5rem; align-items: center; }
.mk-todo-row .mk-list a i { color: var(--mk-secondary); }
/* Photograph supplied with an admission application (admission_detail.html). */
.mk-photo-row { display: flex; align-items: center; gap: .9rem; padding-bottom: 1rem; margin-bottom: .85rem; border-bottom: 1px solid var(--mk-border); }
.mk-photo { width: 96px; height: 96px; border-radius: var(--mk-radius-lg); object-fit: cover; background: var(--mk-bg); border: 1px solid var(--mk-border); flex: none; }
.mk-photo-row > div { min-width: 0; display: grid; gap: .3rem; justify-items: start; }
.mk-photo-row small { display: block; color: var(--mk-muted); }

/* Landing film manager (publicsite/manage/hero_list.html). */
.mk-film-tips { margin-top: 1rem; }
.mk-film-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1rem; margin-top: 1rem; }
.mk-film { display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: var(--mk-surface); border: 1px solid var(--mk-border); border-radius: var(--mk-radius-lg); }
.mk-film.is-live { border-color: var(--mk-accent); box-shadow: 0 0 0 3px var(--mk-accent-50); }
.mk-film video, .mk-film-empty { display: block; width: 100%; aspect-ratio: 16 / 9; background: #1b1450; object-fit: cover; }
.mk-film-empty { display: grid; place-items: center; color: #fff; font-weight: 700; }
.mk-film-body { display: grid; gap: .55rem; padding: .9rem 1rem 1rem; }
.mk-film-body h2 { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem; margin: 0; font-size: 1.02rem; }
.mk-film-note { margin: 0; color: var(--mk-muted); font-size: .85rem; }
.mk-film-meta { display: flex; flex-wrap: wrap; gap: .2rem .9rem; color: var(--mk-muted); font-size: .8rem; }
.mk-film-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.mk-film-logo { border-radius: 50%; object-fit: cover; }
.mk-film-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.mk-film-actions form { margin: 0; }
