:root {
  /* --- Palette --- */
  --navy-950: #0b1929;
  --navy-900: #112236;
  --navy-800: #1a3a5c;
  --navy-700: #1e4976;
  --navy-600: #245d94;
  --teal-600: #0d7f7a;
  --teal-500: #0fa898;
  --teal-400: #2ec4b6;
  --teal-100: #d0f5f2;
  --teal-50:  #eafaf9;
  --blue-600: #2b4de0;
  --blue-500: #4361EE;
  --blue-400: #6b84f5;
  --blue-50:  #eff2ff;
  --red-600:  #c0392b;
  --red-500:  #e74c3c;
  --red-100:  #fde8e6;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;
  --green-500: #10b981;
  --green-100: #d1fae5;
  --grey-900: #111827;
  --grey-700: #374151;
  --grey-500: #6b7280;
  --grey-300: #d1d5db;
  --grey-100: #f3f4f6;
  --grey-50:  #f9fafb;
  --white:    #ffffff;

  /* --- Semantic aliases (primary names) --- */
  --color-primary:      var(--teal-500);
  --color-primary-dark: var(--teal-600);
  --color-secondary:    var(--navy-800);
  --color-accent:       var(--blue-500);
  --color-danger:       var(--red-500);
  --color-warn:         var(--amber-500);
  --color-success:      var(--green-500);
  --color-surface:      var(--white);
  --color-bg:           var(--grey-50);
  --color-text:         var(--grey-900);
  --color-muted:        var(--grey-500);
  --color-border:       var(--grey-300);

  /* --- Short aliases (for legacy rules — do not add new rules using these) --- */
  --bg:           var(--grey-50);
  --surface:      var(--white);
  --ink:          var(--grey-900);
  --muted:        var(--grey-500);
  --line:         var(--grey-300);
  --brand:        var(--teal-500);
  --brand-2:      var(--teal-600);
  --brand-deep:   var(--navy-800);
  --warn:         var(--amber-500);
  --danger:       var(--red-500);
  --ok:           var(--green-500);

  /* --- Typography --- */
  --sans:    "DM Sans", sans-serif;
  --mono:    "DM Mono", monospace;
  --heading: "Fraunces", serif;

  /* --- Spacing (4px base) --- */
  --sp-1: 4px;  --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px;  --sp-8: 32px;  --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* --- Radius --- */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-full: 9999px;

  /* --- Radius aliases (legacy — do not add new rules using these) --- */
  --radius-lg: var(--r-xl);
  --radius-md: var(--r-lg);
  --radius-sm: var(--r-md);

  /* --- Shadows --- */
  --shadow-xs:   0 1px 2px rgba(0,0,0,0.06);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg:   0 8px 40px rgba(0,0,0,0.14);
  --shadow:      var(--shadow-lg);
  --shadow-soft: var(--shadow-sm);
}

* { box-sizing: border-box; }
html {
  margin: 0;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  /* lock horizontal scroll globally */
  overflow-x: hidden;
  max-width: 100%;
}
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.portal-shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; width: 100%; max-width: 100%; }
.portal-rail { display: none; }
.portal-main { padding: 0 1rem calc(6rem + env(safe-area-inset-bottom)); width: 100%; max-width: 100%; min-width: 0; }
.ops-status-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  min-width: 0;
  flex-wrap: wrap;
}
.ops-topbar-copy {
  display: grid;
  gap: 0.14rem;
}
.ops-topbar-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #183253;
}
.ops-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.ops-create {
  min-width: 164px;
  background: rgba(255, 255, 255, 0.94);
}
.ops-status-pill {
  min-height: 38px;
  padding: 0.42rem 0.82rem;
  border-width: 1px;
  font-size: 0.78rem;
  box-shadow: none;
}
.portal-global-state {
  min-height: 0;
  margin: 0.7rem 0 0;
}
.portal-global-state .state-banner {
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 0.66rem 0.82rem;
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.84rem;
  color: #274365;
}
.portal-global-state .state-banner.success {
  border-color: #abdccb;
  background: #effcf7;
  color: #0e6a55;
}
.portal-global-state .state-banner.warning {
  border-color: #efcf9d;
  background: #fff9ef;
  color: #8f5300;
}
.portal-global-state .state-banner.danger {
  border-color: #efc0c0;
  background: #fff4f4;
  color: #a82222;
}
.portal-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-end;
  margin: 1.35rem 0 1rem;
}
.portal-head .meta { margin: 0.38rem 0 0; color: var(--muted); font-size: 0.93rem; max-width: 72ch; }
.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.69rem;
  font-weight: 700;
  color: var(--muted);
}
h1, h2, h3, h4 { margin: 0.2rem 0 0; }
h2 { font-size: 1.5rem; letter-spacing: -0.02em; }

.head-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.72rem 1rem;
  min-height: 46px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease;
}
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border-color: transparent;
}
.btn.emergency {
  background: linear-gradient(135deg, #d0162a, #f04a3d);
  color: #fff;
  border-color: transparent;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(14, 39, 76, 0.1);
}

.btn:focus-visible,
.nav-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 119, 199, 0.18);
}

.portal-view { display: none; gap: 1.1rem; }
.portal-view.active { display: grid; align-content: start; }
.state-loading,
.state-empty,
.state-error,
.state-offline,
.state-success {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.62rem 0.72rem;
  font-size: 0.84rem;
}
.state-loading,
.state-empty {
  background: #f8fbff;
  color: #314a6c;
}
.state-error {
  border-color: #efc0c0;
  background: #fff4f4;
  color: #a82222;
}
.state-offline {
  border-color: #efcf9d;
  background: #fff9ef;
  color: #8f5300;
}
.state-success {
  border-color: #abdccb;
  background: #effcf7;
  color: #0e6a55;
}

.tab-ux-rail {
  display: grid;
  gap: 0.75rem;
}

.next-action-card {
  border: 1px solid #d1dff5;
  border-left-width: 6px;
  border-radius: 22px;
  padding: 1.05rem 1.08rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.96));
  box-shadow: none;
}
.next-action-card h3 {
  margin: 0.24rem 0 0.28rem;
  font-size: clamp(1.12rem, 3.2vw, 1.42rem);
  letter-spacing: -0.03em;
}
.next-action-card .meta {
  margin: 0.25rem 0 0;
  color: #294a72;
  font-size: 0.92rem;
}
.next-action-card .next-action-actions {
  margin-top: 0.55rem;
}
.next-action-card .next-action-blockers {
  margin-top: 0.48rem;
  border-radius: 10px;
  border: 1px solid #f0d3a3;
  background: #fff8ef;
  padding: 0.45rem 0.52rem;
}
.next-action-card .next-action-blockers ul {
  margin: 0.3rem 0 0;
  padding-left: 1rem;
  color: #7a4b00;
}
.next-action-card.tone-success {
  border-left-color: var(--green-500);
  background: var(--white);
}
.next-action-card.tone-info {
  border-left-color: var(--blue-500);
  background: var(--white);
}
.next-action-card.tone-warning {
  border-left-color: var(--amber-500);
  background: var(--white);
}
.next-action-card.tone-danger {
  border-left-color: var(--red-500);
  background: var(--white);
}

