/* SunDine 7.9.4 global theme and centered popup layer.
   Inputs: html/body data-sundine-theme in {pos007, ember, jade, daylight, midnight}; invalid input falls back to pos007.
   Outputs: consistent CSS variables, decorative pattern layer, centered modal/toast/dialog surfaces on every page and device size. */
:root{
  --sundine-version:"7.9.4";
  --theme-bg:#050201;
  --theme-bg-2:#160b03;
  --theme-panel:rgba(19,10,4,.94);
  --theme-panel-2:rgba(35,18,8,.88);
  --theme-text:#fff8e6;
  --theme-muted:#d8bb83;
  --theme-line:rgba(244,190,91,.28);
  --theme-accent:#f7c35f;
  --theme-accent-2:#e66b2b;
  --theme-good:#52d38b;
  --theme-danger:#ff6a6f;
  --theme-shadow:0 28px 90px rgba(0,0,0,.52);
  --theme-pattern-opacity:.34;
  --theme-pattern-a:rgba(247,195,95,.20);
  --theme-pattern-b:rgba(230,107,43,.14);
  --sundine-vv-left:0px;
  --sundine-vv-top:0px;
  --sundine-vv-width:100vw;
  --sundine-vv-height:100dvh;
  --sundine-vv-center-x:50vw;
  --sundine-vv-center-y:50dvh;
  --bg:var(--theme-bg);
  --panel:var(--theme-panel);
  --panel2:var(--theme-panel-2);
  --text:var(--theme-text);
  --muted:var(--theme-muted);
  --line:var(--theme-line);
  --blue:var(--theme-accent);
  --blue2:var(--theme-accent);
  --green:var(--theme-good);
  --red:var(--theme-danger);
}
html[data-sundine-theme="ember"]{
  --theme-bg:#180704;
  --theme-bg-2:#38120a;
  --theme-panel:rgba(52,18,8,.94);
  --theme-panel-2:rgba(82,31,12,.88);
  --theme-text:#fff5ea;
  --theme-muted:#ffbe8a;
  --theme-line:rgba(255,139,72,.32);
  --theme-accent:#ff8f3d;
  --theme-accent-2:#ffcf76;
  --theme-pattern-a:rgba(255,143,61,.24);
  --theme-pattern-b:rgba(255,207,118,.12);
}
html[data-sundine-theme="jade"]{
  --theme-bg:#03110f;
  --theme-bg-2:#082923;
  --theme-panel:rgba(7,36,31,.94);
  --theme-panel-2:rgba(8,53,45,.88);
  --theme-text:#f0fff9;
  --theme-muted:#9be7cf;
  --theme-line:rgba(74,217,175,.30);
  --theme-accent:#44d9ad;
  --theme-accent-2:#9df6d0;
  --theme-pattern-a:rgba(68,217,173,.22);
  --theme-pattern-b:rgba(157,246,208,.12);
}
html[data-sundine-theme="daylight"]{
  --theme-bg:#fff7e9;
  --theme-bg-2:#ffe3bf;
  --theme-panel:rgba(255,252,247,.96);
  --theme-panel-2:rgba(255,244,227,.92);
  --theme-text:#24150c;
  --theme-muted:#76573d;
  --theme-line:rgba(133,83,39,.22);
  --theme-accent:#c77828;
  --theme-accent-2:#f1a238;
  --theme-shadow:0 22px 70px rgba(101,58,19,.22);
  --theme-pattern-a:rgba(199,120,24,.16);
  --theme-pattern-b:rgba(241,162,56,.10);
}
html[data-sundine-theme="midnight"]{
  --theme-bg:#050816;
  --theme-bg-2:#101a38;
  --theme-panel:rgba(12,18,39,.94);
  --theme-panel-2:rgba(20,31,64,.88);
  --theme-text:#f4f7ff;
  --theme-muted:#a9b8eb;
  --theme-line:rgba(112,143,255,.26);
  --theme-accent:#7da2ff;
  --theme-accent-2:#c1d0ff;
  --theme-pattern-a:rgba(125,162,255,.20);
  --theme-pattern-b:rgba(193,208,255,.10);
}
html[data-sundine-theme],
html[data-sundine-theme] body{
  color:var(--theme-text)!important;
  background:
    radial-gradient(circle at 12% -10%,var(--theme-pattern-a),transparent 32%),
    radial-gradient(circle at 88% 8%,var(--theme-pattern-b),transparent 28%),
    linear-gradient(180deg,var(--theme-bg),var(--theme-bg-2) 78%,var(--theme-bg))!important;
}
.sundine-theme-pattern{
  position:fixed;
  inset:0;
  z-index:0;
  pointer-events:none;
  opacity:var(--theme-pattern-opacity);
  background-image:
    linear-gradient(135deg,transparent 0 44%,var(--theme-pattern-a) 45% 46%,transparent 47% 100%),
    radial-gradient(circle at 18px 18px,var(--theme-pattern-b) 0 2px,transparent 3px),
    radial-gradient(circle at 70% 18%,var(--theme-pattern-a),transparent 24%);
  background-size:54px 54px,36px 36px,100% 100%;
  mix-blend-mode:screen;
}
html[data-sundine-theme="daylight"] .sundine-theme-pattern{mix-blend-mode:multiply;opacity:.22;}
html[data-sundine-theme] body > :not(.sundine-theme-pattern){position:relative;z-index:1;}
html[data-sundine-theme] .phone,
html[data-sundine-theme] .launcher-card,
html[data-sundine-theme] .deploy-executive-shell,
html[data-sundine-theme] .deploy-console-shell{
  background:linear-gradient(180deg,var(--theme-panel),var(--theme-panel-2))!important;
  color:var(--theme-text)!important;
}
html[data-sundine-theme] .topbar,
html[data-sundine-theme] .bottom-bar,
html[data-sundine-theme] .dropdown,
html[data-sundine-theme] .card,
html[data-sundine-theme] .list-card,
html[data-sundine-theme] .role-card,
html[data-sundine-theme] .notice,
html[data-sundine-theme] .modal,
html[data-sundine-theme] .sundine-fix-dialog,
html[data-sundine-theme] .food-card,
html[data-sundine-theme] .deploy-panel,
html[data-sundine-theme] .auth-card{
  background:linear-gradient(180deg,var(--theme-panel),var(--theme-panel-2))!important;
  border-color:var(--theme-line)!important;
  color:var(--theme-text)!important;
  box-shadow:var(--theme-shadow)!important;
}
html[data-sundine-theme] .muted,
html[data-sundine-theme] .small,
html[data-sundine-theme] .hero p,
html[data-sundine-theme] .role-card p{color:var(--theme-muted)!important;}
html[data-sundine-theme] .btn.primary,
html[data-sundine-theme] button.btn.primary,
html[data-sundine-theme] .deploy-primary-btn{
  background:linear-gradient(135deg,var(--theme-accent),var(--theme-accent-2))!important;
  color:var(--theme-bg)!important;
  border-color:transparent!important;
  font-weight:900;
}
html[data-sundine-theme] .btn.ghost,
html[data-sundine-theme] .icon-btn,
html[data-sundine-theme] .capsule,
html[data-sundine-theme] .chip,
html[data-sundine-theme] .search,
html[data-sundine-theme] input,
html[data-sundine-theme] select,
html[data-sundine-theme] textarea{
  background:color-mix(in srgb,var(--theme-panel) 82%,#ffffff 8%)!important;
  border-color:var(--theme-line)!important;
  color:var(--theme-text)!important;
}
html[data-sundine-theme] .price,
html[data-sundine-theme] .badge.blue,
html[data-sundine-theme] .hero-eyebrow b{color:var(--theme-accent)!important;}
.sundine-theme-control{
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-height:42px;
  padding:0 10px;
  border:1px solid var(--theme-line);
  border-radius:999px;
  background:color-mix(in srgb,var(--theme-panel) 86%,#ffffff 6%);
  color:var(--theme-text);
  box-shadow:0 10px 30px rgba(0,0,0,.20);
  white-space:nowrap;
}
.sundine-theme-control span{font-size:12px;font-weight:900;letter-spacing:.08em;color:var(--theme-muted);}
.sundine-theme-control select{
  min-height:34px!important;
  height:34px;
  padding:0 26px 0 8px!important;
  border:0!important;
  background:transparent!important;
  color:var(--theme-text)!important;
  font-size:13px;
  font-weight:850;
  cursor:pointer;
}
.sundine-theme-launcher-card{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin:0 0 14px;
  padding:12px 14px;
  border:1px solid var(--theme-line);
  border-radius:18px;
  background:linear-gradient(135deg,var(--theme-panel),var(--theme-panel-2));
}
.sundine-theme-launcher-card b{color:var(--theme-accent);}

.sundine-version-chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:28px;
  padding:0 9px;
  border-radius:999px;
  border:1px solid var(--theme-line);
  background:linear-gradient(135deg,var(--theme-pattern-a),transparent);
  color:var(--theme-accent);
  font-size:12px;
  font-weight:950;
  letter-spacing:.05em;
}
.topbar .title .sundine-version-chip{margin-left:8px;vertical-align:middle;}
.launcher-card .sundine-version-chip{margin-left:8px;}

.sundine-theme-status{
  position:absolute!important;
  width:1px!important;
  height:1px!important;
  overflow:hidden!important;
  clip:rect(0 0 0 0)!important;
  white-space:nowrap!important;
}
/* Center every small popup surface without centering navigation dropdowns. */
.modal-backdrop,
.sundine-fix-modal,
.game-modal-backdrop,
.sundine-theme-dialog-backdrop{
  position:fixed!important;
  inset:0!important;
  z-index:100000!important;
  display:none!important;
  align-items:center!important;
  justify-content:center!important;
  place-items:center!important;
  padding:clamp(12px,4vw,28px)!important;
  background:rgba(0,0,0,.62)!important;
  backdrop-filter:blur(14px)!important;
  -webkit-backdrop-filter:blur(14px)!important;
}
.modal-backdrop.open,
.sundine-fix-modal.open,
.game-modal-backdrop.open,
.sundine-theme-dialog-backdrop.open{display:flex!important;}
.modal,
.sundine-fix-dialog,
.game-modal,
.sundine-theme-dialog{
  position:relative!important;
  width:min(92vw,560px)!important;
  max-width:560px!important;
  max-height:min(86vh,720px)!important;
  margin:auto!important;
  overflow:auto!important;
  border-radius:26px!important;
  transform:none!important;
  outline:0!important;
}
.modal::before,
.sundine-fix-dialog::before,
.game-modal::before,
.sundine-theme-dialog::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  border-radius:inherit;
  background:
    linear-gradient(135deg,transparent 0 46%,var(--theme-pattern-a) 47% 48%,transparent 49% 100%),
    radial-gradient(circle at 18% 12%,var(--theme-pattern-b),transparent 28%);
  opacity:.72;
}
.modal > *,
.sundine-fix-dialog > *,
.game-modal > *,
.sundine-theme-dialog > *{position:relative;z-index:1;}
#toast.dropdown.open,
.sundine-toast.open,
.sundine-fix-toast,
#undoToast,
.local-preview-json-wrap,
.file-preview-ready-chip{
  position:fixed!important;
  left:var(--sundine-vv-center-x,50vw)!important;
  top:var(--sundine-vv-center-y,50dvh)!important;
  right:auto!important;
  bottom:auto!important;
  transform:translate(-50%,-50%)!important;
  z-index:100001!important;
  width:min(92vw,520px)!important;
  max-height:min(calc(var(--sundine-vv-height,100dvh) - 24px),640px)!important;
  overflow:auto!important;
  border-radius:22px!important;
  padding:14px 16px!important;
  background:linear-gradient(180deg,var(--theme-panel),var(--theme-panel-2))!important;
  border:1px solid var(--theme-line)!important;
  color:var(--theme-text)!important;
  box-shadow:var(--theme-shadow)!important;
}
.sundine-theme-dialog{padding:18px;background:linear-gradient(180deg,var(--theme-panel),var(--theme-panel-2));border:1px solid var(--theme-line);box-shadow:var(--theme-shadow);color:var(--theme-text);}
.sundine-theme-dialog h2{margin:0 0 8px;font-size:22px;}
.sundine-theme-dialog p{margin:6px 0;color:var(--theme-muted);line-height:1.55;}
.sundine-theme-diff{
  display:grid;
  gap:8px;
  margin:14px 0;
  padding:12px;
  border:1px dashed var(--theme-line);
  border-radius:16px;
  background:rgba(255,255,255,.04);
}
.sundine-theme-diff div{display:flex;justify-content:space-between;gap:12px;}
.sundine-theme-dialog-actions{display:flex;gap:10px;justify-content:flex-end;flex-wrap:wrap;margin-top:14px;}
.sundine-theme-dialog-actions button{min-height:44px;border-radius:14px;padding:0 14px;border:1px solid var(--theme-line);cursor:pointer;}
.sundine-theme-apply{background:linear-gradient(135deg,var(--theme-accent),var(--theme-accent-2));color:var(--theme-bg);font-weight:900;}
.sundine-theme-cancel{background:transparent;color:var(--theme-text);}
@media (max-width:620px), (pointer:coarse){
  .sundine-theme-control{width:100%;justify-content:space-between;border-radius:16px;}
  .topbar .sundine-theme-control{width:auto;max-width:50vw;padding:0 8px;}
  .topbar .sundine-theme-control span{display:none;}
  .topbar .sundine-theme-control select{max-width:112px;}
  .modal,.sundine-fix-dialog,.game-modal,.sundine-theme-dialog{width:min(94vw,540px)!important;max-height:84svh!important;border-radius:24px!important;}
  #toast.dropdown.open,.sundine-toast.open,.sundine-fix-toast,#undoToast,.local-preview-json-wrap,.file-preview-ready-chip{width:min(94vw,520px)!important;}
}

