/* === Extracted from index_final_v2_FINAL_escape_fix_FINAL.html === */

:root{ --topbarH:72px; --bg:#f6f9ff; --ink:#0b1220; }
    html,body{height:100%}
    body{margin:0;background:var(--bg);color:var(--ink);font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial;}
    .topbar__inner{min-height:var(--topbarH)}
    .actions{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch}
    #updatedAt,#userBadge{display:inline-block;min-height:1em}
    .heroChart__wrap{height:clamp(220px,56vw,380px)}
    html.view-unlocked #viewGate{display:none!important}

/* === Add Editor Email Modal (does not affect chart layout) === */
#cxModalOverlay{
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#cxModal{
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
  padding: 18px 18px 16px;
}
#cxModal h3{
  margin: 0 0 6px 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
#cxModal .cxModalSub{
  margin: 0 0 14px 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
}
#cxModal .cxField{
  display: grid;
  gap: 6px;
  margin-top: 12px;
}
#cxModal label{
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}
#cxModal input, #cxModal select{
  width: 100%;
  padding: 12px 12px;
  font-size: 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: #f8fafc;
  color: #0f172a;
  outline: none;
}
#cxModal input::placeholder{
  color: rgba(15, 23, 42, 0.45);
}
#cxModal input:focus, #cxModal select:focus{
  background: #ffffff;
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16);
}
#cxModal .cxRow2{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px){
  #cxModal .cxRow2{ grid-template-columns: 1fr; }
}
#cxModal .cxHelp{
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
}
#cxModal .cxModalErr{
  display: none;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  background: #fff1f2;
  color: #991b1b;
  font-size: 12px;
  line-height: 1.35;
}
#cxModal .cxModalActions{
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
#cxModal .cxBtn{
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
#cxModal .cxBtn:hover{ filter: brightness(0.99); }
#cxModal .cxBtnPrimary{
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}
#cxModal .cxBtnPrimary:hover{ filter: brightness(0.97); }
#cxModal .cxBtn:disabled{
  opacity: .55;
  cursor: not-allowed;
}