.form-gate-message {
  margin-bottom: 0.55rem;
  border-radius: 10px;
  border: 1px solid #e2c88e;
  background: #fff8ee;
  color: #7c4e00;
  padding: 0.48rem 0.58rem;
}
.form-gate-message .form-gate-title {
  margin: 0;
  font-weight: 800;
}
.form-gate-message ul {
  margin: 0.3rem 0 0;
  padding-left: 1rem;
}
.form-gate-message .form-gate-recovery {
  margin: 0.32rem 0 0;
  font-size: 0.82rem;
}
.form-gate-message.success {
  border-color: #b4e4cf;
  background: #eefcf6;
  color: #0f6a4c;
}
.form-gate-message.info {
  border-color: #c7dbf9;
  background: #eef5ff;
  color: #1c4d95;
}
.form-gate-message.warning {
  border-color: #efcf9d;
  background: #fff9ef;
  color: #875200;
}
.form-gate-message.danger {
  border-color: #efc0c0;
  background: #fff4f4;
  color: #9f2323;
}

.tab-overview {
  border-radius: 22px;
  padding: 1rem 1.05rem;
  border: 1px solid #ccdaee;
  background:
    radial-gradient(circle at 10% 0, rgba(73, 176, 223, 0.12) 0%, rgba(73, 176, 223, 0) 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(246, 249, 255, 0.95) 100%);
}

.tab-overview-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.72rem;
  margin-bottom: 0.6rem;
}

.tab-overview-head h3 {
  margin: 0.18rem 0 0;
  font-size: clamp(1.05rem, 3.8vw, 1.34rem);
  letter-spacing: -0.03em;
}

.tab-overview-head .meta {
  margin: 0.3rem 0 0;
  color: #355170;
  max-width: 72ch;
}

.tab-overview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.tab-overview-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.tab-overview-metric {
  border: 1px solid #d7e2f0;
  border-radius: 16px;
  padding: 0.72rem 0.78rem;
  background: rgba(255, 255, 255, 0.84);
}

.tab-overview-metric .meta {
  margin: 0;
  font-size: 0.76rem;
  color: #526887;
}

.tab-overview-metric .value {
  margin: 0.22rem 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #1b3559;
}

.tab-overview-metric.warning {
  border-color: #efcf9d;
  background: #fffaf2;
}

.tab-overview-metric.success {
  border-color: #abdccb;
  background: #f2fcf8;
}

.tab-overview-metric.danger {
  border-color: #efc0c0;
  background: #fff6f6;
}

.tab-overview-actions {
  margin-top: 0.62rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.tab-state-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.48rem;
}

.tab-state-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.76rem 0.82rem;
  background: rgba(248, 251, 255, 0.8);
}

.tab-state-card p {
  margin: 0.18rem 0 0;
  font-size: 0.84rem;
}

.tab-state-card.state-info {
  border-color: #c8d9fb;
  background: #eef5ff;
  color: #1d4f9e;
}

.tab-state-card.state-warning {
  border-color: #f2d7a9;
  background: #fff7eb;
  color: #a05a00;
}

.tab-state-card.state-danger {
  border-color: #efc4c8;
  background: #fff1f1;
  color: #b4232a;
}