/* SunDine 7.9.4 modal-visual-viewport hardening.
   Root cause guarded: mobile .phone must never compute overflow-y:auto/scroll from mixed overflow-x and overflow-y values.
   Input: any screen size, any existing modal/backdrop location, theme id in the existing selector.
   Output: document remains the only normal vertical scroll owner; popup surfaces are fixed at the visual viewport center. */
@media (max-width:1100px), (pointer:coarse){
  html[data-sundine-theme] body > .phone,
  html[data-sundine-theme] body .phone,
  body.sundine-customer-fixed > .phone,
  body.sundine-customer-fixed .phone,
  body.sundine-customer-standalone > .phone,
  body.sundine-customer-standalone .phone,
  body:not(.surface-auth) > .phone,
  body:not(.surface-auth) .phone{
    height:auto!important;
    max-height:none!important;
    min-height:100dvh!important;
    overflow:hidden!important;
    overflow-x:clip!important;
    overflow-y:clip!important;
    overscroll-behavior:initial!important;
    -webkit-overflow-scrolling:auto!important;
    touch-action:auto!important;
  }
  body:not(.surface-auth) .phone .main,
  body:not(.surface-auth) .phone .page,
  body:not(.surface-auth) .phone .card,
  body:not(.surface-auth) .phone .list-card,
  body:not(.surface-auth) .phone .panel,
  body:not(.surface-auth) .phone .food-card,
  body:not(.surface-auth) .phone .role-card,
  body:not(.surface-auth) .phone .menu-frame,
  body:not(.surface-auth) .phone .menu-slider,
  body:not(.surface-auth) .phone .menu-page,
  body:not(.surface-auth) .phone .table-wrap,
  body:not(.surface-auth) .phone .table-scroll,
  body:not(.surface-auth) .phone .sundine-table-card,
  body:not(.surface-auth) .phone .pos-cart-panel,
  body.sundine-customer-fixed .main,
  body.sundine-customer-fixed .menu-frame,
  body.sundine-customer-fixed .menu-slider,
  body.sundine-customer-fixed .menu-page,
  body.sundine-customer-standalone .main,
  body.sundine-customer-standalone .menu-frame,
  body.sundine-customer-standalone .menu-slider,
  body.sundine-customer-standalone .menu-page{
    height:auto!important;
    max-height:none!important;
    overflow:visible!important;
    overflow-x:visible!important;
    overflow-y:visible!important;
    scroll-snap-type:none!important;
    overscroll-behavior:initial!important;
    -webkit-overflow-scrolling:auto!important;
    touch-action:auto!important;
  }
}
#itemModal.modal-backdrop,
.modal-backdrop,
.sundine-fix-modal,
.game-modal-backdrop,
.sundine-theme-dialog-backdrop{
  position:fixed!important;
  inset:auto!important;
  left:var(--sundine-vv-left,0px)!important;
  top:var(--sundine-vv-top,0px)!important;
  right:auto!important;
  bottom:auto!important;
  width:var(--sundine-vv-width,100vw)!important;
  height:var(--sundine-vv-height,100dvh)!important;
  min-height:var(--sundine-vv-height,100dvh)!important;
  display:none!important;
  align-items:center!important;
  justify-content:center!important;
  place-items:center!important;
  padding:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))!important;
  overflow:hidden!important;
  contain:layout paint!important;
  isolation:isolate!important;
}
#itemModal.modal-backdrop.open,
.modal-backdrop.open,
.sundine-fix-modal.open,
.game-modal-backdrop.open,
.sundine-theme-dialog-backdrop.open{
  display:grid!important;
}
#itemModal.modal-backdrop.open > .modal,
.modal-backdrop.open > .modal,
.sundine-fix-modal.open > .sundine-fix-dialog,
.game-modal-backdrop.open > .game-modal,
.sundine-theme-dialog-backdrop.open > .sundine-theme-dialog{
  position:fixed!important;
  left:var(--sundine-vv-center-x,50vw)!important;
  top:var(--sundine-vv-center-y,50dvh)!important;
  right:auto!important;
  bottom:auto!important;
  transform:translate3d(-50%,-50%,0)!important;
  width:min(92vw,560px)!important;
  max-width:calc(var(--sundine-vv-width,100vw) - 24px - env(safe-area-inset-left) - env(safe-area-inset-right))!important;
  max-height:calc(var(--sundine-vv-height,100dvh) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom))!important;
  margin:0!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  overscroll-behavior:contain!important;
  -webkit-overflow-scrolling:touch!important;
}
#itemModal.modal-backdrop .modal > .row:first-child,
.modal-backdrop .modal > .row:first-child,
.sundine-fix-dialog .sundine-fix-row:first-child{
  display:flex!important;
  align-items:center!important;
  justify-content:space-between!important;
  flex-wrap:nowrap!important;
  gap:12px!important;
}
#closeItemModal,
#itemModal.modal-backdrop .modal > .row:first-child > .btn,
.modal-backdrop .modal > .row:first-child > .btn,
.sundine-fix-close{
  flex:0 0 44px!important;
  width:44px!important;
  min-width:44px!important;
  max-width:44px!important;
  height:44px!important;
  min-height:44px!important;
  padding:0!important;
  border-radius:14px!important;
  line-height:1!important;
}
#itemModalBody,
#sundineFixItemBody{
  min-width:0!important;
}
@media (max-width:620px), (pointer:coarse){
  #itemModal.modal-backdrop.open > .modal,
  .modal-backdrop.open > .modal,
  .sundine-fix-modal.open > .sundine-fix-dialog,
  .game-modal-backdrop.open > .game-modal,
  .sundine-theme-dialog-backdrop.open > .sundine-theme-dialog{
    width:calc(var(--sundine-vv-width,100vw) - 24px - env(safe-area-inset-left) - env(safe-area-inset-right))!important;
    max-height:calc(var(--sundine-vv-height,100dvh) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom))!important;
    border-radius:22px!important;
  }
}

