:root{
  --bg:#f5f6fb;
  --panel:#fff;
  --panel-alt:#fcfcff;
  --primary:#4b2aad;
  --primary2:#5c39c0;
  --text:#1f2430;
  --muted:#69707d;
  --line:#e7e9f2;
  --accent:#ece5ff;
  --good:#dff5e8;
  --warn:#fff4d6;
  --danger:#ffe2e2;
}

.kairos-notif-wrap,
.kairos-user-wrap{
  position:relative;
  display:inline-block;
}

.user-avatar .kairos-avatar-initials{
  display:grid;
  width:100%;
  height:100%;
  place-items:center;
  background:linear-gradient(135deg,#4b2aad,#b54269);
  color:#fff;
  font-size:12px;
  font-weight:900;
  letter-spacing:.04em;
  text-transform:uppercase;
}

.kairos-notif-trigger{
  position:relative;
  width:36px;
  height:36px;
  border-radius:10px;
  background:#fafafe;
  border:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:160ms ease;
}

.kairos-notif-trigger:hover,
.kairos-user-box:hover{
  background:#f7f8fc;
}

.kairos-notif-trigger:focus-visible,
.kairos-user-box:focus-visible{
  outline:3px solid color-mix(in srgb,var(--primary) 38%,transparent);
  outline-offset:2px;
}

.kairos-notif-status{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

/* The canonical topbar owns notifications. A few legacy Super Admin documents
   still contain their former control, so suppress it after shell hydration. */
html.kairos-topbar-ready .topbar-right .sa-notify{
  display:none !important;
}

.kairos-notif-badge{
  position:absolute;
  top:-5px;
  right:-5px;
  min-width:18px;
  height:18px;
  padding:0 5px;
  border-radius:999px;
  background:var(--primary);
  color:#fff;
  font-size:10px;
  font-weight:700;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 4px 10px rgba(75,42,173,.18);
}

.kairos-notif-dropdown,
.kairos-user-dropdown{
  position:absolute;
  top:46px;
  right:0;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow:0 18px 40px rgba(31,36,48,0.12);
  overflow:hidden;
  display:none;
  z-index:9999;
}

.kairos-notif-dropdown{ width:390px; max-height:520px; }
.kairos-user-dropdown{ width:240px; }

.kairos-notif-dropdown.open,
.kairos-user-dropdown.open{
  display:block;
}

.kairos-notif-header{
  padding:18px 18px 14px 18px;
  border-bottom:1px solid var(--line);
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
}

.kairos-notif-eyebrow{
  margin:0 0 4px 0;
  font-size:12px;
  color:var(--muted);
}

.kairos-notif-title{
  margin:0;
  font-size:18px;
  font-weight:700;
  color:var(--text);
}

.kairos-notif-action{
  border:none;
  background:transparent;
  color:var(--primary);
  font-size:12px;
  font-weight:700;
  cursor:pointer;
  padding:0;
}

.kairos-notif-filters{
  padding:12px 18px;
  border-bottom:1px solid var(--line);
  display:flex;
  gap:8px;
}

.kairos-filter-chip{
  border:1px solid var(--line);
  background:#f7f8fc;
  color:var(--muted);
  border-radius:999px;
  padding:7px 12px;
  font-size:12px;
  font-weight:700;
  cursor:pointer;
  transition:160ms ease;
}

.kairos-filter-chip.active{
  background:var(--accent);
  color:var(--primary);
}

.kairos-notif-list{
  max-height:360px;
  overflow:auto;
  background:var(--panel);
}

.kairos-notif-item{
  padding:14px 18px;
  border-bottom:1px solid var(--line);
  background:var(--panel);
  cursor:pointer;
  transition:160ms ease;
  position:relative;
}

.kairos-notif-item:hover{ background:#fafafe; }
.kairos-notif-item.unread{ background:#f8f6ff; }

.kairos-notif-item.unread::before{
  content:"";
  position:absolute;
  left:0;
  top:10px;
  bottom:10px;
  width:4px;
  border-radius:0 999px 999px 0;
  background:var(--primary);
}

.kairos-notif-meta{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:8px;
}

.kairos-type-badge{
  display:inline-flex;
  align-items:center;
  padding:5px 10px;
  border-radius:999px;
  font-size:11px;
  font-weight:700;
  text-transform:capitalize;
}

.type-assignment{ background:var(--accent); color:var(--primary); }
.type-lesson{ background:#eef2ff; color:#4338ca; }
.type-student_alert{ background:var(--danger); color:#b42318; }
.type-message{ background:#eefaf3; color:#18794e; }
.type-attendance{ background:var(--warn); color:#9a6700; }
.type-ocr_review{ background:var(--warn); color:#9a6700; }
.type-grading{ background:var(--accent); color:var(--primary); }
.type-system{ background:#f3f4f6; color:#4b5563; }

.kairos-notif-time{
  font-size:11px;
  color:var(--muted);
  white-space:nowrap;
}

.kairos-notif-item-title{
  margin:0 0 6px 0;
  font-size:14px;
  font-weight:700;
  color:var(--text);
}

.kairos-notif-item-body{
  margin:0 0 8px 0;
  font-size:13px;
  line-height:1.45;
  color:var(--muted);
}

.kairos-notif-link{
  font-size:12px;
  font-weight:700;
  color:var(--primary);
}

.kairos-notif-footer{
  padding:12px 18px 14px 18px;
  background:var(--panel);
  display:flex;
  justify-content:flex-start;
}

.kairos-notif-footer a{
  text-decoration:none;
  color:var(--primary);
  font-size:12px;
  font-weight:700;
}

.kairos-notif-empty{
  padding:28px 18px;
  text-align:center;
}

.kairos-notif-empty h4{
  margin:0 0 8px 0;
  font-size:16px;
  color:var(--text);
}

.kairos-notif-empty p{
  margin:0;
  font-size:13px;
  color:var(--muted);
}

.kairos-user-box{
  display:flex;
  align-items:center;
  gap:8px;
  background:#fafafe;
  border:1px solid var(--line);
  border-radius:14px;
  padding:6px 8px;
  cursor:pointer;
  transition:160ms ease;
}

.kairos-user-menu-header{
  padding:14px 16px;
  border-bottom:1px solid var(--line);
  background:#fcfcff;
}

.kairos-user-menu-name{
  margin:0 0 4px 0;
  font-size:14px;
  font-weight:700;
  color:var(--text);
}

.kairos-user-menu-role{
  margin:0;
  font-size:12px;
  color:var(--muted);
}

.kairos-user-menu-list{
  display:flex;
  flex-direction:column;
  padding:8px 0;
}

.kairos-user-menu-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:11px 16px;
  text-decoration:none;
  color:var(--text);
  font-size:13px;
  font-weight:600;
  transition:160ms ease;
}

.kairos-user-menu-item:hover{ background:#fafafe; }
.kairos-user-menu-item.muted{ color:var(--muted); font-weight:600; }

.kairos-user-menu-divider{
  height:1px;
  background:var(--line);
  margin:8px 0;
}

.kairos-user-menu-item.logout{ color:#b42318; }

@media (max-width: 640px){
  .kairos-notif-dropdown{ width:min(92vw,390px); right:-10px; }
  .kairos-user-dropdown{ width:min(88vw,240px); right:-10px; }
}


/* === Topbar loading skeleton ===
   While the profile resolves, the topbar used to be visibility:hidden — a
   blank gap that reflowed into content, and on a cold cache that gap could
   last a school_ref dereference plus a second doc read. It now shows a
   shimmer skeleton in the shape of what is arriving: two logo/avatar
   blocks and four text bars. Same footprint, so nothing shifts when the
   real profile lands.

   Text is hidden with `color:transparent` rather than `visibility:hidden`
   so each bar keeps the exact width of the string it is standing in for,
   and screen readers still announce the live "Loading…"/"Not signed in"
   text underneath. */
@keyframes kairos-topbar-shimmer{
  0%{ background-position: 140% 0; }
  100%{ background-position: -140% 0; }
}
html:not(.kairos-topbar-ready) .school-logo,
html:not(.kairos-topbar-ready) .user-avatar,
html:not(.kairos-topbar-ready) .school-name,
html:not(.kairos-topbar-ready) .school-sub,
html:not(.kairos-topbar-ready) .user-name,
html:not(.kairos-topbar-ready) .user-role{
  color:transparent;
  /* background-color must be reset, not just overlaid: the logo/avatar chips
     carry an opaque light backing (so arbitrary school artwork stays legible)
     and the shimmer gradient is semi-transparent — left alone, that backing
     shows through and the skeleton reads as a solid white disc on the dark
     topbar instead of a shimmering placeholder. */
  background-color:rgba(125,125,160,.10);
  background-image:linear-gradient(
    100deg,
    rgba(125,125,160,0) 30%,
    rgba(125,125,160,.20) 50%,
    rgba(125,125,160,0) 70%
  );
  background-size:220% 100%;
  background-repeat:no-repeat;
  box-shadow:none;
  animation:kairos-topbar-shimmer 1.4s ease infinite;
  border-radius:8px;
}
/* The logo and avatar are round chips — keep their silhouette while empty. */
html:not(.kairos-topbar-ready) .school-logo,
html:not(.kairos-topbar-ready) .user-avatar{
  border-radius:999px;
}
/* Their <img> would otherwise paint a fallback over the shimmer. */
html:not(.kairos-topbar-ready) .school-logo img,
html:not(.kairos-topbar-ready) .user-avatar img{
  opacity:0;
}
.school-logo.kairos-image-loading,
.user-avatar.kairos-image-loading{
  background-color:rgba(125,125,160,.10)!important;
  background-image:linear-gradient(100deg,rgba(125,125,160,0) 30%,rgba(125,125,160,.20) 50%,rgba(125,125,160,0) 70%)!important;
  background-size:220% 100%!important;
  animation:kairos-topbar-shimmer 1.4s ease infinite;
}
.school-logo.kairos-image-loading img,
.user-avatar.kairos-image-loading img{opacity:0}
/* Text bars need a minimum width: an empty/short string would collapse to a
   sliver that reads as a glitch rather than a loading state. */
html:not(.kairos-topbar-ready) .school-name,
html:not(.kairos-topbar-ready) .user-name{ min-width:104px; }
html:not(.kairos-topbar-ready) .school-sub,
html:not(.kairos-topbar-ready) .user-role{ min-width:72px; }
/* The caret and notification bell carry no data — no skeleton, just quiet. */
html:not(.kairos-topbar-ready) .kairos-notif-trigger{ opacity:.45; }

@media (prefers-reduced-motion: reduce){
  html:not(.kairos-topbar-ready) .school-logo,
  html:not(.kairos-topbar-ready) .user-avatar,
  html:not(.kairos-topbar-ready) .school-name,
  html:not(.kairos-topbar-ready) .school-sub,
  html:not(.kairos-topbar-ready) .user-name,
  html:not(.kairos-topbar-ready) .user-role{
    animation:none;
  }
}

/* === Topbar shell base layout ===
   Defines the structural rules for the topbar and its child elements.
   topbar-shell.js targets these class names; they live here so pages
   don't need to redeclare them in page-local <style> blocks.        */
.topbar{
  background:#fff;
  border-bottom:1px solid var(--line);
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:12px 18px;
  gap:16px;
  position:sticky;
  top:0;
  z-index:60;
}
.topbar-left,.topbar-right{display:flex;align-items:center;gap:12px;}
.school-logo,.user-avatar{width:40px;height:40px;border-radius:999px;overflow:hidden;background:var(--accent,#ece5ff);flex-shrink:0;}
.school-logo img,.user-avatar img{width:100%;height:100%;object-fit:cover;display:block;}
.school-name,.user-name{font-weight:700;font-size:15px;color:var(--text,#1f2430);line-height:1.1;}
.school-sub,.user-role{font-size:11px;color:var(--muted,#69707d);line-height:1.1;}
.notif{position:relative;width:36px;height:36px;border-radius:10px;background:#fafafe;border:1px solid var(--line,#e7e9f2);display:flex;align-items:center;justify-content:center;}
.notif-badge{position:absolute;top:-5px;right:-5px;min-width:18px;height:18px;border-radius:999px;background:var(--primary,#4b2aad);color:#fff;font-size:10px;font-weight:700;display:flex;align-items:center;justify-content:center;padding:0 5px;}
.user-box{display:flex;align-items:center;gap:8px;background:#fafafe;border:1px solid var(--line,#e7e9f2);border-radius:14px;padding:6px 8px;}

/* === Topbar title + school pill (ENROLLMENT-INVITE A3) ===
   Octahedron's topbar (public/shared/css/octa-shell.css, [data-octa-topbar])
   shows a page title+subtitle next to a "school pill" (logo/name/location
   chip). Tetrahedron's topbar never had that — just the bare .school-logo/
   .school-name pair topbar-shell.js already populates from the real profile.

   This is purely ADDITIVE: two new wrapper classes, .tetra-topbar-title and
   .tetra-topbar-pill. Neither touches .topbar/.topbar-left/.school-logo/
   .school-name/.school-sub, so every page that does NOT opt in (all of them,
   until adopted page by page) renders byte-identical to before. A page opts
   in by wrapping its EXISTING .school-logo+.school-name markup in a
   .tetra-topbar-pill div and adding a .tetra-topbar-title block before it —
   topbar-shell.js keeps targeting the same inner class names, unaware of the
   new wrapper, so no JS changes were needed to add this. */
.tetra-topbar-title{
  display:flex; flex-direction:column; gap:2px; min-width:0;
  padding-right:12px; margin-right:2px; border-right:1px solid var(--line,#e7e9f2);
}
.tetra-topbar-title-main{
  font-weight:800; font-size:15px; color:var(--text,#1f2430); line-height:1.15;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:280px;
}
.tetra-topbar-title-sub{
  font-size:11px; color:var(--muted,#69707d); line-height:1.15;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:320px;
}
.tetra-topbar-pill{
  display:flex; align-items:center; gap:10px;
  padding:4px 10px 4px 4px; background:#fafafe; border:1px solid var(--line,#e7e9f2);
  border-radius:14px; min-width:0;
}
/* Inside the pill, the pre-existing .school-logo/.school-name/.school-sub
   need no size/color overrides — they already carry their own; the pill just
   frames them. Only tighten the outer gap the plain (unpilled) layout used. */
.tetra-topbar-pill .school-logo{width:32px;height:32px;}