.tab-state-card.state-success {
  border-color: #b5e7d2;
  background: #edf9f4;
  color: #0f7a54;
}

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem;
}
.card-head { display: flex; justify-content: space-between; gap: 0.4rem; align-items: center; margin-bottom: 0.45rem; }
.card-head h3 { letter-spacing: -0.01em; }
.card-body { display: grid; gap: 0.55rem; }
.chip {
  border: 1px solid #d6e3f8;
  border-radius: 999px;
  padding: 0.2rem 0.52rem;
  font-size: 0.72rem;
  background: #f7fbff;
  color: #32476b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  white-space: nowrap;
  font-weight: 600;
}
.badge {
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
  font-size: 0.72rem;
  border: 1px solid #d6e3f8;
  background: #f7fbff;
  color: #2f456a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  white-space: nowrap;
  font-weight: 600;
}
.badge.ok { color: var(--ok); border-color: #98dfd0; background: #eefcf8; }
.badge.warn { color: #b45309; border-color: var(--amber-500); background: var(--amber-100); }
.badge.danger { color: var(--danger); border-color: #f0b9b9; background: #fff5f5; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
.kpi {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.68rem;
  background: linear-gradient(180deg, #ffffff 0%, #f6fbff 100%);
  min-width: 0;
}
.kpi p { margin: 0; }
.kpi .meta { font-size: 0.76rem; color: var(--muted); }
.kpi .value { font-size: 1.2rem; font-weight: 800; }
.alert-banner {
  border: 1px solid #f0b9b9;
  border-radius: var(--radius-sm);
  background: #fff5f5;
  color: var(--danger);
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.55rem;
  font-weight: 700;
}

.list { display: grid; gap: 0.42rem; }
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfdff;
  padding: 0.55rem;
}
.row p { margin: 0; }
.row .meta { color: var(--muted); font-size: 0.82rem; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 0.56rem 0.62rem; text-align: left; border-bottom: 1px solid #eaf0f8; font-size: 0.9rem; }
th { background: #f5f9ff; position: sticky; top: 0; z-index: 2; }
.mono { font-family: var(--mono); font-size: 0.76rem; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 0.45rem; }
.picker-grid {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  max-height: 180px;
  overflow: auto;
  background: #fbfdff;
}

/* ── Child chip picker — replaces checkbox grid & select[multiple] ── */
.child-chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1.5px solid #d4e2f4;
  border-radius: 14px;
  background: #f8fbff;
}
.child-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px 6px 8px;
  border: 1.5px solid #c8d7ee;
  border-radius: 999px;
  cursor: pointer;
  background: #fff;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  color: #2a4870;
}
.child-chip input[type="checkbox"] {
  /* visually hidden — chip itself is the affordance */
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.child-chip:has(input:checked) {
  background: var(--teal-500);
  border-color: var(--teal-600);
  color: #fff;
}
.child-chip:has(input:checked) .child-chip-av {
  background: rgba(255,255,255,0.25);
  color: #fff;
}
.child-chip-av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #dbeeff;
  color: var(--navy-800);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
}
.child-chip-name { white-space: nowrap; }
.outcomes-grid {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  background: linear-gradient(135deg, #f8fbff, #f2f8ff);
}
.outcome-tile {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  border: 1px solid #d9e4f7;
  border-radius: 12px;
  padding: 0.6rem;
  background: #fff;
  cursor: pointer;
  transition: 140ms ease;
}
.outcome-tile:hover {
  border-color: #b7c9ea;
  box-shadow: 0 7px 18px rgba(26, 71, 138, 0.08);
}
.outcome-tile.selected {
  border-color: #82c7b5;
  background: linear-gradient(135deg, #eefcf8, #f4fffb);
  box-shadow: 0 8px 18px rgba(13, 126, 101, 0.14);
}
.outcome-tile input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex: 0 0 auto;
}
.outcome-copy {
  display: grid;
  gap: 0.1rem;
}
.outcome-copy strong {
  font-size: 0.9rem;
  color: #123257;
}
.outcome-copy small {
  font-size: 0.77rem;
  line-height: 1.3;
  color: var(--muted);
}
.nappy-flow {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}
.nappy-section {
  border: 1px solid #dbe6f8;
  border-radius: 12px;
  background: linear-gradient(135deg, #f9fcff, #f5faff);
  padding: 0.62rem;
  display: grid;
  gap: 0.48rem;
}
.nappy-section-head {
  display: flex;
  justify-content: space-between;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}
.nappy-section-head h4 {
  margin: 0;
  font-size: 0.92rem;
  color: #17365d;
}
.hygiene-grid .outcome-tile {
  min-height: 72px;
}
.hygiene-grid .outcome-tile.selected {
  border-color: #82c7b5;
  background: linear-gradient(135deg, #eefcf8, #f4fffb);
  box-shadow: 0 8px 18px rgba(13, 126, 101, 0.14);
}
label { display: grid; gap: 0.3rem; font-size: 0.84rem; color: #294062; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.72rem 0.8rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
textarea { resize: vertical; }
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(20, 112, 194, 0.52);
  box-shadow: 0 0 0 3px rgba(28, 116, 205, 0.12);
}
label.full { grid-column: 1 / -1; }
.actions { display: flex; gap: 0.42rem; flex-wrap: wrap; margin-top: 0.45rem; }

.morning-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(242, 248, 255, 0.96), rgba(244, 255, 249, 0.96));
}
.morning-progress {
  min-width: 76px;
  text-align: center;
  padding: 0.52rem 0.68rem;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.task-tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.task-tile {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem;
  background: #fbfdff;
  cursor: pointer;
  transition: 140ms ease;
}
.task-tile.checked {
  border-color: #8fd4c6;
  background: linear-gradient(135deg, #effcf8, #f5fffb);
  box-shadow: 0 8px 18px rgba(19, 153, 125, 0.12);
}
.task-tile input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex: 0 0 auto;
}
.task-tile span {
  color: #213a5a;
  font-size: 0.86rem;
  line-height: 1.35;
}
.task-rail {
  display: grid;
  gap: 0.5rem;
}
.task-row {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: flex-start;
  border: 1px solid rgba(211, 223, 241, 0.95);
  border-radius: 16px;
  padding: 0.78rem 0.82rem;
  background: rgba(251, 253, 255, 0.94);
}
.task-row h4 {
  margin: 0;
  font-size: 0.9rem;
  color: #17385c;
}
.task-row p {
  margin: 0.24rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}
.task-row.warn {
  border-color: #efcf9d;
  background: #fffaf1;
}
.task-row.danger {
  border-color: #efc0c0;
  background: #fff5f5;
}
.task-row.info {
  border-color: #c9daf2;
  background: #f6faff;
}

.checklist-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  overflow: hidden;
}
.checklist-title {
  padding: 0.55rem 0.7rem;
  font-weight: 800;
  color: #16355a;
  background: linear-gradient(135deg, #eef6ff, #f6fbff);
  border-bottom: 1px solid #dde8f8;
}
.checklist-table-wrap {
  overflow: auto;
  max-height: 420px;
}
.checklist-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
.checklist-table th,
.checklist-table td {
  border-bottom: 1px solid #e5edf9;
  border-right: 1px solid #eaf0fa;
  padding: 0.5rem 0.52rem;
  vertical-align: top;
  font-size: 0.86rem;
}
.checklist-table th:first-child,
.checklist-table td:first-child {
  min-width: 360px;
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
}
.checklist-table thead th {
  background: #f4f8ff;
  color: #39557b;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 3;
}
.checklist-table thead th:first-child {
  z-index: 4;
  background: #edf5ff;
}
.checklist-table .check-cell {
  text-align: center;
  width: 46px;
}
.checklist-table .check-cell input {
  width: 18px;
  height: 18px;
}
.checklist-table .check-cell.muted-day {
  color: #adc0dd;
}
.checklist-table .check-cell.active-day {
  background: #f2f9f4;
}
.check-index {
  color: #5e7291;
  font-weight: 700;
  margin-right: 0.3rem;
}

.mobile-nav {
  display: none;
}

.capture-fab {
  position: fixed;
  right: 0.85rem;
  bottom: calc(5.8rem + env(safe-area-inset-bottom));
  z-index: 40;
  border: 0;
  border-radius: 999px;
  min-height: 48px;
  padding: 0.7rem 1rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(20, 56, 102, 0.24);
}

.sr-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  clip: rect(0, 0, 0, 0);
  overflow: hidden;
}
.nav-btn {
  border: 0;
  border-radius: 12px;
  background: rgba(244, 248, 255, 0.72);
  font-size: 0.75rem;
  font-weight: 700;
  color: #3f5578;
  min-height: 44px;
  padding: 0.52rem 0.3rem;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}
.nav-btn.active { background: linear-gradient(135deg, rgba(225, 248, 242, 0.96), rgba(232, 242, 255, 0.96)); color: #0d5a5e; }
.nav-btn:hover { transform: translateY(-1px); }

.capture-dialog { border: 1px solid var(--line); border-radius: 16px; width: min(640px, 94vw); }
.capture-dialog::backdrop { background: rgba(8, 18, 34, 0.5); }
.capture-dialog form { padding: 1rem; }
.emergency-dialog form {
  display: grid;
  gap: 0.6rem;
}
.dialog-actions { margin-top: 0.6rem; display: flex; justify-content: flex-end; gap: 0.4rem; }
.capture-preview {
  display: grid;
  gap: 0.45rem;
}
#captureLivePreview {
  width: 100%;
  min-height: 120px;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0c1b31;
}

.resource-list {
  display: grid;
  gap: 0.5rem;
}
.resource-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  padding: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.resource-item p {
  margin: 0;
}
.emergency-item {
  border-color: #f2c2c2;
  background: linear-gradient(135deg, #fff7f7, #fff);
}

.portal-collapsible .card-head.is-collapsible-head {
  cursor: pointer;
  position: relative;
  padding-right: 1.8rem;
  min-height: 36px;
}

.portal-collapsible .card-head.is-collapsible-head::after {
  content: "▾";
  position: absolute;
  right: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #c9d8f4;
  background: linear-gradient(135deg, #f6f9ff, #eef5ff);
  color: #284475;
  font-size: 0.8rem;
  line-height: 1;
}

.portal-collapsible.is-collapsed .card-head.is-collapsible-head::after {
  content: "▸";
}

.portal-collapsible.is-collapsed .card-body {
  display: none;
}

.template-command .card,
.template-inbox .card,
.template-form .card {
  background: transparent;
}

.tab-ux-rail {
  gap: 0.75rem;
}

.next-action-card {
  border-radius: 22px;
  padding: 1.05rem 1.08rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(249, 251, 255, 0.97));
  box-shadow: none;
}

.tab-overview {
  border-radius: 22px;
  padding: 1rem 1.05rem;
  border: 1px solid rgba(203, 215, 234, 0.92);
  background:
    radial-gradient(circle at 12% 0, rgba(100, 200, 220, 0.13) 0%, rgba(100, 200, 220, 0) 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.99) 0%, rgba(245, 249, 255, 0.95) 100%);
  box-shadow: none;
}

.tab-overview-metric {
  border: 1px solid rgba(209, 223, 245, 0.95);
  border-radius: 16px;
  padding: 0.72rem 0.76rem;
  background: rgba(255, 255, 255, 0.78);
}

.tab-state-card {
  border: 1px solid rgba(206, 219, 239, 0.92);
  border-radius: 16px;
  padding: 0.72rem 0.78rem;
  background: rgba(248, 251, 255, 0.82);
}

.card {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
  padding: 0;
  border-bottom: 0;
  align-items: baseline;
}

.module-section {
  display: grid;
  gap: 0.65rem;
  padding: 0.25rem 0 0.95rem;
  border-top: 1px solid rgba(210, 222, 241, 0.9);
}

.module-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.module-section > .card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: baseline;
  justify-content: space-between;
}

.card-head h3 {
  font-size: clamp(1rem, 2vw, 1.28rem);
  margin: 0;
}

.card-body {
  margin-left: 0;
  padding: 0;
  border-left: 0;
  display: grid;
  gap: 0.8rem;
}

.workspace-grid,
.workspace-main,
.workspace-aside,
.workspace-stack {
  display: grid;
  gap: 1.1rem;
  align-content: start;
}

.workspace-main,
.workspace-aside,
.workspace-stack,
.portal-view > .grid-2,
.portal-view > .room-support-grid {
  padding: 1rem 1.05rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(247, 250, 255, 0.84));
  border: 1px solid rgba(203, 215, 234, 0.94);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
}

.workspace-panel {
  display: grid;
  gap: 0.75rem;
  padding: 0 0 0.95rem;
  border-top: 1px solid rgba(206, 220, 242, 0.86);
}

.workspace-panel:first-child {
  border-top: 0;
  padding-top: 0;
}

.kpi {
  border: 1px solid rgba(212, 223, 239, 0.96);
  border-radius: 16px;
  padding: 0.88rem;
  background: rgba(255, 255, 255, 0.82);
}

.row {
  border: 1px solid rgba(209, 223, 245, 0.88);
  border-radius: 14px;
  background: rgba(251, 253, 255, 0.92);
  padding: 0.72rem 0.75rem;
}

.portal-view > section:not(.tab-ux-rail) {
  position: relative;
}

.portal-view > section:not(.tab-ux-rail)::before {
  display: none;
}

.grid-2 {
  grid-template-columns: 1fr;
  gap: 1.1rem;
}

.chip {
  border: 0;
  border-radius: 999px;
  padding: 0.24rem 0.6rem;
  background: transparent;
  color: #60779a;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.table-wrap,
.resource-item,
.row,
.kpi,
.tab-overview-metric {
  box-shadow: none;
}

.table-wrap {
  border-width: 1px 0 0;
  border-style: solid;
  border-color: rgba(212, 224, 242, 0.95);
  border-radius: 0;
  background: transparent;
}

table {
  background: transparent;
}

th,
td {
  padding: 0.68rem 0.72rem;
}

th {
  font-size: 0.78rem;
  color: #536987;
  background: rgba(244, 248, 255, 0.94);
}

.row {
  border-width: 0 0 1px;
  border-radius: 0;
  background: transparent;
  padding: 0.68rem 0;
}

.row:last-child {
  border-bottom: 0;
}

.row.is-unread {
  background: rgba(13, 148, 136, 0.06);
  border-left: 3px solid #0d9488;
  padding-left: calc(0.9rem - 3px);
}

.resource-item {
  border-width: 0 0 1px;
  border-radius: 0;
  background: transparent;
  padding: 0.72rem 0;
}

.resource-item:last-child {
  border-bottom: 0;
}

@media (max-width: 760px) {
  .global-topbar {
    grid-template-columns: 1fr;
    padding-top: calc(0.72rem + env(safe-area-inset-top));
  }
  .ops-status-wrap {
    align-items: flex-start;
    justify-content: flex-start;
  }
  .ops-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
  }
  .ops-actions > * {
    flex: initial;
    min-width: 0;
  }
  .ops-actions .ops-create {
    grid-column: 1 / -1;
    width: 100%;
  }
  .tab-overview-head {
    flex-direction: column;
  }
  .tab-overview-chips {
    justify-content: flex-start;
  }
  .tab-overview-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .portal-main {
    padding: 0.7rem 0.7rem 1rem;
  }
  .portal-head {
    flex-direction: column;
    align-items: stretch;
  }
  .head-actions {
    width: 100%;
    display: flex !important;
    flex-direction: column;
    gap: 0.45rem;
  }
  .head-actions .btn {
    width: 100%;
    min-width: 0;
    text-align: center;
    padding-inline: 0.6rem;
    font-size: 0.84rem;
    line-height: 1.15;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .actions .btn {
    flex: 1 1 180px;
  }
  .row {
    flex-direction: column;
    align-items: stretch;
  }
  .task-row {
    align-items: stretch;
  }
  .morning-head {
    flex-direction: column;
    align-items: stretch;
  }
  .morning-progress {
    width: 100%;
  }
  .task-tile {
    padding: 0.72rem;
  }
  .portal-collapsible .card-head.is-collapsible-head {
    min-height: 42px;
    padding-right: 2rem;
  }
  .portal-collapsible .card-head.is-collapsible-head::after {
    width: 1.35rem;
    height: 1.35rem;
    right: 0.15rem;
  }
  input,
  select,
  textarea {
    font-size: 16px;
  }
  table {
    min-width: 520px;
  }
  .capture-dialog {
    width: calc(100vw - 1rem);
    max-height: 90vh;
  }
  .capture-dialog form {
    padding: 0.75rem;
  }
  .workspace-main,
  .workspace-aside,
  .workspace-stack,
  .portal-view > .grid-2,
  .portal-view > .room-support-grid {
    padding: var(--sp-4);
  }
  .module-section > .card-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 420px) {
  .kpis {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 860px) {
  .tab-ux-rail {
    grid-template-columns: minmax(290px, 0.9fr) minmax(0, 1.3fr);
    align-items: start;
  }
  .tab-ux-rail .next-action-card {
    position: sticky;
    top: 5.4rem;
  }
  .tab-ux-rail .tab-overview {
    min-height: 100%;
  }
  .tab-ux-rail .tab-state-grid {
    grid-column: 1 / -1;
  }
  .tab-state-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tab-overview-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .workspace-grid.workspace-grid-dashboard {
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  }
  .workspace-grid.workspace-grid-room {
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.86fr);
  }
  .portal-shell { grid-template-columns: 164px 1fr; }
  .portal-rail {
    display: block;
    background: var(--navy-900);
    color: #ecf5ff;
    border-right: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 26px;
    padding: 1rem 0.95rem;
    box-shadow: 0 24px 54px rgba(10, 26, 52, 0.22);
  }
  .brand-wrap { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.1rem; }
  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--teal-500);
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
  }
  .portal-rail .kicker { color: rgba(240, 248, 255, 0.86); }
  .portal-rail h1 { margin: 0.2rem 0 0; font-size: 1.08rem; }
  .side-nav { display: grid; gap: 0.42rem; }
  .side-nav .nav-btn {
    text-align: left;
    color: #d8e8ff;
    border: 1px solid rgba(200, 220, 255, 0.22);
    border-radius: 14px;
    padding: 0.78rem 0.82rem;
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.9rem;
  }
  .side-nav .nav-btn.active {
    color: var(--white);
    background: var(--teal-500);
    border-color: transparent;
    box-shadow: none;
  }
  .mobile-nav { display: none; }
  .capture-fab { display: none; }
  .portal-main { padding: 1.15rem 1.3rem 1.4rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .picker-grid { grid-template-columns: 1fr 1fr; }
  .outcomes-grid { grid-template-columns: 1fr 1fr; }
  .task-tile-grid { grid-template-columns: 1fr 1fr; }
}

/* Guide-aligned educator shell */
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
}

.portal-shell {
  background: var(--bg);
}
@media (min-width: 861px) {
  .portal-shell {
    background:
      linear-gradient(90deg, var(--navy-900) 0, var(--navy-900) 164px, transparent 164px),
      var(--bg);
  }
}

.global-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: center;
  background: var(--navy-900);
  border: 0;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
}

