body.auth-pending { height:100svh; overflow:hidden!important; }
body.auth-pending #appShell { visibility:hidden; pointer-events:none; }
/* Lay out the hidden workbench while idle, instead of on the flight's first frame. */
body.auth-pending #moduleViewWorkbench:not([hidden]) { display:block; }
.auth-overlay { position:fixed; inset:0; z-index:10000; display:flex; align-items:center; background:#f9f9f9; color:#292825; overflow-x:hidden; overflow-y:auto; padding:32px 40px; min-height:100svh; font-family:Inter,"PingFang SC","Microsoft YaHei",sans-serif; }
.auth-overlay.hidden,.auth-overlay [hidden] { display:none!important; }
.auth-overlay * { box-sizing:border-box; }
.auth-experience { width:100%; height:calc(100svh - 64px); min-height:580px; margin:auto; display:grid; grid-template-columns:minmax(0,1fr) 400px; gap:48px; align-items:center; }
.auth-hero { height:100%; background:transparent; border:0; box-shadow:none; display:grid; grid-template-rows:44px minmax(0,1fr) 20px; padding:8px 0; min-width:0; overflow:visible; }
.auth-brand { display:flex; gap:12px; align-items:center; font-size:15px; font-weight:650; }
.auth-brand img { width:32px; height:32px; }
.auth-brand>span { color:#292825; }
html.motion-ready .auth-overlay .auth-brand { animation:none!important; opacity:1!important; transform:none!important; }
.auth-brand-subtitle { display:block; font-size:10px; letter-spacing:.16em; color:#77736a; margin-top:3px; font-weight:400; }
.auth-hero-center { text-align:center; padding:8px 0; align-self:center; min-width:0; }
.auth-character-stage { --auth-stage-height:clamp(280px,calc(100svh - 300px),660px); height:var(--auth-stage-height); display:grid; place-items:center; overflow:visible; isolation:isolate; }
.auth-character-stage svg { width:min(100%,calc(clamp(320px,calc(100svh - 290px),720px) * var(--character-scale,1)),calc(var(--auth-stage-height) - 80px)); height:auto; aspect-ratio:1; max-width:calc(100% - 32px); max-height:calc(100% - 80px); overflow:visible; pointer-events:none; }
.auth-hero-title { font-size:clamp(24px,2.4vw,32px); letter-spacing:-.06em; font-weight:550; margin:10px 0 12px; color:#292825; }
#characterStatus { color:#797469; font-size:13px; margin:0 0 24px; min-height:20px; }
.auth-character-actions { position:relative; z-index:2; display:flex; justify-content:center; gap:10px; flex-wrap:wrap; }
.auth-character-actions button { position:relative; z-index:3; min-height:44px; padding:10px 16px; border-radius:24px; border:1px solid #dddacf; background:transparent; color:#4d4a41; font:inherit; font-size:12px; cursor:pointer; touch-action:manipulation; }
.auth-character-actions span { margin-left:10px; }
.auth-hero-footer { font-size:11px; color:#898376; }
.auth-card { position:relative; display:block; width:100%; height:min(800px,100%); padding:22px 26px; overflow-y:auto; scrollbar-gutter:stable; border:1px solid #e3e5ea; border-radius:24px; background:#fff; box-shadow:0 12px 50px #29282505; color:#292825; }
.auth-card-inner { min-width:0; }
.auth-card-tools { display:flex; justify-content:flex-end; margin:0 0 8px; }
.auth-tool-button { display:grid; place-items:center; width:44px; height:44px; padding:0; border:0; background:transparent; color:#716d63; border-radius:50%; cursor:pointer; font-size:20px; }
.auth-card h1 { font-size:30px; line-height:1.3; letter-spacing:-.05em; margin:0 0 8px; color:#292825; font-weight:600; min-height:39px; }
.auth-card-subtitle { font-size:13px; color:#78736b; margin:0 0 20px; line-height:1.7; min-height:44px; }
.auth-mode-tabs { display:flex; gap:4px; background:#f5f4ef; border:0; border-radius:12px; padding:4px; margin:0 0 22px; box-shadow:none; min-height:52px; }
.auth-mode-tab { flex:1; min-width:0; min-height:44px; border:0; border-radius:8px; background:transparent; color:#797368; font:inherit; font-size:12px; cursor:pointer; padding:8px 4px; }
.auth-mode-tab.is-active { color:#282720; background:#fff; box-shadow:0 1px 5px #29282512; }
.auth-fields { display:grid; gap:16px; align-content:start; min-height:388px; }
.auth-field { min-width:0; }
.auth-field label { display:block; font-size:12px; color:#565148; font-weight:550; margin:0 0 7px; }
.auth-input-shell { position:relative; display:flex; align-items:center; min-width:0; }
.auth-input-shell>i { position:absolute; left:14px; color:#938d82; font-size:18px; pointer-events:none; }
.auth-overlay .auth-field input { width:100%; min-width:0; height:48px; padding:12px 44px; border:1px solid #e0ddd4; border-radius:10px; background:#fcfbf9; color:#292825; font:inherit; font-size:14px; box-shadow:none; }
/* Keep the icon inset when the shared themed form padding applies. */
#authOverlay .auth-input-shell > input { padding-left:44px; }
.auth-field input::placeholder { color:#969086; }
.auth-field input:-webkit-autofill { -webkit-text-fill-color:#292825; box-shadow:0 0 0 1000px #fcfbf9 inset; }
.auth-password-toggle { position:absolute; right:2px; top:2px; height:44px; width:40px; border:0; background:transparent; color:#7d766b; font-size:18px; cursor:pointer; }
/* Keep centering independent of the shared button press transform. */
#authOverlay #authPasswordToggle { top:0; bottom:0; right:4px; width:48px; height:48px; margin-block:auto; padding:0; display:grid; place-items:center; transform:none; }
#authOverlay #authPassword { padding-right:56px; }
/* Edge supplies its own reveal icon; this form already has an accessible one. */
#authPassword::-ms-reveal, #authPassword::-ms-clear { display:none; }
.auth-overlay :focus-visible { outline:3px solid #778967; outline-offset:3px; }
.auth-remember-slot { min-height:80px; padding-top:12px; }
.auth-remember-row { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:4px; margin:0; font-size:11px; }
.auth-remember { display:flex; gap:7px; align-items:center; min-height:44px; color:#746d62; }
.auth-remember input { width:16px; height:16px; accent-color:#49563d; }
.auth-link { min-height:44px; padding:4px 0; border:0; background:transparent; color:#655e52; font:inherit; cursor:pointer; }
.auth-actions { display:grid; gap:8px; margin-top:18px; }
.auth-overlay .auth-button { width:100%; min-height:48px; padding:12px 16px; font:inherit; font-size:13px; border:1px solid #dfdbd2; border-radius:10px; color:#554e43; background:#fff; cursor:pointer; box-shadow:none; }
.auth-overlay .auth-button.primary { color:#faf9f6; background:#292d25; border-color:#292d25; font-weight:550; }
.auth-overlay button:disabled { opacity:.55; cursor:wait; }
.auth-message { color:#858074; font-size:11px; line-height:1.7; min-height:20px; margin:14px 0; text-align:center; overflow-wrap:anywhere; }
.auth-message.error { color:#a54337; }
.auth-message.success { color:#46693e; }
.auth-trust { display:flex; justify-content:space-between; gap:10px; padding-top:16px; border-top:1px solid #efede6; }
.auth-trust-item { display:flex; align-items:center; gap:5px; background:transparent; border:0; box-shadow:none; color:#8b8478; font-size:10px; }
.auth-trust-item strong { font-weight:400; }
.auth-trust-item>span>span { display:none; }
@media(max-width:1050px) { .auth-overlay { padding:24px; } .auth-experience { gap:24px; grid-template-columns:minmax(0,1fr) 360px; height:calc(100svh - 48px); } .auth-card { padding:22px; } }
/* On phones the overlay owns scrolling; the form grows with its content. */
@media(max-width:680px) { .auth-overlay { display:block; overflow-y:auto; padding:18px 16px 32px; } .auth-experience { height:auto; min-height:0; display:grid; grid-template-columns:minmax(0,1fr); gap:24px; max-width:450px; } .auth-hero { height:auto; display:block; padding:0; } .auth-hero-center { padding:16px 0 0; } .auth-character-stage { --auth-stage-height:clamp(300px,64svh,460px); } .auth-character-stage svg { width:min(100%,calc(330px * var(--character-scale,1)),calc(var(--auth-stage-height) - 24px)); height:auto; } .auth-hero-title { font-size:24px; margin:4px 0 8px; } .auth-hero-footer { display:none; } #characterStatus { margin-bottom:12px; font-size:12px; } .auth-card { height:auto; min-height:740px; overflow:visible; scrollbar-gutter:auto; padding:24px; border-radius:20px; } .auth-card-tools { position:absolute; top:12px; right:12px; } .auth-card h1 { font-size:26px; padding-right:28px; } .auth-card-subtitle { margin-bottom:20px; } .auth-overlay .auth-field input { font-size:16px; } }
@media(max-width:390px) { .auth-card { padding:20px 16px; } .auth-overlay { padding-inline:12px; } .auth-trust { flex-wrap:wrap; } }


#authDrawerOpen, #authDrawerClose, #authDrawerBackdrop { display:none; }

@media (max-width:759px) {
  html:has(body.auth-pending #authOverlay:not(.hidden)) { scrollbar-gutter:auto; }
  #authOverlay {
    display:block; inset:0; height:100vh; height:100dvh; width:100vw;
    min-height:0; padding:0; overflow:clip;
  }
  #authOverlay.hidden { display:none; }
  #authOverlay .auth-experience { display:block; position:relative; top:var(--auth-visible-top,0px); overflow:clip; width:100%; max-width:none; height:var(--auth-visible-height,100%); min-height:0; margin:0; }
  #authOverlay .auth-hero {
    display:grid; grid-template-rows:auto minmax(0,1fr); width:100%; height:100%;
    padding:max(16px,env(safe-area-inset-top)) 18px max(14px,env(safe-area-inset-bottom));
  }
  #authOverlay .auth-hero-center { align-self:center; padding:0; }
  #authOverlay .auth-hero-footer { display:none; }
  #authOverlay .auth-character-stage { --auth-stage-height:clamp(80px,calc(var(--auth-visible-height,100dvh) - 320px),420px); height:var(--auth-stage-height); }
  #authOverlay .auth-character-stage svg { width:min(84vw,calc((var(--auth-stage-height) - 20px) * var(--character-scale,1)),var(--auth-stage-height)); height:min(84vw,calc((var(--auth-stage-height) - 20px) * var(--character-scale,1)),var(--auth-stage-height)); max-width:100%; max-height:none; }
  #authOverlay .auth-hero-title { margin:4px 0; font-size:clamp(20px,5vw,28px); }
  #authOverlay #characterStatus { margin:4px auto 10px; }
  #authDrawerOpen {
    display:block; margin:14px auto 0; padding:10px 36px; min-height:44px; border:0; border-radius:99px;
    font:inherit; font-weight:600; cursor:pointer; color:var(--md-on-primary,#fff); background:var(--md-primary,#315d4e);
  }
  #authOverlay #characterStatus[data-status="error"] { color:var(--md-error,#a23127); }
  #authDrawerBackdrop, #authDrawer {
    position:absolute; visibility:hidden; pointer-events:none; transition:visibility 0s linear 270ms;
  }
  #authDrawerBackdrop { display:block; inset:0; z-index:1; opacity:0; background:rgb(16 24 30 / 15%); transition:opacity 240ms ease,visibility 0s linear 270ms; }
  #authOverlay #authDrawer {
    z-index:2; inset:auto max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
    width:auto; max-width:none; margin:0 auto; height:75%; min-height:0; max-height:calc(100% - max(12px,env(safe-area-inset-top)) - max(12px,env(safe-area-inset-bottom)));
    padding:clamp(14px,4vw,25px) clamp(16px,5vw,28px) max(12px,env(safe-area-inset-bottom));
    overflow:visible; scrollbar-gutter:auto; container:auth-sheet / size;
    border:1px solid rgb(255 255 255 / 78%); border-radius:32px;
    background:var(--md-surface,#f6f8f7); color:var(--md-on-surface,#202723);
    box-shadow:inset 0 1px 0 rgb(255 255 255 / 90%),0 -10px 44px rgb(23 37 45 / 13%);
    transform:translateY(calc(100% + max(14px,env(safe-area-inset-bottom)))); transition:transform 260ms cubic-bezier(.3,0,.35,1),visibility 0s linear 270ms;
  }
  @supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))) {
    #authOverlay #authDrawer { background:rgb(250 251 251 / 68%); background:color-mix(in srgb,var(--md-surface,#f8faf9) 67%,transparent);
      -webkit-backdrop-filter:blur(21px) saturate(1.55); backdrop-filter:blur(21px) saturate(1.55); }
  }
  #authOverlay[data-drawer-open="true"] #authDrawerBackdrop { opacity:1; visibility:visible; pointer-events:auto; transition-delay:0s; }
  #authOverlay[data-drawer-open="true"] #authDrawer { transform:translateY(0); visibility:visible; pointer-events:auto; transition-delay:0s; }
  #authOverlay #authDrawer .auth-card-tools { position:absolute; top:10px; right:12px; margin:0; display:flex; flex-direction:row-reverse; z-index:1; }
  #authDrawer .auth-tool-button { width:36px; height:36px; min-height:0; padding:0; border-radius:50%; }
  #authDrawerClose { display:grid; background:rgb(255 255 255 / 60%); color:var(--md-on-surface,#202723); }
  #authDrawer .auth-card-inner { display:grid; align-content:start; gap:clamp(8px,2cqh,14px); width:100%; min-height:0; }
  #authDrawer h1 { min-height:0; margin:0; padding:0 68px 0 0; font-size:clamp(20px,5.2vw,28px); line-height:1.3; }
  #authDrawer .auth-card-subtitle, #authDrawer .auth-trust { display:none; }
  #authDrawer .auth-mode-tabs { margin:0; min-height:0; padding:3px; }
  #authDrawer .auth-mode-tab { min-height:38px; padding:3px; font-size:12px; line-height:1.25; }
  #authOverlay #authDrawer .auth-fields { display:grid; grid-template-columns:minmax(0,1fr); align-content:start; gap:clamp(5px,1.4cqh,12px); min-height:0; }
  #authDrawer .auth-fields:has(> :not([hidden])) { margin:0; }
  #authDrawer .auth-field { display:grid; grid-template-columns:minmax(0,1fr); gap:3px; }
  #authDrawer .auth-field label { margin:0; font-size:12px; line-height:16px; }
  #authOverlay #authDrawer .auth-field input { height:44px; min-height:0; padding:4px 12px 4px 40px; font-size:16px; background:rgb(255 255 255 / 78%); }
  #authOverlay #authDrawer #authPassword { padding-right:48px; }
  #authOverlay #authDrawer #authPasswordToggle { height:100%; width:40px; }
  #authDrawer .auth-remember-slot { min-height:0; padding:0; }
  #authDrawer .auth-remember-slot:has([hidden]), #authDrawer .auth-fields:not(:has(> :not([hidden]))) { display:none; }
  #authDrawer .auth-remember-row { min-height:0; gap:4px; }
  #authDrawer .auth-remember, #authDrawer .auth-link { min-height:32px; margin:0; line-height:1.25; font-size:12px; }
  #authDrawer .auth-actions { display:flex; gap:6px; margin:0; }
  #authOverlay #authDrawer .auth-button { min-height:42px; padding:4px 8px; }
  #authDrawer:not([data-mode="pending-approval"]) .auth-secondary { display:none; }
  #authDrawer .auth-message { margin:0; min-height:0; line-height:1.35; font-size:12px; }
  #authDrawer .auth-field > .auth-message { grid-column:1 / -1; }
  #authOverlay[data-short="true"] #authDrawer { padding:8px 14px max(6px,env(safe-area-inset-bottom)); }
  #authOverlay[data-short="true"][data-contracted="true"] #authDrawer { bottom:max(3px,env(safe-area-inset-bottom)); height:calc(100% - 6px); max-height:calc(100% - 3px - max(3px,env(safe-area-inset-bottom))); }
  #authOverlay[data-short="true"] .auth-hero { padding-block:6px; }
  #authOverlay[data-short="true"] .auth-brand { position:absolute; left:12px; top:8px; }
  #authOverlay[data-short="true"] .auth-hero-center { grid-row:1 / -1; }
  #authOverlay[data-short="true"] .auth-character-stage { --auth-stage-height:clamp(64px,calc(var(--auth-visible-height,100dvh) - 198px),170px); }
  #authOverlay[data-short="true"] #authDrawerOpen { margin-top:5px; }
  @container auth-sheet (max-height:460px) {
    #authDrawer .auth-card-inner { gap:6px; }
    #authDrawer .auth-field { gap:2px; }
    #authOverlay #authDrawer .auth-fields { gap:6px; }
    #authOverlay #authDrawer .auth-field input { height:40px; }
  }
  #authOverlay[data-contracted="true"] #authDrawer :is(.auth-mode-tabs,#authHelpButton,[data-mode-hint="true"]) { display:none; }
  @container auth-sheet (max-height:368px) {
    #authDrawer .auth-card-inner { --field-height:40px; gap:5px; }
    #authDrawer h1 { font-size:19px; line-height:26px; }
    #authOverlay #authDrawer .auth-card-tools { top:4px; right:8px; }
    #authDrawer .auth-tool-button { height:30px; width:32px; }
    #authDrawer .auth-mode-tab { min-height:28px; }
    #authOverlay #authDrawer .auth-fields { gap:5px; }
    #authDrawer .auth-field { position:relative; gap:2px; }
    #authDrawer .auth-field label {
      position:absolute; z-index:1; inset:0 auto auto 12px; display:flex; align-items:center;
      height:var(--field-height); font-size:13px; line-height:1.2; pointer-events:none;
    }
    #authOverlay #authDrawer .auth-input-shell input { height:var(--field-height); padding:0 12px 0 76px; }
    #authOverlay #authDrawer #authPassword { padding-right:38px; }
    #authOverlay #authDrawer #authPasswordToggle { width:32px; right:3px; }
    #authDrawer .auth-input-shell > i { display:none; }
    #authDrawer .auth-remember, #authDrawer .auth-link { min-height:26px; }
    #authOverlay #authDrawer .auth-button { min-height:36px; }
  }
  /* A wide, shallow sheet fits its title and mode selector on one line.
     Every input still gets a full row, including registration and reset. */
  @container auth-sheet (max-height:460px) and (min-width:460px) {
    #authOverlay[data-contracted="false"] #authDrawer .auth-card-inner { --field-height:35px; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px 12px; }
    #authOverlay[data-contracted="false"] #authModeHeading { position:absolute; inset:8px auto auto 16px; padding:0; font-size:19px; line-height:26px; }
    #authOverlay[data-contracted="false"] #authDrawer .auth-mode-tabs { grid-area:1 / 1 / 2 / -1; margin:0 68px 0 138px; }
    #authOverlay[data-contracted="false"] #authDrawer .auth-fields { grid-area:2 / 1 / 3 / -1; gap:4px; }
    #authOverlay[data-contracted="false"] #authDrawer .auth-actions { grid-area:3 / 2; }
    #authOverlay[data-contracted="false"] #authDrawer :is(.auth-remember-slot,.auth-card-inner > .auth-message) { grid-area:3 / 1; align-self:center; }
    #authOverlay[data-contracted="false"] #authDrawer[data-mode="employee"] .auth-card-inner > .auth-message { grid-area:4 / 1 / 5 / -1; }
    #authOverlay[data-contracted="false"] #authDrawer .auth-field:has(.auth-message) { grid-template-columns:minmax(0,2fr) minmax(0,1fr); gap:8px; }
    #authOverlay[data-contracted="false"] #authDrawer .auth-field > .auth-message { grid-area:1 / 2; align-self:center; }
  }
  @container auth-sheet (max-height:279px) {
    #authOverlay[data-contracted="true"] #authDrawer .auth-card-inner { gap:4px; }
    #authOverlay[data-contracted="true"] #authDrawer .auth-fields { gap:4px; }
    #authOverlay[data-contracted="true"] #authDrawer[data-mode="register"]:has(.auth-message:not([data-mode-hint="true"])) #authModeHeading {
      position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip-path:inset(50%);
    }
    #authOverlay[data-contracted="true"] #authDrawer[data-mode="register"]:has(.auth-message:not([data-mode-hint="true"])) .auth-card-tools { top:auto; bottom:7px; }
    #authOverlay[data-contracted="true"] #authDrawer[data-mode="register"]:has(.auth-message:not([data-mode-hint="true"])) .auth-actions { padding-right:38px; }
  }
  /* Let four single-column fields and their error message share the shortest
     keyboard viewport. The close control stays alongside the submit action. */
  @container auth-sheet (max-height:242px) {
    #authOverlay[data-contracted="true"] #authDrawer .auth-card-inner {
      --field-height:clamp(37px,calc((100cqh - 56px) / 4),40px); gap:2px;
    }
    #authOverlay[data-contracted="true"] #authDrawer .auth-fields { gap:2px; }
    #authOverlay[data-contracted="true"] #authDrawer .auth-field { gap:0; }
    #authOverlay[data-contracted="true"] #authDrawer .auth-button { min-height:32px; }
    #authOverlay[data-contracted="true"] #authDrawer:is([data-mode="register"],[data-mode="employee"]) #authModeHeading {
      position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip-path:inset(50%);
    }
    #authOverlay[data-contracted="true"] #authDrawer:is([data-mode="register"],[data-mode="employee"]) .auth-card-tools { top:auto; bottom:7px; }
    #authOverlay[data-contracted="true"] #authDrawer:is([data-mode="register"],[data-mode="employee"]) .auth-actions { padding-right:38px; }
  }
}