/* 7.9.4 Native Mobile Scroll First-Swipe Final Override
   Root cause: document must keep vertical ownership; ordinary content cannot become a nested scroll owner.
   Allowed exceptions: modal/dialog/dropdown/textarea and explicitly designed console/log scroll regions. */
@media (max-width:1100px), (pointer:coarse){
  html{height:auto!important;min-height:100%!important;overflow-x:clip!important;overflow-y:auto!important;overscroll-behavior-y:auto!important;-webkit-overflow-scrolling:touch!important;touch-action:auto!important;scroll-behavior:auto!important;}
  body:not(.surface-auth){height:auto!important;min-height:100%!important;max-height:none!important;display:block!important;overflow:visible!important;overflow-x:visible!important;overflow-y:visible!important;overscroll-behavior:initial!important;-webkit-overflow-scrolling:auto!important;touch-action:auto!important;}
  body:not(.surface-auth) .phone{height:auto!important;max-height:none!important;min-height:100dvh!important;overflow:hidden!important;overflow-x:clip!important;overflow-y:clip!important;overscroll-behavior:initial!important;-webkit-overflow-scrolling:auto!important;touch-action:auto!important;}
  body:not(.surface-auth) .phone .main,
  body:not(.surface-auth) .phone .page,
  body:not(.surface-auth) .phone .panel,
  body:not(.surface-auth) .phone .card,
  body:not(.surface-auth) .phone .list-card,
  body:not(.surface-auth) .phone .food-card,
  body:not(.surface-auth) .phone .role-card,
  body:not(.surface-auth) .phone .menu-frame,
  body:not(.surface-auth) .phone .menu-slider,
  body:not(.surface-auth) .phone .menu-page,
  body:not(.surface-auth) .phone .table-wrap,
  body:not(.surface-auth) .phone .table-scroll,
  body:not(.surface-auth) .phone .sundine-table-card,
  body:not(.surface-auth) .phone .pos-cart-panel,
  body.sundine-customer-standalone .main,
  body.sundine-customer-standalone .page,
  body.sundine-customer-standalone .panel,
  body.sundine-customer-standalone .card,
  body.sundine-customer-standalone .food-card,
  body.sundine-customer-standalone .role-card,
  body.sundine-customer-standalone .menu-frame,
  body.sundine-customer-standalone .menu-slider,
  body.sundine-customer-standalone .menu-page,
  body.sundine-customer-standalone .table-wrap,
  body.sundine-customer-standalone .table-scroll,
  body.sundine-customer-standalone .sundine-table-card,
  body.sundine-customer-standalone .pos-cart-panel{
    height:auto!important;
    max-height:none!important;
    overflow:visible!important;
    overflow-x:visible!important;
    overflow-y:visible!important;
    overscroll-behavior:initial!important;
    -webkit-overflow-scrolling:auto!important;
    scroll-snap-type:none!important;
    touch-action:auto!important;
    transform-style:flat!important;
  }
  body:not(.surface-auth) .phone .chip-row,
  body.sundine-customer-standalone .chip-row{overflow:visible!important;overflow-x:visible!important;overflow-y:visible!important;flex-wrap:wrap!important;touch-action:auto!important;scrollbar-width:none!important;}
  body:not(.surface-auth) .phone .menu-slider,
  body.sundine-customer-standalone .menu-slider{transform:none!important;transition:none!important;will-change:auto!important;}
}


/* 7.9.4 High-specificity mobile body/native-scroll override.
   Reason: legacy selectors with multiple :not() entries used overflow-x:hidden + overflow-y:visible/auto;
   on mobile that can compute to a nested root/body scroll owner before the first finger gesture. */
@media (max-width:1100px), (pointer:coarse){
  body:not(.surface-auth):not(.sundine-modal-locked),
  body.sundine-customer-standalone:not(.surface-auth):not(.sundine-modal-locked),
  body.surface-customer:not(.surface-auth):not(.sundine-modal-locked){
    height:auto!important;
    min-height:100%!important;
    max-height:none!important;
    overflow:visible!important;
    overflow-x:visible!important;
    overflow-y:visible!important;
    overscroll-behavior-y:auto!important;
    -webkit-overflow-scrolling:auto!important;
    touch-action:auto!important;
  }
  body:not(.surface-auth) .phone{
    overflow:hidden!important;
    overflow-x:clip!important;
    overflow-y:clip!important;
    -webkit-overflow-scrolling:auto!important;
    touch-action:auto!important;
  }
}