.ops-topbar-copy .kicker,
.portal-head .kicker,
.next-action-card .kicker,
.card-label,
.chip {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ops-topbar-copy .kicker {
  color: var(--teal-400);
}

.ops-topbar-title {
  color: var(--white);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
}

.ops-create {
  border: none;
  border-radius: var(--r-md);
  background: var(--white);
  color: var(--grey-900);
  padding: 7px 12px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
}

.ops-status-pill {
  border-radius: var(--r-full);
  border: none;
  padding: 3px 10px;
  min-height: 0;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
}

.ops-status-pill.success {
  background: var(--green-500);
  color: var(--white);
}

.ops-status-pill.warning {
  background: var(--amber-500);
  color: var(--white);
}

.ops-status-pill.danger {
  background: var(--red-500);
  color: var(--white);
}

.ops-status-pill.info {
  background: var(--blue-500);
  color: var(--white);
}

.portal-global-state .state-banner {
  border: 0;
  border-radius: var(--r-md);
  box-shadow: none;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
}

.portal-global-state .state-banner.success {
  background: var(--green-100);
  color: var(--color-success);
}

.portal-global-state .state-banner.warning {
  background: var(--amber-100);
  color: #78350f;
}

.portal-global-state .state-banner.danger {
  background: var(--red-100);
  color: var(--red-600);
}

.portal-head {
  margin: var(--sp-5) 0 var(--sp-6);
}

#welcomeHeading {
  font-family: var(--heading);
  font-size: 36px;
  font-weight: 300;
  line-height: 1.18;
  color: var(--navy-800);
  letter-spacing: 0;
  margin-top: 4px;
}