/* === Modal extras (password change) === */
.cxCheck{display:flex;gap:10px;align-items:center;font-size:14px;color:#1f2a37;}
.cxCheck input{width:16px;height:16px;}
.cxBtnGhost{background:#ffffff;border:1px solid #d7dde6;color:#0f172a;}
.cxBtnGhost:hover{background:#f3f6fb;}
.cxPwSuccessTitle{font-size:18px;font-weight:800;color:#0f172a;margin-bottom:4px;}
.cxPwSuccessSub{font-size:14px;color:#4b5563;margin-bottom:12px;line-height:1.4;}
.cxPwBox{border:1px solid #e5e7eb;border-radius:14px;padding:12px;background:#f8fafc;}
.cxPwBoxLabel{font-size:12px;color:#6b7280;margin-bottom:8px;}
.cxPwBoxRow{display:flex;gap:10px;align-items:center;}
#cxPwSuccessValue{flex:1;min-width:0;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;}

/* === CLS guard: ensure the above-the-fold layout is stable from the first frame === */
  :root { --topbarH: 72px; } /* match your design */
  .topbar__inner{ min-height: var(--topbarH); }
  .actions{
    flex-wrap: nowrap;         /* no wrapping => stable topbar height */
    overflow-x: auto;          /* if narrow, scroll horizontally */
    -webkit-overflow-scrolling: touch;
  }
  /* Stabilkan meta text (updated/user badge) */
  #updatedAt, #userBadge{ display:inline-block; min-height: 1em; }
  /* Avoid shift from the hero chart: do not use vh */
  .heroChart__wrap{ height: clamp(220px, 56vw, 380px); }
  /* If the user has already unlocked before, viewGate never participates in layout */
  html.view-unlocked #viewGate{ display:none !important; }

/* === Inlined from styles.css === */
:root{
  --bg: #0b1220; /* dark navy */
}
body::before{
  background:
    radial-gradient(1200px 520px at 18% -10%, rgba(120,170,255,.18), transparent 74%),
    radial-gradient(1000px 460px at 88% 0%,  rgba(60,120,255,.12), transparent 76%),
    linear-gradient(180deg, rgba(255,255,255,.04), transparent 45%),
    var(--bg);
}
:root{
  --bg:#f6f9ff; --panel:#fff; --ink:#0b1220; --muted:#5a6b86;
  --b2:#8db6ff; --b3:#2b6cff;
  --shadow1:0 10px 30px rgba(16,24,40,.08);
  --shadow2:0 18px 60px rgba(16,24,40,.12);
  --r:18px; --pad:18px; --ring:0 0 0 3px rgba(43,108,255,.18);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial;
  color:var(--ink);
  background:
    radial-gradient(1000px 420px at 20% 0%, rgba(141,182,255,.26), transparent 60%),
    radial-gradient(900px 380px at 85% 10%, rgba(43,108,255,.14), transparent 60%),
    var(--bg);
  line-height:1.45;
}
.container{width:calc(100% - 32px); max-width:none; margin:0 auto}
.skip-link{position:absolute;left:-999px;top:auto;width:1px;height:1px;overflow:hidden}
.skip-link:focus{
  left:12px;top:12px;width:auto;height:auto;padding:10px 12px;border-radius:12px;
  background:var(--panel);box-shadow:var(--shadow1);outline:none;z-index:50;
}
.topbar{
  position:sticky;top:0;z-index:20;
  backdrop-filter:blur(10px);
  background:rgba(246,249,255,.72);
  border-bottom:1px solid rgba(141,182,255,.35);
}
.topbar__inner{display:flex;align-items:center;justify-content:space-between;padding:12px 0;gap:12px}
.brand{display:flex;align-items:center;gap:12px}
.brand__mark{
  width:38px;height:38px;border-radius:12px;
  background:linear-gradient(135deg,var(--b2),var(--b3));
  box-shadow:0 10px 24px rgba(43,108,255,.22);
}
.brand__logo{
  width:38px;height:38px;border-radius:12px;display:block;
  background:#fff;object-fit:contain;
  border:1px solid rgba(141,182,255,.35);
  box-shadow:0 10px 24px rgba(43,108,255,.12);
}
.brand__title{font-weight:950}
.brand__subtitle{font-size:12px;color:var(--muted)}
.actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap;justify-content:flex-end}
.btn{
  appearance:none;border:1px solid rgba(43,108,255,.25);
  background:linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,.78));
  padding:10px 12px;border-radius:14px;cursor:pointer;font-weight:850;
  box-shadow:0 8px 18px rgba(16,24,40,.06);
}
.btn:focus{outline:none;box-shadow:var(--shadow1),var(--ring)}
.btn--ghost{background:rgba(255,255,255,.55);border-color:rgba(141,182,255,.45);box-shadow:none}
.pill{font-size:12px;padding:6px 10px;border-radius:999px;border:1px solid rgba(141,182,255,.55);background:rgba(255,255,255,.7)}
.select{
  border:1px solid rgba(43,108,255,.25);
  background:rgba(255,255,255,.78);
  padding:10px 12px;border-radius:14px;font-weight:850;
}
.select:focus{outline:none;box-shadow:var(--shadow1),var(--ring)}
.hero{padding:22px 0 10px;display:grid;grid-template-columns:1.1fr .9fr;gap:16px;align-items:start}
.h1{margin:0;font-size:clamp(22px,2.2vw,34px);letter-spacing:-.2px}
.h2{margin:0;font-size:18px;letter-spacing:-.1px}
.lead{margin:10px 0 12px;color:var(--muted);max-width:72ch}
.meta{display:flex;gap:10px;flex-wrap:wrap}
.muted{color:var(--muted);font-size:13px}
.hero__cards{display:grid;grid-template-columns:1fr;gap:12px}
.card{
  background:var(--panel);border-radius:var(--r);padding:var(--pad);
  border:1px solid rgba(141,182,255,.35);box-shadow:var(--shadow1);
  position:relative;transform:translateZ(0);
}
.card::before{
  content:"";position:absolute;inset:0;border-radius:var(--r);pointer-events:none;
  background:radial-gradient(500px 140px at 10% 0%, rgba(141,182,255,.20), transparent 60%);
  opacity:.9;
}
@media (hover:hover){
  .card:hover{box-shadow:var(--shadow2);transform:translateY(-2px) perspective(800px) rotateX(.6deg);transition:.18s}
}
.kpi{display:flex;flex-direction:column;gap:8px}
.kpi__label{font-size:12px;color:var(--muted)}
.kpi__value{font-weight:950;font-size:22px;letter-spacing:-.2px}
.kpi__note{font-size:12px;color:var(--muted)}
/* ===== Hero bar chart (Cx Milestone Progress) ===== */
.heroChart .heroChart__head{position:relative;z-index:1;display:flex;flex-direction:column;gap:4px;margin-bottom:10px}
.heroChart__title{font-weight:950;font-size:16px;letter-spacing:-.1px}
.heroChart__wrap{
  position:relative;z-index:1;
  border-radius:16px;overflow:hidden;
  border:1px solid rgba(141,182,255,.28);
  background:#d0d0d0;
  height:clamp(220px, 30vh, 380px);
}
.heroChart__wrap canvas{width:100%;height:100%;display:block}
/* ===== Chart cards: keep a consistent, responsive height ===== */
.chart-wrap{height:clamp(240px, 34vh, 460px)}
.chart-wrap canvas{width:100%;height:100%}
.grid3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;padding:10px 0 14px}
.chart-card .card__head{position:relative;z-index:1;padding-bottom:10px}
.chart-wrap{position:relative;border-radius:16px;overflow:hidden;border:1px solid rgba(141,182,255,.28)}
.chart-wrap--dark{background:#3f3f3f}
canvas{display:block;width:100%;height:auto}
.tooltip{
  position:absolute;left:12px;bottom:12px;max-width:min(520px,calc(100% - 24px));
  background:rgba(11,18,32,.92);color:#fff;padding:8px 10px;border-radius:14px;
  font-size:12px;opacity:0;transform:translateY(6px);transition:.12s;
  pointer-events:none;box-shadow:0 16px 40px rgba(0,0,0,.18);
}
.tooltip.is-on{opacity:1;transform:translateY(0)}
.note{margin-top:10px;padding:10px 12px;border-radius:14px;border:1px solid rgba(141,182,255,.35);background:rgba(255,255,255,.72);color:var(--muted);font-size:13px}
.note--error{border-color:rgba(180,35,24,.35);color:#6b0f0f}
.editor__head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;position:relative;z-index:1}
.editor__actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.table-wrap{margin-top:12px;overflow:auto;border:1px solid rgba(141,182,255,.28);border-radius:16px;background:#fff;position:relative;z-index:1}
table{width:100%;border-collapse:collapse}
th,td{padding:10px 10px;border-bottom:1px solid rgba(141,182,255,.22);white-space:nowrap;font-size:13px}
th{position:sticky;top:0;background:#f3f7ff;text-align:left;font-weight:950}
td input{
  width:140px;max-width:40vw;padding:8px 10px;border-radius:12px;
  border:1px solid rgba(141,182,255,.55);background:rgba(246,249,255,.8);
  font:inherit;
}
td input:focus{outline:none;box-shadow:var(--ring)}
.footer{padding:18px 0 34px}
@media (max-width:980px){
  .hero{grid-template-columns:1fr}
  .grid3{grid-template-columns:1fr}
  .hero__cards{grid-template-columns:1fr}
}
@media (max-width:560px){
  .hero__cards{grid-template-columns:1fr}
}
@media (prefers-reduced-motion:reduce){
  *{scroll-behavior:auto!important;transition:none!important}
}
/* ===== 2-Panel layout: Left (dashboard) + Right (Weekly Input editor) ===== */
:root{
  --editorW: 30vw;            /* right panel width = 30% viewport */
  --topbarH: 72px;            /* will be overwritten by JS for accuracy */
}
.appShell{position:relative;min-height:calc(100dvh - var(--topbarH));}
/* Left content: reserve space for the flyover editor when open */
.mainLeft{
  padding-right:16px;
  transition:padding-right .24s ease;
  will-change:padding-right;
}
body.editor-open .mainLeft{
  padding-right:calc(16px + var(--editorW) + 16px);
}
/* Right panel: flyover drawer from right to left */
.editor-panel{
  position:fixed;
  top:var(--topbarH);
  right:0;
  width:var(--editorW);
  height:calc(100dvh - var(--topbarH));
  overflow:auto;
  transform:translateX(105%);
  transition:transform .24s ease;
  z-index:40;
  border-radius:18px 0 0 18px;
  margin:0;
  padding-right:calc(var(--pad) + env(safe-area-inset-right));
}
body.editor-open .editor-panel{ transform:translateX(0); }
/* Scrim for mobile/touch usability */
.editor-scrim{
  position:fixed;
  top:var(--topbarH);
  left:0;right:0;bottom:0;
  border:0;
  background:rgba(11,18,32,.22);
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease;
  z-index:35;
}
body.editor-open .editor-scrim{
  opacity:1;
  pointer-events:auto;
}
/* Close button small */
.editor-close{white-space:nowrap}
@media (min-width:981px){
  .editor-scrim{display:none}
}
@media (max-width:980px){
  /* On smaller screens, editor becomes a large drawer */
  :root{ --editorW: min(92vw, 560px); }
  body.editor-open .mainLeft{ padding-right:16px; }
}
/* Hide inline error/hint boxes (use console + status pill instead) */
#errorBox,#hintBox{display:none!important}
/* ===== Chart-card hover: move without blur (disable 3D tilt) ===== */
.chart-card{
  backface-visibility: hidden;
  transform: translateZ(0);
  will-change: transform;
}
@media (hover:hover){
  .chart-card.card:hover{
    /* override .card:hover perspective/rotateX to avoid blur */
    transform: translateY(-6px);
  }
}
/* ===== Zoom modal responsive chart sizing ===== */
#chartZoomModal #czmCanvas{
  width:100%;
  height:100%;
  display:block;
}
/* ===== Click-to-zoom modal (responsive) ===== */
#chartZoomModal{
  position:fixed;
  inset:0;
  display:none;
  z-index:9999;
}
#chartZoomModal.is-open{display:block;}
#chartZoomModal .czm-backdrop{
  position:absolute; inset:0;
  background:rgba(0,0,0,.55);
}
#chartZoomModal .czm-panel{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  width:min(980px, calc(100% - 16px));
  background:#ffffff;
  border-radius:18px;
  box-shadow:0 24px 80px rgba(0,0,0,.35);
  padding:12px;
}
#chartZoomModal .czm-topbar{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-bottom:10px;
}
#chartZoomModal .czm-close{
  border:1px solid rgba(0,0,0,.15);
  background:#fff;
  border-radius:999px;
  padding:8px 12px;
  font-weight:700;
  cursor:pointer;
}
#chartZoomModal .czm-canvasWrap{
  background:#3f3f3f; /* Dark Gray 4 */
  border-radius:16px;
  overflow:hidden;
  border:1px solid rgba(0,0,0,.10);
  height:min(62vh, 520px);
  min-height:320px;
}
#chartZoomModal #czmCanvas{
  width:100%;
  height:100%;
  display:block;
}
.footer__inner{display:flex;flex-direction:column;align-items:center;text-align:center;gap:6px;margin-top:10px}
.footer__wish{opacity:1;color:#4b5b74}
@media (max-width: 640px){
  #chartZoomModal .czm-panel{
    left:0;
    top:0;
    transform:none;
    width:100%;
    height:100%;
    border-radius:0;
    padding:10px;
    padding-top:calc(10px + env(safe-area-inset-top));
  }
  #chartZoomModal .czm-topbar{margin-bottom:8px}
  #chartZoomModal .czm-canvasWrap{
    height:calc(100dvh - (54px + env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    min-height:0;
  }
}
/* =========================================================
   CLS HOTFIX (CSS-only)
   Goal: eliminate layout shifts flagged on .appShell in PSI
   - Prevent topbar height changes from wrapping controls
   - Avoid dvh + JS-updated --topbarH driving reflow on load
   - Stabilize heroChart height (avoid vh on mobile)
   ========================================================= */
/* 1) Stabilize the sticky topbar height (avoid wrapping -> pushing content down) */
.topbar__inner{ min-height:72px; }
.btn,.pill,.select{ white-space:nowrap; }
/* On small screens, keep actions in one row; allow horizontal scroll instead of wrap */
@media (max-width:980px){
  .actions{
    flex-wrap:nowrap;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
  }
  .actions::-webkit-scrollbar{ display:none; }
}
/* 2) Stop .appShell & editor overlay from depending on JS-updated --topbarH / dynamic dvh */
:root{ --topbarHStable:72px; }
/* Use svh (stable viewport height) to avoid URL bar induced jumps */
.appShell{ min-height:calc(100svh - var(--topbarHStable)); }
.editor-panel{
  top:var(--topbarHStable);
  height:calc(100svh - var(--topbarHStable));
}
.editor-scrim{ top:var(--topbarHStable); }
/* 3) heroChart: avoid vh on mobile (vh/dvh can shift during load on Chrome mobile) */
@media (max-width:980px){
  .heroChart__wrap{ height:clamp(220px, 56vw, 360px); contain:layout paint; }
}
@media (min-width:981px){
  .heroChart__wrap{ height:clamp(240px, 28vw, 420px); contain:layout paint; }
}
/* 4) Minor stability for dynamic badges/text */
#userBadge{ display:inline-block; min-width:18ch; }
/* Optional: stabilize scrollbar gutter (desktop) */
@media (min-width:981px){
  body{ scrollbar-gutter: stable; }
}

/* === View gate: hide menu wrapper until the dashboard is unlocked === */
html:not(.view-unlocked) #navMenuWrapper{display:none!important;}

/* === Topbar navigation menu (wrapper in navbar; dropdown fixed overlay) === */
  .menu-wrapper{ position:relative; flex:0 0 auto; }
  .menu-btn{ display:inline-flex; align-items:center; gap:10px; white-space:nowrap; }
  .menu-btn .icon-inline{ font-size:16px; line-height:1; }
  /* Dropdown is fixed => not clipped by overflow on .actions */
  .floating-dropdown{
    position:fixed;
    width:min(360px, calc(100vw - 24px));
    max-height:min(520px, calc(100vh - 24px));
    overflow:auto;
    background:rgba(255,255,255,.96);
    border:1px solid rgba(12, 18, 32, .12);
    border-radius:16px;
    box-shadow:0 22px 60px rgba(11,18,32,.18);
    z-index:3000;
    padding:0;
  }
  .dropdown-header{
    display:flex; align-items:center; justify-content:space-between;
    padding:12px 14px;
    border-bottom:1px solid rgba(12, 18, 32, .10);
    position:sticky; top:0; background:inherit;
  }
  .dropdown-header h3{ margin:0; font-size:14px; }
  .close-btn{
    width:34px; height:34px;
    border-radius:10px;
    border:1px solid rgba(12, 18, 32, .12);
    background:transparent;
    cursor:pointer;
    font-size:18px;
    line-height:1;
  }
  .dropdown-content{ padding:10px; display:grid; gap:10px; }
  .menu-group{
    padding:10px;
    border:1px solid rgba(12, 18, 32, .10);
    border-radius:14px;
    background:rgba(255,255,255,.80);
  }
  .menu-title{ font-size:12px; font-weight:700; opacity:.72; margin-bottom:8px; }
  .menu-item{
    width:100%;
    text-align:left;
    padding:10px 10px;
    border-radius:12px;
    border:1px solid rgba(12, 18, 32, .10);
    background:transparent;
    cursor:pointer;
    font-weight:600;
  }
  .menu-item:focus{ outline:2px solid rgba(40,100,255,.35); outline-offset:2px; }

/* === Added: Manage Users table + textarea === */
  #cxModal textarea{width:100%;padding:12px 12px;font-size:14px;border-radius:12px;border:1px solid rgba(15,23,42,0.18);background:#f8fafc;color:#0f172a;outline:none;resize:vertical;min-height:72px;}
  #cxModal textarea:focus{border-color:rgba(15,23,42,0.35);}
  .cxTableWrap{border:1px solid rgba(15,23,42,0.12);border-radius:12px;overflow:auto;max-height:280px;background:#ffffff;}
  .cxTable{width:100%;border-collapse:collapse;font-size:13px;}
  .cxTable th,.cxTable td{padding:10px 12px;border-bottom:1px solid rgba(15,23,42,0.08);text-align:left;white-space:nowrap;}
  .cxTable thead th{position:sticky;top:0;background:#f8fafc;z-index:1;}
  .cxTable tbody tr:hover{background:rgba(15,23,42,0.04);cursor:pointer;}

.hidden{display:none!important;}
  .cxOwnerModal{position:fixed;inset:0;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center;z-index:9999}
  .cxOwnerCard{width:min(520px,92vw);background:#fff;border-radius:16px;box-shadow:0 24px 64px rgba(0,0,0,.25);overflow:hidden}
  .cxOwnerHead{display:flex;align-items:center;justify-content:space-between;padding:16px 18px;border-bottom:1px solid #eee}
  .cxOwnerTitle{font-weight:800;font-size:16px}
  .cxOwnerClose{background:transparent;border:0;font-size:18px;cursor:pointer}
  .cxOwnerBody{padding:16px 18px}
  .cxOwnerText{color:#667085;line-height:1.45}
  .cxOwnerLabel{display:block;font-weight:700;margin:10px 0 6px}
  .cxOwnerInput{width:100%;padding:10px 12px;border:1px solid #d0d5dd;border-radius:12px;outline:none;box-sizing:border-box}
  .cxOwnerHint{margin-top:8px;font-size:12px;color:#667085}
  .cxOwnerRow{display:flex;gap:10px;align-items:center}
  .cxOwnerToast{margin-top:12px;padding:10px 12px;border-radius:12px;background:#f2f4f7;color:#101828}