#welcomeHeading em {
  font-style: italic;
  color: var(--teal-500);
}

.portal-head .meta {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--grey-500);
  margin-top: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  min-height: unset;
  border-radius: var(--r-md);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  border: none;
  box-shadow: none;
}

.btn.primary {
  background: var(--teal-500);
  color: var(--white);
}

.btn.primary:hover:not(:disabled) {
  background: var(--teal-600);
  box-shadow: 0 4px 14px rgba(15,168,152,.35);
}

.btn:not(.primary):not(.danger):not(.emergency) {
  background: transparent;
  color: var(--teal-500);
  border: 1.5px solid var(--teal-400);
}

.btn:not(.primary):not(.danger):not(.emergency):hover:not(:disabled) {
  background: var(--teal-50);
  box-shadow: none;
}

.btn.emergency {
  background: var(--red-500);
  color: var(--white);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
}

.btn.emergency:hover:not(:disabled) {
  background: var(--red-600);
  box-shadow: none;
}

.portal-main {
  padding: var(--sp-4) var(--sp-6) calc(6rem + env(safe-area-inset-bottom));
}

.workspace-main,
.workspace-aside,
.workspace-stack,
.portal-view > .grid-2,
.portal-view > .room-support-grid {
  padding: var(--sp-6);
  background: var(--white);
  border: 1px solid var(--grey-100);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.next-action-card {
  background: var(--white);
  border: 1px solid var(--grey-100);
  border-left: 4px solid var(--amber-500);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}

.next-action-card .kicker {
  color: var(--amber-500);
  margin-bottom: 8px;
}

.next-action-card h3 {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-800);
  margin-bottom: 8px;
}

.next-action-card .meta {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--grey-500);
  line-height: 1.5;
}

.next-action-card .next-action-blockers {
  background: var(--amber-100);
  border: 0;
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.next-action-card .next-action-blockers ul {
  color: var(--color-warn);
  font-size: 12px;
}

.tab-overview {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  border: 1px solid var(--grey-100);
  box-shadow: var(--shadow-sm);
}

.tab-overview-head h3 {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--navy-800);
}

.tab-overview-head .meta {
  font-size: 12px;
  color: var(--grey-500);
}

.tab-overview-metric {
  background: var(--grey-50);
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
}

.tab-overview-metric .value {
  font-family: var(--sans);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--navy-800);
}

.tab-overview-metric .meta {
  font-size: 11px;
  color: var(--grey-500);
}

.tab-state-card {
  border-radius: 8px;
  border: 0;
  padding: 8px 16px;
  font-size: 12px;
  box-shadow: none;
}

.tab-state-card .kicker {
  color: inherit;
}

.tab-state-card.state-success {
  background: var(--green-100);
  color: var(--color-success);
}

.tab-state-card.state-warning {
  background: var(--amber-100);
  color: var(--color-warn);
}

.tab-state-card.state-danger {
  background: var(--red-100);
  color: var(--red-600);
}

.tab-state-card.state-info {
  background: var(--blue-50);
  color: var(--blue-600);
}

.module-section {
  border-top: 1px solid var(--grey-100);
}

.module-section > .card-head {
  align-items: center;
  margin-bottom: var(--sp-4);
}

.card-head h3 {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-800);
  margin: 0;
  letter-spacing: 0;
}

.chip {
  background: var(--teal-50);
  color: var(--teal-600);
  border: 1px solid var(--teal-100);
  border-radius: var(--r-full);
  padding: 2px 8px;
}

.kpi {
  background: var(--grey-50);
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
}

.kpi .meta {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--grey-500);
}

.kpi .value {
  font-family: var(--sans);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--navy-800);
}

label {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--grey-700);
}

input,
select,
textarea {
  border: 1.5px solid var(--grey-300);
  border-radius: var(--r-md);
  background: var(--white);
  color: var(--grey-900);
  padding: 9px 12px;
  box-shadow: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(15,168,152,.15);
}

.row,
.resource-item {
  border-color: var(--grey-100);
}

.table-wrap {
  border-color: var(--grey-100);
}

th {
  background: var(--grey-50);
  color: var(--grey-500);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}

.nav-btn {
  font-family: var(--sans);
}

@media (max-width: 768px) {
  .portal-shell {
    background: var(--bg);
  }

  .global-topbar {
    border-radius: 0;
    margin-top: 0;
    padding: var(--sp-3) var(--sp-4);
  }

  .portal-main {
    padding: var(--sp-4) var(--sp-4) var(--sp-6);
  }

  #welcomeHeading {
    font-size: 22px;
  }

  .mobile-nav {
    background: var(--navy-950);
    display: flex;
    gap: var(--sp-2);
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0 calc(-1 * var(--sp-4)) var(--sp-4);
    padding: var(--sp-2) var(--sp-4);
    border-top: 0;
    border-radius: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .mobile-nav::-webkit-scrollbar {
    display: none;
  }

  .mobile-nav .nav-btn {
    background: transparent;
    color: rgba(255,255,255,0.5);
    border: none;
    border-radius: var(--r-full);
    flex: 0 0 auto;
    min-width: max-content;
    min-height: 40px;
    padding: 8px 14px;
    white-space: nowrap;
  }

  .mobile-nav .nav-btn.active {
    background: var(--teal-500);
    color: var(--white);
    border-radius: var(--r-full);
  }

  .capture-fab {
    display: none;
  }

  .ops-actions > .btn,
  .actions .btn,
  .dialog-actions .btn {
    width: 100%;
  }

  .tab-overview-metrics,
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ═══════════════════════════════════════════════════════
   EP SHELL REDESIGN — dark navy sidebar + module headers
   ═══════════════════════════════════════════════════════ */

/* Sidebar nav icons */
.ep-nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  display: inline-block;
}
.side-nav .nav-btn {
  display: flex !important;
  align-items: center;
  gap: 9px;
}
.ep-sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  margin-top: auto;
}
.ep-sidebar-edu {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  line-height: 1.3;
}
.ep-sidebar-edu-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-500);
  flex-shrink: 0;
}

/* Module hero — dark navy full-width banner */
.ep-hero {
  background: #0b1929;
  color: #fff;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.ep-hero-kicker {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--teal-400);
  margin: 0 0 4px;
}
.ep-hero-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  margin: 0 0 3px;
  font-family: var(--sans);
}
.ep-hero-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  margin: 0;
}
.ep-hero-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.ep-hero-live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 4px 10px;
}
.ep-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-500);
  flex-shrink: 0;
  animation: ep-pulse 2.2s ease-in-out infinite;
}
@keyframes ep-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.55; transform: scale(0.8); }
}
.ep-hero-alert {
  font-size: 11px;
  font-weight: 700;
  color: #fecaca;
  background: rgba(220,38,38,0.2);
  border: 1px solid rgba(220,38,38,0.35);
  border-radius: 20px;
  padding: 4px 10px;
}

/* KPI strip below hero */
.ep-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 1px;
  background: var(--grey-100);
  border-bottom: 1px solid var(--grey-100);
}
.ep-kpi-card {
  background: #fff;
  padding: 14px 16px;
  cursor: default;
  transition: background 0.15s;
}
.ep-kpi-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--grey-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 5px;
}
.ep-kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 2px;
  line-height: 1;
  font-family: var(--sans);
}
.ep-kpi-meta {
  font-size: 10px;
  color: var(--grey-400);
  margin: 0;
}
.ep-kpi-card.warn .ep-kpi-value  { color: #b45309; }
.ep-kpi-card.danger .ep-kpi-value { color: #dc2626; }
.ep-kpi-card.ok .ep-kpi-value    { color: #059669; }

/* Module header bar */
.ep-mod-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: 50px;
  background: #0f172a;
  flex-shrink: 0;
}
.ep-mod-title {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  letter-spacing: -0.01em;
}
.ep-mod-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(15,168,152,0.2);
  color: var(--teal-400);
  border: 1px solid rgba(15,168,152,0.3);
  font-family: var(--mono);
}
.ep-mod-spacer { flex: 1; }
.ep-mod-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  font-family: var(--sans);
}
.ep-mod-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }
.ep-mod-btn.primary {
  background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
  border-color: transparent;
  color: #fff;
}

/* Tab strip */
.ep-tab-strip {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--grey-100);
  background: #fff;
  overflow-x: auto;
  padding: 0 16px;
  flex-shrink: 0;
  scrollbar-width: none;
}
.ep-tab-strip::-webkit-scrollbar { display: none; }
.ep-tab-btn {
  flex-shrink: 0;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--grey-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--sans);
  white-space: nowrap;
}
.ep-tab-btn:hover { color: #0f172a; }
.ep-tab-btn.active { color: var(--teal-500); border-bottom-color: var(--teal-500); }

/* Tab panels */
.ep-tab-panel { display: contents; }
.ep-tab-panel.ep-tab-hidden { display: none !important; }

/* Content wrapper */
.ep-content {
  padding: 20px;
  display: grid;
  gap: 16px;
  align-content: start;
}

/* Card header redesign — match admin portal style */
.module-section > .card-head {
  background: #0f172a;
  margin: -1rem -1rem 0.85rem;
  padding: 10px 14px;
  border-radius: 15px 15px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.module-section > .card-head h3 {
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1;
  text-align: center;
}
.module-section > .card-head .chip {
  background: rgba(15,168,152,0.2);
  color: var(--teal-400);
  border: 1px solid rgba(15,168,152,0.3);
  font-family: var(--mono);
}

/* Remove old portal-head when ep-hero is present */
.portal-view .portal-head-hidden { display: none; }

/* Hide the legacy tab-ux-rail state banners — superseded by ep-hero + ep-kpi-strip */
.tab-ux-rail { display: none !important; }

/* ═══════════════════════════════════════════════════════
   MOBILE-FIRST RESPONSIVE — ≤860px
   Educators are primarily on phones and tablets.
   ═══════════════════════════════════════════════════════ */
@media (max-width: 860px) {
  /* ── Hard-clamp everything inside the viewport ── */
  .portal-view,
  .portal-view > *,
  .ep-content,
  .ep-kpi-strip,
  .ep-hero,
  .ep-mod-head,
  .ep-tab-strip,
  .workspace-grid,
  .workspace-main,
  .workspace-aside,
  .grid-2,
  .card,
  section {
    max-width: 100% !important;
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── Prevent all horizontal overflow ── */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  .portal-shell, .portal-main {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* ── Shell: no sidebar, single column ── */
  .portal-shell { grid-template-columns: 1fr !important; }
  .portal-rail  { display: none !important; }

  /* ── Topbar: single-row compact strip ── */
  .global-topbar {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 8px 12px !important;
    margin-top: 0 !important;
    border-radius: 0 !important;
    gap: 8px !important;
    position: sticky;
    top: 0;
    z-index: 40;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .ops-status-wrap {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex: 1 !important;
    min-width: 0 !important;
  }
  .ops-topbar-copy { display: none !important; }
  .ops-status-pill { font-size: 10px !important; padding: 3px 8px !important; white-space: nowrap; }
  .ops-actions {
    display: flex !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    flex-shrink: 0 !important;
  }
  /* Hide low-priority topbar items */
  #logoutBtn  { display: none !important; }
  .ops-create { display: none !important; }
  /* Compact buttons */
  .ops-actions .btn {
    padding: 6px 12px !important;
    font-size: 12px !important;
    min-height: 36px !important;
    white-space: nowrap !important;
  }

  /* ── Mobile bottom nav dock ── */
  .mobile-nav {
    display: flex !important;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    background: #0b1929;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 6px 0 calc(8px + env(safe-area-inset-bottom));
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-nav::-webkit-scrollbar { display: none; }
  .mobile-nav .nav-btn {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 6px;
    min-width: 56px;
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    border-radius: 8px;
    border: none;
    background: transparent;
    min-height: 48px;
  }
  .mobile-nav .nav-btn .ep-nav-icon { font-size: 20px; }
  .mobile-nav .nav-btn.active {
    color: var(--teal-400);
    background: rgba(15,168,152,0.12);
  }

  /* ── Body bottom padding for nav dock ── */
  .portal-main {
    padding: 0 10px calc(72px + env(safe-area-inset-bottom)) !important;
  }

  /* ── Dashboard hero ── */
  .ep-hero {
    padding: 14px 14px !important;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .ep-hero-title { font-size: 18px !important; }
  .ep-hero-right { flex-wrap: wrap; gap: 6px; }

  /* ── KPI strip: 2×2 on mobile ── */
  .ep-kpi-strip {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .ep-kpi-value { font-size: 20px !important; }

  /* ── Module header ── */
  .ep-mod-head { padding: 0 12px !important; height: 44px !important; }
  .ep-mod-title { font-size: 12px !important; }

  /* ── Tab strip: scrollable ── */
  .ep-tab-strip { padding: 0 8px !important; }
  .ep-tab-btn { padding: 10px 12px !important; font-size: 12px !important; }

  /* ── Content ── */
  .ep-content { padding: 10px !important; gap: 10px !important; }

  /* ── Collapse multi-column layouts to single column ── */
  .workspace-grid,
  .workspace-grid.workspace-grid-dashboard,
  .workspace-grid.workspace-grid-room {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
  .workspace-main,
  .workspace-aside {
    padding: var(--sp-4) !important;
  }
  .grid-2 { grid-template-columns: 1fr !important; }
  .kpis   { grid-template-columns: repeat(2, 1fr) !important; }

  /* ── Forms: single column on mobile ── */
  .form-grid  { grid-template-columns: 1fr !important; }
  .picker-grid { grid-template-columns: 1fr !important; }
  .outcomes-grid { grid-template-columns: 1fr !important; }
  .task-tile-grid { grid-template-columns: 1fr !important; }

  /* ── Touch-friendly input sizes ── */
  input, select, textarea {
    min-height: 44px;
    font-size: 16px !important; /* prevents iOS auto-zoom */
  }
  .btn {
    min-height: 44px !important;
    font-size: 14px !important;
  }
  label { font-size: 13px !important; }

  /* ── Tables: reset forced min-widths, enable horizontal scroll ── */
  table { min-width: 0 !important; }
  /* Override forced cell widths on checklist tables */
  .checklist-table th:first-child,
  .checklist-table td:first-child {
    min-width: 0 !important;
    width: auto !important;
    position: static !important; /* sticky inside overflow container breaks scroll */
    white-space: normal !important;
  }
  /* Checklist block: allow inner scroll (override overflow:hidden) */
  .checklist-block { overflow-x: auto !important; overflow-y: visible !important; }
  .checklist-table-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .table-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; max-width: 100%; }
  /* Compact table cells — allow text to wrap (no white-space: nowrap) */
  td, th { font-size: 12px !important; padding: 6px 8px !important; }
  th { white-space: nowrap; } /* column headers can stay single-line */

  /* ── Cards ── */
  .card { border-radius: 10px !important; overflow-x: hidden !important; }
  /* Remove negative margins — they bleed outside container on mobile */
  .module-section > .card-head {
    margin: 0 0 0.85rem !important;
    border-radius: 9px 9px 0 0 !important;
    padding: 11px 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── Checklist week table ── */
  .checklist-week-table { overflow-x: auto; }

  /* ── KPI strip ep cards ── */
  .ep-kpi-card { padding: 10px 12px !important; }
  .ep-kpi-label { font-size: 9px !important; }

  /* ── Global state banner ── */
  .portal-global-state { margin: 4px 0 0 !important; }

  /* ── Hide capture FAB (covered by topbar Quick Capture) ── */
  .capture-fab { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   PHONE — purpose-built layout (≤599px)
   Tablets (600–860px) keep the full desktop layout via the rail.
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {

  /* ── Topbar: Emergency only — remove Quick Capture btn & sync pill ── */
  #captureBtn        { display: none !important; }
  #educatorSyncBadge { display: none !important; }
  .ops-status-wrap   { display: none !important; }

  /* ── Global state: only show danger toasts, hide routine sync banners ── */
  #educatorGlobalState .state-banner.success,
  #educatorGlobalState .state-banner.warning,
  #educatorGlobalState .state-banner.info { display: none !important; }

  /* ── FAB: circular + button above bottom nav ── */
  .capture-fab {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: fixed !important;
    right: 16px !important;
    bottom: calc(68px + env(safe-area-inset-bottom) + 14px) !important;
    z-index: 45 !important;
    width: 52px !important;
    height: 52px !important;
    border-radius: 50% !important;
    background: var(--teal-500) !important;
    color: transparent !important;
    font-size: 0 !important;
    padding: 0 !important;
    box-shadow: 0 4px 20px rgba(10,168,150,0.4) !important;
    border: none !important;
  }
  .capture-fab::before {
    content: "+";
    font-size: 28px;
    font-weight: 300;
    color: #fff;
    line-height: 1;
  }

  /* ── Bottom nav: icons only — 6 items fit cleanly ── */
  .mobile-nav .nav-btn span:not(.ep-nav-icon) { display: none !important; }
  .mobile-nav .nav-btn { min-width: 0 !important; flex: 1 !important; padding: 6px 4px !important; }
  .mobile-nav .nav-btn .ep-nav-icon { font-size: 22px !important; }

  /* ── Layout ── */
  .portal-main { padding: 0 0 calc(68px + env(safe-area-inset-bottom)) !important; }
  .ep-content  { padding: 0 !important; gap: 0 !important; }

  /* ── All content sections: consistent padding ── */
  .workspace-main,
  .workspace-aside,
  .workspace-stack,
  .workspace-panel,
  .grid-2,
  .ep-tab-panel > section,
  .ep-tab-panel > .grid-2 {
    padding: 14px !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    background: var(--white) !important;
  }

  /* ── Hero: compact single row ── */
  .ep-hero--phone {
    padding: 12px 14px !important;
    flex-direction: row !important;
    align-items: center !important;
    min-height: 0 !important;
  }
  .ep-hero--phone .ep-hero-kicker { font-size: 9px !important; }
  .ep-hero--phone .ep-hero-title  { font-size: 17px !important; }
  .ep-hero-alert { display: none !important; }

  /* ── KPI strip: 2×2 full bleed ── */
  .ep-kpi-strip {
    border-radius: 0 !important;
    margin: 0 !important;
    gap: 1px !important;
    background: var(--grey-300) !important;
    grid-template-columns: 1fr 1fr !important;
  }
  .ep-kpi-card {
    border-radius: 0 !important;
    border: none !important;
    background: var(--white) !important;
    padding: 12px 10px !important;
  }

  /* ── Flat full-width card sections ── */
  .module-section > .card-head { margin: 0 !important; border-radius: 0 !important; }
  .card { border-radius: 0 !important; border-left: none !important; border-right: none !important; }

  /* ── Morning-head summary ── */
  .morning-head { flex-direction: column !important; gap: 6px !important; padding: 12px !important; border-radius: 10px !important; }
  .morning-progress { align-self: flex-start !important; }

  /* ── Mobile checklist (today-only vertical list) ── */
  .mob-checklist-block { border: 1px solid #dde8f8; border-radius: 12px; overflow: hidden; margin-bottom: 10px; }
  .mob-checklist-title {
    display: flex; justify-content: space-between; align-items: center;
    padding: 9px 12px; font-size: 13px; font-weight: 700; color: #1a3a5c;
    background: #f0f6ff; border-bottom: 1px solid #dde8f8;
  }
  .mob-checklist-day {
    font-size: 11px; font-weight: 600; color: var(--teal-600);
    background: var(--teal-50); padding: 2px 8px; border-radius: 999px;
  }
  .mob-checklist-list { list-style: none; padding: 0; margin: 0; }
  .mob-checklist-item { border-bottom: 1px solid #f0f4fb; }
  .mob-checklist-item:last-child { border-bottom: none; }
  .mob-checklist-item label {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 13px 14px; cursor: pointer;
  }
  .mob-checklist-item input[type="checkbox"] {
    width: 22px !important; height: 22px !important; min-height: 22px !important;
    flex-shrink: 0; margin: 1px 0 0; accent-color: var(--teal-500);
  }
  .mob-check-label { font-size: 14px; line-height: 1.45; color: #1e3a5f; }
  .mob-checklist-item.is-done .mob-check-label { color: var(--grey-500); text-decoration: line-through; }

  /* ── Due tasks section ── */
  .mob-due-section { padding: 0 0 4px !important; margin-top: 8px; }

  /* ── Child chip picker: bigger chips on phone ── */
  .child-chip { padding: 9px 16px 9px 10px !important; font-size: 14px !important; }
  .child-chip-av { width: 30px !important; height: 30px !important; font-size: 13px !important; }

  /* ── Form inputs: visible bordered style across ALL sections ── */
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="search"],
  input[type="date"],
  input[type="time"],
  input[type="password"],
  select,
  textarea {
    border: 1.5px solid #c8d7ee !important;
    border-radius: 10px !important;
    padding: 11px 13px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background: #fafcff !important;
    font-size: 15px !important;
    color: var(--grey-900) !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.04) !important;
    min-height: 46px !important;
    display: block !important;
  }
  textarea { min-height: 88px !important; resize: vertical !important; }
  select { appearance: auto !important; }
  label {
    display: block !important;
    margin-bottom: 14px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #3a526e !important;
  }
  label > input, label > select, label > textarea { margin-top: 6px !important; }

  /* ── Full-width action buttons ── */
  .actions .btn, form > .btn, form .actions .btn { width: 100% !important; justify-content: center !important; }
  #morningChecklistForm .actions .btn { width: 100% !important; }
}

/* ── Schedule tab ───────────────────────────────────── */
#view-schedule .ep-tab-panel { display: block; }
#view-schedule .ep-tab-panel.ep-tab-hidden { display: none !important; }

/* ── Educator Live Chat (Comms tab › Chat sub-tab) ────────── */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.ep-chat-shell{display:flex;flex-direction:column;height:480px;border:1px solid var(--teal-100,#d0f5f2);border-radius:8px;overflow:hidden;background:#fff}
.ep-chat-messages{flex:1;overflow-y:auto;padding:1rem;display:flex;flex-direction:column;gap:.5rem}
.ep-chat-bubble{max-width:72%;padding:.5rem .75rem;border-radius:12px;font-size:.875rem;line-height:1.4;word-break:break-word}
.ep-chat-bubble.from-me{align-self:flex-end;background:#0d9488;color:#fff;border-bottom-right-radius:2px}
.ep-chat-bubble.from-admin{align-self:flex-start;background:#f1f5f9;color:#1e293b;border-bottom-left-radius:2px}
.ep-chat-bubble .chat-meta{font-size:.7rem;opacity:.65;margin-top:3px}
.ep-chat-input-row{display:flex;gap:.5rem;padding:.75rem;border-top:1px solid var(--teal-100,#d0f5f2);background:#fafcff}
.ep-chat-input-row textarea{flex:1;resize:none;border:1px solid #e2e8f0;border-radius:6px;padding:.5rem;font-size:.875rem;height:40px;font-family:inherit;line-height:1.4}
.ep-chat-input-row textarea:focus{outline:2px solid var(--teal-500,#0fa898);outline-offset:1px}
@media(max-width:860px){.ep-chat-shell{height:420px}.ep-chat-messages{min-height:260px}}
